📄 dlg_incomebill.frm
字号:
Exit Sub
End Sub
Private Sub cmdPrint_Click()
printBill
End Sub
' 打印(预览)单据
Private Sub printBill()
' 标准版本
If g_CustomerSN = 0 Then
previewData0
End If
' 第一个客户
If g_CustomerSN = 1 Then
previewData1
End If
' 第二个客户
If g_CustomerSN = 2 Then
previewData2
End If
End Sub
Private Sub cmdQuery_Click()
Dim fldName As String
If (cmbField.Text = "供应商编号") Then
fldName = "hpos_organization.orgCode"
End If
If (cmbField.Text = "供应商全称") Then
fldName = "hpos_organization.fullName"
End If
If (cmbField.Text = "单据编号") Then
fldName = "hpos_StockIncomeBill_Master.billNo"
End If
Dim sql As String
sql = sqlMaster & " and ( " + fldName + " like " + Chr(34) + "*" + txtConditon.Text + "*" + Chr(34) + ")"
sql = sql + " and (hpos_StockIncomeBill_Master.billDate between " + Chr(35) + CStr(DTP1.Value) + " 00:00:00" + Chr(35) + " and " + Chr(35) + CStr(DTP2.Value) + " 23:59:59" + Chr(35) + ") "
' 过滤掉出库单中已经引用了的入库单
sql = sql + " and billNo not in(select distinct rsvFld1 from hpos_StockOutBill_Master) "
sql = sql + sqlOrderBy
DataMaster.RecordSource = sql
DataMaster.Refresh
DBGrid1.Refresh
If Not DataMaster.Recordset.EOF Then
cmdEdit.Enabled = True
End If
End Sub
Private Sub cmdEdit_Click()
EditData
End Sub
Private Sub EditData()
enableControls (True)
Dim billId As String
Dim rs As Recordset
' isAdd = False
Set rs = DataMaster.Recordset
If rs.EOF And Not isAdd Then
MsgBox "没有数据了,请先登记!", vbInformation, "提示"
' Comdj_Click
Exit Sub
End If
If Not isAdd Then
txtBillId.Text = rs.Fields("billId")
billNo.Text = rs.Fields("billNo")
txtSupplier.Text = rs.Fields("supplier")
supplierName.Text = rs.Fields("fullName")
billDate.Text = CStr(rs.Fields("billDate"))
handler.Text = rs.Fields("handler")
End If
SSTab1.Tab = 1
Dim rsDtl As Recordset
Dim sql As String
strSQL = "select D.*,P.productCode,P.productName,P.productModel,P.productSpecs,P.productStd,P.productUnit from hpos_StockIncomeBill_Dtl as D left join hpos_products as P on D.productId=P.productId "
' Set rsDtl = g_db.OpenRecordset(strSQL + " where D.billId='" + txtBillId.Text + "' order by int(MID(D.dtlId,len(D.billId)+2,len(D.dtlId)-len(D.billId)-1))")
Set rsDtl = g_db.OpenRecordset(strSQL + " where D.billId='" + txtBillId.Text + "' order by D.billId,CINT(D.rsvFld1) ")
Dim i As Integer
Dim qty, amount, pieceQty, axesWeight As Double
i = 0
mf1.rows = mf1.FixedRows + 1
Do While Not rsDtl.EOF
' 序号列显示编号
If (g_CustomerSN > 1 And Not IsNull(rsDtl.Fields("rsvFld1"))) Then
mf1.TextMatrix(i + 1, 0) = rsDtl.Fields("rsvFld1")
End If
If (i + 1 >= mf1.rows - mf1.FixedRows) Then
mf1.rows = mf1.rows + 1
' mf1.TextMatrix(mf1.rows - mf1.FixedRows, 0) = mf1.rows - mf1.FixedRows
If g_CustomerSN > 1 And IsNumeric(mf1.TextMatrix(mf1.rows - mf1.FixedRows - 1, 0)) Then
mf1.TextMatrix(mf1.rows - mf1.FixedRows, 0) = CInt(mf1.TextMatrix(mf1.rows - mf1.FixedRows - 1, 0)) + 1
End If
End If
If Not IsNull(rsDtl.Fields("barcode")) Then
mf1.TextMatrix(i + 1, 1) = rsDtl.Fields("barcode")
End If
If Not IsNull(rsDtl.Fields("productName")) Then
mf1.TextMatrix(i + 1, 2) = rsDtl.Fields("productName")
End If
If Not IsNull(rsDtl.Fields("productModel")) Then
mf1.TextMatrix(i + 1, 3) = rsDtl.Fields("productModel")
End If
If Not IsNull(rsDtl.Fields("productSpecs")) Then
mf1.TextMatrix(i + 1, 3) = mf1.TextMatrix(i + 1, 3) + " || " + rsDtl.Fields("productSpecs")
End If
If Not IsNull(rsDtl.Fields("productStd")) Then
mf1.TextMatrix(i + 1, 4) = rsDtl.Fields("productStd")
End If
If Not IsNull(rsDtl.Fields("productUnit")) Then
mf1.TextMatrix(i + 1, 5) = rsDtl.Fields("productUnit")
End If
If Not IsNull(rsDtl.Fields("qty")) Then
mf1.TextMatrix(i + 1, 6) = rsDtl.Fields("qty")
qty = qty + rsDtl.Fields("qty")
End If
If Not IsNull(rsDtl.Fields("price")) Then
mf1.TextMatrix(i + 1, 7) = rsDtl.Fields("price")
End If
If IsNumeric(mf1.TextMatrix(i + 1, 6)) And IsNumeric(mf1.TextMatrix(i + 1, 7)) Then
mf1.TextMatrix(i + 1, 8) = Val(mf1.TextMatrix(i + 1, 7)) * Val(mf1.TextMatrix(i + 1, 6))
mf1.TextMatrix(i + 1, 8) = Format(mf1.TextMatrix(i + 1, 8), g_barcode_weight_scale)
mf1.TextMatrix(i + 1, 6) = Format(mf1.TextMatrix(i + 1, 6), g_barcode_weight_scale)
mf1.TextMatrix(i + 1, 7) = Format(mf1.TextMatrix(i + 1, 7), g_barcode_weight_scale)
End If
amount = amount + Val(mf1.TextMatrix(i + 1, 8))
If Not IsNull(rsDtl.Fields("axesWeight")) Then
mf1.TextMatrix(i + 1, 9) = rsDtl.Fields("axesWeight")
End If
If Not IsNull(rsDtl.Fields("pieceQty")) Then
mf1.TextMatrix(i + 1, 10) = rsDtl.Fields("pieceQty")
End If
If IsNumeric(mf1.TextMatrix(i + 1, 9)) And IsNumeric(mf1.TextMatrix(i + 1, 10)) Then
mf1.TextMatrix(i + 1, 11) = Val(mf1.TextMatrix(i + 1, 9)) + Val(mf1.TextMatrix(i + 1, 10)) * Val(mf1.TextMatrix(i + 1, 6))
mf1.TextMatrix(i + 1, 11) = Format(mf1.TextMatrix(i + 1, 11), g_barcode_weight_scale)
mf1.TextMatrix(i + 1, 9) = Format(mf1.TextMatrix(i + 1, 9), g_barcode_weight_scale)
' mf1.TextMatrix(i + 1, 10) = Format(mf1.TextMatrix(i + 1, 10), g_barcode_weight_scale)
axesWeight = axesWeight + Val(mf1.TextMatrix(i + 1, 11))
End If
If Not IsNull(rsDtl.Fields("comment")) Then
mf1.TextMatrix(i + 1, 12) = rsDtl.Fields("comment")
End If
If Not IsNull(rsDtl.Fields("productId")) Then
mf1.TextMatrix(i + 1, 13) = rsDtl.Fields("productId")
End If
rsDtl.MoveNext
i = i + 1
Loop
For r = i + 1 To mf1.rows - mf1.FixedRows
For c = mf1.FixedCols To mf1.cols - mf1.FixedCols
mf1.TextMatrix(r, c) = ""
Next
Next
' 计算累加数据
Call fillTotalDataFromDtlData
supplierName.SetFocus: supplierName.SelStart = 0: supplierName.SelLength = Len(supplierName.Text)
gridCustomer.Visible = False
End Sub
Private Sub DBGrid1_DblClick()
EditData
End Sub
' 隐藏增删改打印等按钮
Private Sub hiddenButtons()
Me.cmdDelete.Visible = False
Me.cmdDeleteLine.Visible = False
Me.cmdEdit.Visible = False
Me.cmdPrint.Visible = False
' Me.cmdQuery.Visible = False
Me.Comqx.Visible = False
Me.ComEnd.Visible = False
Me.Combc.Visible = False
End Sub
Private Sub Form_Load()
Me.WindowState = vbMaximized
hiddenButtons
' Me.mf1.Enabled = False
frm_main.text1.Text = "2"
SSTab1.Tab = 0
grid1IsVisible = False
isAdd = False
cmbField.AddItem "供应商编号", 0
cmbField.AddItem "供应商全称", 1
cmbField.AddItem "单据编号", 2
cmbField.Text = "单据编号"
enableControls (False)
'自动识别数据库路径
Data1.DatabaseName = g_dbPath
Data2.DatabaseName = g_dbPath
DataMaster.DatabaseName = g_dbPath
m_billType = 0
mf1.rows = 2: mf1.cols = 14 '定义mf1表的总行数、总列数
'定义mf1表的列宽和表头信息
s = Array("500", "1300", "1200", "1300", "1100", "450", "1000", "0", "0", "1000", "500", "1000", "1300", 0)
y = Array("序号", "条 码 号", "物料名称", "型号||规格", " 标 准", "单位", "净重", "价格", "金额", "皮重", "件/箱", "毛重", "工号", "productId")
For i = 0 To mf1.cols - 1
mf1.ColWidth(i) = s(i): mf1.TextMatrix(0, i) = y(i)
Next i
mf1.FixedRows = 1: mf1.FixedCols = 1 '定义mf1表的固定行数、固定列数
'定义mf1表的列序号
' For i = mf1.FixedRows To mf1.rows - mf1.FixedRows
' mf1.TextMatrix(i, 0) = i
' Next i
mf1.AllowUserResizing = flexResizeColumns
'定义msfgTtl表的列宽和表头信息
msfgTtl.rows = 2: msfgTtl.cols = 11 '定义msfgTtl表的总行数、总列数
msfgTtl.FixedRows = 1: msfgTtl.FixedCols = 1 '定义mf1表的固定行数、固定列数
s = Array("500", "900", "1400", "1300", "1100", "700", "1000", "0", "600", "1000", 0)
y = Array("序号", "物料编号", "物料名称", "型号||规格", " 标 准", "单位", "总净重", "金额", "总件数", "总毛重", "productId")
For i = 0 To msfgTtl.cols - 1
msfgTtl.ColWidth(i) = s(i): msfgTtl.TextMatrix(0, i) = y(i)
Next i
msfgTtl.rows = 101
For i = msfgTtl.FixedRows To msfgTtl.rows - msfgTtl.FixedRows
msfgTtl.TextMatrix(i, 0) = i
Next i
billDate.Text = CStr(Now) '设置出库日期
'DTP1.Format = dtpCustom
'DTP1.CustomFormat = "yyyy-MM-dd HH:mm:ss" '"yyyy年MM月dd日 HH时mm分ss秒"
'DTP1.Value = Now
DTP2.Value = CStr(Date)
Data1.RecordSource = "select * from hpos_products"
Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=1 order by fullName"
sqlMaster = "SELECT hpos_StockIncomeBill_Master.*,hpos_organization.* FROM hpos_StockIncomeBill_Master LEFT JOIN hpos_organization ON hpos_organization.orgId = hpos_StockIncomeBill_Master.supplier where billtype=" + CStr(m_billType)
sqlOrderBy = " order by hpos_StockIncomeBill_Master.billDate desc "
cmdQuery_Click
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True
End Sub
Private Sub gridCustomer_DblClick()
selectCustomer
End Sub
Private Sub gridCustomer_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then '当按回车键时
selectCustomer
End If
If KeyCode = vbKeyEscape Then '按ESC键
gridCustomer.Visible = False 'gridCustomer不可见
End If
End Sub
Private Sub selectCustomer()
With Data2.Recordset
If Data2.Recordset.RecordCount > 0 Then
If Data2.Recordset.Fields("orgId") <> "" Then
'赋值给mf1表格
If .Fields("OrgId") <> "" Then txtSupplier.Text = .Fields("OrgId")
If .Fields("fullName") <> "" Then supplierName.Text = .Fields("fullName")
gridCustomer.Visible = False
Else
MsgBox "没有数据可选择!", vbCritical, "提示"
gridCustomer.Visible = False 'gridCustomer不可见
End If
End If
End With
' supplierName.SetFocus: supplierName.SelStart = 0: supplierName.SelLength = Len(supplierName.Text)
mf1GetFocus
End Sub
Private Sub grid1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then '当按回车键时
With Data1.Recordset
If Data1.Recordset.RecordCount > 0 Then
If Data1.Recordset.Fields("barcode") <> "" Then
' '赋值给mf1表格
text1.Text = mf1.Text '赋值给text1
text1.SetFocus
If (mf1.row = mf1.rows - mf1.FixedRows) Then
mf1.rows = mf1.rows + 1
mf1.TextMatrix(mf1.rows - mf1.FixedRows, 0) = mf1.rows - mf1.FixedRows
End If
mf1.row = mf1.row + 1: mf1.col = 1 '到达第5列
grid1.Visible = False
Else
MsgBox "没有数据供选择!", vbCritical, "提示"
grid1.Visible = False 'grid1不可见
text1.SetFocus
End If
End If
End With
text1.SetFocus 'text1获得焦点
End If
If KeyCode = vbKeyEscape Then '按ESC键
grid1.Visible = False 'grid1不可见
text1.SetFocus 'text1获得焦点
End If
End Sub
Private Sub gridCustomer_LostFocus()
gridCustomer.Visible = False
End Sub
Private Sub mf1_GotFocus()
If mf1.row >= mf1.FixedRows And (mf1.col = 1) Then
text1.Width = mf1.CellWidth
text1.Height = mf1.CellHeight
text1.Left = mf1.CellLeft + mf1.Left
text1.Top = mf1.CellTop + mf1.Top
text1.Text = mf1.Text
text1.Visible = True 'text1可见
text1.SetFocus
text1.Locked = False
End If
End Sub
Private Sub supplierName_Change()
'查询供应商信息
Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=1 and ((hpos_organization.fullName like " + Chr(34) + supplierName.Text + "*" + Chr(34) + ")or (hpos_organization.shortenedform like " + Chr(34) + supplierName.Text + "*" + Chr(34) + "))order by fullName"
Data2.Refresh
Dim rsMaster As Recordset
Set rsMaster = Data2.Recordset
' If rsMaster.EOF Or supplierName.Text = "" Or IsNull(rsMaster) Or IsNull(rsMaster.Fields("fullName")) Or (supplierName.Text = rsMaster.Fields("fullName") And Not isAdd) Then
If rsMaster.EOF Or supplierName.Text = "" Or IsNull(rsMaster) Then
gridCustomer.Visible = False
Else
gridCustomer.Visible = True
End If
End Sub
Private Sub supplierName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyPageDown Then '按PageDown键
Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=1 and ((hpos_organization.fullName like " + Chr(34) + supplierName.Text + "*" + Chr(34) + ")or (hpos_organization.shortenedform like " + Chr(34) + supplierName.Text + "*" + Chr(34) + "))order by fullName"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -