当前位置:文档之家› supermaket

supermaket

经典VB超市管理系统<源代码>

系统代码清单Dim stremployee As String

Dim rs_employee As New ADODB.Recordset

Private Sub Form_Activate()

stremployee = "select * from employee "

rs_employee.Open stremployee, cnn, adOpenStatic, adLockOptimistic

Dim i As Integer

For i = 0 To rs_employee.RecordCount - 1

Combo1.AddItem (rs_employee.Fields("员工姓名"))

rs_employee.MoveNext

Next

rs_employee.Close

End Sub

Private Sub Form_Load()

cnn.Provider = "microsoft.jet.oledb.4.0"

cnn.ConnectionString = App.Path & "\sellsystem.mdb"

cnn.Open

End Sub

Private Sub Picture1_Click()

End Sub

Private Sub Label3_Click()

If Combo1.Text = "" Then

MsgBox "请输入用户名!", vbOKOnly + vbInformation, "注意"

Combo1.SetFocus

Exit Sub

ElseIf Text1.Text = "" Then

MsgBox "请输入密码!", vbOKOnly + vbInformation, "注意"

Text1.SetFocus

Exit Sub

End If

stremployee = "select * from employee where 员工姓名='" & Combo1.Text & "' and 员工密码='" & Text1.Text & "'"

rs_employee.Open stremployee, cnn, adOpenStatic, adLockOptimistic

If rs_employee.EOF = True Then

MsgBox "用户名或密码错误,请从新输入!", vbOKOnly + vbInformation, "注意"

Combo1.SetFocus

rs_employee.Close

Exit Sub

Else

strs = rs_employee.Fields("员工编号")

rs_employee.Close

End If

If Combo1.Text = "administrator" Then frminitial.Show

Else

frmMain.Show

frmMain.mnBuyAll.Enabled = False frmMain.mnSellAll.Enabled = False frmMain.mnTable.Enabled = False

End If

Unload Me

End Sub

Private Sub Label4_Click()

Unload Me

cnn.Close

End Sub

Private Sub Picture2_Click()

End Sub

Dim rs_sell As New ADODB.Recordset

Dim rs_goods As New ADODB.Recordset

Dim rs_buy As New ADODB.Recordset

Dim rs_retreat As New ADODB.Recordset

Dim rs_manufacturer As New ADODB.Recordset Dim rs_employee As New ADODB.Recordset Dim rs_fctotal As New ADODB.Recordset

Dim rs_total As New ADODB.Recordset

Dim strsell As String

Dim strgoods As String

Dim strbuy As String

Dim strretreat As String

Dim strmanufacturer As String

Dim stremployee As String

Dim strfctotal As String

Dim strtotal As String

Dim inty As Integer

Dim intm As Integer

Dim intd As Integer

Private Sub Form_Load()

inty = Year(Date)

intm = Month(Date)

intd = Day(Date)

Flash1.Movie = App.Path & "\99.swf"

End Sub

Private Sub Form_Resize()

Flash1.Width = Me.Width

Flash1.Height = Me.Height

End Sub

Private Sub mnabout_Click()

frmAbout.Show

End Sub

Private Sub mnBuy_Click()

frmAddgoods.Show

End Sub

Private Sub mnBuyMonth_Click()

frmBuyall.Text2.Enabled = False

frmBuyall.SSTab1.Tab = 1

frmBuyall.SSTab1.TabEnabled(0) = False

frmBuyall.SSTab1.TabEnabled(1) = True

frmBuyall.SSTab1.TabEnabled(2) = False

frmBuyall.SSTab1.TabEnabled(3) = False

frmBuyall.Show

strbuy = "select * from buy where 进货年=" & inty & " and 进货月=" & intm & " " rs_buy.Open strbuy, cnn, adOpenKeyset, adLockPessimistic

frmBuyall.Adodc2.RecordSource = strbuy

frmBuyall.Adodc2.Refresh

frmBuyall.DataGrid2.ReBind

If rs_buy.EOF = True Then

frmBuyall.Adodc6.RecordSource = strbuy

frmBuyall.Adodc6.Refresh

frmBuyall.DataGrid6.ReBind

MsgBox "您本月没有进货记录!", vbOKOnly + vbInformation, "注意" https://www.doczj.com/doc/6a6707155.html,mand9.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand10.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand11.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand12.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand13.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand14.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand15.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand16.Enabled = False

rs_buy.Close

Exit Sub

End If

rs_buy.Close

strfctotal = "select 生产厂商,sum(总金额) as 各厂商进货总金额from buy where 进货年=" & inty & " and 进货月=" & intm & " group by 生产厂商"

rs_fctotal.Open strfctotal, cnn, adOpenKeyset, adLockPessimistic

frmBuyall.Adodc6.RecordSource = strfctotal

frmBuyall.Adodc6.Refresh

frmBuyall.DataGrid6.ReBind

rs_fctotal.Close

strtotal = "select sum(总金额) as 进货总金额from buy where 进货年=" & inty & " and 进货月=" & intm & " "

rs_total.Open strtotal, cnn, adOpenKeysetm, adLockPessimistic

frmBuyall.Text2.Text = rs_total.Fields("进货总金额")

rs_total.Close

End Sub

Private Sub mnBuyQuarterly_Click()

frmBuyall.Text3.Enabled = False

frmBuyall.SSTab1.Tab = 2

frmBuyall.SSTab1.TabEnabled(0) = False

frmBuyall.SSTab1.TabEnabled(1) = False

frmBuyall.SSTab1.TabEnabled(2) = True

frmBuyall.SSTab1.TabEnabled(3) = False

frmBuyall.Show

Select Case intm

Case Is < 4

intm = 3

Case Is < 7

intm = 6

Case Is < 10

intm = 9

Case Is > 10

intm = 12

End Select

strbuy = "select * from buy where 进货年=" & inty & " and 进货月between " & (intm - 2) & " and " & intm & " "

rs_buy.Open strbuy, cnn, adOpenKeyset, adLockPessimistic

frmBuyall.Adodc2.RecordSource = strbuy

frmBuyall.Adodc2.Refresh

frmBuyall.DataGrid2.ReBind

If rs_buy.EOF = True Then

frmBuyall.Adodc6.RecordSource = strbuy

frmBuyall.Adodc6.Refresh

frmBuyall.DataGrid6.ReBind

MsgBox "您本季度没有进货记录!", vbOKOnly + vbInformation, "注意"

https://www.doczj.com/doc/6a6707155.html,mand17.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand18.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand19.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand20.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand21.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand22.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand23.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand24.Enabled = False

rs_buy.Close

Exit Sub

End If

rs_buy.Close

strfctotal = "select 生产厂商,sum(总金额) as 各厂商进货总金额from buy where 进货年=" & inty & " and 进货月between " & (intm - 2) & " and " & intm & " group by 生产厂商"

rs_fctotal.Open strfctotal, cnn, adOpenKeyset, adLockPessimistic

frmBuyall.Adodc6.RecordSource = strfctotal

frmBuyall.Adodc6.Refresh

frmBuyall.DataGrid6.ReBind

rs_fctotal.Close

strtotal = "select sum(总金额) as 进货总金额from buy where 进货年=" & inty & " and 进货月between " & (intm - 2) & " and " & intm & " "

rs_total.Open strtotal, cnn, adOpenKeysetm, adLockPessimistic

frmBuyall.Text3.Text = rs_total.Fields("进货总金额")

rs_total.Close

intm = Month(Date)

End Sub

Private Sub mnBuyTable_Click()

frmBuyTable.Show

End Sub

Private Sub mnBuyToday_Click()

frmBuyall.Text1.Enabled = False

frmBuyall.SSTab1.Tab = 0

frmBuyall.SSTab1.TabEnabled(0) = True

frmBuyall.SSTab1.TabEnabled(1) = False

frmBuyall.SSTab1.TabEnabled(3) = False

frmBuyall.Show

strbuy = "select * from buy where 进货年=" & inty & " and 进货月=" & intm & " and 进货日=" & intd & " "

rs_buy.Open strbuy, cnn, adOpenKeyset, adLockPessimistic

frmBuyall.Adodc1.RecordSource = strbuy

frmBuyall.Adodc1.Refresh

frmBuyall.DataGrid1.ReBind

If rs_buy.EOF = True Then

frmBuyall.Adodc5.RecordSource = strbuy

frmBuyall.Adodc5.Refresh

frmBuyall.DataGrid5.ReBind

MsgBox "您今日没有进货记录!", vbOKOnly + vbInformation, "注意"

https://www.doczj.com/doc/6a6707155.html,mand1.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand2.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand3.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand4.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand5.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand6.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand7.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand8.Enabled = False

rs_buy.Close

Exit Sub

End If

rs_buy.Close

strfctotal = "select 生产厂商,sum(总金额) as 各厂商进货总金额from buy where 进货年=" & inty & " and 进货月=" & intm & "and 进货日=" & intd & " group by 生产厂商"

rs_fctotal.Open strfctotal, cnn, adOpenKeyset, adLockPessimistic

frmBuyall.Adodc5.RecordSource = strfctotal

frmBuyall.Adodc5.Refresh

frmBuyall.DataGrid5.ReBind

rs_fctotal.Close

strtotal = "select sum(总金额) as 进货总金额from buy where 进货年=" & inty & " and 进货月=" & intm & "and 进货日=" & intd & ""

rs_total.Open strtotal, cnn, adOpenKeysetm, adLockPessimistic

frmBuyall.Text1.Text = rs_total.Fields("进货总金额")

rs_total.Close

End Sub

Private Sub mnBuyYear_Click()

frmBuyall.Text4.Enabled = False

frmBuyall.SSTab1.Tab = 3

frmBuyall.SSTab1.TabEnabled(0) = False

frmBuyall.SSTab1.TabEnabled(2) = False

frmBuyall.SSTab1.TabEnabled(3) = True

frmBuyall.Show

strbuy = "select * from buy where 进货年=" & inty & " "

rs_buy.Open strbuy, cnn, adOpenKeyset, adLockPessimistic

frmBuyall.Adodc4.RecordSource = strbuy

frmBuyall.Adodc4.Refresh

frmBuyall.DataGrid4.ReBind

If rs_buy.EOF = True Then

frmBuyall.Adodc8.RecordSource = strbuy

frmBuyall.Adodc8.Refresh

frmBuyall.DataGrid8.ReBind

MsgBox "您今年没有进货记录!", vbOKOnly + vbInformation, "注意"

https://www.doczj.com/doc/6a6707155.html,mand25.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand26.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand27.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand28.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand29.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand30.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand31.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand32.Enabled = False

rs_buy.Close

Exit Sub

End If

rs_buy.Close

strfctotal = "select 生产厂商,sum(总金额) as 各厂商进货总金额from buy where 进货年=" & inty & " group by 生产厂商"

rs_fctotal.Open strfctotal, cnn, adOpenKeyset, adLockPessimistic

frmBuyall.Adodc8.RecordSource = strfctotal

frmBuyall.Adodc8.Refresh

frmBuyall.DataGrid8.ReBind

rs_fctotal.Close

strtotal = "select sum(总金额) as 进货总金额from buy where 进货年=" & inty & " "

rs_total.Open strtotal, cnn, adOpenKeysetm, adLockPessimistic

frmBuyall.Text4.Text = rs_total.Fields("进货总金额")

rs_total.Close

End Sub

Private Sub mnChangeEmployee_Click()

cnn.Close

frmLogin.Show

Unload Me

End Sub

Private Sub mnChangePwd_Click() frmChangePwd.Show

End Sub

Private Sub mnEmployeeTable_Click() frmEmployeeTable.Show

End Sub

Private Sub mnExit_Click()

cnn.Close

Unload Me

End Sub

Private Sub mnGoodsTable_Click() frmShowGoodstable.Show

End Sub

Private Sub mnlogin_Click() frmLogin.Show

End Sub

Private Sub mnManufacturerTable_Click() frmManufacturerTable.Show

End Sub

Private Sub mnRetreat_Click() frmRetreatgoods.Show

End Sub

Private Sub mnRetreatTable_Click() frmRetreatTable.Show

End Sub

Private Sub mnSell_Click() frmSellgoods.Show

End Sub

Private Sub mnSellMonth_Click() frmSellall.SSTab1.Tab = 1

frmSellall.Text2.Enabled = False frmSellall.SSTab1.TabEnabled(0) = False frmSellall.SSTab1.TabEnabled(1) = True

frmSellall.SSTab1.TabEnabled(3) = False

frmSellall.Show

strsell = "select * from sell where 销售年=" & inty & " and 销售月=" & intm & " "

rs_sell.Open strsell, cnn, adOpenKeyset, adLockPessimistic

frmSellall.Adodc2.RecordSource = strsell

frmSellall.Adodc2.Refresh

frmSellall.DataGrid2.ReBind

If rs_sell.EOF = True Then

frmSellall.Adodc6.RecordSource = strsell

frmSellall.Adodc6.Refresh

frmSellall.DataGrid6.ReBind

MsgBox "您本月没有销售记录!", vbOKOnly + vbInformation, "注意"

https://www.doczj.com/doc/6a6707155.html,mand9.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand10.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand11.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand12.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand13.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand14.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand15.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand16.Enabled = False

rs_sell.Close

Exit Sub

End If

rs_sell.Close

strfctotal = "select 生产厂商,sum(总金额) as 各厂商销售总金额from sell where 销售年=" & inty & " and 销售月=" & intm & " group by 生产厂商"

rs_fctotal.Open strfctotal, cnn, adOpenKeyset, adLockPessimistic

frmSellall.Adodc6.RecordSource = strfctotal

frmSellall.Adodc6.Refresh

frmSellall.DataGrid6.ReBind

rs_fctotal.Close

strtotal = "select sum(总金额) as 销售总金额from sell where 销售年=" & inty & " and 销售月=" & intm & " " rs_total.Open strtotal, cnn, adOpenKeysetm, adLockPessimistic

frmSellall.Text2.Text = rs_total.Fields("销售总金额")

rs_total.Close

End Sub

Private Sub mnSellQuarterly_Click()

frmSellall.SSTab1.Tab = 2

frmSellall.Text3.Enabled = False

frmSellall.SSTab1.TabEnabled(0) = False

frmSellall.SSTab1.TabEnabled(1) = False

frmSellall.SSTab1.TabEnabled(2) = True

frmSellall.Show

Select Case intm

Case Is < 4

intm = 3

Case Is < 7

intm = 6

Case Is < 10

intm = 9

Case Is > 10

intm = 12

End Select

strsell = "select * from sell where 销售年=" & inty & " and 销售月between " & (intm - 2) & " and " & intm & " "

rs_sell.Open strsell, cnn, adOpenKeyset, adLockPessimistic

frmSellall.Adodc2.RecordSource = strsell

frmSellall.Adodc2.Refresh

frmSellall.DataGrid2.ReBind

If rs_sell.EOF = True Then

frmSellall.Adodc6.RecordSource = strsell

frmSellall.Adodc6.Refresh

frmSellall.DataGrid6.ReBind

MsgBox "您本季度没有销售记录!", vbOKOnly + vbInformation, "注意"

https://www.doczj.com/doc/6a6707155.html,mand17.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand18.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand19.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand20.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand21.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand22.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand23.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand24.Enabled = False

rs_sell.Close

Exit Sub

End If

rs_sell.Close

strfctotal = "select 生产厂商,sum(总金额) as 各厂商销售总金额from sell where 销售年=" & inty & " and 销售月between " & (intm - 2) & " and " & intm & " group by 生产厂商"

rs_fctotal.Open strfctotal, cnn, adOpenKeyset, adLockPessimistic

frmSellall.Adodc6.RecordSource = strfctotal

frmSellall.Adodc6.Refresh

frmSellall.DataGrid6.ReBind

rs_fctotal.Close

strtotal = "select sum(总金额) as 销售总金额from sell where 销售年=" & inty & " and 销售月between " & (intm - 2) & " and " & intm & " "

rs_total.Open strtotal, cnn, adOpenKeysetm, adLockPessimistic

frmSellall.Text3.Text = rs_total.Fields("销售总金额")

rs_total.Close

intm = Month(Date)

End Sub

Private Sub mnSellTable_Click()

frmSellTable.Show

End Sub

Private Sub mnSellToday_Click()

frmSellall.SSTab1.Tab = 0

frmSellall.Text1.Enabled = False

frmSellall.SSTab1.TabEnabled(0) = True

frmSellall.SSTab1.TabEnabled(1) = False

frmSellall.SSTab1.TabEnabled(2) = False

frmSellall.SSTab1.TabEnabled(3) = False

frmSellall.Show

strsell = "select * from sell where 销售年=" & inty & " and 销售月=" & intm & " and 销售日=" & intd & " "

rs_sell.Open strsell, cnn, adOpenKeyset, adLockPessimistic

frmSellall.Adodc1.RecordSource = strsell

frmSellall.Adodc1.Refresh

frmSellall.DataGrid1.ReBind

If rs_sell.EOF = True Then

frmSellall.Adodc5.RecordSource = strsell

frmSellall.Adodc5.Refresh

frmSellall.DataGrid5.ReBind

MsgBox "您今日没有销售记录!", vbOKOnly + vbInformation, "注意"

https://www.doczj.com/doc/6a6707155.html,mand1.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand2.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand3.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand4.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand5.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand6.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand7.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand8.Enabled = False

rs_sell.Close

Exit Sub

End If

rs_sell.Close

strfctotal = "select 生产厂商,sum(总金额) as 各厂商销售总金额from sell where 销售年=" & inty & " and 销售月=" & intm & "and 销售日=" & intd & " group by 生产厂商"

rs_fctotal.Open strfctotal, cnn, adOpenKeyset, adLockPessimistic

frmSellall.Adodc5.RecordSource = strfctotal

frmSellall.DataGrid5.ReBind

rs_fctotal.Close

strtotal = "select sum(总金额) as 销售总金额from sell where 销售年=" & inty & " and 销售月=" & intm & "and 销售日=" & intd & ""

rs_total.Open strtotal, cnn, adOpenKeysetm, adLockPessimistic

frmSellall.Text1.Text = rs_total.Fields("销售总金额")

rs_total.Close

End Sub

Private Sub mnSellYear_Click()

frmSellall.Text4.Enabled = False

frmSellall.SSTab1.Tab = 3

frmSellall.SSTab1.TabEnabled(0) = False

frmSellall.SSTab1.TabEnabled(1) = False

frmSellall.SSTab1.TabEnabled(2) = False

frmSellall.SSTab1.TabEnabled(3) = True

frmSellall.Show

strsell = "select * from sell where 销售年=" & inty & " "

rs_sell.Open strsell, cnn, adOpenKeyset, adLockPessimistic

frmSellall.Adodc4.RecordSource = strsell

frmSellall.Adodc4.Refresh

frmSellall.DataGrid4.ReBind

If rs_sell.EOF = True Then

frmSellall.Adodc8.RecordSource = strsell

frmSellall.Adodc8.Refresh

frmSellall.DataGrid8.ReBind

MsgBox "您今年没有销售记录!", vbOKOnly + vbInformation, "注意"

https://www.doczj.com/doc/6a6707155.html,mand25.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand26.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand27.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand28.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand29.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand30.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand31.Enabled = False

https://www.doczj.com/doc/6a6707155.html,mand32.Enabled = False

rs_sell.Close

Exit Sub

End If

rs_sell.Close

strfctotal = "select 生产厂商,sum(总金额) as 各厂商销售总金额from sell where 销售年=" & inty & " group by 生产厂商"

rs_fctotal.Open strfctotal, cnn, adOpenKeyset, adLockPessimistic

frmSellall.Adodc8.RecordSource = strfctotal

frmSellall.DataGrid8.ReBind

rs_fctotal.Close

strtotal = "select sum(总金额) as 销售总金额from sell where 销售年=" & inty & " " rs_total.Open strtotal, cnn, adOpenKeysetm, adLockPessimistic

frmSellall.Text4.Text = rs_total.Fields("销售总金额")

rs_total.Close

End Sub

' 在通用中定义的有关连接数据表的记录集

Dim rs_goods As New ADODB.Recordset

Dim rs_buy As New ADODB.Recordset

Dim rs_manufacturer As New ADODB.Recordset

Dim str_goods As String

Dim str_buy As String

Dim str_manufacturer As String

Dim Numgooods As Integer

Private Sub Command1_Click()

'对入库时做的一些屏蔽操作!

If Text1.Text = "" Then

MsgBox "请填写进货编号!", vbOKOnly + vbInformation, "注意"

Text1.SetFocus

Exit Sub

ElseIf Text2.Text = "" Then

MsgBox "请填写商品编号!", vbOKOnly + vbInformation, "注意"

Text2.SetFocus

Exit Sub

ElseIf Text3.Text = "" Then

MsgBox "请填写商品名称!", vbOKOnly + vbInformation, "注意"

Text3.SetFocus

Exit Sub

ElseIf Text4.Text = "" Then

MsgBox "请填写生产厂商!", vbOKOnly + vbInformation, "注意"

Text4.SetFocus

Exit Sub

ElseIf Text5.Text = "" Then

MsgBox "请填写商品型号!", vbOKOnly + vbInformation, "注意"

Text5.SetFocus

Exit Sub

ElseIf Text6.Text = "" Then

MsgBox "请填写商品数量!", vbOKOnly + vbInformation, "注意"

Text6.SetFocus

Exit Sub

ElseIf Text7.Text = "" Then

MsgBox "请填写商品进货价格!", vbOKOnly + vbInformation, "注意"

Text7.SetFocus

Exit Sub

ElseIf Text8.Text = "" Then

MsgBox "请填写商品销货价格!", vbOKOnly + vbInformation, "注意"

Text8.SetFocus

Exit Sub

ElseIf Text13.Text = "" Then

MsgBox "请填写进货总金额!", vbOKOnly + vbInformation, "注意"

Text13.SetFocus

Exit Sub

End If

'下面是对进货表进行添加记录操作!

str_buy = "select * from buy where 进货编号='" & Text1.Text & "'"

rs_buy.Open str_buy, cnn, adOpenStatic, adLockOptimistic ' 打开进货表

If rs_buy.EOF = True Then

rs_buy.AddNew

rs_buy.Fields("进货编号") = Text1.Text

rs_buy.Fields("商品名称") = Text3.Text

rs_buy.Fields("生产厂商") = Text4.Text

rs_buy.Fields("型号") = Text5.Text

rs_buy.Fields("数量") = Val(Text6.Text)

rs_buy.Fields("进货价") = Val(Text7.Text)

rs_buy.Fields("进货年") = Text9.Text

rs_buy.Fields("进货月") = Text10.Text

rs_buy.Fields("进货日") = Text11.Text

rs_buy.Fields("业务员编号") = Text12.Text

rs_buy.Fields("总金额") = Val(Text13.Text)

rs_buy.Update

rs_buy.Close ' 关闭进货表

Else

MsgBox "此进货编号已存在,请重添!", vbOKOnly + vbInformation, "注意" Text1.Text = ""

Text1.SetFocus

rs_buy.Close

Exit Sub ' 关闭进货表

End If

'下面是对商品库存表进行入库操作!

Dim sql As String

sql = "select * from goods where 商品编号= '" & Text2.Text & "'"

rs_goods.Open sql, cnn, adOpenStatic, adLockOptimistic

If rs_goods.EOF = True Then

rs_goods.Close

str_goods = "select * from goods"

rs_goods.Open str_goods, cnn, adOpenStatic, adLockOptimistic ' 打开库存表rs_goods.AddNew

rs_goods.Fields("商品编号") = Text2.Text

rs_goods.Fields("商品名称") = Text3.Text

rs_goods.Fields("生产厂商") = Text4.Text

rs_goods.Fields("型号") = Text5.Text

rs_goods.Fields("数量") = Val(Text6.Text)

rs_goods.Fields("进货价") = Val(Text7.Text)

rs_goods.Fields("销货价") = Val(Text8.Text)

rs_goods.Update

MsgBox "商品入库成功", vbOKOnly + vbExclamation, ""

rs_goods.Close ' 关闭库存表

Else

numgoods = rs_goods.Fields("数量")

rs_goods.Fields("数量") = Val(Text6.Text) + numgoods

rs_goods.Update

MsgBox "商品入库成功", vbOKOnly + vbExclamation, ""

rs_goods.Close ' 关闭库存表

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text7.Text = ""

Text8.Text = ""

Text13.Text = ""

End Sub

Private Sub Command3_Click()

'对入库时做的一些屏蔽操作!

If Text14.Text = "" Then

MsgBox "请填写厂商编号!", vbOKOnly + vbInformation, "注意"

Text14.SetFocus

Exit Sub

ElseIf Text15.Text = "" Then

MsgBox "请填写厂商名称!", vbOKOnly + vbInformation, "注意"

Text15.SetFocus

Exit Sub

ElseIf Text16.Text = "" Then

MsgBox "请填写厂商联系人姓名!", vbOKOnly + vbInformation, "注意"

Text16.SetFocus

Exit Sub

ElseIf Text17.Text = "" Then

MsgBox "请填写电话!", vbOKOnly + vbInformation, "注意"

Text17.SetFocus

Exit Sub

ElseIf Text18.Text = "" Then

MsgBox "请填写厂商地址!", vbOKOnly + vbInformation, "注意"

Text18.SetFocus

Exit Sub

End If

'下面是对进货商表进行入库操作!

str_manufacturer = "select * from manufacturer where 厂商编号='" & Text14.Text & "'" rs_manufacturer.Open str_manufacturer, cnn, adOpenStatic, adLockOptimistic

If rs_manufacturer.EOF = True Then

rs_manufacturer.AddNew

rs_manufacturer.Fields("厂商编号") = Text14.Text

rs_manufacturer.Fields("厂商名称") = Text15.Text

rs_manufacturer.Fields("联系人姓名") = Text16.Text

rs_manufacturer.Fields("电话") = Text17.Text

rs_manufacturer.Fields("厂商地址") = Text18.Text

rs_manufacturer.Update

MsgBox "添加厂商成功", vbOKOnly + vbExclamation, ""

rs_manufacturer.Close

Else

MsgBox "该编号已存在,请确认!", vbOKOnly + vbInformation, ""

Text14.Text = ""

Text14.SetFocus

rs_manufacturer.Close

Exit Sub

End If

End Sub

Private Sub Command4_Click()

Text14.Text = ""

Text15.Text = ""

Text16.Text = ""

Text17.Text = ""

Text18.Text = ""

End Sub

Private Sub Form_Load()

Text9.Enabled = False

Text10.Enabled = False

Text11.Enabled = False

Text12.Enabled = False

Text9.Text = Year(Date)

Text10.Text = Month(Date)

Text11.Text = Day(Date)

Text12.Text = strs

End Sub

Private Sub Text2_Change()

'如果商品编号存在,则直接出现本商品的相关数据

str_goods = "select * from goods where 商品编号='" & Text2.Text & "'" rs_goods.Open str_goods, cnn, adOpenStatic, adLockOptimistic

Text3.Text = rs_goods.Fields("商品名称")

Text4.Text = rs_goods.Fields("生产厂商")

Text5.Text = rs_goods.Fields("型号")

Text7.Text = rs_goods.Fields("进货价")

Text8.Text = rs_goods.Fields("销货价")

rs_goods.Close

End Sub

Private Sub Text6_Change()

'总金额的直接出现操作

If Text7.Text <> "" Then

Text13.Text = Val(Text6.Text) * Val(Text7.Text)

End If

End Sub

Private Sub Text7_Change()

'总金额的直接出现操作

If Text6.Text <> "" Then

Text13.Text = Val(Text6.Text) * Val(Text7.Text)

End If

End Sub

Dim rs_goods As New ADODB.Recordset

Dim rs_sell As New ADODB.Recordset

Dim str_goods As String

Dim str_sell As String

Dim numgoods As Integer

Private Sub Command1_Click()

If Text1.Text = "" Then

MsgBox "请填写销货编号!", vbOKOnly + vbInformation, "注意" Text1.SetFocus

Exit Sub

ElseIf Text2.Text = "" Then

MsgBox "请填写商品编号!", vbOKOnly + vbInformation, "注意"

Text2.SetFocus

Exit Sub

End If

str_goods = "select * from goods where 商品编号='" & Text2.Text & "'"

rs_goods.Open str_goods, cnn, adOpenStatic, adLockOptimistic

If rs_goods.EOF = True Then

MsgBox "对不起,此商品型号已无货!请选择其他型!", vbOKOnly + vbInformation, "注意" rs_goods.Close

Exit Sub

End If

rs_goods.Close

If Text11.Text = "" Then

MsgBox "请填写销货数量!", vbOKOnly + vbInformation, "注意"

Text11.SetFocus

Exit Sub

End If

Text12.Text = Val(Text6.Text) * Val(Text11.Text)

'下面是对销售表进行入库操作!

str_sell = "select * from sell where 销货编号='" & Text1.Text & "'"

rs_sell.Open str_sell, cnn, adOpenStatic, adLockOptimistic

If rs_sell.EOF = True Then

rs_sell.AddNew

rs_sell.Fields("销货编号") = Text1.Text

rs_sell.Fields("商品编号") = Text2.Text

rs_sell.Fields("商品名称") = Text3.Text

rs_sell.Fields("生产厂商") = Text4.Text

rs_sell.Fields("型号") = Text5.Text

rs_sell.Fields("单价") = Text6.Text

rs_sell.Fields("销售年") = Text7.Text

rs_sell.Fields("销售月") = Text8.Text

rs_sell.Fields("销售日") = Text9.Text

rs_sell.Fields("业务员编号") = Text10.Text

rs_sell.Fields("数量") = Val(Text11.Text)

rs_sell.Fields("总金额") = Val(Text12.Text)

rs_sell.Fields("销售时") = Text13.Text

rs_sell.Fields("销售分") = Text14.Text

rs_sell.Fields("销售秒") = Text15.Text

rs_sell.Update

rs_sell.Close

Else

MsgBox "此销货编号已存在,请重添!", vbOKOnly + vbInformation, "注意"

Text1.Text = ""

Text1.SetFocus

rs_sell.Close

Exit Sub

End If

'下面是对商品库存表的减货操作!

str_goods = "select * from goods where 商品编号='" & Text2.Text & "'" rs_goods.Open str_goods, cnn, adOpenStatic, adLockOptimistic numgoods = rs_goods.Fields("数量")

rs_goods.Fields("数量") = numgoods - Val(Text11.Text)

rs_goods.Update

rs_goods.Close

MsgBox "销售成功!", vbOKOnly + vbExclamation, "注意"

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text11.Text = ""

Text12.Text = ""

Text13.Text = ""

Text14.Text = ""

Text15.Text = ""

End Sub

Private Sub Form_Load()

Text7.Text = Year(Date)

Text8.Text = Month(Date)

Text9.Text = Day(Date)

Text10.Text = strs

Text3.Enabled = False

Text4.Enabled = False

Text5.Enabled = False

Text6.Enabled = False

Text7.Enabled = False

Text8.Enabled = False

Text9.Enabled = False

Text10.Enabled = False

Text12.Enabled = False

Text13.Enabled = False

Text14.Enabled = False

Text15.Enabled = False

End Sub

Private Sub Text11_Change()

If Text6.Text <> "" Then

Text12.Text = Val(Text6.Text) * Val(Text11.Text)

End If

End Sub

Private Sub Text12_Change()

Text13.Text = Val(Hour(Time))

Text14.Text = Val(Minute(Time))

Text15.Text = Val(Second(Time))

End Sub

Private Sub Text2_Change()

str_goods = "select * from goods where 商品编号='" & Text2.Text & "'" rs_goods.Open str_goods, cnn, adOpenStatic, adLockOptimistic

Text3.Text = rs_goods.Fields("商品名称")

Text4.Text = rs_goods.Fields("生产厂商")

Text5.Text = rs_goods.Fields("型号")

Text6.Text = rs_goods.Fields("销货价")

rs_goods.Close

End Sub

Dim inty As Integer

Dim intm As Integer

Dim intd As Integer

Private Sub Command1_Click()

Adodc1.Recordset.MoveFirst

End Sub

Private Sub Command10_Click()

If Adodc2.Recordset.EOF = True Then

MsgBox "已是末记录!", vbOKOnly + vbInformation, "注意"

Adodc2.Recordset.MoveLast

Else

Adodc2.Recordset.MoveNext

End If

End Sub

Private Sub Command11_Click()

相关主题
文本预览
相关文档 最新文档