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

📄 frm_jhgl_scjhd.frm

📁 PMS是一个生产管理系统,功能强大,供大家享用,希望大家支持!!
💻 FRM
📖 第 1 页 / 共 3 页
字号:
End Sub

Private Sub Dtp_Tcrq_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Dtp_Wgrq.SetFocus
End Sub

Private Sub Dtp_Tcrq_LostFocus()  ' 投产时间
Dtp_Tcrq.CalendarBackColor = &HFFFFFF
End Sub


Private Sub Dtp_Wgrq_GotFocus()
Dtp_Wgrq.CalendarBackColor = &HFFFF80
End Sub

Private Sub Dtp_Wgrq_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Cbx_wcf.SetFocus
End Sub

Private Sub Dtp_Wgrq_LostFocus()
Dtp_Wgrq.CalendarBackColor = &HFFFFFF
End Sub

Private Sub Form_Activate()
  Adodc1.ConnectionString = PublicStr
 
  If sql <> "" Then
     Adodc1.RecordSource = sql & " order by scjhd_id"
     Adodc1.Refresh
     Call view_data     '调用过程
     If Adodc1.Recordset.RecordCount = 0 Then
        MsgBox "没有找到符合条件的记录!", , "提示窗口"
     End If
  End If
 Call Dgr_Title
 End Sub

Sub Dgr_Title()
  Dgr_Scjhd.Columns(0).Caption = "生产计划单编号"
  Dgr_Scjhd.Columns(1).Caption = "产品编号"
  Dgr_Scjhd.Columns(2).Caption = "产品名称"
  Dgr_Scjhd.Columns(3).Caption = "产品规格"
  Dgr_Scjhd.Columns(4).Caption = "计量单位"
  Dgr_Scjhd.Columns(5).Caption = "数量"
  Dgr_Scjhd.Columns(6).Caption = "计划投产日期"
  Dgr_Scjhd.Columns(7).Caption = "计划完工日期"
  Dgr_Scjhd.Columns(8).Caption = "完工否"
  Dgr_Scjhd.Columns(9).Caption = "备注信息"
End Sub

Private Sub Form_Load()
 Dim rs2 As New ADODB.Recordset
 rs2.Open "select * from tb_SCGL_cpxx ", cnn, adOpenKeyset
 If rs2.RecordCount > 0 Then
   For i = 0 To rs2.RecordCount - 1
     '向Cbx_cpbh控件中添加数据项
     Cbx_Cpbh.AddItem Trim(rs2.Fields("cpxx_id"))
     rs2.MoveNext
   Next i
 End If
 Cbx_Cpbh.ListIndex = 0
 
  tlbState Toolbar1, False
  view_data
  '设置DataGrid标题
  Call Dgr_Title
  '设置控件状态
  For i = 0 To 5
      Text1(i).Enabled = False
  Next i
  Cbx_Cpbh.Enabled = False
  Dtp_Tcrq.Enabled = False
  Dtp_Wgrq.Enabled = False
  Cbx_wcf.Enabled = False
  End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
sql = ""
End Sub

Private Sub Text1_GotFocus(Index As Integer)
  Text1(Index).BackColor = &HFFFF80  '设置背景色为蓝色
  Text1(Index).SelStart = 0  '
  Text1(Index).SelLength = Len(Text1(Index))
End Sub

Private Sub text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then  '按下回车键
   If Index = 4 Then  '如果光标在Text1(4)上,
     Dtp_Tcrq.SetFocus  '则将焦点设置在Dtp_Tcrq上
     Exit Sub  '结束本事件
   End If
   If Index = 5 Then Exit Sub  '若光标在Text1(5)上,则结束
   Text1(Index + 1).SetFocus  '光标移至下一个文本框
End If
End Sub

Private Sub Text1_LostFocus(Index As Integer)
  Text1(Index).BackColor = &HFFFFFF   '设置背景色为白色
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  Select Case Button.key
    Case "add"   '添加
       blnadd1 = True
       tlbState Toolbar1, True
       '自动创建编号
       Mystr = Left(Date, 4) + Right(Left(Date, 7), 2) + Right(Date, 2)
       Dim rs1 As New ADODB.Recordset
       rs1.Open "select * from tb_SCGL_scjhd  where scjhd_id like+ '%'+'" + Mystr + "'+'%'", cnn, adOpenKeyset
       If rs1.RecordCount > 0 Then
          If rs1.EOF = False Then rs1.MoveLast
          Text1(0).Text = "JH" + Mystr + Format(Val(Right(Trim(rs1.Fields("scjhd_id")), 3)) + 1, "###000") '编号自动加1
       Else
          Text1(0).Text = "JH" + Mystr + "001"
       End If
       rs1.Close     '关闭数据集对象
       '设置控件状态
       For i = 1 To 5
         Text1(i).Enabled = True
         Text1(i).Text = ""
       Next i
       Cbx_Cpbh.Enabled = True
       Cbx_wcf.Enabled = True
       Dtp_Tcrq.Enabled = True
       Dtp_Wgrq.Enabled = True
       Dtp_Tcrq.Value = Date
       Dtp_Wgrq.Value = Date + 30
       For i = 8 To 11
          Toolbar1.Buttons(i).Enabled = False
       Next i
'       SSTab1.Tab = 0
      Cbx_Cpbh.SetFocus
    Case "modify"    '修改
       If Adodc1.Recordset.RecordCount > 0 Then
         blnadd1 = False
          view_data
         For i = 1 To 5
             Text1(i).Enabled = True
         Next i
         tlbState Toolbar1, True
         Cbx_Cpbh.Enabled = True
         Cbx_wcf.Enabled = True
         Dtp_Tcrq.Enabled = True
         Dtp_Wgrq.Enabled = True
         For i = 8 To 11
             Toolbar1.Buttons(i).Enabled = False
         Next i
       Else
         MsgBox "系统没有要修改的数据!", , "客户关系管理系统"
       End If
    Case "delete"    '删除
       If Adodc1.Recordset.RecordCount > 0 Then
              Adodc1.Recordset.Delete
              Unload Me
              Adodc1.Refresh
              Frm_Jhgl_Scjhd.Show 1
       Else
         MsgBox "系统没有要删除的数据!", , "提示窗口"
       End If
    Case "save"   '保存
      If Text1(1) = "" Then
         MsgBox "系统不允许产品名称为空!", , "提示窗口"
         Exit Sub
      End If
      If Text1(2) = "" Then
         MsgBox "系统不允许产品规格为空!", , "提示窗口"
         Exit Sub
      End If
      If Text1(3) = "" Then
         MsgBox "系统不允许计量单位为空!", , "提示窗口"
         Exit Sub
      End If
      If Text1(4) = "" Then
         MsgBox "系统不允许数量为空!", , "提示窗口"
         Exit Sub
      End If
      On Error GoTo SaveErr     '出现错误转向错误处理
      If blnadd1 = False Then
        Set rs1 = New ADODB.Recordset
        rs1.Open "select * from  tb_SCGL_scjhd where scjhd_id='" + Text1(0) + "'order by scjhd_id", cnn, adOpenStatic
        If rs1.RecordCount > 0 Then
           Myval = MsgBox("您确实要修改这条数据吗?", vbYesNo)
           If Myval = vbYes Then
              cnn.Execute ("update tb_SCGL_scjhd set scjhd_cpbh='" + Cbx_Cpbh.Text + "',scjhd_cpmc='" + Text1(1) + "',scjhd_cpgg='" + Text1(2) + _
              "',scjhd_jldw='" + Text1(3).Text + "',scjhd_jhsl='" + Text1(4) + "',scjhd_tcrq='" + str(Dtp_Tcrq.Value) + "',scjhd_wgrq='" + str(Dtp_Wgrq.Value) + _
              "',scjhd_wcf='" + Trim(Cbx_wcf.Text) + "',scjhd_bz='" + Text1(5) + "'where scjhd_id='" + Text1(0) + "'")
               Adodc1.Refresh
               Set Dgr_Scjhd.DataSource = Adodc1
               Call Dgr_Title
           End If
        End If
        rs1.Close
      Else
        StrTemp = Val(Left(Date, 4) + Right(Left(Date, 7), 2) + Right(Date, 2))
        Str1 = Val(Left(Dtp_Tcrq.Value, 4) + Right(Left(Dtp_Tcrq.Value, 7), 2) + Right(Dtp_Tcrq.Value, 2))
        If Val(StrTemp) > Val(Str1) Then
            MsgBox "投产日期不能小于今天的日期", , "信息提示"
            Dtp_Tcrq.Value = Date
            Dtp_Tcrq.SetFocus
            Exit Sub
        End If
        
        Str1 = Val(Left(Dtp_Tcrq.Value, 4) + Right(Left(Dtp_Tcrq.Value, 7), 2) + Right(Dtp_Tcrq.Value, 2))
        Str2 = Val(Left(Dtp_Wgrq.Value, 4) + Right(Left(Dtp_Wgrq.Value, 7), 2) + Right(Dtp_Wgrq.Value, 2))
        If Str1 > Str2 Then
            MsgBox "输入的完工日期不能早于开工日期!", , "信息提示"
            Dtp_Wgrq.SetFocus
            Exit Sub
        End If
        If Trim(Cbx_wcf.Text) = "是" Then
            MsgBox "该订单并未完工!", , "信息提示"
            Cbx_wcf.SetFocus
            Exit Sub
        End If
        Set rs1 = New ADODB.Recordset
        rs1.Open "tb_SCGL_scjhd", cnn, adOpenKeyset, adLockOptimistic
        '添加客户信息
        rs1.AddNew
        rs1.Fields("scjhd_id") = Text1(0).Text
        rs1.Fields("scjhd_cpbh") = Cbx_Cpbh.Text
        rs1.Fields("scjhd_cpmc") = Text1(1).Text
        rs1.Fields("scjhd_cpgg") = Text1(2).Text
        rs1.Fields("scjhd_jldw") = Text1(3).Text
        rs1.Fields("scjhd_jhsl") = Text1(4).Text
        rs1.Fields("scjhd_tcrq") = Dtp_Tcrq.Value
        rs1.Fields("scjhd_wgrq") = Dtp_Wgrq.Value
        rs1.Fields("scjhd_wcf") = Trim(Cbx_wcf.Text)
        rs1.Fields("scjhd_bz") = Text1(5).Text
        rs1.Update     '更新数据库
        Adodc1.Refresh
        rs1.Close
      End If
      Call Dgr_Title
      For i = 0 To 5
        Text1(i).Enabled = False
      Next i
       Cbx_Cpbh.Enabled = False
       Cbx_wcf.Enabled = False
       Dtp_Tcrq.Enabled = False
       Dtp_Wgrq.Enabled = False
      tlbState Toolbar1, False
      For i = 8 To 11
          Toolbar1.Buttons(i).Enabled = True
      Next i
      Exit Sub
SaveErr:    '错误处理
      MsgBox Err.Description, , "信息提示"
    Case "cancel"
      view_data
      For i = 0 To 5
         Text1(i).Enabled = False
      Next i
       Cbx_Cpbh.Enabled = False
       Cbx_wcf.Enabled = False
       Dtp_Tcrq.Enabled = False
       Dtp_Wgrq.Enabled = False
      tlbState Toolbar1, False
      For i = 8 To 11
          Toolbar1.Buttons(i).Enabled = True
      Next i
    Case "find"
      Tb = "tb_SCGL_scjhd"
      Load Frm_Cxct
      Frm_Cxct.Show 1
    Case "first"     '移到第一条记录
      If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MoveFirst
      Call view_data     '调用过程
      Call Dgr_Title
    Case "previous"     '移到上一条记录
      If Adodc1.Recordset.RecordCount > 0 Then
         If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MovePrevious
         If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
      End If
      Call view_data     '调用过程
      Call Dgr_Title
    Case "next"    '移到下一条记录
      If Adodc1.Recordset.RecordCount > 0 Then
         If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
         If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
      End If
      Call view_data     '调用过程
      Call Dgr_Title
    Case "last"     '移到最后一条记录
      If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveLast
      Call view_data     '调用过程
      Call Dgr_Title
    Case "close"
      Unload Me
  End Select
End Sub

⌨️ 快捷键说明

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