1.请购作业程序Private Sub ComCX_Click()’查询'在"编号"文本框中输入编号,连接数据库,查询编号,并将"编号","品名","规格","单位","单价"的数据分别导入到相应文本框。
Set CN = New ADODB.ConnectionSet Rs = New ADODB.RecordsetCN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb;Persist Security Info=False"'打开数据库Rs.CursorType = adOpenStatic '制定一个静态游标Rs.LockType = adLockOptimistic '设置锁定模式为开放式Rs.Open "select * from JLBH where FtextBHSJ Like'" & "%" & Trim(textBHSJ.Text) & "%" & "'", CNDoEventsDo Until Rs.EOF = TrueIf Rs.EOF = False ThenlistBHSJ1.AddItem (Rs.Fields(0))listPMSJ1.AddItem (Rs.Fields(1))listGGSJ1.AddItem (Rs.Fields(2))listDWSJ1.AddItem (Rs.Fields(3))listDJSJ1.AddItem (Rs.Fields(4))Rs.MoveNextEnd IfLoopEnd SubPrivate Sub comFHZY_Click()’返回上页frmQGZY.HidefrmCKGLXT.ShowEnd SubPrivate Sub comQD_Click()’录入数据If textBHSJ.Text = "" Or textPMSJ.Text = "" Or textGGSJ.Text = "" Or textDWSJ.Text = "" Or textDJSJ.Text = "" Or textQGSLSJ.Text = "" ThenMsgBox "请将数据补充完整!"textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""textQGSLSJ.Text = ""ElseDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = "Select textBHSJ From qgzy where textBHSJ= '" & Trim(textBHSJ.Text) & "'"strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"strconn = strconn & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'"cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)str1 = "Insert Into qgzy (textBHSJ,textPMSJ,textGGSJ,textDWSJ,textDJSJ,textQGSJ)"str1 = str1 + "Values('" & Trim(textBHSJ.Text) & "','" & Trim(textPMSJ.Text) & "','" & Trim(textGGSJ.Text) & "','" & Trim(textDWSJ.Text) & "','" & Trim(textDJSJ.Text) & "','" & Trim(textQGSLSJ.Text) & "')"cnn.Execute str1listBHSJ1.AddItem (Trim(textBHSJ.Text))listPMSJ1.AddItem (Trim(textPMSJ.Text))listGGSJ1.AddItem (Trim(textGGSJ.Text))listDWSJ1.AddItem (Trim(textDWSJ.Text))listDJSJ1.AddItem (Trim(textDJSJ.Text))listQGSLSJ1.AddItem (Trim(textQGSLSJ.Text))MsgBox "数据输入成功!"rst.Closecnn.CloseSet Rs = NothingSet CN = NothingtextBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""textQGSLSJ.Text = ""End IfEnd SubPrivate Sub comsc_Click()’删除If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThentextBHSJ.Text = listBHSJ1.List(i)textPMSJ.Text = listPMSJ1.List(i)textGGSJ.Text = listGGSJ1.List(i)textDWSJ.Text = listDWSJ1.List(i)textDJSJ.Text = listDJSJ1.List(i)textQGSLSJ.Text = listQGSLSJ1.List(i)End IfNextEnd IfDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = "Select FtextBHSJ From jlbh where FtextBHSJ='" & Trim(textBHSJ.Text) & "'"strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"strconn = strconn & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'"cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)If rst.EOF = False Thenstr1 = "Delete from qgzy where FtextBHSJ='" & Trim(textBHSJ.Text) & "'"cnn.Execute str1textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""textQGSLSJ.Text = ""If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistBHSJ1.RemoveItem (i)listPMSJ1.RemoveItem (i)listGGSJ1.RemoveItem (i)listDWSJ1.RemoveItem (i)listDJSJ1.RemoveItem (i)listQGSLSJ1.RemoveItem (i)End IfNextEnd IfMsgBox "数据已删除!"ElseMsgBox "无此数据!"textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""textQGSLSJ.Text = ""End Ifrst.Closecnn.CloseSet Rs = NothingSet CN = NothingEnd Sub‘以下是listbox串连显示Private Sub listBHSJ1_Click()If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistPMSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listDJSJ1_Click()If listDJSJ1.SelCount > 0 ThenFor i = listDJSJ1.ListCount - 1 To 0 Step -1If listDJSJ1.Selected(i) ThenlistQGSLSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listDWSJ1_Click()If listDWSJ1.SelCount > 0 ThenFor i = listDWSJ1.ListCount - 1 To 0 Step -1If listDWSJ1.Selected(i) ThenlistDJSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listGGSJ1_Click()If listGGSJ1.SelCount > 0 ThenFor i = listGGSJ1.ListCount - 1 To 0 Step -1If listGGSJ1.Selected(i) ThenlistDWSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listPMSJ1_Click()If listPMSJ1.SelCount > 0 ThenFor i = listPMSJ1.ListCount - 1 To 0 Step -1If listPMSJ1.Selected(i) ThenlistGGSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listQGSLSJ1_Click()If listQGSLSJ1.SelCount > 0 ThenFor i = listQGSLSJ1.ListCount - 1 To 0 Step -1If listQGSLSJ1.Selected(i) ThenlistBHSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd Sub2.增加料号程序Private Sub comFHZY_Click()’返回上页frmJLBH.HidefrmCKGLXT.ShowEnd SubPrivate Sub comSCBH_Click()’删除If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThentextBHSJ.Text = listBHSJ1.List(i)textPMSJ.Text = listPMSJ1.List(i)textGGSJ.Text = listGGSJ1.List(i)textDWSJ.Text = listDWSJ1.List(i)textDJSJ.Text = listDJSJ1.List(i)End IfNextEnd IfDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = "Select FtextBHSJ From jlbh where FtextBHSJ='" & Trim(textBHSJ.Text) & "'"strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"strconn = strconn & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'"cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)If rst.EOF = False Thenstr1 = "Delete * from jlbh where FtextBHSJ='" & Trim(textBHSJ.Text) & "'"cnn.Execute str1textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistBHSJ1.RemoveItem (i)listPMSJ1.RemoveItem (i)listGGSJ1.RemoveItem (i)listDWSJ1.RemoveItem (i)listDJSJ1.RemoveItem (i)End IfNextEnd IfMsgBox "编号已删除!"ElseMsgBox "无此编号!请确认后重新输入"textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""End Ifrst.Closecnn.CloseSet Rs = NothingSet CN = NothingEnd SubPrivate Sub comZJBH_Click()’新增料号If textBHSJ.Text = "" Or textPMSJ.Text = "" Or textGGSJ.Text = "" Or textDWSJ.Text = "" Or textDJSJ.Text = "" ThenMsgBox "请将数据补充完整!"textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""ElseDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = "Select FtextBHSJ From jlbh where FtextBHSJ= '" & Trim(textBHSJ.Text) & "'"strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"strconn = strconn & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'"cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)If rst.EOF = False ThenMsgBox "该编号已存在,不能追加!"Elsestr1 = "Insert Into jlbh (FtextBHSJ,FtextPMSJ,FtextGGSJ,FtextDWSJ,FtextDJSJ)"str1 = str1 + "Values('" & Trim(textBHSJ.Text) & "','" & Trim(textPMSJ.Text) & "','" & Trim(textGGSJ.Text) & "','" & Trim(textDWSJ.Text) & "','" & Trim(textDJSJ.Text) & "')"cnn.Execute str1listBHSJ1.AddItem (Trim(textBHSJ.Text))listPMSJ1.AddItem (Trim(textPMSJ.Text))listGGSJ1.AddItem (Trim(textGGSJ.Text))listDWSJ1.AddItem (Trim(textDWSJ.Text))listDJSJ1.AddItem (Trim(textDJSJ.Text))MsgBox "恭喜您,添加成功!"End Ifrst.Closecnn.CloseSet Rs = NothingSet CN = NothingtextBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""End IfEnd Sub‘以下是listbox循环选中程序Private Sub listBHSJ1_Click()If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistPMSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listDJSJ1_Click()If listDJSJ1.SelCount > 0 ThenFor i = listDJSJ1.ListCount - 1 To 0 Step -1If listDJSJ1.Selected(i) ThenlistBHSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listDWSJ1_Click()If listDWSJ1.SelCount > 0 ThenFor i = listDWSJ1.ListCount - 1 To 0 Step -1If listDWSJ1.Selected(i) ThenlistDJSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listGGSJ1_Click()If listGGSJ1.SelCount > 0 ThenFor i = listGGSJ1.ListCount - 1 To 0 Step -1If listGGSJ1.Selected(i) ThenlistDWSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listPMSJ1_Click()If listPMSJ1.SelCount > 0 ThenFor i = listPMSJ1.ListCount - 1 To 0 Step -1If listPMSJ1.Selected(i) ThenlistGGSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd Sub。