📄 sc_rb_djb.frm
字号:
TDBGrid1.Columns(11).Value = TDBGrid2.Columns(7).Value
TDBGrid1.Columns(12).Value = TDBGrid2.Columns(8).Value
TDBGrid1.Columns(13).Value = TDBGrid2.Columns(9).Value
TDBGrid1.Columns(14).Value = TDBGrid2.Columns(10).Value
TDBGrid1.Columns(15).Value = TDBGrid2.Columns(11).Value
TDBGrid1.Columns(17).Value = TDBGrid2.Columns(12).Value
TDBGrid1.Columns(18).Value = TDBGrid2.Columns(13).Value
TDBGrid1.Columns(19).Value = TDBGrid2.Columns(14).Value
TDBGrid1.Columns(21).Value = Combo(1).Text
TDBGrid1.Columns(20).Value = Text1(0).Text
Call ScSL_Tj
TDBGrid1.Columns(16).Value = Y_ScSL
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 Sc_RBB_B where RBDH='" & Trim(Text1(0).Text) & "'"
Adodc_body_general.Refresh
End If
End Sub
Private Sub text1_KeyDown(Index As Integer, KeyCode As Integer, caizhft 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.AllowAddNew = True
TDBGrid1.AllowDelete = True
TDBGrid1.AllowUpdate = True
TDBGrid3.Enabled = False
CmD_FinD.Enabled = False
CmD_SH.Enabled = False
cmdxq.Enabled = False
cmdxq.Enabled = False
cmdnext.Enabled = False
cmdmd.Enabled = False
cmdqd.Enabled = False
Cmdprint.Enabled = False
Cmddelete.Enabled = False
Cmdadd.Enabled = False
Cmdedit.Enabled = False
Cmdreturn.Enabled = False
CmdOK.Enabled = True
Cmdcancel.Enabled = True
For i = 0 To Combo.Count - 1
Combo(i).Enabled = True
Next i
For i = 0 To Text1.Count - 1
Text1(i).Locked = False
Next i
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 RBDH_ado = New Recordset
RBDH_ado.Open "select distinct RBDH from Sc_RBB_H where year(DJRQ)='" & Year(Date) & "'and month(DJRQ)='" & Month(Date) & "' AND DAY(DJRQ)='" & Day(Date) & "' order by RBDH", DB, adOpenStatic
If RBDH_ado.RecordCount < 1 Then
bh = "0001"
Else
RBDH_ado.MoveLast
bhx = Trim(Str(Val(Right(RBDH_ado.Fields("RBDH").Value, 4)) + 1))
If Len(bhx) = 1 Then
bh = "000" & bhx
End If
If Len(bhx) = 2 Then
bh = "00" + bhx
End If
If Len(bhx) = 3 Then
bh = "0" + bhx
End If
If Len(bhx) >= 4 Then
bh = bhx
End If
End If
If AdoprimaryRs.Recordset.RecordCount > 0 Then
AdoprimaryRs.Recordset.MoveLast
End If
AdoprimaryRs.Recordset.AddNew
Text1(0).Text = "R" + ni + yue + ri + Trim(bh)
Text1(1).Text = VBA.Date$
Combo(0).Text = "制令生产"
End Sub
Private Sub cmdDelete_Click() '删除
If MsgBox("是否真的删除当前记录 ?", vbYesNo + 32, "系统提示") = vbYes Then
Call Xg_Com
BJH = Trim(Text1(0).Text)
On Error Resume Next
Adodc_body_general.Recordset.ActiveConnection.Execute "delete from Sc_RBB_B where RBDH='" & BJH & "'"
Adodc_body_general.Recordset.UpdateBatch adAffectAll
DB.Execute "delete from Sc_RBB_H where RBDH='" & BJH & "'"
AdoprimaryRs.Refresh
Adodc_body_general.Refresh
End If
End Sub
Private Sub cmdEdit_Click() '修改
TDBGrid1.AllowAddNew = True
TDBGrid1.AllowDelete = True
TDBGrid1.AllowUpdate = True
For i = 0 To Combo.Count - 1
Combo(i).Enabled = True
Next i
For i = 0 To Text1.Count - 1
Text1(i).Locked = False
Next i
TDBGrid3.Enabled = False
CmD_FinD.Enabled = False
CmD_SH.Enabled = False
cmdxq.Enabled = False
cmdxq.Enabled = False
cmdmd.Enabled = False
cmdqd.Enabled = False
cmdnext.Enabled = False
Cmdprint.Enabled = False
Cmddelete.Enabled = False
Cmdadd.Enabled = False
Cmdedit.Enabled = False
Cmdreturn.Enabled = False
CmdOK.Enabled = True
Cmdcancel.Enabled = True
Call Xg_Com
On Error GoTo EditErr
Exit Sub
EditErr:
MsgBox Err.Description
End Sub
Private Sub cmdCancel_Click() '取消
TDBGrid2.Visible = False
LC = False
For i = 0 To Combo.Count - 1
Combo(i).Enabled = False
Next i
On Error Resume Next
If Tjbz = True Then
If Adodc_body_general.Recordset.RecordCount > 0 Then
Adodc_body_general.Recordset.MoveFirst
For i = 1 To Adodc_body_general.Recordset.RecordCount
Adodc_body_general.Recordset.Delete
Adodc_body_general.Recordset.MoveNext
Next i
End If
End If
TDBGrid2.Visible = False
TDBGrid3.Enabled = True
CmD_SH.Enabled = True
CmD_FinD.Enabled = True
cmdnext.Enabled = True
cmdxq.Enabled = True
cmdxq.Enabled = True
cmdmd.Enabled = True
cmdqd.Enabled = True
Cmdprint.Enabled = True
TDBGrid1.AllowAddNew = False
TDBGrid1.AllowDelete = False
TDBGrid1.AllowUpdate = False
For i = 0 To Text1.Count - 1
Text1(i).Locked = True
Next i
Text1(0).SetFocus
Cmddelete.Enabled = True
Cmdadd.Enabled = True
Cmdedit.Enabled = True
Cmdreturn.Enabled = True
CmdOK.Enabled = False
Cmdcancel.Enabled = False
AdoprimaryRs.Recordset.CancelUpdate
Adodc_body_general.Recordset.CancelUpdate
If Tjbz <> True Then
Call Xg_Com
End If
If mvBookMark > 0 Then
AdoprimaryRs.Recordset.Bookmark = mvBookMark
Else
AdoprimaryRs.Recordset.MoveFirst
End If
Tjbz = False
End Sub
Private Sub cmdOK_Click() '确认
On Error Resume Next
TDBGrid2.Visible = False
For i = 0 To Combo.Count - 1
Combo(i).Enabled = False
Next i
If Adodc_body_general.Recordset.RecordCount > 0 Then
Adodc_body_general.Recordset.MoveLast
TDBGrid1.MoveNext
Adodc_body_general.Recordset.Requery
End If
AdoprimaryRs.Recordset.UpdateBatch adAffectAll
If Tjbz = True Then
AdoprimaryRs.Recordset.Requery
AdoprimaryRs.Recordset.MoveLast
End If
Tjbz = False
CmD_SH.Enabled = True
TDBGrid3.Enabled = True
CmD_FinD.Enabled = True
cmdnext.Enabled = True
cmdxq.Enabled = True
cmdxq.Enabled = True
cmdmd.Enabled = True
cmdqd.Enabled = True
Cmdprint.Enabled = True
Cmddelete.Enabled = True
Cmdadd.Enabled = True
Cmdedit.Enabled = True
Cmdreturn.Enabled = True
CmdOK.Enabled = False
Cmdcancel.Enabled = False
Cmdcancel.Enabled = False
CmdOK.Enabled = False
Call combo_load
For i = 0 To Text1.Count - 1
Text1(i).Locked = True
Next i
TDBGrid1.AllowAddNew = False
TDBGrid1.AllowDelete = False
TDBGrid1.AllowUpdate = False
If LC = True Then
Adodc_body_general.Recordset.ActiveConnection.Execute "update Sc_RBB_B set RBDH='" & Text1(0).Text & "' where RBDH=''"
Adodc_body_general.Recordset.UpdateBatch adAffectAll
Adodc_body_general.Recordset.Requery
End If
Call Qr_Com
LC = False
Call base_com_load
End Sub
Private Sub text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then ' 按回车
KeyAscii = 0
SendKeys "{TAB}"
End If
End Sub
Sub combo_load()
On Error Resume Next
Set combo_data = New Recordset
combo_data.Open "select DISTINCT bmmc from sys_bmsz", DB, adOpenStatic, adLockOptimistic
If combo_data.RecordCount > 0 Then
LB = Combo(1).Text
Combo(1).Clear
For i = 1 To combo_data.RecordCount
Combo(1).AddItem (combo_data.Fields("bmmc"))
If combo_data.EOF = False Then
combo_data.MoveNext
End If
Next i
combo_data.MoveFirst
Combo(1).Text = LB
End If
Set Combo_dATA2 = New Recordset
Combo_dATA2.Open "select DISTINCT NAME from sys_GZRY WHERE ZHWU LIKE '%" & 管 & "%' ", DB, adOpenStatic, adLockOptimistic
If Combo_dATA2.RecordCount > 0 Then
LB = Combo(2).Text
Combo(2).Clear
For i = 1 To Combo_dATA2.RecordCount
Combo(2).AddItem (Combo_dATA2.Fields("NAME"))
If Combo_dATA2.EOF = False Then
Combo_dATA2.MoveNext
End If
Next i
Combo_dATA2.MoveFirst
Combo(2).Text = LB
End If
End Sub
Sub base_com_load()
Ado_BgY.ConnectionString = Conn_Str
Ado_BgY.RecordSource = "select DISTINCT bgy from Sc_RBB_B where not bgy is null ORDER BY bgy"
Ado_BgY.Refresh
End Sub
Private Sub text1_LostFocus(Index As Integer)
If Index = 0 And Cmdadd.Enabled = False And Tjbz = True Then
Set Data_Cx = New Recordset
Data_Cx.Open "select * from Sc_RBB_H where RBDH='" & Text1(0).Text & "'", DB, adOpenStatic, adLockReadOnly
If Data_Cx.RecordCount > 0 Then
MsgBox "报告单号,不能重复,请核对!", 16 + vbOKOnly, "系统提示"
Text1(0).Text = ""
Exit Sub
End If
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
DB.Execute "update sc_zztz_b set wanch='未完成' where zzdh='" & .Fields("zzdh").Value & "' and ddbh='" & .Fields("ddbh").Value & "' and cpbh='" & .Fields("cpbh").Value & "' and cpmc='" & .Fields("cpmc").Value & "' and caizh='" & .Fields("caizh").Value & "' and yanse='" & .Fields("yanse").Value & "'"
.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("y_csl").Value + .Fields("sl").Value >= .Fields("zl_sl").Value Then
DB.Execute "update sc_zztz_b set wanch='完成' where zzdh='" & .Fields("zzdh").Value & "' and 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
If .Fields("Y_scl").Value + .Fields("sl").Value < .Fields("zl_sl").Value Then
DB.Execute "update sc_zztz_b set wanch='未完成' where zzdh='" & .Fields("zzdh").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 ScSL_Tj()
Set SCtJ = New Recordset
With Ado_cpxx.Recordset
SCtJ.Open " select sum(isnull(sl,0)) as Y_scl from sc_rbb_B where zzdh='" & .Fields("zzdh").Value & "' and 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, adOpenStatic, adLockReadOnly
.MoveFirst
If SCtJ.RecordCount > 0 And Not IsNull(SCtJ!y_scl) Then
Y_ScSL = SCtJ!y_scl
Else
Y_ScSL = 0
End If
SCtJ.Requery
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -