VB+SQLServer2000物流管理系统 第8页

VB+SQLServer2000物流管理系统 第8页

5.1.2车辆调度安排模块的实现

5.2  车辆调度安排模块运行结果

代码如下:

Dim i As Integer

Dim c

Private Sub Cmd_Select_Click()

  frm_T_Cldd.Left = 4700

  frm_T_Cldd.Top = 3000

  frm_T_Cldd.Show 1

End Sub

Private Sub Dgr_Sjll_Click()

   On Error Resume Next

   If Adodc1.Recordset.RecordCount > 0 Then

      Txt_id.Text = Adodc1.Recordset.Fields("cldd_id")

      Text1(0).Text = Adodc1.Recordset.Fields("cldd_cphm")

      Text1(1).Text = Adodc1.Recordset.Fields("cldd_czxm")

      Text1(2).Text = Adodc1.Recordset.Fields("cldd_sjxm")

      Text1(3).Text = Adodc1.Recordset.Fields("cldd_zxrw")

      Text1(4).Text = Adodc1.Recordset.Fields("cldd_phmc")

      DT1.Value = Adodc1.Recordset.Fields("cldd_rwsj")

      Text1(5).Text = Adodc1.Recordset.Fields("cldd_shdd")

      Txt_bz.Text = Adodc1.Recordset.Fields("cldd_bz")

    End If

    For i = 0 To 6

      Text1(i).Locked = False

    Next i

End Sub

Private Sub DT1_KeyDown(KeyCode As Integer, Shift As Integer)

   If KeyCode = 13 Then

      Text1(4).SetFocus

   End If

End Sub

Private Sub Form_Load()

   Me.Left = (Screen.Width - Me.Width) / 2

   Me.Top = (Screen.Height - Me.Height) / 2

   Call LoadFile

   For i = 1 To 5

      Text1(i).Locked = True

   Next i

   Adodc1.ConnectionString = PublicStr

   Adodc1.RecordSource = "select * from tb_Goods_cldd order by cldd_id"

   Adodc1.Refresh

   DT1.Value = Date

        Call DBGCon

        Call Tbr_cortrol(Tbr_xxcz, True)

End Sub

Private Sub Tbr_xxcz_ButtonClick(ByVal Button As MSComctlLib.Button)

  Select Case Button.Index

     Case 1

         Call Tbr_cortrol(Tbr_xxcz, False)

         For i = 0 To 5                          '单击“添加”按钮,锁定文本框控件

            Text1(i).Text = ""

            Txt_bz.Text = ""

            Text1(0).SetFocus

            Text1(i).Locked = False

            Txt_id.Locked = False

            Txt_bz.Locked = False

         Next i

           AdoRs.Open "select * from tb_Goods_cldd order by cldd_id", Cnn, adOpenKeyset

             If AdoRs.RecordCount > 0 Then

                AdoRs.MoveLast

                  StrNum = Mid(AdoRs.Fields("cldd_id"), 2, Len(AdoRs.Fields("cldd_id")))

                  Call Con_PublicNum      '调用位数转换函数

                  Txt_id.Text = "A" & StrIn

              Else

                  Txt_id.Text = "A0001"

              End If

           AdoRs.Close

     Case 2                            '删除信息

         Call Deletes

         Call DBGCon

     Case 3                            '修改信息

         Call Edits

         Call DBGCon

     Case 4                            '保存信息

        Call Saves

        Call DBGCon

     Case 5

        Call Tbr_cortrol(Tbr_xxcz, True)

        For i = 0 To 5

           Text1(i).Text = ""

           Txt_id.Text = ""

           Txt_bz.Text = ""

           Txt_id.SetFocus

           Text1(i).Locked = True

           Txt_id.Locked = True

           Txt_bz.Locked = True

        Next i

        Adodc1.RecordSource = "select * from tb_Goods_cldd order by cldd_id"

        Adodc1.Refresh

        Call DBGCon

     Case 6                             '打印信息

        On Error Resume Next

        DEvr1.rsCom_cldd.Open "select * from tb_Goods_cldd where cldd_id='" + Txt_id + "'"

          If DEvr1.rsCom_cldd.RecordCount > 0 Then

                      DRP_Cldd.Show 1

          Else

             MsgBox "该车辆调度单信息不存在", 48, "提示信息"

          End If

     Case 7

        Unload Me

  End Select

End Sub

Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)

   On Error Resume Next

   If KeyCode = 13 Then

       If Index = 0 Then

          Cmd_Select_Click

          Exit Sub

       End If

   End If

   If KeyCode = 13 Or KeyCode = 40 Then

     If Index = 3 Then

         DT1.SetFocus

         Exit Sub

     End If

   End If

   If Index = 5 Then

     If KeyCode = 13 Or KeyCode = 40 Then

       Txt_bz.SetFocus

     End If

   End If

      If Index = 4 Then

         If KeyCode = 38 Then

            DT1.SetFocus

            Exit Sub

         End If

      End If

   If Index < 6 And KeyCode = 38 Then Text1(Index - 1).SetFocus

   If Index >= 0 And KeyCode = 40 Then Text1(Index + 1).SetFocus

   If Index >= 0 And KeyCode = 13 Then Text1(Index + 1).SetFocus

End Sub

Private Sub Saves()     '保存信息的事件过程

   If Text1(0).Text = "" Or Text1(3).Text = "" Then

      MsgBox "重要信息不能为空值", 48, "提示信息"

  Else

       AdoRs.Open "select * from tb_Goods_cldd where cldd_cphm='" + Text1(0).Text + "'", Cnn, adOpenKeyset

         If AdoRs.RecordCount > 0 Then

              MsgBox "该车辆已经被派出", 48, "提示信息"

              AdoRs.Close

         Else

              AdoRs.Close

            c = MsgBox("确认保存信息吗", 33, "提示信息")

              If c = vbOK Then

                Set AdoRs = Cnn.Execute("insert into tb_Goods_cldd values('" & Txt_id & "','" & Text1(0) _

                & "','" & Text1(1) & "','" & Text1(2) & "','" & Text1(3) & "','" _

                & STR(DT1.Value) & "','" & Text1(4) & "','" & Text1(5) & "','" & Txt_bz & "')")

                MsgBox "数据保存成功", 64, "提示信息"

            Else

            End If

               Adodc1.RecordSource = "select * from tb_Goods_cldd order by cldd_id"

               Adodc1.Refresh

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有