📄 frmshipmentsinvoice.frm
字号:
Case "cmdCancel":
Unload Me
Case "cmdEdit":
EditOperatorInf
Case "cmdFind"
fraFind.Visible = True
Case "cmdRefurbish":
FillMshf1 ("select * from vShipmentsInvoices")
Case "cmdExport":
Dim strFile As String
frmMain.CDFile.ShowOpen
strFile = frmMain.CDFile.FileName
If strFile = "" Then Exit Sub
ExportExcel MSHF1, strFile
End Select
End Sub
Private Function FormatQuery() As String
FormatQuery = "select * from vShipmentsInvoices"
If Trim$(txtInvoiceNo) = "" Then
FormatQuery = FormatQuery & " where InvoiceNo<>''"
Else
FormatQuery = FormatQuery & " where InvoiceNo='" & txtInvoiceNo & "'"
End If
If txtCustomerNo <> "" Then
FormatQuery = FormatQuery & "and CustomerNo='" & txtCustomerNo & "'"
End If
If chkFounddate.Value = vbChecked Then
FormatQuery = FormatQuery & " and FoundDate >= '" & FormatDateStr(Founddate.Value, "long") & "'"
FormatQuery = FormatQuery & " and FoundDate <= '" & FormatDateStr(EndFounddate.Value, "long") & "'"
End If
If chkdelivery.Value = vbChecked Then
FormatQuery = FormatQuery & " and Delivery >= '" & FormatDateStr(delivery.Value, "long") & "'"
FormatQuery = FormatQuery & " and Delivery <= '" & FormatDateStr(EndDelivery.Value, "long") & "'"
End If
If Trim$(txtCustomer) <> "" Then
FormatQuery = FormatQuery & " and Customer" & objDatabase.FormatLikeSQL(txtCustomer)
End If
If Trim$(txtPayment) <> "" Then
FormatQuery = FormatQuery & " and Payment" & objDatabase.FormatLikeSQL(txtPayment)
End If
End Function
Private Sub cmdCancel_Click()
fraFind.Visible = False
End Sub
Private Sub CmdCustomer_Click()
frmCustomerSelect.Show vbModal
GetCustomerInfo frmCustomerSelect.CustomerNo
End Sub
Private Sub GetCustomerInfo(CustomerNo As String)
Dim rs As ADODB.Recordset
On Error GoTo errLabel
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
Set .ActiveConnection = Cn
End With
rs.Open "select * from tCustomer where CustomerNo=" & objDatabase.FormatSQL(CustomerNo)
If Not rs.EOF Then
txtCustomer = rs.Fields!CustomerName
txtCustomerNo = rs.Fields!CustomerNo
End If
rs.Close
remClear:
Set rs = Nothing
Exit Sub
errLabel:
objDatabase.DatabaseError
GoTo remClear
End Sub
Private Sub CmdFind_Click()
FillMshf1 FormatQuery
fraFind.Visible = False
End Sub
Private Sub cmdFindAll_Click()
FillMshf1 ("select * from vShipmentsInvoices")
fraFind.Visible = False
End Sub
Private Sub Form_Load()
'设置窗口大小
FormInit Me, True
SetObjectWH Frame1
SetObjectWH MSHF1
FillMshf1 ("select * from vShipmentsInvoices")
Initcbb txtInvoiceNo, "InvoiceNo", "tShipmentsInvoice"
Initcbb txtPayment, "Payment", "tBasicPayment"
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = False
ActiveBar21.Bands("toolbar").Tools.item("cmdEdit").Enabled = False
InitTitle
HookWheel Me.hwnd
End Sub
Private Sub InitTitle()
Label3.item(4).Caption = "發票編號"
Label5.Caption = "客戶編號"
Label11.Caption = "客戶名稱"
Label6.Caption = "付款方式"
Label4.Caption = "交期"
Label13.Caption = "至"
Label1.Caption = "發票日期"
Label2.Caption = "至"
Label12.Caption = "模糊查詢項"
cmdFindAll.Caption = "全部 &A"
cmdFind.Caption = "查詢 &F"
cmdCancel.Caption = "取消 &C"
Me.Caption = "出貨發票"
End Sub
Private Sub EditOperatorInf()
frmShipmentsInvoiceInfo.newItem = False
If lngrow = 1 Then
MsgBox "請選擇記錄!", vbInformation + vbOKOnly, "提示"
Exit Sub
End If
With frmShipmentsInvoiceInfo
.InitInfo MSHF1.TextMatrix(lngrow, 1)
.txtFabricNo = MSHF1.TextMatrix(lngrow, 14)
.txtFabricName = MSHF1.TextMatrix(lngrow, 15)
.txtComposition = MSHF1.TextMatrix(lngrow, 16)
'.txtLayoutColor = MSHF1.TextMatrix(lngRow, 17)
.txtInvoicePrice = MSHF1.TextMatrix(lngrow, 19)
.txtUnit = MSHF1.TextMatrix(lngrow, 9)
.txtOrigin = MSHF1.TextMatrix(lngrow, 12)
.txtRemarks = MSHF1.TextMatrix(lngrow, 20)
.txtUpdateOperator = MSHF1.TextMatrix(lngrow, 21)
.Founddate.Value = MSHF1.TextMatrix(lngrow, 5)
End With
frmShipmentsInvoiceInfo.Show vbModal
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = False
ActiveBar21.Bands("toolbar").Tools.item("cmdEdit").Enabled = False
End Sub
Private Sub DelOperatorInf()
Dim strSql As String
If lngrow <= 1 Then
MsgBox "请选中一条要删除的记录!", vbExclamation, "提示"
Exit Sub
End If
On Error GoTo errHandle
If MsgBox("确定要刪除?", vbQuestion + vbYesNo, "询问") = vbNo Then
Exit Sub
Else
strSql = "delete from tShipmentsInvoice where id=" & MSHF1.TextMatrix(lngrow, 23)
objDatabase.ExecCmd strSql
MsgBox "刪除成功!", vbInformation, "提示"
End If
FillMshf1 ("select * from vShipmentsinvoices")
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = False
ActiveBar21.Bands("toolbar").Tools.item("cmdEdit").Enabled = False
Exit Sub
errHandle:
objDatabase.DatabaseError
End Sub
Public Sub FillMshf1(ByVal strSql As String)
Dim rs As ADODB.Recordset
Dim lngrow As Long
Screen.MousePointer = vbHourglass
On Error GoTo errLabel
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
Set .ActiveConnection = Cn
End With
rs.Open strSql
With MSHF1
.Redraw = False
.Rows = 2
.Cols = 24
.Clear
'初始化
.WordWrap = False
.TextMatrix(0, 0) = "序號"
.ColWidth(0) = 500
.TextMatrix(0, 1) = "發票編號"
.ColWidth(1) = 1200
.TextMatrix(0, 2) = "客戶編號"
.ColWidth(2) = 1200
.TextMatrix(0, 3) = "客戶名稱"
.ColWidth(3) = 1500
.TextMatrix(0, 4) = "聯繫人"
.ColWidth(4) = 1500
.TextMatrix(0, 5) = "發票日期"
.ColWidth(5) = 1200
.TextMatrix(0, 6) = "幣種"
.ColWidth(6) = 1200
.TextMatrix(0, 7) = "合計"
.ColWidth(7) = 1200
.TextMatrix(0, 8) = "大寫"
.ColWidth(8) = 2500
.TextMatrix(0, 9) = "單位"
.ColWidth(9) = 1200
.TextMatrix(0, 10) = "付款方式"
.ColWidth(10) = 1500
.TextMatrix(0, 11) = "交期"
.ColWidth(11) = 1200
.TextMatrix(0, 12) = "原產地"
.ColWidth(12) = 1500
.TextMatrix(0, 13) = "合约编号"
.ColWidth(13) = 1200
.TextMatrix(0, 14) = "布号"
.ColWidth(14) = 1200
.TextMatrix(0, 15) = "布名"
.ColWidth(15) = 1500
.TextMatrix(0, 16) = "组织"
.ColWidth(16) = 1500
.TextMatrix(0, 17) = "颜色花型"
.ColWidth(17) = 1500
.TextMatrix(0, 18) = "出貨數量"
.ColWidth(18) = 1200
.TextMatrix(0, 19) = "单价"
.ColWidth(19) = 1200
.TextMatrix(0, 20) = "備注"
.ColWidth(20) = 2500
.TextMatrix(0, 21) = "填寫人"
.ColWidth(21) = 1500
.TextMatrix(0, 22) = "填寫日期"
.ColWidth(22) = 1200
.TextMatrix(0, 23) = ""
.ColWidth(23) = 0
'.....................................................
.Rows = rs.RecordCount + 2
On Error Resume Next
For lngrow = 2 To rs.RecordCount + 1
.TextMatrix(lngrow, 0) = lngrow - 1
.TextMatrix(lngrow, 1) = Trim$(NullValue(rs.Fields!InvoiceNo))
.TextMatrix(lngrow, 2) = Trim$(NullValue(rs.Fields!CustomerNo))
.TextMatrix(lngrow, 3) = Trim$(NullValue(rs.Fields!Customer))
.TextMatrix(lngrow, 4) = Trim$(NullValue(rs.Fields!Linkman))
.TextMatrix(lngrow, 5) = Trim$(NullValue(rs.Fields!Founddate))
.TextMatrix(lngrow, 6) = Trim$(NullValue(rs.Fields!CurrencyName))
.TextMatrix(lngrow, 7) = Trim$(NullValue(rs.Fields!Amount))
.TextMatrix(lngrow, 8) = Trim$(NullValue(rs.Fields!AmountCn))
.TextMatrix(lngrow, 9) = Trim$(NullValue(rs.Fields!unit))
.TextMatrix(lngrow, 10) = Trim$(NullValue(rs.Fields!Payment))
.TextMatrix(lngrow, 11) = Trim$(NullValue(rs.Fields!delivery))
.TextMatrix(lngrow, 12) = Trim$(NullValue(rs.Fields!Origin))
.TextMatrix(lngrow, 13) = Trim$(NullValue(rs.Fields!ContractNo))
.TextMatrix(lngrow, 14) = Trim$(NullValue(rs.Fields!FabricNo))
.TextMatrix(lngrow, 15) = Trim$(NullValue(rs.Fields!FabricName))
.TextMatrix(lngrow, 16) = Trim$(NullValue(rs.Fields!Composition))
.TextMatrix(lngrow, 17) = Trim$(NullValue(rs.Fields!eLayoutColor))
.TextMatrix(lngrow, 18) = Trim$(NullValue(rs.Fields!InvoiceQuantity))
.TextMatrix(lngrow, 19) = Trim$(NullValue(rs.Fields!InvoicePrice))
.TextMatrix(lngrow, 20) = Trim$(NullValue(rs.Fields!Remarks))
.TextMatrix(lngrow, 21) = Trim$(NullValue(rs.Fields!UpdateOperator))
.TextMatrix(lngrow, 22) = FormatDateStr(rs.Fields!UpdateDate, "long")
.TextMatrix(lngrow, 23) = NullValue(rs.Fields!ID)
rs.MoveNext
Next
lngrow = 0
.TextMatrix(1, 0) = "总计"
.TextMatrix(1, 1) = .Rows - 2
SetItemBackColor MSHF1
.Redraw = True
End With
rs.Close
remClear:
Set rs = Nothing
Screen.MousePointer = vbDefault
Exit Sub
errLabel:
On Error Resume Next
MSHF1.Redraw = True
GoTo remClear
End Sub
Private Sub MSHF1_Click()
lngrow = Val(MSHF1.row)
If lngrow <= 1 Then
MSHF1.Sort = 1
Else
MSHF1.row = lngrow
MSHF1.col = 0
MSHF1.ColSel = MSHF1.Cols - 1
End If
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = True
ActiveBar21.Bands("toolbar").Tools.item("cmdEdit").Enabled = True
End Sub
Private Sub MSHF1_DblClick()
EditOperatorInf
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -