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

📄

📁 这是一个航空公司用来计算货物运价的系统。
💻
📖 第 1 页 / 共 2 页
字号:
      Caption         =   "请输入相应的运价信息"
      Height          =   255
      Left            =   4200
      TabIndex        =   1
      Top             =   120
      Width           =   2055
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义变量
Dim cur1, cur2, cur3, cur4, cur5, cur6, cur7, cur8, cur9 As Currency 'cur1~cur9为M~3000九个级别的运价数据
Private Sub Command1_Click()
'############################################
'初始化判断数据的合法性
'############################################
Dim SQL, SQL0, fflag As String 'SQL为最终SQL语句,SQL0为临时SQL语句,fflag为运价类型
Dim s0 As String 's0用来存放数据校验SQL语句
Dim Msg, Style, Title, Response As String
If IsNumeric(Text1.Text) <> True And Text1.Text <> "" Then
MsgBox ("请在此输入正确的M运价!!")
Text1.Text = ""
Text1.SetFocus
ElseIf IsNumeric(Text2.Text) <> True And Text2.Text <> "" Then
MsgBox ("请在此输入正确的N运价!!")
Text2.Text = ""
Text2.SetFocus
ElseIf IsNumeric(Text3.Text) <> True And Text3.Text <> "" Then
MsgBox ("请在此输入正确的45Kg运价!!")
Text3.Text = ""
Text3.SetFocus
ElseIf IsNumeric(Text4.Text) <> True And Text4.Text <> "" Then
MsgBox ("请在此输入正确的100Kg运价!!")
Text4.Text = ""
Text4.SetFocus
ElseIf IsNumeric(Text5.Text) <> True And Text5.Text <> "" Then
MsgBox ("请在此输入正确的300Kg运价!!")
Text5.Text = ""
Text5.SetFocus
ElseIf IsNumeric(Text6.Text) <> True And Text6.Text <> "" Then
MsgBox ("请在此输入正确的500Kg运价!!")
Text6.Text = ""
Text6.SetFocus
ElseIf IsNumeric(Text7.Text) <> True And Text7.Text <> "" Then
MsgBox ("请在此输入正确的1000Kg运价!!")
Text7.Text = ""
Text7.SetFocus
ElseIf IsNumeric(Text8.Text) <> True And Text8.Text <> "" Then
MsgBox ("请在此输入正确的2000Kg运价!!")
Text8.Text = ""
Text8.SetFocus
ElseIf IsNumeric(Text9.Text) <> True And Text9.Text <> "" Then
MsgBox ("请在此输入正确的3000Kg运价!!")
Text9.Text = ""
Text9.SetFocus
ElseIf IsNumeric(Text12.Text) <> True And Text12.Text <> "" Then
MsgBox ("请在此输入正确等级附加率!!")
Text12.Text = ""
Text12.SetFocus
ElseIf DTPicker1.Value > DTPicker2.Value Then
MsgBox ("您输入的有效期时间段有误!!!")
DTPicker1.SetFocus
ElseIf Text13.Text = "" Then
MsgBox ("请输入起始站!!")
Text13.SetFocus
ElseIf Text14.Text = "" Then
MsgBox ("请输入到达站!!")
Text14.SetFocus
Else '正确情况
cur1 = Val(Text1.Text)
cur2 = Val(Text2.Text)
cur3 = Val(Text3.Text)
cur4 = Val(Text4.Text)
cur5 = Val(Text5.Text)
cur6 = Val(Text6.Text)
cur7 = Val(Text7.Text)
cur8 = Val(Text8.Text)
cur9 = Val(Text9.Text)
'----------首先判断数据的合法性------------
If Option2.Value Then '等级商品运价
'等级商品运价的条件是M~3000九个等级数据均为空,只有等级百分比不为空
If Text10.Text = "" Then
MsgBox ("请在此输入货物编码!!")
Text10.Text = ""
Text10.SetFocus
ElseIf Text12.Text = "" Or IsNumeric(Text12.Text) <> True Then
    MsgBox ("请在此输入正确的附加百分比!!")
    Text12.Text = ""
    Text12.SetFocus
    Else '输入的等级商品运价信息正确
    '**********进行数据插入操作***********
            'SQL语句生成部分
            If Option2.Value Then
            fflag = "2"
                ElseIf Option1.Value Then
            fflag = "1"
            Else
                fflag = "3"
            End If
            s0 = "select * from tbl_fare_bz where fflag='" & Trim(fflag) & "' and DEP='" & Trim(Text13.Text) & "' and DEST='" & Trim(Text14.Text) & "' and CARRIER='" & Trim(Text11.Text) & "' and GSNO='" & Trim(Text10.Text) & "' and ((BEGDATE<='" & DTPicker2.Value & "' and ENDDATE>='" & DTPicker1.Value & "') or (ENDDATE>='" & DTPicker1.Value & "' and BEGDATE<='" & DTPicker2.Value & "'))"
            '判断是否存在重复记录
            Dim x As Object
            Set x = CreateObject("db_yunjia.REC")
            If x.CHK0(s0) Then
                MsgBox ("错误!!存在重复记录!!")
                Text1.SetFocus
            Else
                '生成插入SQL语句
                SQL0 = "insert into tbl_fare_bz (DEP,DEST,CARRIER,FFLAG,GSNO,BEGDATE,ENDDATE,FJBF,J0,J1,J2,J3,J4,J5,J6,J7,J8) values ('" & Trim(Text13.Text) & "','" & Trim(Text14.Text) & "','" & Trim(Text11.Text) & "','" & Trim(fflag) & "','" & Trim(Text10.Text) & "','" & DTPicker1.Value & "','" & DTPicker2.Value & "','" & Trim(Text12.Text) & "',null,null,null,null,null,null,null,null,null)"
                '插入数据
                Dim y As Object
                Set y = CreateObject("db_yunjia.REC")
                If y.INS0(SQL0) Then
                    '提示数据插入成功,询问是否需要插入另以条记录
                    Msg = "记录成功添加,您是否需要添加另以条??"   ' 定义信息。
                    Style = vbYesNo + vbQuestion + vbDefaultButton2   ' 定义按钮。
                    Title = "恭喜!!数据添加成功!!"   ' 定义标题。
                    Response = MsgBox(Msg, Style, Title)
                    If Response = vbYes Then '需要添加新的记录,清除前面所有文本框的内容
                        Text1.Text = ""
                        Text2.Text = ""
                        Text3.Text = ""
                        Text4.Text = ""
                        Text5.Text = ""
                        Text6.Text = ""
                        Text7.Text = ""
                        Text8.Text = ""
                        Text9.Text = ""
                        Text10.Text = ""
                        Text11.Text = ""
                        Text12.Text = ""
                        Text13.Text = ""
                        Text14.Text = ""
                        Option1.Value = True
                        DTPicker1.Value = "2000-1-1"
                        DTPicker2.Value = "2000-1-1"
                        Text1.SetFocus
                    Else
                        Unload Form2
                        Form4.Show
                    End If
                Else
                    MsgBox ("错误!!数据插入失败!!")
                End If
            End If
End If
    Else '普通商品运价或指定商品运价
    '普货或指定商品的cur3~cur7均不为空
    If Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Then '45~1000Kg级别之间有一项数据为空
    MsgBox ("45~1000Kg这几个等级数据不能为空!!")
    Text3.SetFocus
    ElseIf (Text8.Text = "" And Text9.Text <> "") Or (Text8.Text <> "" And Text9.Text = "") Then
    MsgBox ("2000,3000Kg这两个重量级别的运价只能同时为空或同事赋值!!")
    Text8.SetFocus
    Else
    '进一步判断这些数据的合法性,主要是cur2~cur9这几个数据是逐步缩小的
    If cur2 <> 0 And cur2 < cur3 Then 'N出错
    MsgBox ("您所输入的N运价有误!!")
    Text2.Text = ""
    Text2.SetFocus
    ElseIf (cur2 <> 0 And cur3 > cur2) Or cur3 < cur4 Then '45Kg出错了
    MsgBox ("您所输入的45Kg级运价有误!!")
    Text3.Text = ""
    Text3.SetFocus
    ElseIf cur4 > cur3 Or cur4 < cur5 Then '100Kg出错了
    MsgBox ("您所输入的100Kg级运价有误!!")
    Text4.Text = ""
    Text4.SetFocus
    ElseIf cur5 > cur4 Or cur5 < cur6 Then '300kg出错了
    MsgBox ("您所输入的300Kg级运价有误!!")
    Text5.Text = ""
    Text5.SetFocus
    ElseIf cur6 > cur5 Or cur6 < cur7 Then '500kg出错了
    MsgBox ("您所输入的500Kg级运价有误!!")
    Text6.Text = ""
    Text6.SetFocus
    ElseIf cur7 > cur6 Or cur7 < cur8 Then '1000kg出错了
    MsgBox ("您所输入的1000Kg级运价有误!!")
    Text7.Text = ""
    Text7.SetFocus
    ElseIf cur8 > cur7 Or cur8 < cur9 Then '2000kg出错了
    MsgBox ("您所输入的2000Kg级运价有误!!")
    Text8.Text = ""
    Text8.SetFocus
    ElseIf cur9 > cur8 Then '3000Kg出错了
    MsgBox ("您所输入的3000Kg级运价有误!!")
    Text9.Text = ""
    Text9.SetFocus
    ElseIf Text10.Text = "" Then
    MsgBox ("请在此输入货物编码!!")
    Text10.Text = ""
    Text10.SetFocus
    ElseIf Text11.Text = "" Then
    MsgBox ("请在此输入代理商编码!!")
    Text11.Text = ""
    Text11.SetFocus
    Else '输入的普货或指定商品运价信息正确
    '**********进行数据插入操作***********
    '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            'SQL语句生成部分
            If Option2.Value Then
            fflag = "2"
                ElseIf Option1.Value Then
            fflag = "1"
            Else
                fflag = "3"
            End If
            s0 = "select * from tbl_fare_bz where fflag='" & Trim(fflag) & "' and DEP='" & Trim(Text13.Text) & "' and DEST='" & Trim(Text14.Text) & "' and CARRIER='" & Trim(Text11.Text) & "' and GSNO='" & Trim(Text10.Text) & "' and ((BEGDATE<='" & DTPicker2.Value & "' and ENDDATE>='" & DTPicker1.Value & "') or (ENDDATE>='" & DTPicker1.Value & "' and BEGDATE<='" & DTPicker2.Value & "'))"
            '判断是否存在重复记录
            Dim x0 As Object
            Set x0 = CreateObject("db_yunjia.REC")
            If x0.CHK0(s0) Then
                MsgBox ("错误!!存在重复记录!!")
                Text1.SetFocus
            Else
                '生成插入SQL语句
                SQL0 = "insert into tbl_fare_bz (DEP,DEST,CARRIER,FFLAG,GSNO,BEGDATE,ENDDATE,FJBF,J0,J1,J2,J3,J4,J5,J6,J7,J8) values ('" & Trim(Text13.Text) & "','" & Trim(Text14.Text) & "','" & Trim(Text11.Text) & "','" & Trim(fflag) & "','" & Trim(Text10.Text) & "','" & DTPicker1.Value & "','" & DTPicker2.Value & "',null,"
                '对M运价作出判断
                If Val(Text1.Text) > 0 Then
                    SQL0 = SQL0 & "'" & Trim(Text1.Text) & "',"
                Else
                    SQL0 = SQL0 & "null,"
                End If
                'N运价
                If Val(Text2.Text) > 0 Then
                    SQL0 = SQL0 & "'" & Trim(Text2.Text) & "',"
                Else
                    SQL0 = SQL0 & "null,"
                End If
                '一次写完45~1000Kg运价
                     SQL0 = SQL0 & "'" & Trim(Text3.Text) & "','" & Trim(Text4.Text) & "','" & Trim(Text5.Text) & "','" & Trim(Text6.Text) & "','" & Trim(Text7.Text) & "',"
                '判断2000Kg和3000Kg级别的数据
                If Val(Text8.Text) > 0 Then
                    SQL0 = SQL0 & "'" & Trim(Text8.Text) & "','" & Trim(Text9.Text) & "')"
                Else
                    SQL0 = SQL0 & "null,null)"
                End If
                '插入数据
                Dim y0 As Object
                Set y0 = CreateObject("db_yunjia.REC")
                If y0.INS0(SQL0) Then
                    '提示数据插入成功,询问是否需要插入另以条记录
                    Msg = "记录成功添加,您是否需要添加另以条??"   ' 定义信息。
                    Style = vbYesNo + vbQuestion + vbDefaultButton2   ' 定义按钮。
                    Title = "恭喜!!数据添加成功!!"   ' 定义标题。
                    Response = MsgBox(Msg, Style, Title)
                    If Response = vbYes Then '需要添加新的记录,清除前面所有文本框的内容
                        Text1.Text = ""
                        Text2.Text = ""
                        Text3.Text = ""
                        Text4.Text = ""
                        Text5.Text = ""
                        Text6.Text = ""
                        Text7.Text = ""
                        Text8.Text = ""
                        Text9.Text = ""
                        Text10.Text = ""
                        Text11.Text = ""
                        Text12.Text = ""
                        Text13.Text = ""
                        Text14.Text = ""
                        Option1.Value = True
                        DTPicker1.Value = "2000-1-1"
                        DTPicker2.Value = "2000-1-1"
                        Text1.SetFocus
                    Else
                        Unload Form2
                        Form4.Show
                    End If
                Else
                    MsgBox ("错误!!数据插入失败!!")
                End If
            End If
    End If
End If
End If
End If
End Sub
Private Sub Command2_Click()
Unload Form2
Form4.Show
End Sub

Private Sub Form_Load() '默认情况下,不允许用户输入附加率
Text12.Enabled = False
End Sub

Private Sub Option1_Click() '不允许用户输入附加率
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Text6.Enabled = True
Text7.Enabled = True
Text8.Enabled = True
Text9.Enabled = True
Text12.Enabled = False
End Sub
Private Sub Option3_Click() '不允许用户输入附加率
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Text6.Enabled = True
Text7.Enabled = True
Text8.Enabled = True
Text9.Enabled = True
Text12.Enabled = False
End Sub

Private Sub Option2_Click() '选中等级商品运价后,只允许用户输入附加百分比
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text6.Enabled = False
Text7.Enabled = False
Text8.Enabled = False
Text9.Enabled = False
Text12.Enabled = True
End Sub

⌨️ 快捷键说明

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