storedealtable.frm

来自「一个关于电脑管理汽车的软件」· FRM 代码 · 共 1,081 行 · 第 1/3 页

FRM
1,081
字号
 Case 6
  If lstAddress.SelectedItem Is Nothing Then Exit Sub
  VarCrystal.DispalyStoreDealReport lstAddress.SelectedItem.Text, 29
 End Select
 VarInitData.DealListView lstAddress, lstAddressIndex
End Sub



Private Sub Command3_Click(Index As Integer)
 Dim TempSQL As String
 Dim TempRS As MYSQL_RS
 Dim TempFindIndex As Long
 Dim i As Long
 Dim j As Long, TempCount As Long
 Dim TempMoney As Double
 Dim TempItemCount As Long
 Dim TemplstCount As Long

 Select Case Index
  Case 0 '增加新的记录"
   'If lblBillNum.Caption <> "" Then
    Addrow6.Show 1
  ' End If
  Case 1 '删除记录
   If lstBillDocu.ListItems.Count > 0 And lstBillDocuIndex > 0 Then
    If MsgBox("确定删除这条记录吗?", vbOKCancel, VarInitData.SysPrompt) = vbOK Then
    lstBillDocu.ListItems.Remove lstBillDocuIndex
    OrgRS.DeleteKeyRS lstBillDocuIndex
    With StoreDealTable
     TemplstCount = .lstBillDocu.ListItems.Count
     .lblGItemCount = TemplstCount
     TempCount = 0
     TempMoney = 0
     For i = 1 To TemplstCount
      TempCount = TempCount + Val(.lstBillDocu.ListItems(i).SubItems(4))
      TempMoney = TempMoney + Val(.lstBillDocu.ListItems(i).SubItems(4)) * Val(.lstBillDocu.ListItems(i).SubItems(7))
     Next i
     .lblGCount = TempCount
     .lblGMoney = Format(TempMoney, "0.00")
    End With
    End If
   End If
  Case 2 '保存记录
   SaveToStockBill
   VarOption = 0
   If lstBillDocu.ListItems.Count > 0 And lstBillDocuIndex > 0 Then
    If OrgRS.KeyCount > 0 Or OrgRS.DelKeyCount > 0 Then
     TempSQL = "select * from storedealtable2" & " Where billnum = " & Quote(Trim(lblBillNum.Caption))
     Set TempRS = New MYSQL_RS
     TempRS.OpenRs TempSQL, gCnn
     With TempRS
      If OrgRS.DelKeyCount > 0 Then
       For j = 1 To OrgRS.DelKeyCount
        .MoveFirst
        .MovePrevious
        TempFindIndex = .FindNext("AKey", CStr(OrgRS.DelKeyRSValue(j)))
        If TempFindIndex > -1 Then
          .Delete
          .Update
        End If
       Next j
      End If
      i = 0
      If OrgRS.KeyCount > 0 Then
       .MoveFirst
       .MovePrevious
       For j = 1 To OrgRS.KeyCount
         TempFindIndex = .FindNext("AKey", CStr(OrgRS.KeyRSValue(j)))
         If TempFindIndex > -1 Then
          i = i + 1
          SaveToStockBillDocu TempRS, lstBillDocu, i
         End If
       Next j
      End If
      .CloseRecordset
      .ReleaseMemory
      Set TempRS = Nothing
     End With
     OrgRS.Clear
    End If
     TempSQL = "select * from storedealtable2" '& " Where billnum = " & Quote(Trim(lblBillNum.Caption))
     Set TempRS = New MYSQL_RS
     TempRS.OpenRs TempSQL, gCnn
    With TempRS
     If .RecordCount > 0 Then
      .MoveLast
      .MoveNext
     End If
     i = i + 1
     TempCount = lstBillDocu.ListItems.Count
     If i <= TempCount Then
      For j = i To TempCount
      ' .MoveNext
       SaveToStockBillDocu TempRS, lstBillDocu, j
      Next j
     End If
     .CloseRecordset
     .ReleaseMemory
     Set TempRS = Nothing
    End With
   End If
   Frame2.Enabled = False
   BillStateBS = 0
   For i = 0 To 3
    Command3(i).Visible = False
   Next i
   For i = 0 To 6
    Command1(i).Visible = True
   Next i
   SSStock.TabEnabled(0) = True
   SSStock.Tab = 0
  Case 3
   VarOption = 0
   Frame2.Enabled = False
   BillStateBS = 0
   For i = 0 To 3
    Command3(i).Visible = False
   Next i
   For i = 0 To 6
    Command1(i).Visible = True
   Next i
   SSStock.TabEnabled(0) = True
   SSStock.Tab = 0
   OrgRS.Clear
   VarInitData.LoadData lstBillDocu, VarInitData.DisplaySQLVal(30)
   
 End Select
 VarInitData.DealListView lstBillDocu, lstBillDocuIndex
 
End Sub

Private Sub Form_Activate()
    VarInitData.DealListView lstAddress, lstAddressIndex

End Sub

Private Sub Form_Load()
  Dim i As Integer
  Dim TempSQL As String
    VarInitData.InitBSE BSE1
    Frame2.Visible = False
    Frame2.Enabled = False
    lstBillDocu.Visible = False
    lstAddress.Visible = True
    For i = 0 To 3
     Command3(i).Visible = False
    Next i
    Set OrgRS = New ChangeHistory
   ' OrgRs.KeyCount = 0
    VarInitData.LoadData lstAddress, VarInitData.DisplaySQLVal(29)
    
    TempSQL = "Select name From workertable "
    VarInitData.LoadData cmbCheckMan, TempSQL, 1
End Sub


Private Sub Form_Resize()
 If Me.ScaleHeight > 0 And Me.ScaleWidth > 0 Then
  frameInfo.left = Me.ScaleLeft
  frameInfo.top = Me.ScaleTop
  frameInfo.Width = Me.ScaleWidth
  SSStock.top = frameInfo.top + frameInfo.Height
  SSStock.left = Me.ScaleLeft + 70
  SSStock.Width = Me.ScaleWidth - 140
  SSStock.Height = Me.ScaleHeight - frameInfo.Height - 50    'Screen.Height - 2650
  lstAddress.top = 450
  lstAddress.left = 70
  lstAddress.Width = SSStock.Width - 140
  lstAddress.Height = SSStock.Height - 550
  Frame2.left = 70
  Frame2.top = 450
  Frame2.Width = SSStock.Width - 140
  lstBillDocu.top = Frame2.top + Frame2.Height
  lstBillDocu.left = 70
  lstBillDocu.Width = SSStock.Width - 140
  lstBillDocu.Height = SSStock.Height - Frame2.Height - 550
 End If
End Sub


Private Sub Form_Unload(Cancel As Integer)
 If BSE1.EngineStarted Then BSE1.EndSubClassing

End Sub



Private Sub lstAddress_DblClick()
    If lstAddress.SelectedItem Is Nothing Then Exit Sub
   ' LoadRecord Val(lstAddress.SelectedItem.Text)
End Sub








Private Sub lstAddress_ItemClick(ByVal Item As MSComctlLib.ListItem)
'Dim templong As Long
'Stop
lstAddressIndex = Item.Index
'templong = Item.Text
End Sub


Private Sub lstBillDocu_DblClick()
 If BillStateBS > 0 Then
  If lstBillDocu.SelectedItem Is Nothing Then Exit Sub
   ModifyBS = True
   lstBillDocuIndex = lstBillDocu.SelectedItem.Index
   Addrow6.Show 1
 End If
End Sub

Private Sub lstBillDocu_ItemClick(ByVal Item As MSComctlLib.ListItem)
 lstBillDocuIndex = Item.Index
 
End Sub

Private Sub Option1_Click(Index As Integer)
 VarOption = Index + 1
End Sub

Private Sub SSStock_Click(PreviousTab As Integer)
 Dim TempSQL As String
 Dim TempStr As String
 Dim TempRS As MYSQL_RS
 Dim TempBillType As Integer
 Dim i As Integer
 If PreviousTab <> 0 Then
  For i = 0 To 6
   Command1(i).Visible = True
  Next i
  For i = 0 To 2
   Command3(i).Visible = False
  Next i
  Frame2.Visible = False
  lstBillDocu.Visible = False
  lstAddress.Visible = True
  VarInitData.DealListView lstAddress, lstAddressIndex
 Else
  Frame2.Visible = True
  If BillStateBS > 0 Then
   Frame2.Enabled = True
  Else
   Frame2.Enabled = False
  End If
  lstBillDocu.Visible = True
  lstAddress.Visible = False
  If BillStateBS <> 1 Then ClearFrame2
  If lstAddress.ListItems.Count > 0 Then
   TempStr = lstAddress.ListItems(lstAddressIndex).Text
  Else
   TempStr = ""
  End If
  If BillStateBS = 1 Then TempStr = ""
  TempSQL = VarInitData.DisplaySQLVal(30) & " Where billnum = " & Quote(TempStr)
  VarInitData.LoadData2 lstBillDocu, TempSQL, OrgRS
  VarInitData.DealListView lstBillDocu, lstBillDocuIndex
 ' If BillStateBS = 2 Then OrgRs.InitItem lstBillDocu.ListItems.Count
  If lstAddressIndex > 0 And lstAddress.ListItems.Count > 0 Then
   If BillStateBS <> 1 Then
    StoreDealTable.lblBillNum = lstAddress.ListItems(lstAddressIndex).Text

    With lstAddress.ListItems(lstAddressIndex)
      DTDate.Value = .SubItems(1)
      StoreDealTable.lblOperateMan = .SubItems(2)
      StoreDealTable.cmbCheckMan = .SubItems(3)
      StoreDealTable.lblGItemCount = .SubItems(4)
      StoreDealTable.lblGCount = .SubItems(5)
      StoreDealTable.lblGMoney = .SubItems(6)
    End With
   End If
  End If
 End If
End Sub
Private Sub ClearFrame2()
 With StoreDealTable
  .lblBillNum = ""
  .lblGCount = "0"
  .lblGItemCount = "0"
  .lblOperateMan = ""
  .lblGMoney = "0"
  .cmbCheckMan = ""
  .DTDate = Date
 End With
End Sub

Private Sub SaveToStockBill()
 Dim TempRS As MYSQL_RS
 Dim i As Integer
 Dim TempSQL As String
    Set TempRS = New MYSQL_RS
    If BillStateBS = 2 Then
     TempSQL = "Select * From storedealtable Where billnum = " & Quote(Trim(lblBillNum))
    ElseIf BillStateBS = 1 Then
     TempSQL = "Select * From counttable where countname =" & Quote("库存盘点单号")
     TempRS.OpenRs TempSQL, gCnn
     TempRS.Fields("count").Value = CLng(TempRS.Fields("count").Value) + 1
     lblBillNum = VarInitData.DealVarNo(CStr(TempRS.Fields("count")), 6, "KCP")
     TempRS.Update
     TempRS.CloseRecordset
     TempRS.ReleaseMemory
     Set TempRS = Nothing
     
     Set TempRS = New MYSQL_RS
     TempSQL = "Select * From storedealtable" 'Where AKey = " & Val(txtAKey)
    End If
    TempRS.OpenRs TempSQL, gCnn
    If BillStateBS <> 2 Then
     If TempRS.RecordCount > 0 Then
      TempRS.MoveLast
      TempRS.MoveNext
     End If
    End If
    With TempRS
     If .EOF Then .AddNew
     .Fields("billnum") = lblBillNum.Caption
     .Fields("date") = StoreDealTable.DTDate
     .Fields("lookthroughman") = StoreDealTable.cmbCheckMan
     .Fields("profitlosscount") = Val(StoreDealTable.lblGCount)
     .Fields("profitlossmoney") = Val(StoreDealTable.lblGMoney)
     .Fields("gitemcount") = Val(StoreDealTable.lblGItemCount)
     .Fields("operateman") = StoreDealTable.lblOperateMan
          
     .Update
    End With
    Set TempRS = Nothing
    TempSQL = VarInitData.DisplaySQLVal(29)
    VarInitData.LoadData lstAddress, TempSQL
End Sub
Private Sub SaveToStockBillDocu(VarRS As MYSQL_RS, lstBillDocu As ListView, ByVal i As Long)
  With VarRS
   If .EOF Then .AddNew
   .Fields("billnum") = lblBillNum
   .Fields("goodscoding") = lstBillDocu.ListItems(i).Text
   .Fields("goodsname") = lstBillDocu.ListItems(i).SubItems(1)
   .Fields("goodsstandard") = lstBillDocu.ListItems(i).SubItems(2)
   .Fields("orgcount") = lstBillDocu.ListItems(i).SubItems(3)
   .Fields("profitlosscount") = lstBillDocu.ListItems(i).SubItems(4)
   .Fields("unit") = lstBillDocu.ListItems(i).SubItems(5)
   .Fields("orgcost") = lstBillDocu.ListItems(i).SubItems(6)
   .Fields("costunit") = lstBillDocu.ListItems(i).SubItems(7)
   .Fields("orggoodspos") = lstBillDocu.ListItems(i).SubItems(8)
   .Fields("goodspos") = lstBillDocu.ListItems(i).SubItems(9)
   .Fields("brand") = lstBillDocu.ListItems(i).SubItems(10)
   .Fields("goodssort") = lstBillDocu.ListItems(i).SubItems(11)
   .Fields("producehere") = lstBillDocu.ListItems(i).SubItems(12)
   .Fields("sellprice") = lstBillDocu.ListItems(i).SubItems(13)
   .Fields("modifyreason") = lstBillDocu.ListItems(i).SubItems(14)
   .Update
  End With
  
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?