中南大学数据库课程设计源代码.docx

上传人:b****7 文档编号:10766020 上传时间:2023-02-22 格式:DOCX 页数:20 大小:16.90KB
下载 相关 举报
中南大学数据库课程设计源代码.docx_第1页
第1页 / 共20页
中南大学数据库课程设计源代码.docx_第2页
第2页 / 共20页
中南大学数据库课程设计源代码.docx_第3页
第3页 / 共20页
中南大学数据库课程设计源代码.docx_第4页
第4页 / 共20页
中南大学数据库课程设计源代码.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

中南大学数据库课程设计源代码.docx

《中南大学数据库课程设计源代码.docx》由会员分享,可在线阅读,更多相关《中南大学数据库课程设计源代码.docx(20页珍藏版)》请在冰豆网上搜索。

中南大学数据库课程设计源代码.docx

中南大学数据库课程设计源代码

Form1

PublicintjobidAsInteger

PublicintuserjdAsInteger

PrivateSubcmdOK_Click()

DimsqlAsString

DimrsAsADODB.Recordset

DimstrusernameAsString

DimintuserkeyAsInteger

OnErrorGoToerrhandler:

IfTrim(txtusername.Text="")Then

MsgBox"请输入用户名称!

",vbExclamation

txtusername.SetFocus

Else

sql="select*frommember_21001where登录名='"&txtusername.Text&"'"

Setrs=ExeSQL(sql)

Ifrs.EOF=TrueThen

MsgBox"没有此用户,请重新输入用户名!

",vbExclamation

txtusername.SetFocus

Else

IfTrim(rs!

密码)=Trim(txtuserkey.Text)Then

MsgBox"登陆成功!

",vbExclamation

rs.Close

Me.Hide

frmTip.Show

UnloadMe

Else

MsgBox"密码不正确,请重新输入",vbExclamation

txtuserkey.SetFocus

txtuserkey.Text=""

EndIf

EndIf

EndIf

ExitSub

errhandler:

MsgBox"错误号"&Err.Number&"错误描述"&Err.Description

EndSub

PrivateSubcmdCancel_Click()

DimcnnAsNewADODB.Connection

DimadorsAsNewADODB.Recordset

cnn.ConnectionString="Provider=SQLOLEDB.1;Password=sa;UserID=sa;InitialCatalog=白志恒_21001;DataSource=WIN-20120304XBO"

cnn.Open

Ifcnn.State=adStateOpenThen

Setadors.ActiveConnection=cnn'设置cmd的ActiveConnection属性,指定与其关联的数据库连接

Setadors=cnn.Execute("deletefromlingshi_21001")

cnn.Close'关闭与数据库的连接

EndIf

UnloadMe

EndSub

PrivateSubCommand1_Click()

Form2.Show

UnloadMe

EndSub

PrivateSubguanli_Click()

DimsqlAsString

DimrsAsADODB.Recordset

DimstrusernameAsString

DimintuserkeyAsInteger

OnErrorGoToerrhandler:

IfTrim(txtusername.Text="")Then

MsgBox"请输入管理员账户!

",vbExclamation

txtusername.SetFocus

Else

sql="select*fromadmin_21001wherename='"&txtusername.Text&"'"

Setrs=ExeSQL(sql)

Ifrs.EOF=TrueThen

MsgBox"对不起,该账户不是管理员账户!

",vbExclamation

txtusername.SetFocus

Else

IfTrim(rs!

Password)=Trim(txtuserkey.Text)Then

MsgBox"登陆成功!

",vbExclamation

rs.Close

Me.Hide

Form7.Show

UnloadMe

Else

MsgBox"密码不正确,请重新输入",vbExclamation

txtuserkey.SetFocus

txtuserkey.Text=""

EndIf

EndIf

EndIf

ExitSub

errhandler:

MsgBox"错误号"&Err.Number&"错误描述"&Err.Description

EndSub

PrivateSubForm_Unload(CancelAsInteger)

DimcnnAsNewADODB.Connection

DimadorsAsNewADODB.Recordset

cnn.ConnectionString="Provider=SQLOLEDB.1;Password=sa;UserID=sa;InitialCatalog=白志恒_21001;DataSource=WIN-20120304XBO"

cnn.Open

Ifcnn.State=adStateOpenThen

Setadors.ActiveConnection=cnn'设置cmd的ActiveConnection属性,指定与其关联的数据库连接

Adodc1.RecordSource="select*frommember_21001"

Setadors=cnn.Execute("insertintolingshi_21001select昵称,等级,积分frommember_21001where登录名='"+txtusername+"'")

cnn.Close'关闭与数据库的连接

EndIf

DimstrAsString

EndSub

Form2

PrivateSubCommand1_Click()

DimcnnAsNewADODB.Connection

DimadorsAsNewADODB.Recordset

cnn.ConnectionString="Provider=SQLOLEDB.1;Password=sa;UserID=sa;InitialCatalog=白志恒_21001;DataSource=WIN-20120304XBO"

cnn.Open

 

Ifcnn.State=adStateOpenThen

Setadors.ActiveConnection=cnn'设置cmd的ActiveConnection属性,指定与其关联的数据库连接

IfText1.Text=""OrText2.Text=""OrText3.Text=""OrText4.Text=""Then

MsgBox"输入的用户注册信息不完全!

!

",,"提示信息"

Else

Adodc1.RecordSource="select*frommember_21001where登录名='"+Text1+"'"'判断注册的用户名是否存在

Adodc1.Refresh

IfAdodc1.Recordset.RecordCount>0Then

MsgBox"该账号已经存在,请您更换其他账号!

",48,"提示信息"

Text1.SetFocus

Else

IfText2.Text=Text3.TextThen'判断两次输入的密码是否一致

Adodc1.RecordSource="select*frommember_21001"

Adodc1.Refresh

'保存注册信息

Setadors=cnn.Execute("insertintomember_21001values('"&Text1.Text&"','"&Text5.Text&"','"&Text2.Text&"','0','0','"&Text4.Text&"')")

MsgBox"注册成功!

!

",48,"用户注册信息提示"

cnn.Close'关闭与数据库的连接

Text1.Text=""

Text2.Text=""

Text3.Text=""

Text4.Text=""

Text5.Text=""

UnloadMe

Form1.Show

Else

MsgBox"两次输入的密码不一致,请您确认后重新输入",48,"用户注册信息提示"

Text3.Text=""

Text4.Text=""

Text3.SetFocus

EndIf

EndIf

EndIf

Else

EndIf

EndSub

 

PrivateSubCommand2_Click()

UnloadMe

Form1.Show

EndSub

 

PrivateSubText1_KeyDown(KeyCodeAsInteger,ShiftAsInteger)

IfKeyCode=13Then

Text2.SetFocus

Else

EndIf

EndSub

PrivateSubText2_KeyDown(KeyCodeAsInteger,ShiftAsInteger)

IfKeyCode=13Then'如果按下的是回车键,则光标落到文本框当中

Text3.SetFocus

Else

EndIf

EndSub

 

PrivateSubText3_KeyDown(KeyCodeAsInteger,ShiftAsInteger)

IfKeyCode=13Then'如果按下的是回车键,则光标落到文本框当中

Text4.SetFocus

Else

EndIf

EndSub

PrivateSubText4_KeyDown(KeyCodeAsInteger,ShiftAsInteger)

IfKeyCode=13Then

CallCommand1_Click

Else

EndIf

EndSub

Form3

PrivateSubCommand1_Click()

UnloadMe

Form4.Show

EndSub

PrivateSubCommand2_Click()

UnloadMe

Form6.Show

EndSub

PrivateSubCommand3_Click()

UnloadMe

Form9.Show

EndSub

PrivateSubCommand4_Click()

DimcnnAsNewADODB.Connection

DimadorsAsNewADODB.Recordset

cnn.ConnectionString="Provider=SQLOLEDB.1;Password=sa;UserID=sa;InitialCatalog=白志恒_21001;DataSource=WIN-20120304XBO"

cnn.Open

 

Ifcnn.State=adStateOpenThen

Setadors.ActiveConnection=cnn'设置cmd的ActiveConnection属性,指定与其关联的数据库连接

Setadors=cnn.Execute("deletefromlingshi_21001")

cnn.Close'关闭与数据库的连接

EndIf

UnloadMe

EndSub

 

PrivateSubCommand5_Click()

DimcnnAsNewADODB.Connection

DimadorsAsNewADODB.Recordset

cnn.ConnectionString="Provider=SQLOLEDB.1;Password=sa;UserID=sa;InitialCatalog=白志恒_21001;DataSource=WIN-20120304XBO"

cnn.Open

 

Ifcnn.State=adStateOpenThen

Setadors.ActiveConnection=cnn'设置cmd的ActiveConnection属性,指定与其关联的数据库连接

Setadors=cnn.Execute("deletefromlingshi_21001")

cnn.Close'关闭与数据库的连接

EndIf

UnloadMe

Form1.Show

EndSub

PrivateSubForm_Load()

DimstrAsString

str="select*fromlingshi_21001"

Adodc4.RecordSource=str

Adodc4.Refresh

EndSub

Form4

PrivateSubCommand1_Click()

DimstrAsString

str="select*fromproduct_21001where"&Combo1.Text&"like'%"&Text1.Text&"%'"

Adodc1.RecordSource=str

Adodc1.Refresh

EndSub

PrivateSubCommand2_Click()

Form3.Show

UnloadMe

EndSub

PrivateSubCommand3_Click()

DimstrAsString

str="select*fromproduct_21001where"&Combo1.Text&"like'%"&Text1.Text&"%'orderby价格asc"

Adodc1.RecordSource=str

Adodc1.Refresh

EndSub

PrivateSubCommand4_Click()

DimstrAsString

str="select*fromproduct_21001where"&Combo1.Text&"like'%"&Text1.Text&"%'orderby价格desc"

Adodc1.RecordSource=str

Adodc1.Refresh

EndSub

PrivateSubCommand5_Click()

DimcnnAsNewADODB.Connection

DimadorsAsNewADODB.Recordset

cnn.ConnectionString="Provider=SQLOLEDB.1;Password=sa;UserID=sa;InitialCatalog=白志恒_21001;DataSource=WIN-20120304XBO"

cnn.Open

 

Ifcnn.State=adStateOpenThen

Setadors.ActiveConnection=cnn'设置cmd的ActiveConnection属性,指定与其关联的数据库连接

Setadors=cnn.Execute("insertintobuy_history_21001select'"&Label3.Caption&"',编号,品牌,型号,颜色,类别,容量,能耗,价格,'0',卖家fromproduct_21001where编号='"+Text2+"'")

MsgBox"购买成功!

",48,"用户注册信息提示"

Setadors=cnn.Execute("updatebuy_history_21001set实际价格=价格/10*(10-(select等级fromlingshi_21001))where编号='"+Text2+"'")

Text2.Text=""

cnn.Close'关闭与数据库的连接

EndIf

DimstrAsString

EndSub

PrivateSubCommand6_Click()

DimcnnAsNewADODB.Connection

DimadorsAsNewADODB.Recordset

cnn.ConnectionString="Provider=SQLOLEDB.1;Password=sa;UserID=sa;InitialCatalog=白志恒_21001;DataSource=WIN-20120304XBO"

cnn.Open

 

Ifcnn.State=adStateOpenThen

Setadors.ActiveConnection=cnn'设置cmd的ActiveConnection属性,指定与其关联的数据库连接

Adodc1.RecordSource="select*fromproduct_21001"

Setadors=cnn.Execute("insertintotuijian_21001select'"&Label3.Caption&"',编号,品牌,型号,颜色,类别,容量,能耗,价格,卖家fromproduct_21001where编号='"+Text3+"'")

MsgBox"谢谢您的推荐!

",48,"用户注册信息提示"

Text3.Text=""

cnn.Close'关闭与数据库的连接

EndIf

DimstrAsString

EndSub

PrivateSubForm_Load()

Combo1.AddItem"品牌"

Combo1.AddItem"型号"

Combo1.AddItem"颜色"

Combo1.AddItem"类别"

Combo1.AddItem"价格"

Combo1.Text="品牌"

EndSub

PrivateSubPicture1_Click()

Form5.Show

UnloadMe

EndSub

Form5

PrivateSubCommand1_Click()

UnloadMe

Form4.Show

EndSub

Form6

PrivateSubCommand1_Click()

DimcnnAsNewADODB.Connection

DimadorsAsNewADODB.Recordset

cnn.ConnectionString="Provider=SQLOLEDB.1;Password=sa;UserID=sa;InitialCatalog=白志恒_21001;DataSource=WIN-20120304XBO"

cnn.Open

 

Ifcnn.State=adStateOpenThen

Setadors.ActiveConnection=cnn'设置cmd的ActiveConnection属性,指定与其关联的数据库连接

Adodc1.RecordSource="select*fromtuijian2_21001"

Adodc1.Refresh

Setadors=cnn.Execute("insertintotuijian2_21001values('"&Text5.Text&"','"&Text1.Text&"','"&Text2.Text&"','"&Text3.Text&"','"&Text4.Text&"')")

MsgBox"感谢您的推荐,我们会尽快进货!

",48,"用户注册信息提示"

cnn.Close'关闭与数据库的连接

Text1.Text=""

Text2.Text=""

Text3.Text=""

Text4.Text=""

Text5.Text=""

EndIf

EndSub

PrivateSubCommand2_Click()

Form3.Show

UnloadMe

EndSub

Form7

PrivateSubCommand1_Click()

UnloadMe

Form8.Show

EndSub

PrivateSubCommand2_Click()

DimcnnAsNewADODB.Connection

DimadorsAsNewADODB.Recordset

cnn.ConnectionString="Provider=SQLOLEDB.1;Password=sa;UserID=sa;InitialCatalog=白志恒_21001;DataSource=WIN-20120304XBO"

cnn.Open

 

Ifcnn.State=adStateOpenThen

Setadors.ActiveConnection=cnn'设置cmd的ActiveConnection属性,指定与其关联的数据库连接

Adodc1.RecordSource="select*fromproduct_21001"

Adodc1.Refresh

Setadors=cnn.Execute("deletefromproduct_21001where编号='"+Text1+"'")

MsgBox"删除完毕!

",48,"用户注册信息提示"

cnn.Close'关闭与数据库的连接

EndIf

DimstrAsString

str="select*fromproduct_21001"

Adodc1.RecordSource=str

Adodc1.Refresh

EndSub

PrivateSubCommand3_Click()

Dimstr1AsString

IfText2.Text=""Then

str1="select登录名,昵称,等级,积分,qqfrommember_21001"

Else

str1=

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1