?? dlg_incomebill2.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 + -