?? form_wastebook.frm
字號:
excelSheet.Columns(getExcelColId(7) & ":" & getExcelColId(7)).ColumnWidth = 3
excelSheet.Columns(getExcelColId(2) & ":" & getExcelColId(2)).ColumnWidth = 11
Dim range As Excel.range
Set range = excelSheet.range(getExcelCellArea(1, 1) & ":" & getExcelCellArea(getShowDataCols(mfgStock), 1))
range.MergeCells = True
range.Value = rptTitle
range.Font.Bold = True
range.Font.Name = "宋體"
range.Font.Size = 14
range.HorizontalAlignment = xlCenter
excelSheet.Cells(2, 1) = "起始日期:"
excelSheet.Cells(2, 2) = DTP1.Value
excelSheet.Cells(2, 4) = "截止日期:"
excelSheet.Cells(2, 5) = DTP2.Value
' 加打印日期
excelSheet.Cells(2, 7) = "打印日期:"
excelSheet.Cells(2, 8) = Format(Date, "yyyy-MM-dd")
excelSheet.Columns(getExcelColId(8) & ":" & getExcelColId(8)).ColumnWidth = 8
' 設置某列的格式
Set range = excelSheet.range(getExcelCellArea(1, dtlRow + 1) & ":" & getExcelCellArea(1, dtlRow + mfgStock.rows - mfgStock.FixedRows))
range.NumberFormatLocal = "yyyy-MM-dd "
Dim i As Integer
For i = 4 To 12
Set range = excelSheet.range(getExcelCellArea(i, dtlRow + 1) & ":" & getExcelCellArea(i, dtlRow + mfgStock.rows - mfgStock.FixedRows))
range.NumberFormatLocal = g_barcode_weight_scale + "_ "
Next
Set range = excelSheet.range(getExcelCellArea(10, dtlRow + 1) & ":" & getExcelCellArea(10, dtlRow + mfgStock.rows - mfgStock.FixedRows))
range.NumberFormatLocal = "#0_ "
Dim col As Integer
For col = 1 To getShowDataCols(mfgStock)
' excelSheet.Columns(getExcelColId(col) & ":" & getExcelColId(col)).EntireColumn.AutoFit
excelSheet.Columns(getExcelColId(col) & ":" & getExcelColId(col)).ShrinkToFit = False
Next col
Set range = excelSheet.range(getExcelCellArea(1, 1), getExcelCellArea(mfgStock.cols, mfgStock.rows + dtlRow))
autoFitSize range
excelSheet.PageSetup.Orientation = xlLandscape
excelSheet.Cells.PrintPreview
End Sub
Private Sub cmdQuery_Click()
mfgStock.rows = mfgStock.FixedRows
Dim sql As String
Dim fldName As String
If (cmbField.Text = "物料名稱") Then
fldName = "productName"
End If
If (cmbField.Text = "物料編號") Then
fldName = "productCode"
End If
If (cmbField.Text = "單據編號") Then
fldName = "billNo"
End If
If (cmbField.Text = "客戶編號") Then
fldName = "orgCode"
End If
If (cmbField.Text = "客戶全稱") Then
fldName = "fullName"
End If
If (cmbField.Text = "工 號") Then
fldName = "comment"
End If
Dim startDate As String '開始日期
Dim endDate As String ' 起始日期
If g_userGroup = 1 Then
startDate = CStr(Date)
endDate = CStr(Date)
Else
startDate = CStr(DTP1.Value)
endDate = CStr(DTP2.Value)
End If
sql = sqlMaster & " and ( " + fldName + " like " + Chr(34) + "*" + txtConditon.Text + "*" + Chr(34) + ")"
sql = sql + " and (billDate between " + Chr(35) + startDate + " 00:00:00" + Chr(35) + " and " + Chr(35) + endDate + " 23:59:59" + Chr(35) + ") "
If optInOrOut(1).Value = True Then
sql = sql + " and tableName='hpos_StockIncomeBill_Dtl' "
End If
If optInOrOut(2).Value = True Then
sql = sql + " and tableName='hpos_StockOutBill_Dtl' "
End If
sql = sql + sqlOrderBy
'sql = "SELECT V.*, productCode, productName, productSpecs, productModel, productUnit, productStd, qty*V.price AS netWeightAmt, pieceQty*axesWeight AS axesTtlWeight FROM V_hpos_StockWasteBook AS V ORDER BY store, billDate, productCode, tableName,productName "
Set rsStock = g_db.OpenRecordset(sql)
If rsStock.RecordCount > 2000 Then
MsgBox "數據量太大(不能超過2000條),請縮小時間范圍或者精確查詢條件!"
Me.txtConditon.SetFocus
Exit Sub
End If
Dim qty, amount, pieceQty, axesWeight As Double
With rsStock
Do While Not .EOF
' 系數:入庫位1,出庫位-1
Dim k As Integer
' If .Fields("tableName") = "hpos_StockIncomeBill_Dtl" Then
' k = 1
' Else
' k = -1
' End If
k = 1
mfgStock.rows = mfgStock.rows + 1
mfgStock.row = mfgStock.rows - mfgStock.FixedRows
mfgStock.TextMatrix(mfgStock.row, 0) = CStr(mfgStock.row)
If Not IsNull(.Fields("billDate")) Then
mfgStock.TextMatrix(mfgStock.row, 1) = .Fields("billDate")
End If
If Not IsNull(.Fields("billNo")) Then
mfgStock.TextMatrix(mfgStock.row, 2) = .Fields("billNo")
End If
If Not IsNull(.Fields("productCode")) Then
mfgStock.TextMatrix(mfgStock.row, 3) = .Fields("productCode")
End If
If Not IsNull(.Fields("productName")) Then
mfgStock.TextMatrix(mfgStock.row, 4) = .Fields("productName")
End If
If Not IsNull(.Fields("productModel")) Then
mfgStock.TextMatrix(mfgStock.row, 5) = .Fields("productModel")
End If
If Not IsNull(.Fields("productSpecs")) Then
mfgStock.TextMatrix(mfgStock.row, 5) = mfgStock.TextMatrix(mfgStock.row, 5) + " || " + .Fields("productSpecs")
End If
If Not IsNull(.Fields("productStd")) Then
mfgStock.TextMatrix(mfgStock.row, 6) = .Fields("productStd")
End If
If Not IsNull(.Fields("productUnit")) Then
mfgStock.TextMatrix(mfgStock.row, 7) = .Fields("productUnit")
End If
If Not IsNull(.Fields("netWeight")) Then
mfgStock.TextMatrix(mfgStock.row, 8) = Format(.Fields("netWeight") * k, g_barcode_weight_scale)
End If
If Not IsNull(.Fields("netWeightAmt")) Then
mfgStock.TextMatrix(mfgStock.row, 9) = Format(.Fields("netWeightAmt") * k, g_barcode_weight_scale)
End If
If Not IsNull(.Fields("axesTtlWeight")) Then
mfgStock.TextMatrix(mfgStock.row, 10) = Format(.Fields("axesTtlWeight") * k, g_barcode_weight_scale)
End If
If Not IsNull(.Fields("ttlPQty")) Then
mfgStock.TextMatrix(mfgStock.row, 11) = Format(Val(.Fields("ttlPQty")), "#0")
End If
If Not IsNull(.Fields("tableName")) Then
If Trim(.Fields("tableName")) = "hpos_StockIncomeBill_Dtl" Then
mfgStock.TextMatrix(mfgStock.row, 12) = "入庫"
End If
If Trim(.Fields("tableName")) = "hpos_StockOutBill_Dtl" Then
mfgStock.TextMatrix(mfgStock.row, 12) = "出庫"
End If
End If
' If Not IsNull(.Fields("billNo")) Then
' mfgStock.TextMatrix(mfgStock.row, 12) = .Fields("billNo")
' End If
If Not IsNull(.Fields("fullName")) Then
mfgStock.TextMatrix(mfgStock.row, 13) = .Fields("fullName")
End If
If Not IsNull(.Fields("dtlId")) Then
mfgStock.TextMatrix(mfgStock.row, 14) = .Fields("dtlId")
End If
.MoveNext
Loop
End With
End Sub
Private Sub cmdReturn_Click()
frm_main.Enabled = True
Unload Me
End Sub
Private Sub Form_Load()
Dim sql As String
'DTP1.Format = dtpCustom
'DTP1.CustomFormat = "yyyy-MM-dd HH:mm:ss" '"yyyy年MM月dd日 HH時mm分ss秒"
'DTP1.Value = Now
DTP1.Value = CStr(DateAdd("d", -2, Date))
DTP2.Value = CStr(Date)
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
cmbField.AddItem "物料編號", 0
cmbField.AddItem "物料名稱", 1
cmbField.AddItem "單據編號", 2
cmbField.AddItem "客戶編號", 3
cmbField.AddItem "客戶全稱", 4
cmbField.AddItem "工 號", 5
cmbField.Text = "物料編號"
' If g_userGroup = 1 Then
' DTP1.Value = CStr(Date)
' DTP1.Visible = False
' DTP2.Visible = False
' Label10.Visible = False
' Label5.Visible = False
' End If
sqlMaster = " SELECT orgCode, fullName, shortenedform, productCode, productName, productSpecs, productModel, productUnit, productStd, tableName, billId, orgId, store, billDate, billNo, handler, billType, dtlId, barcode, productId,qty*pieceQty+outqty*outpieceQty as netWeight,qty*pieceQty*price+outqty*outpieceQty*outprice AS netWeightAmt,pieceQty+outpieceQty as ttlPQty, axesWeight+outaxesWeight AS axesTtlWeight " & _
" FROM V_hpos_StockWasteBook WHERE 1=1 "
sqlOrderBy = " ORDER BY store, billDate, productCode, tableName,productName "
mfgStock.rows = 2: mfgStock.cols = 15 '定義mfgStock表的總行數、總列數
mfgStock.FixedRows = 1: mfgStock.FixedCols = 1 '定義mfgStock表的固定行數、固定列數
mfgStock.rows = mfgStock.FixedRows
s = Array("500", "1600", "1200", "900", "1200", "1300", "900", "450", "750", "0", "750", "750", "500", "1200", "0")
y = Array("序號", "業務日期", "單據編號", "物料編號", "物料名稱", "型號||規格", "標準", "單位", "總凈重", "金額", "總皮重", "件/箱", "出/入", "供應商/客戶", "dtlId")
setFlexGridColsWidth s, mfgStock
setFlexGridHead y, mfgStock
'定義mfgStock表的列序號
For i = mfgStock.FixedRows To mfgStock.rows - mfgStock.FixedRows
mfgStock.TextMatrix(i, 0) = i
Next i
' 查詢
' cmdQuery_Click
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True
End Sub
Private Sub mfgStock_DblClick()
If mfgStock.ColSel <> mfgStock.FixedCols - 1 Then
mfgStock.ColWidth(mfgStock.ColSel) = 0
chkDisplayAllCols.Value = 0
End If
End Sub
Private Sub optInOrOut_Click(Index As Integer)
Dim i As Integer
optInOrOut(Index).Value = True
For i = 0 To optInOrOut.Count - 1
If i <> Index Then
optInOrOut(i).Value = False
End If
Next
cmdQuery_Click
End Sub
Private Sub txtConditon_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then '按回車鍵
cmdQuery_Click
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -