📄 yy_khsh_djb.frm
字号:
TDBGrid1.Columns(19).Value = "完成"
End If
End If
End Sub
Private Sub TDBGrid1_BeforeColupdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)
If Cmdadd.Enabled = False And (ColIndex = 12 Or ColIndex = 9 Or ColIndex = 8) Then
TDBGrid1.Columns(12).Value = Val(TDBGrid1.Columns(9).Value) * Val(TDBGrid1.Columns(8).Value)
End If
End Sub
Private Sub TDBGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If Cmdadd.Enabled = False Then
If KeyCode = 46 Then
With Adodc_body_general.Recordset
DB.Execute "update yy_khdd set wanch='未完成' where ddbh='" & .Fields("ddbh").Value & "' and cpbh='" & .Fields("cpbh").Value & "' and cpmc='" & .Fields("cpmc").Value & "' and caizh='" & .Fields("caizh").Value & "' and yanse='" & .Fields("yanse").Value & "'"
Adodc_body_general.Recordset.Delete
Adodc_body_general.Recordset.UpdateBatch adAffectAll
Adodc_body_general.Refresh
End With
End If
End If
End Sub
Private Sub Text1_Change(Index As Integer)
If Index = 0 Then
Adodc_body_general.ConnectionString = Conn_Str
Adodc_body_general.RecordSource = "select * from yy_cpshd with (nolock) where left(shdbh,2)<>'BS' and shdbh='" & Text1(0).Text & "'"
Adodc_body_general.Refresh
End If
End Sub
Private Sub Text1_Click(Index As Integer)
If KeyAscii = 13 Then ' 按回车
KeyAscii = 0
SendKeys "{TAB}"
End If
End Sub
Private Sub text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 40 Then '向下箭头
If Index + 1 < Text1.Count Then
Text1(Index + 1).SetFocus
Else
Text1(0).SetFocus
End If
End If
If KeyCode = 38 Then '向上箭头
If Index - 1 >= 0 Then
Text1(Index - 1).SetFocus
Else
Text1(Text1.Count - 1).SetFocus
End If
End If
End Sub
Private Sub Cmdadd_Click() '添加
Tjbz = True
TDBGrid1.AllowDelete = True
TDBGrid1.AllowUpdate = True
Dim ni As String
Dim yue As String
Dim ri As String
CmD_SH.Enabled = False
CmD_FinD.Enabled = False
Cmdreturn.Enabled = False
cmdxq.Enabled = False
cmdnext.Enabled = False
cmdmd.Enabled = False
cmdqd.Enabled = False
Cmdprint.Enabled = False
TDBGrid3.Enabled = False
Cmddelete.Enabled = False
Cmdadd.Enabled = False
Cmdedit.Enabled = False
Cmdreturn.Enabled = False
CmdOK.Enabled = True
Cmdcancel.Enabled = True
ni = Right(Year(Date), 2)
If Len(Month(Date)) < 2 Then
yue = "0" & Month(Date)
Else
yue = Month(Date)
End If
If Len(Day(Date)) < 2 Then
ri = "0" & Day(Date)
Else
ri = Day(Date)
End If
Set DdBh_Ado = New Recordset
DdBh_Ado.Open "select distinct shdbh from yy_cpshdt where left(shdbh,2)='SH' and year(djrq)='" & Year(Date) & "'and month(djrq)='" & Month(Date) & "' order by shdbh", DB, adOpenStatic
If DdBh_Ado.RecordCount < 1 Then
bh = "00001"
Else
DdBh_Ado.MoveLast
bhx = Trim(Str(Val(Right(DdBh_Ado.Fields("shdbh").Value, 5)) + 1))
If Len(bhx) = 1 Then
bh = "0000" & bhx
End If
If Len(bhx) = 2 Then
bh = "000" + bhx
End If
If Len(bhx) = 3 Then
bh = "00" + bhx
End If
If Len(bhx) = 4 Then
bh = "0" + bhx
End If
If Len(bhx) > 4 Then
bh = bhx
End If
End If
On Error GoTo AddErr
If AdoprimaryRs.Recordset.RecordCount > 0 Then
AdoprimaryRs.Recordset.MoveLast
End If
AdoprimaryRs.Recordset.AddNew
For i = 0 To Text1.Count - 1
Text1(i).Enabled = True
Next i
For i = 0 To Combo.Count - 1
Combo(i).Enabled = True
Next i
Text1(0).Text = "SH" + ni + yue + bh
Text1(1).Text = VBA.Date
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub cmdDelete_Click() '删除
On Error Resume Next
If MsgBox("是否真的删除当前记录 ?", vbYesNo + 32, "系统提示") = vbYes Then
Call Xg_Com
Adodc_body_general.Recordset.ActiveConnection.Execute "delete from yy_cpshd where shdbh='" & Trim(Text1(0).Text) & "'"
Adodc_body_general.Recordset.UpdateBatch adAffectAll
DB.Execute "delete from yy_cpshdt where shdbh='" & Trim(Text1(0).Text) & "'"
End If
AdoprimaryRs.Refresh
Adodc_body_general.Refresh
End Sub
Private Sub cmdEdit_Click() '修改
TDBGrid1.AllowDelete = True
TDBGrid1.AllowUpdate = True
For i = 0 To Text1.Count - 1
Text1(i).Enabled = True
Next i
For i = 0 To Combo.Count - 1
Combo(i).Enabled = True
Next i
'Call Xg_Com
CmD_SH.Enabled = False
CmD_FinD.Enabled = False
Cmdreturn.Enabled = False
cmdxq.Enabled = False
cmdnext.Enabled = False
cmdmd.Enabled = False
cmdqd.Enabled = False
Cmdprint.Enabled = False
TDBGrid3.Enabled = False
Cmddelete.Enabled = False
Cmdadd.Enabled = False
Cmdedit.Enabled = False
Cmdreturn.Enabled = False
CmdOK.Enabled = True
Cmdcancel.Enabled = True
On Error GoTo EditErr
Exit Sub
EditErr:
MsgBox Err.Description
End Sub
Private Sub cmdCancel_Click() '取消
If Tjbz = True Then
DB.Execute "delete from yy_CPSHD where SHDBH='" & Trim(Text1(0).Text) & "'"
Adodc_body_general.Recordset.UpdateBatch adAffectAll
End If
Tjbz = False
TDBGrid1.AllowDelete = False
TDBGrid1.AllowUpdate = False
For i = 0 To Text1.Count - 1
Text1(i).Enabled = False
Next i
For i = 0 To Combo.Count - 1
Combo(i).Enabled = False
Next i
CmD_SH.Enabled = True
CmD_FinD.Enabled = True
Cmdreturn.Enabled = True
cmdxq.Enabled = True
cmdnext.Enabled = True
cmdmd.Enabled = True
cmdqd.Enabled = True
Cmdprint.Enabled = True
TDBGrid3.Enabled = True
Cmddelete.Enabled = True
Cmdadd.Enabled = True
Cmdedit.Enabled = True
Cmdreturn.Enabled = True
CmdOK.Enabled = False
Cmdcancel.Enabled = False
On Error Resume Next
AdoprimaryRs.Recordset.CancelUpdate
If mvBookMark > 0 Then
AdoprimaryRs.Recordset.Bookmark = mvBookMark
Else
AdoprimaryRs.Recordset.MoveFirst
End If
End Sub
Private Sub cmdOK_Click() '确认
'On Error Resume Next
TDBGrid1.AllowDelete = False
TDBGrid1.AllowUpdate = False
If Text1(0).Text = "" Then
MsgBox "所有名称不能为空", 48, "提示"
Text1(0).SetFocus
Exit Sub
End If
If Text1(1).Text = "" Then
MsgBox "所有名称不能为空", 48, "提示"
Text1(0).SetFocus
Exit Sub
End If
For i = 0 To Text1.Count - 1
Text1(i).Enabled = False
Next i
For i = 0 To Combo.Count - 1
Combo(i).Enabled = False
Next i
Dim sums1 As Recordset
Set Sumsl = New Recordset
Sumsl.Open "select sum(isnull(sl,0)) as zsl,sum(isnull(je,0)) as zje from yy_cpshd where shdbh='" & Text1(0).Text & "'", DB, adOpenStatic
Sumsl.MoveFirst
If Sumsl.RecordCount > 0 And Not IsNull(Sumsl!zje) Then
Text1(6).Text = Sumsl!zsl
Text1(5).Text = Sumsl!zje
End If
CmD_SH.Enabled = True
CmD_FinD.Enabled = True
Cmdreturn.Enabled = True
cmdxq.Enabled = True
cmdnext.Enabled = True
cmdmd.Enabled = True
cmdqd.Enabled = True
Cmdprint.Enabled = True
TDBGrid3.Enabled = True
Cmddelete.Enabled = True
Cmdadd.Enabled = True
Cmdedit.Enabled = True
Cmdreturn.Enabled = True
CmdOK.Enabled = False
Cmdcancel.Enabled = False
Tjbz = False
AdoprimaryRs.Recordset.UpdateBatch adAffectAll
Adodc_body_general.Recordset.UpdateBatch adAffectAll
If AdoprimaryRs.Recordset.BOF Then
AdoprimaryRs.Recordset.MovePrevious
AdoprimaryRs.Recordset.MoveNext
Else
AdoprimaryRs.Recordset.MoveNext
AdoprimaryRs.Recordset.MovePrevious
End If
Call Qr_Com
Exit Sub
End Sub
Sub Cob_Load()
Set Combo6_Data = New Recordset
Combo6_Data.Open "select DISTINCT khbh from yy_khzl where not khbh is null order by khbh", DB, adOpenStatic
If Combo6_Data.RecordCount > 0 Then
For i = 1 To Combo6_Data.RecordCount
Combo(0).AddItem (Combo6_Data.Fields("khbh"))
If Combo6_Data.EOF = False Then
Combo6_Data.MoveNext
End If
Next i
End If
Set Combo7 = New Recordset
Combo7.Open "select DISTINCT name from sys_gzry where zhwu like '%员%'", DB, adOpenStatic
If Combo7.RecordCount > 0 Then
For i = 1 To Combo7.RecordCount
Combo(1).AddItem (Combo7.Fields("name"))
If Combo7.EOF = False Then
Combo7.MoveNext
End If
Next i
End If
End Sub
Sub Shd_Dr()
Combo(2).Clear
Set Combo8 = New Recordset
Combo8.Open "select DISTINCT ddbh from yy_khdd where khbh='" & Trim(Combo(0).Text) & "' and wanch<>'完成'", DB, adOpenStatic
If Combo8.RecordCount > 0 Then
For i = 1 To Combo8.RecordCount
Combo(2).AddItem (Combo8.Fields("ddbh"))
If Combo8.EOF = False Then
Combo8.MoveNext
End If
Next i
End If
End Sub
Sub Xg_Com() '修改时发票标志
On Error Resume Next
With Adodc_body_general.Recordset
If .RecordCount > 0 Then
.MoveFirst
For i = 1 To .RecordCount
If Trim(.Fields("th_f").Value) <> "有退货" Then
DB.Execute "update yy_khdd set wanch='未完成' where ddbh='" & .Fields("ddbh").Value & "' and cpbh='" & .Fields("cpbh").Value & "' and cpmc='" & .Fields("cpmc").Value & "' and caizh='" & .Fields("caizh").Value & "' and yanse='" & .Fields("yanse").Value & "'"
End If
.MoveNext
Next i
End If
End With
End Sub
Sub Qr_Com() '导入时的发票标志
On Error Resume Next
With Adodc_body_general.Recordset
If .RecordCount > 0 Then
.MoveFirst
For i = 1 To .RecordCount
If .Fields("shsl").Value + .Fields("sl").Value >= .Fields("ddsl").Value Then
DB.Execute "update yy_khdd set wanch='完成' where ddbh='" & .Fields("ddbh").Value & "' and cpbh='" & .Fields("cpbh").Value & "' and cpmc='" & .Fields("cpmc").Value & "' and caizh='" & .Fields("caizh").Value & "' and yanse='" & .Fields("yanse").Value & "'"
DB.Execute "update yy_khth set wanch='完成' where ddbh='" & .Fields("dddh").Value & "' and cpbh='" & .Fields("cpbh").Value & "' and cpmc='" & .Fields("cpmc").Value & "' and caizh='" & .Fields("caizh").Value & "' and yanse='" & .Fields("yanse").Value & "'"
End If
If .Fields("shsl").Value + .Fields("sl").Value < .Fields("ddsl").Value Then
DB.Execute "update yy_khdd set wanch='未完成' where ddbh='" & .Fields("ddbh").Value & "' and cpbh='" & .Fields("cpbh").Value & "' and cpmc='" & .Fields("cpmc").Value & "' and caizh='" & .Fields("caizh").Value & "' and yanse='" & .Fields("yanse").Value & "'"
End If
.MoveNext
Next i
End If
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -