📄 planarrangements.frm
字号:
Top = 1520
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "完成数量"
Height = 180
Left = 360
TabIndex = 8
Top = 1520
Width = 720
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "-"
Height = 180
Left = 3480
TabIndex = 4
Top = 555
Width = 90
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "计划单号"
Height = 180
Left = 360
TabIndex = 2
Top = 580
Width = 720
End
End
Attribute VB_Name = "PlanArrangements"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public DspIsModify As Boolean
Private Sub Command1_Click()
PlanAdd.opTypeIsSearch = True
PlanAdd.Show vbModal
Text1.Text = Mid(PlanAdd.TaskPlanID_9, 1, 7)
Text2.Text = Mid(PlanAdd.TaskPlanID_9, 8, 2)
IniFlex Grid, PlanAdd.TaskPlanID_9
Call Text4_GotFocus
End Sub
Private Sub Command2_Click()
PlanAdd.opTypeIsSearch = False
PlanAdd.Show vbModal
End Sub
Private Sub Command3_Click()
If Combo1.Text = "" Then Exit Sub
SimulationDayPlan Grid, Combo1.Text, PlanAdd.TaskPlanID_9, CDate(Format(DTPicker1.Value, "yyyy-mm-dd") & " " & Format(DTPicker2.Value, "hh:mm")), Val(Text3.Text)
End Sub
Private Sub Command4_Click(Index As Integer)
Select Case Index
Case 1
Unload Me
End Select
End Sub
Private Sub Command5_Click()
If MsgBox("是否确定修改计划配置信息", vbInformation Or vbYesNo, "提示") = vbYes Then
ModifyPlan Grid, Text1.Text & Text2.Text, Text4.Text
End If
End Sub
Private Sub Command6_Click()
SavePlan Grid
End Sub
Private Sub Command7_Click()
If MsgBox("是否确定删除计划配置信息", vbInformation Or vbYesNo, "提示") = vbYes Then
DelPlan Text1.Text & Text2.Text, Text4.Text
End If
End Sub
Private Sub DChose_Change()
Grid.TextMatrix(Grid.Row, Grid.Col) = DChose.Value
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
LoadTimeFA Combo1
Grid.ColWidth(1) = 1500
Grid.ColWidth(2) = 1500
Grid.ColWidth(3) = 1500
Grid.ColWidth(4) = 1500
Grid.ColAlignment(0) = flexAlignCenterCenter
Grid.ColAlignment(1) = flexAlignCenterCenter
Grid.ColAlignment(2) = flexAlignCenterCenter
Grid.ColAlignment(3) = flexAlignCenterCenter
Grid.ColAlignment(4) = flexAlignCenterCenter
Command6.Visible = IIf(DspIsModify = True, False, True)
Command5.Visible = IIf(DspIsModify = True, True, False)
Command3.Visible = IIf(DspIsModify = True, False, True)
Command1.Visible = IIf(DspIsModify = True, False, True)
Command2.Visible = IIf(DspIsModify = True, False, True)
Command7.Visible = IIf(DspIsModify = True, True, False)
Label5.Visible = IIf(DspIsModify = True, False, True)
Combo1.Visible = IIf(DspIsModify = True, False, True)
ConvertFont Me
End Sub
Private Sub Grid_Scroll()
DChose.Visible = False
End Sub
Private Sub Grid_EnterCell()
If Grid.TextMatrix(Grid.Row, Grid.Col) = "" Then Exit Sub
On Error GoTo ex
Select Case Grid.Col
Case 1, 3
DChose.Format = dtpShortDate
DChose.Value = CDate(Grid.TextMatrix(Grid.Row, Grid.Col))
DChose.Visible = True
DChose.Left = Grid.CellLeft + Grid.Left
DChose.Top = Grid.CellTop + Grid.Top
DChose.Width = Grid.CellWidth
DChose.Height = Grid.CellHeight
Case 2, 4
DChose.Format = dtpTime
DChose.Value = CDate(Grid.TextMatrix(Grid.Row, Grid.Col))
DChose.Visible = True
DChose.Left = Grid.CellLeft + Grid.Left
DChose.Top = Grid.CellTop + Grid.Top
DChose.Width = Grid.CellWidth
DChose.Height = Grid.CellHeight
End Select
Exit Sub
ex:
DChose.Visible = False
End Sub
Private Sub Text3_GotFocus()
txtSelAll Text3
End Sub
Private Sub Text3_LostFocus()
If IsNumeric(Text3.Text) = False Then
If TestNum(PlanAdd.TaskPlanID_9, Text3.Text) = False Then
MsgBox "计划剩余数量不足", vbInformation, "提示"
End If
MsgBox "输入错误", vbInformation, "提示"
txtSelAll Text3
End If
End Sub
Private Sub Text4_GotFocus()
Text4.Text = IIf(DspIsModify = False, GetSubPlanID(Text1.Text & Text2.Text), Text4.Text)
End Sub
Private Sub Text4_LostFocus()
If Text1.Text <> "" And Text2.Text <> "" Then
Text4.Text = AddZero(2 - Len(Trim(Text4.Text))) & Trim(Text4.Text)
End If
End Sub
'==========================================================================================
Private Sub SavePlan(Flex As MSFlexGrid)
If rs.State = 1 Then rs.Close
rs.Open "Select * from 生产计划", DBConn, adOpenKeyset, adLockOptimistic, adCmdText
Dim i
For i = 1 To Flex.Rows - 1
rs.AddNew
rs.Fields("计划单号").Value = Trim(Text1.Text)
rs.Fields("批次号").Value = Trim(Text2.Text)
rs.Fields("子批次号").Value = Trim(Text4.Text)
rs.Fields("完成数量").Value = Trim(Text3.Text)
rs.Fields("制定人").Value = ""
rs.Fields("制定时间").Value = Now()
rs.Fields("部门名称").Value = GetDepartByPlanID(Trim(Text1.Text) & Trim(Text2.Text))
rs.Fields("班组名称").Value = Flex.TextMatrix(i, 0)
rs.Fields("生产日期").Value = CDate(Flex.TextMatrix(i, 1))
rs.Fields("生产时间").Value = CDate(Flex.TextMatrix(i, 2))
rs.Fields("完成日期").Value = CDate(Flex.TextMatrix(i, 3))
rs.Fields("完成时间").Value = CDate(Flex.TextMatrix(i, 4))
rs.Update
Next i
MsgBox "保存完成", vbInformation, "提示"
End Sub
Private Sub ModifyPlan(Flex As MSFlexGrid, Plan_9 As String, SubPlan_2 As String)
If rs.State = 1 Then rs.Close
rs.Open "Select * from 生产计划 where 计划单号='" & Mid(Plan_9, 1, 7) & "' and 批次号='" & Mid(Plan_9, 8, 2) & "' and 子批次号='" & SubPlan_2 & "' ", DBConn, adOpenKeyset, adLockOptimistic, adCmdText
Dim i
For i = 1 To Flex.Rows - 1
rs.Fields("计划单号").Value = Trim(Text1.Text)
rs.Fields("批次号").Value = Trim(Text2.Text)
rs.Fields("子批次号").Value = Trim(Text4.Text)
rs.Fields("完成数量").Value = Trim(Text3.Text)
rs.Fields("制定人").Value = ""
rs.Fields("制定时间").Value = Now()
rs.Fields("部门名称").Value = GetDepartByPlanID(Trim(Text1.Text) & Trim(Text2.Text))
rs.Fields("班组名称").Value = Flex.TextMatrix(i, 0)
rs.Fields("生产日期").Value = CDate(Flex.TextMatrix(i, 1))
rs.Fields("生产时间").Value = CDate(Flex.TextMatrix(i, 2))
rs.Fields("完成日期").Value = CDate(Flex.TextMatrix(i, 3))
rs.Fields("完成时间").Value = CDate(Flex.TextMatrix(i, 4))
rs.Update
Next i
MsgBox "修改完成", vbInformation, "提示"
End Sub
Public Sub LoadConfig(Flex As MSFlexGrid, Plan_9 As String, SubPlan_2 As String)
Dim i
For i = 1 To Flex.Rows - 1
SQL = "Select * from 生产计划 where 计划单号='" & Mid(Plan_9, 1, 7) & "' and 批次号='" & Mid(Plan_9, 8, 2) & "' and 子批次号='" & SubPlan_2 & "' and 班组名称='" & Flex.TextMatrix(i, 0) & "'"
If rs.State = 1 Then rs.Close
rs.Open SQL, DBConn, adOpenKeyset, adLockOptimistic, adCmdText
If Not rs.EOF Then
Flex.TextMatrix(i, 1) = Format(rs.Fields("生产日期").Value, "yyyy-mm-dd")
Flex.TextMatrix(i, 2) = Format(rs.Fields("生产时间").Value, "hh:mm")
Flex.TextMatrix(i, 3) = Format(rs.Fields("完成日期").Value, "yyyy-mm-dd")
Flex.TextMatrix(i, 4) = Format(rs.Fields("完成时间").Value, "hh:mm")
End If
Next i
End Sub
Private Sub DelPlan(Plan_9 As String, SubPlan_2 As String)
If rs.State = 1 Then rs.Close
rs.Open "delete from 生产计划 where 计划单号='" & Mid(Plan_9, 1, 7) & "' and 批次号='" & Mid(Plan_9, 8, 2) & "' and 子批次号='" & SubPlan_2 & "' ", DBConn, adOpenKeyset, adLockOptimistic, adCmdText
MsgBox "删除完成", vbInformation, "提示"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -