?? form_outbill.frm
字號:
Dim m_billType As Integer
Private Sub cmdCHeck_Click()
Dim strMsg As String
SSTab1.Tab = 1
strMsg = checkbarcodesRepeated(mf1)
If strMsg <> "" Then
MsgBox "紅色顯示部分條碼重復!", vbCritical, "警告"
End If
End Sub
Private Sub cmdDelete_Click()
Dim rs As Recordset
Set rs = DataMaster.Recordset
If Not IsNull(rs) And rs.RecordCount > 0 And Not IsNull(rs.Fields("billId")) Then
Dim sql As String
If MsgBox("真的要刪除嗎?", vbYesNo + vbQuestion + vbDefaultButton2, "提示") = vbYes Then
sql = " delete from hpos_StockOutBill_Dtl where billId=" + Chr(34) + rs.Fields("billId") + Chr(34)
g_db.Execute sql
sql = " delete from hpos_StockOutBill_Master where billId=" + Chr(34) + rs.Fields("billId") + Chr(34)
g_db.Execute sql
DataMaster.Refresh
MsgBox "已經刪除!", vbInformation, "提示"
' EditData
If SSTab1.Tab = 1 Then
SSTab1.Tab = 0
End If
End If
If Not DataMaster.Recordset.EOF Then
cmdEdit.Enabled = True
enableControls (True)
Else
clearData mf1
clearData msfgTtl
txttakeunit.Text = ""
txtBillId.Text = ""
takeunitName.Text = ""
handler.Text = ""
txtStockDataNo.Text = ""
Me.txtPrevBillNo.Text = ""
cmdEdit.Enabled = False
enableControls (False)
End If
End If
End Sub
Private Sub cmdDeleteLine_Click()
' If mf1.RowSel <> 0 Then
For i = mf1.FixedCols To mf1.cols - mf1.FixedCols
mf1.TextMatrix(mf1.row, i) = ""
Next i
text1.Text = ""
Call fillTotalDataFromDtlData
If mf1.row > 1 Then
mf1.row = mf1.row - 1
End If
' End If
Exit Sub
End Sub
Private Sub cmdImport_Click()
Dim filePath As String
filePath = ""
filePath = "C:\盤點機目錄\ck.txt"
If Dir(filePath) = "" Then
MsgBox "對不起,找不到文件【" + filePath + "】", vbInformation, "提示"
Exit Sub
End If
If MsgBox("真的要導入文件" + vbCrLf + "【" + filePath + "】的數據嘛?", vbYesNo + vbQuestion + vbDefaultButton1, "提示") = vbNo Then
Exit Sub
End If
' 將文本文件中的數據導入到數據庫中
If importDataFromFile(filePath, "CK") = True Then
MsgBox "恭喜,導入成功!", vbInformation, "提示"
Else
MsgBox "對不起,導入失敗!", vbInformation, "提示"
End If
cmdQuery_Click
End Sub
Private Sub cmdPrevNo_Click()
Load dlg_incomeBill2
dlg_incomeBill2.Show vbModal, Me
'' 重新設置箱號
' If Me.txtOutNo.Text <> "" Then
' setGridSequence Me.mf1, m_prevBillNo + 1, 0
' End If
fillTotalDataFromDtlData
Me.mf1.row = mf1.rows - 1
Me.mf1.SetFocus
End Sub
Private Sub cmdPrint_Click()
If Me.chkSkinWeight.Value = 1 Then
g_outputSkinWeight = True
Else
g_outputSkinWeight = False
End If
printBill
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_StockOutBill_Master.billNo"
End If
Dim sql As String
sql = sqlMaster & " and ( " + fldName + " like " + Chr(34) + "*" + txtConditon.Text + "*" + Chr(34) + ")"
sql = sql + " and (hpos_StockOutBill_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 + 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)
clearMasterData
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
takeunitName.Enabled = True: handler.Enabled = True
text1.Enabled = True: mf1.Enabled = True: Combc.Enabled = True: Comqx.Enabled = True: Comdj.Enabled = True
billNo.Enabled = True
cmdEdit.Enabled = True
If Not isAdd Then
If Not IsNull(rs.Fields("billId")) Then txtBillId.Text = rs.Fields("billId")
If Not IsNull(rs.Fields("billNo")) Then billNo.Text = rs.Fields("billNo")
If Not IsNull(rs.Fields("takeunit")) Then txttakeunit.Text = rs.Fields("takeunit")
If Not IsNull(rs.Fields("fullName")) Then takeunitName.Text = rs.Fields("fullName")
If Not IsNull(rs.Fields("billDate")) Then billDate.Text = CStr(rs.Fields("billDate"))
If Not IsNull(rs.Fields("handler")) Then handler.Text = rs.Fields("handler")
If Not IsNull(rs.Fields("rsvFld3")) Then Me.txtStockDataNo.Text = rs.Fields("rsvFld3")
' 入庫單號碼
If Not IsNull(rs.Fields("rsvFld1")) Then Me.txtPrevBillNo.Text = rs.Fields("rsvFld1")
' 頁碼
If Not IsNull(rs.Fields("rsvFld2")) Then Me.txtPageNo.Text = rs.Fields("rsvFld2")
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_StockOutBill_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
takeunitName.SetFocus: takeunitName.SelStart = 0: takeunitName.SelLength = Len(takeunitName.Text)
gridCustomer.Visible = False
End Sub
Private Sub DBGrid1_DblClick()
EditData
End Sub
Private Sub Form_Load()
' Me.cmdImport.Visible = False
Me.txtStockDataNo.Visible = False
Me.Label8.Visible = False
enableControls (False)
SSTab1.Tab = 0
grid1IsVisible = False
isAdd = False
cmbField.AddItem "客戶編號", 0
cmbField.AddItem "客戶全稱", 1
cmbField.AddItem "單據編號", 2
cmbField.Text = "單據編號"
'自動識別數據庫路徑
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=0 order by fullName"
sqlMaster = "SELECT hpos_StockOutBill_Master.*,hpos_organization.* FROM hpos_StockOutBill_Master LEFT JOIN hpos_organization ON hpos_organization.orgId = hpos_StockOutBill_Master.takeunit where billtype=" + CStr(m_billType)
sqlOrderBy = " order by hpos_StockOutBill_Master.billNo 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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -