⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmtrafficadd.frm

📁 自己写的物流管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      AutoSize        =   -1  'True
      Caption         =   "发货日期:"
      Height          =   180
      Left            =   9210
      TabIndex        =   7
      Top             =   960
      Width           =   900
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      Caption         =   "吨"
      Height          =   180
      Left            =   5640
      TabIndex        =   6
      Top             =   2265
      Width           =   180
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "重    量:"
      Height          =   180
      Left            =   3360
      TabIndex        =   4
      Top             =   2265
      Width           =   900
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "车 类 型:"
      Height          =   180
      Left            =   3330
      TabIndex        =   3
      Top             =   960
      Width           =   900
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "车    号:"
      Height          =   180
      Left            =   330
      TabIndex        =   1
      Top             =   960
      Width           =   900
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "新  增  运  单"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   4920
      TabIndex        =   0
      Top             =   240
      Width           =   2400
   End
End
Attribute VB_Name = "frmTrafficAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private ID As Integer
Private CARNUM As String
Private DATENUM As Long
Private PRODUCTNAME As String
Private PRODUCTTYPE As Integer
Private TRAINTYPE As Integer
Private SENDSTATION As Integer
Private RECEIVESTATION As Integer
Private SENDER As Integer
Private RECEIVER As Integer
Private WEIGHT As Single
Private BASICCARRIAGE As Single
Private LOCALCARRIAGE As Single
Private SERVECHARGE As Single
Private LOADCHARGE As Single
Private FAVOURABILE As Single
Private SHORTCARRIAGE As Single
Private STORAGECHARGE As Single
Private CLEARCHARGE As Single
Private total As Single
Private FLAG As Integer


Private Sub Command1_Click()

    If CheckForm() = True Then
    
        '插入数据
        Dim strsql As String
        Dim DB As New clsDataBase
        strsql = "INSERT INTO TRAFFIC (ID,CARNUM,DATENUM,PRODUCTNAME,PRODUCTTYPE," & _
        "TRAINTYPE,SENDSTATION,RECEIVESTATION,SENDER,RECEIVER,WEIGHT,BASICCARRIAGE," & _
        "LOCALCARRIAGE,SERVECHARGE,LOADCHARGE,FAVOURABILE,SHORTCARRIAGE,STORAGECHARGE," & _
        "CLEARCHARGE,TOTAL,FLAG) VALUES(" & sys.NumToInsert(txtID.Text) & "," & sys.StrToInsert(txtCarNum.Text) & ", " & _
        "" & sys.StrToInsert(dtpDateNum.Value) & "," & sys.NumToInsert(cmbProductName.ItemData(cmbProductName.ListIndex)) & "," & sys.NumToInsert(cmbProductType.ItemData(cmbProductType.ListIndex)) & ", " & _
        "" & sys.NumToInsert(cmbTrainType.ItemData(cmbTrainType.ListIndex)) & "," & sys.NumToInsert(cmbSendStation.ItemData(cmbSendStation.ListIndex)) & "," & sys.NumToInsert(cmbReceiveStation.ItemData(cmbReceiveStation.ListIndex)) & "," & _
        "" & sys.NumToInsert(cmbSender.ItemData(cmbSender.ListIndex)) & "," & sys.NumToInsert(cmbReceiver.ItemData(cmbReceiver.ListIndex)) & "," & _
        "" & sys.NumToInsert(txtWeight.Text) & "," & sys.NumToInsert(txtBasicCarriage.Text) & "," & sys.NumToInsert(txtLocalCarriage.Text) & "," & _
        "" & sys.NumToInsert(txtServeCharge.Text) & "," & sys.NumToInsert(txtLoadCharge.Text) & "," & sys.NumToInsert(txtFavourabile.Text) & "," & _
        "" & sys.NumToInsert(txtShortCarriage.Text) & "," & sys.NumToInsert(txtStorageCharge.Text) & "," & sys.NumToInsert(txtClearCharge.Text) & "," & sys.NumToInsert(txtTotal.Text) & ",False )"
        sys.DB.ExecuteSQL (strsql)
        MsgBox "操作成功!"
        Unload frmTrafficAdd
    End If
End Sub

Private Sub Command2_Click()

    Unload Me
End Sub


Private Sub Form_Load()

    Me.Top = 0
    Me.Left = 0
    Me.Width = MainForm.Width * 0.8
    Me.Height = MainForm.Height * 0.7
    
    '取得最大ID
    Dim inum As Integer
    Dim strsql As String
    Dim DB As New clsDataBase
    Dim rs As New ADODB.Recordset
    
    strsql = "SELECT MAX(ID) AS MAXID FROM TRAFFIC"
    Set rs = sys.DB.OpenRecordSet(strsql)
    If Not IsNull(rs(0)) Then
        ID = rs(0) + 1
    Else
        ID = 0
    End If
    txtID.Text = ID
    
    '初始化车类型
    cmbTrainType.AddItem ("高边")
    cmbTrainType.ItemData(0) = 0
    cmbTrainType.AddItem ("蓬车")
    cmbTrainType.ItemData(1) = 1
    cmbTrainType.ListIndex = 0
    
    '初始化货物类型
    cmbProductType.AddItem ("包装")
    cmbProductType.ItemData(0) = 0
    cmbProductType.AddItem ("散装")
    cmbProductType.ItemData(1) = 1
    cmbProductType.ListIndex = 0
    
    '初始化品名
    strsql = "SELECT * FROM PRODUCT"
    Set rs = sys.DB.OpenRecordSet(strsql)
    If Not (rs.BOF) Or (rs.EOF) Then
        inum = 0
        Do While Not rs.EOF
            cmbProductName.AddItem (rs("NAME"))
            cmbProductName.ItemData(inum) = rs("ID")
            rs.MoveNext
            inum = inum + 1
        Loop
    End If
    If cmbProductName.ListIndex <> -1 Then
        cmbProductName.ListIndex = 0
    Else
        cmbProductName.ListIndex = -1
    End If
    
    
    '初始化发站
    strsql = "SELECT * FROM STATION ORDER BY NAME"
    Set rs = sys.DB.OpenRecordSet(strsql)
    If Not (rs.BOF) Or (rs.EOF) Then
        inum = 0
        Do While Not rs.EOF
            cmbSendStation.AddItem (rs("NAME"))
            cmbSendStation.ItemData(inum) = rs("ID")
            rs.MoveNext
            inum = inum + 1
        Loop
    End If
    If cmbSendStation.ListIndex <> -1 Then
        cmbSendStation.ListIndex = 0
    Else
        cmbSendStation.ListIndex = -1
    End If
    
    '初始化到站
    strsql = "SELECT * FROM STATION  ORDER BY NAME DESC"
    Set rs = sys.DB.OpenRecordSet(strsql)
    If Not (rs.BOF) Or (rs.EOF) Then
        inum = 0
        Do While Not rs.EOF
            cmbReceiveStation.AddItem (rs("NAME"))
            cmbReceiveStation.ItemData(inum) = rs("ID")
            rs.MoveNext
            inum = inum + 1
        Loop
    End If
    If cmbReceiveStation.ListIndex <> -1 Then
        cmbReceiveStation.ListIndex = 0
    Else
        cmbReceiveStation.ListIndex = -1
    End If
    
    '初始化发货人
    strsql = "SELECT * FROM CLIENT  ORDER BY NAME"
    Set rs = sys.DB.OpenRecordSet(strsql)
    If Not (rs.BOF) Or (rs.EOF) Then
        inum = 0
        Do While Not rs.EOF
            cmbSender.AddItem (rs("NAME"))
            cmbSender.ItemData(inum) = rs("ID")
            rs.MoveNext
            inum = inum + 1
        Loop
    End If
    If cmbSender.ListIndex <> -1 Then
        cmbSender.ListIndex = 0
    Else
        cmbSender.ListIndex = -1
    End If
    
   '初始化收货人
    strsql = "SELECT * FROM CLIENT  ORDER BY NAME DESC"
    Set rs = sys.DB.OpenRecordSet(strsql)
    If Not (rs.BOF) Or (rs.EOF) Then
        inum = 0
        Do While Not rs.EOF
            cmbReceiver.AddItem (rs("NAME"))
            cmbReceiver.ItemData(inum) = rs("ID")
            rs.MoveNext
            inum = inum + 1
        Loop
    End If
    If cmbReceiver.ListIndex <> -1 Then
        cmbReceiver.ListIndex = 0
    Else
        cmbReceiver.ListIndex = -1
    End If
    
    dtpDateNum.Value = Date

End Sub

'合计
Private Sub MakeTotal()
    
    txtTotal.Text = sys.TextToNum(txtBasicCarriage.Text) + sys.TextToNum(txtLocalCarriage.Text) + sys.TextToNum(txtServeCharge.Text) - sys.TextToNum(txtFavourabile.Text) + sys.TextToNum(txtLoadCharge.Text) + sys.TextToNum(txtShortCarriage.Text) + sys.TextToNum(txtStorageCharge.Text) + sys.TextToNum(txtClearCharge.Text)
    If sys.TextToNum(txtWeight.Text) <> 0 Then
        txtAvg.Text = FormatNumber(sys.TextToNum(txtTotal.Text / txtWeight.Text), 2)
    Else
        txtAvg.Text = 0
    End If
End Sub

'检查表单数据
Private Function CheckForm() As Boolean

    CheckForm = False

    If txtCarNum.Text = "" Then
    
        MsgBox "车号不能为空!"
        txtCarNum.SetFocus
    ElseIf cmbProductName.Text = "" Then
    
        MsgBox "品名不能为空!"
        cmbProductName.SetFocus
    ElseIf cmbSendStation.Text = "" Then
    
        MsgBox "发站不能为空!"
        cmbSendStation.SetFocus
    ElseIf cmbReceiveStation.Text = "" Then
    
        MsgBox "到站不能为空!"
        cmbReceiveStation.SetFocus
    ElseIf txtWeight.Text = "" Then
    
        MsgBox "重量不能为空!"
        txtWeight.SetFocus
    ElseIf txtBasicCarriage.Text = "" Then
    
        MsgBox "国铁运费不能为空!"
        txtBasicCarriage.SetFocus
    ElseIf txtServeCharge.Text = "" Then
    
        MsgBox "服务费不能为空!"
        txtServeCharge.SetFocus
    Else
    
        CheckForm = True
    End If
    
End Function


Private Sub Form_Unload(Cancel As Integer)

    If frmTraffic.Visible = True Then
        
        Call frmTraffic.query
    End If
End Sub

Private Sub txtBasicCarriage_Change()

    Call MakeTotal

End Sub

Private Sub txtClearCharge_Change()

    Call MakeTotal
End Sub

Private Sub txtFavourabile_Change()

    Call MakeTotal
End Sub

Private Sub txtLoadCharge_Change()

    Call MakeTotal
End Sub

Private Sub txtLocalCarriage_Change()

    Call MakeTotal
End Sub

Private Sub txtServeCharge_Change()

    Call MakeTotal
End Sub

Private Sub txtShortCarriage_Change()

    Call MakeTotal
End Sub

Private Sub txtStorageCharge_Change()

    Call MakeTotal
End Sub

Private Sub txtWeight_Change()
    Call MakeTotal
End Sub

⌨️ 快捷键说明

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