📄 mutilplanarrangements.frm
字号:
End Sub
Private Sub chs_Change()
' chs.CustomFormat = "yyyy-mm-dd hh:mm"
If Grid.Col > 5 Then Grid.TextMatrix(Grid.Row, Grid.Col) = chs.Text
End Sub
Private Sub CJHCJS_Click()
'
End Sub
Private Sub Command1_Click()
If BM.Text = "" Then
MsgBox "请先选择部门", vbInformation, "提示"
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "请先选择时制", vbInformation, "提示"
Exit Sub
End If
PlanAdd.opTypeIsSearch = True
PlanAdd.Show vbModal
If PlanAdd.TaskPlanID_9 <> "" Then
Grid.TextMatrix(Grid.Row, 0) = Mid(PlanAdd.TaskPlanID_9, 1, 7)
Grid.TextMatrix(Grid.Row, 1) = Mid(PlanAdd.TaskPlanID_9, 8, 2)
Grid.TextMatrix(Grid.Row, 2) = GetSubPlanID(Grid.TextMatrix(Grid.Row, 0) & Grid.TextMatrix(Grid.Row, 1))
Grid.TextMatrix(Grid.Row, 3) = GetCustomer(Grid.TextMatrix(Grid.Row, 0), Grid.TextMatrix(Grid.Row, 1))
Grid.TextMatrix(Grid.Row, 4) = GetGuiGe(Grid.TextMatrix(Grid.Row, 0), Grid.TextMatrix(Grid.Row, 1))
Grid.Rows = Grid.Rows + 1
End If
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Me.WindowState = 2
InitFlexGrid
chs.Text = CDate(Format(Now(), "yyyy-mm-dd") & " 07:30")
LoadTimeFA Combo1
DepartToCombo BM
ConvertFont Me
End Sub
Private Sub Form_Resize()
On Error Resume Next
Picture1.Top = 0
Picture1.Left = 0
Picture1.Width = Me.ScaleWidth
Toolbar1.Top = Picture1.Top + Picture1.Height
Toolbar1.Left = 0
Toolbar1.Width = Me.ScaleWidth
Grid.Top = Toolbar1.Top + Toolbar1.Height + 20
Grid.Left = 0
Grid.Width = Me.ScaleWidth
Grid.Height = Me.ScaleHeight - Grid.Top
Grid.BackColorBkg = &HEEFCFD
End Sub
Private Sub InitFlexGrid()
On Error Resume Next
'合并第一列
Grid.Rows = 3
Grid.Cols = 6
Grid.MergeCells = flexMergeRestrictRows
Grid.MergeRow(0) = True
Grid.TextMatrix(0, 0) = "计划信息"
Grid.TextMatrix(1, 0) = "计划单号"
Grid.TextMatrix(0, 1) = "计划信息"
Grid.TextMatrix(1, 1) = "批次号"
Grid.TextMatrix(0, 2) = "计划信息"
Grid.TextMatrix(1, 2) = "子批次号"
Grid.TextMatrix(0, 3) = "计划信息"
Grid.TextMatrix(1, 3) = "用户"
Grid.TextMatrix(0, 4) = "计划信息"
Grid.TextMatrix(1, 4) = "规格"
Grid.ColWidth(4) = 2000
Grid.TextMatrix(0, 5) = "计划信息"
Grid.TextMatrix(1, 5) = "生产数量"
Grid.ColAlignment(0) = flexAlignCenterCenter
Grid.ColAlignment(1) = flexAlignCenterCenter
Grid.ColAlignment(2) = flexAlignCenterCenter
Grid.ColAlignment(3) = flexAlignCenterCenter
Banzu_Str = ""
SQL = "SELECT * from 班组信息 where 部门名称='" & BM.Text & "'"
If rs.State = 1 Then rs.Close
rs.Open SQL, DBConn, adOpenKeyset, adLockOptimistic, adCmdText
If Not rs.EOF Then
Banzu_Num = rs.RecordCount
Grid.Cols = 6 + Banzu_Num * 2
Do While Not rs.EOF
Banzu_Str = Banzu_Str & rs.Fields("班组名称").Value & ","
rs.MoveNext
Loop
End If
Dim S As String
S = Banzu_Str
Debug.Print Banzu_Num
Debug.Print Banzu_Str
' On Error Resume Next
Dim i, j
For i = 1 To Banzu_Num
j = (1 + i) * 2 + 2
Grid.TextMatrix(0, j) = GetItem(S, ",", i - 1)
Grid.TextMatrix(1, j) = "开始时间"
Grid.TextMatrix(0, j + 1) = GetItem(S, ",", i - 1)
Grid.TextMatrix(1, j + 1) = "结束时间"
Grid.ColAlignment(j) = flexAlignCenterCenter
Grid.ColAlignment(j + 1) = flexAlignCenterCenter
Grid.ColWidth(j) = 2000
Grid.ColWidth(j + 1) = 2000
Next i
End Sub
Private Sub Grid_EnterCell()
Command1.Visible = False
txt.Visible = False
chs.Visible = False
Select Case Grid.Col
Case 0
Command1.Left = Grid.CellLeft + Grid.Left + Grid.CellWidth - Command1.Width
Command1.Top = Grid.CellTop + Grid.Top
Command1.Height = Grid.CellHeight
Command1.Width = Command1.Height
Command1.Visible = True
Case 1, 3, 4
Case 2, 5
If Grid.TextMatrix(Grid.Row, 0) = "" Then Exit Sub
txt.Text = Grid.TextMatrix(Grid.Row, Grid.Col)
txt.Left = Grid.CellLeft + Grid.Left
txt.Top = Grid.CellTop + Grid.Top
txt.Width = Grid.CellWidth
txt.Height = Grid.CellHeight
txt.Visible = True
Case Else
On Error Resume Next
If Grid.TextMatrix(Grid.Row, 0) = "" Then Exit Sub
chs.Text = IIf(Grid.TextMatrix(Grid.Row, Grid.Col) <> "", Grid.TextMatrix(Grid.Row, Grid.Col), chs.Text)
chs.Left = Grid.CellLeft + Grid.Left
chs.Top = Grid.CellTop + Grid.Top
chs.Width = Grid.CellWidth
chs.Height = Grid.CellHeight
chs.Visible = True
End Select
End Sub
Private Sub Grid_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then PopupMenu SYS
End Sub
Private Sub Grid_Scroll()
Command1.Visible = False
chs.Visible = False
End Sub
Private Sub sch_Click()
Grid.RemoveItem Grid.Row
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Caption
Case "计划预排"
SimulationDayMutilPlan Grid, Option1.Value
Case "保存修改"
If MsgBox("是否确定保存", vbInformation Or vbYesNo, "提示") = vbYes Then SaveDayMutilPlan Grid
Case "计划评估"
SimulationToLv
Case "计划添加"
PlanAdd.opTypeIsSearch = False
PlanAdd.Show vbModal
End Select
End Sub
Private Sub txt_Change()
Grid.TextMatrix(Grid.Row, Grid.Col) = txt.Text
End Sub
'===========================================================================================
Private Sub SimulationToLv()
'将当前配置的计划单信息导入预估的表
'On Error Resume Next
Capacity.ListView1.ListItems.Clear
Dim i
For i = 2 To Grid.Rows - 1
Capacity.ListView1.ListItems.Add i - 1, "S" & Rnd(), Grid.TextMatrix(i, 0)
Capacity.ListView1.ListItems(i - 1).SubItems(1) = Grid.TextMatrix(i, 1)
Capacity.ListView1.ListItems(i - 1).SubItems(2) = Grid.TextMatrix(i, 2)
Capacity.ListView1.ListItems(i - 1).SubItems(3) = GetMeterType(Grid.TextMatrix(i, 0) & Grid.TextMatrix(i, 1)) '表计类型
Capacity.ListView1.ListItems(i - 1).SubItems(4) = Grid.TextMatrix(i, 5)
Capacity.ListView1.ListItems(i - 1).SubItems(5) = Grid.TextMatrix(i, 3)
Capacity.ListView1.ListItems(i - 1).SubItems(6) = Grid.TextMatrix(i, 4)
Next i
Capacity.Show
End Sub
'===========================================================================================
Private Sub SimulationDayMutilPlan(Flex As MSFlexGrid, SameDay As Boolean)
'多个计划单的预安排
Dim S As String
S = Banzu_Str
On Error Resume Next
Dim BanZu As String
Dim i, j, k, L
For i = 2 To Flex.Rows - 2
Dim Plan_7, SubPlan_2, SubTask_2 As String
Dim FristTime As Date
Dim SL As Integer
Plan_7 = Flex.TextMatrix(i, 0) '计划单号
SubPlan_2 = Flex.TextMatrix(i, 1) '批次号
SubTask_2 = Flex.TextMatrix(i, 2) '子批次号
FristTime = CDate(Flex.TextMatrix(i, 6)) '首工序开始时间
SL = CDate(Flex.TextMatrix(i, 5)) '数量
IniFlex Grid2, Plan_7 & SubPlan_2
SimulationDayPlan Grid2, Combo1.Text, Plan_7 & SubPlan_2, CDate(Format(FristTime, "yyyy-mm-dd hh:mm")), SL
For k = 1 To Grid2.Rows - 1
BanZu = Grid2.TextMatrix(k, 0)
For j = 1 To Banzu_Num
If BanZu = GetItem(S, ",", j - 1) Then
Flex.TextMatrix(i, (1 + j) * 2 + 2) = Grid2.TextMatrix(k, 1) & " " & Grid2.TextMatrix(k, 2)
Flex.TextMatrix(i, (1 + j) * 2 + 3) = Grid2.TextMatrix(k, 3) & " " & Grid2.TextMatrix(k, 4)
Exit For
End If
Next j
Next k
If SameDay = True Then
If Flex.TextMatrix(i + 1, 0) <> "" Then Flex.TextMatrix(i + 1, 6) = Flex.TextMatrix(i, 6 + 1)
End If
Next
End Sub
Private Sub SaveDayMutilPlan(Flex As MSFlexGrid)
Dim i, j, k
For i = 2 To Flex.Rows - 1
For j = 1 To Banzu_Num
If Flex.TextMatrix(i, (1 + j) * 2 + 2) <> "" And Flex.TextMatrix(i, 0) <> "" Then
If rs.State = 1 Then rs.Close
rs.Open "生产计划", DBConn, adOpenKeyset, adLockOptimistic, adCmdTable
rs.AddNew
rs.Fields("部门名称").Value = GetDepart(Grid.TextMatrix(i, 0), Grid.TextMatrix(i, 1))
rs.Fields("班组名称").Value = Flex.TextMatrix(0, (1 + j) * 2 + 2)
rs.Fields("计划单号").Value = Grid.TextMatrix(i, 0)
rs.Fields("批次号").Value = Grid.TextMatrix(i, 1)
rs.Fields("子批次号").Value = Grid.TextMatrix(i, 2)
rs.Fields("生产日期").Value = CDate(Format(Flex.TextMatrix(i, (1 + j) * 2 + 2), "yyyy-mm-dd"))
rs.Fields("生产时间").Value = CDate(Format(Flex.TextMatrix(i, (1 + j) * 2 + 2), "hh:mm"))
rs.Fields("完成日期").Value = CDate(Format(Flex.TextMatrix(i, (1 + j) * 2 + 3), "yyyy-mm-dd"))
rs.Fields("完成时间").Value = CDate(Format(Flex.TextMatrix(i, (1 + j) * 2 + 3), "hh:mm"))
rs.Fields("完成数量").Value = Grid.TextMatrix(i, 5)
rs.Fields("制定人").Value = ""
rs.Fields("制定时间").Value = Now()
rs.Update
End If
Next j
Next i
MsgBox "保存完成", vbInformation, "提示"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -