Sub MToMMoveS_DragDetected(e As MouseEvent)
HideMoreJobData
If MasterTA.IsInitialized = False Then Return
Dim M As Map = MasterTA.Tag
Dim ToastTxt As String = ""
'11/16/24 - critical parts
If Main.CriticalPartMap.ContainsKey(M.Get("Os_ID").As(Int)) Then '11/16/24 - critical parts
Main.CurrentCPFlag = True
Main.CurrentCPMachinesMap = Main.CriticalPartMap.Get(M.Get("Os_ID").As(Int))
If Main.CurrentCPMachinesMap.Size = 0 Then
ToastTxt = $"[textsize=30][color=red]This job requires approved machines${CRLF}but you have no machines qualified to do this OP![/color][/textsize]"$
Else
Dim ML As String
For Each Mac As String In Main.CurrentCPMachinesMap.Values
ML = $"${ML}, ${Mac}"$
Next
ML = ML.SubString(2)
ToastTxt = $"[textsize=30][color=0xFF0300FF]This job can use the following approved machines:${CRLF}${ML}[/color][/textsize]"$
End If
Else
Main.CurrentCPFlag = False
End If
'11/16/24 - critical parts
If ToastTxt.Length > 0 Then
Toast.VerticalCenterPercentage = 5
Toast.DurationMs = 5000
Toast.Show(ToastTxt, Null)
Toast.DurationMs = 3000
End If
MoveMachine2.SetDragModeAndData2(TransferMode.ANY, Array As String("MoveJob", "MToMMove" & WCName, "Os_WCCode", "Os_ID", "SchO_ID", "SchO_Order", "Height", "Width", "Text"), Array As Object(WCName, "", M.Get("Os_WCCode"), M.Get("Os_ID"), M.Get("SchO_ID"), M.Get("SchO_Order"), MasterTA.Height, MasterTA.Width, ""), MasterTA.Snapshot)
Sleep(1)
End Sub
Sub MToMMoveT_DragEntered(e As DragEvent)
Dim L As Node = e.GetEventTarget, StyleTxt As String
If L Is TextArea Then StyleTxt = ";-fx-control-inner-background: " Else StyleTxt = "-fx-background-color: "
Dim Db As Dragboard = e.GetDragboard
Dim TF As Boolean = False
If Db.HasContent("MToMMove" & WCName) Then
TF = (e.GetGestureSource <> e.GetEventTarget) 'We are over ourself so we can't move in front of ourself so go RED below
End If
DADSaveStyle = L.Style
Dim ThisMachMap As Map = L.Tag.as(Map).Get("ListView").As(ListView).Parent.As(Pane).GetNode(2).Tag '11/16/24 - critical parts - moved this
If Main.CurrentCPFlag Then '11/16/24 - critical parts
If Not(Main.CurrentCPMachinesMap.ContainsKey(ThisMachMap.get("SchM_ID"))) Then
L.Style = StyleTxt & "red;"
Return
End If
End If
If Main.UsingWCsBool Then
If Db.HasContent("AddNewOP") Then
If WCName.EqualsIgnoreCase(Db.GetContent("Os_WCCode")) Then
L.Style = StyleTxt & "green;" '#adff2f;"
Else
L.Style = StyleTxt & "yellow;"
End If
Else if (Db.HasContent("MoveJob")) And TF Then
L.Style = StyleTxt & "green;"
Else If (Db.HasContent("MoveJob")) And Not(Db.HasContent("MToMMove" & WCName)) Then
L.Style = StyleTxt & "yellow;"
Else
L.Style = StyleTxt & "red;"
End If
Else
If (Db.HasContent("MoveJob")) And Not(TF) Then
L.Style = StyleTxt & "red;"
Else If ThisMachMap.Get("SchM_WCCode").As(String).EqualsIgnoreCase(Db.GetContent("Os_WCCode")) Then
L.Style = StyleTxt & "green;"
Else If (Db.HasContent("MoveJob")) And Not(Db.HasContent("MToMMove" & WCName)) Then
L.Style = StyleTxt & "yellow;"
Else
L.Style = StyleTxt & "yellow;"
End If
End If
End Sub
Sub MToMMoveT_DragDone(e As DragEvent)
' Log("DragDone : transfer mode " & e.GetTransferMode & " completed") ' null if not successfull
RightScrollPane.PrefWidth = 8dip
End Sub
Sub MToMMoveT_DragOver(e As DragEvent)
Dim Db As Dragboard = e.GetDragboard
Dim TF As Boolean = False
If Db.HasContent("MToMMove" & WCName) Then
TF = ((e.GetGestureSource <> e.GetEventSource))
End If
If ((e.GetDragboard.HasContent("MToMMove" & WCName) And TF) Or Db.HasContent("AddNewOP") Or Db.HasContent("MoveJob")) Then
e.AcceptTransferModes(TransferMode.MOVE)
End If
End Sub
Sub MToMMoveT_DragExited(e As DragEvent)
Dim L As Node = e.GetEventSource
L.Style = DADSaveStyle ' ";-fx-control-inner-background: rgba(95,158,160,.2);"
L.RequestFocus 'KEEPS FROM JUMPING TO TOP!!
End Sub
Sub MToMMoveT_DragDropped(e As DragEvent)
Dim SchedSaved As Boolean = False 'Flag to indicate we HAVE saved the change in case of an error
Dim DroppingWC As String
Dim L As Node = e.GetGestureTarget
Try
If e.GetDragboard.HasContent("MoveMachine") Then Return
If e.GetDragboard.HasContent("MToMMove" & WCName) Then
If (e.GetGestureSource = e.GetGestureTarget) Then Return 'We are on top of ourself
End If
Dim ThisMachMap As Map = L.Tag.as(Map).Get("ListView").As(ListView).Parent.As(Pane).GetNode(2).Tag '11/16/24 - critical parts this line moved here
If Main.CurrentCPFlag Then '11/16/24 - critical parts
If Not(Main.CurrentCPMachinesMap.ContainsKey(ThisMachMap.get("SchM_ID"))) Then
Return
End If
End If
Dim Crsr As JdbcResultSet
Dim TATarget As Pane
TATarget = e.GetGestureTarget
Dim TargetMap As Map = TATarget.Tag, WCCode As String, Order As Int, TargetMachMap As Map
'If it is a gap Item then we want to use the NEXT REAL Items Data
Dim LV As ListView = TargetMap.Get("ListView")
Dim P As Pane
If TargetMap.ContainsKey("GapItem") Then
P = LV.Items.Get(LV.Items.IndexOf(TATarget) + 1)
TargetMap = P.Tag 'in this case these two are the same
TargetMachMap = P.Tag
Else
TargetMachMap = LV.Tag
End If
If 0 = TargetMap.GetDefault("Os_ID", 0) Then 'we are dropping on machine, not another job so it goes at the end GetDefault Os_ID is not IN this MAP
Order = 0
Else
Order = TargetMap.Get("SchO_Order")
End If
WCCode = e.GetDragboard.GetContent("Os_WCCode")
If Main.UsingWCsBool Then
DroppingWC = WCName
Else
DroppingWC = ThisMachMap.Get("SchM_WCCode")
End If
'Warn if different WC
If DroppingWC.ToLowerCase.CompareTo(WCCode.tolowercase) <> 0 Then
If Not(DADMod.NoDifWCWarning) Then
Dim DSA As DSADlgMod
DSA.Initialize(MachinesFrm, WCCode, DroppingWC, "", "")
DADMod.NoDifWCWarning = DSA.DontShowAgain
If Not(DSA.DSADlgYes) Then Return
End If
End If
If e.GetDragboard.HasContent("MoveJob") Then
Dim TATarget As Pane, LVTarget As ListView, TASource As Pane, LVSource As ListView ', T3 As TextArea
TATarget = e.GetGestureTarget
Dim MapSource As Map
If e.GetDragboard.HasContent("MToMMove" & DroppingWC) Then 'same WC
TASource = e.GetGestureSource
MapSource = TASource.Tag
Else
Dim Db As Dragboard = e.GetDragboard
Dim MFM As MachinesFrmMod = Main.MachineFrmModList.get(Db.GetContent("MoveJob"))
TASource = MFM.FindOp(Db.GetContent("SchO_ID"), False)
MapSource = TASource.Tag
End If
#If Debug
Dim MapSourceMachHOLD As Int = MapSource.Get("SchO_SchMTID") 'For Testing
#End If
'This next line fixes a problem if you try to move things too quickly'
'It moves the last TARGET or the previous SOURCE not the selected item so make sure the dragbord and Map soure are the same
'If they are not then exit
If e.GetDragboard.GetContent("SchO_ID") <> MapSource.Get("SchO_ID") Then Return
'We are dropping on the on NEXT ON THE SAME MACHINE one which would simply put us right back where we are
If Order = (MapSource.Get("SchO_Order") + 1) And (TargetMap.Get("SchM_ID").As(String).EqualsIgnoreCase(MapSource.Get("SchO_SchMTID"))) Then Return
' MOVING TO MACHINE NEW ORDER
'We pass the [ScheduleOp] @SchO_SchMTID, @InsertOs_ID,@SchO_Order, @RemoveSchO_ID , @MoveSchO_ID
Dim SQLStr As String = $"ScheduleOp ${TargetMap.Get("SchM_ID")}, 0, ${Order}, 0, ${e.GetDragboard.GetContent("SchO_ID")};"$
#If Debug
Log($"ScheduleOp 0, SchO_OSId, SchO_Order, SchO_ID"$)
#End If
Dim SenderFilter As Object = Main.SKSQL.ExecQueryAsync ("MoveOp", SQLStr, Null) '1/30/19 - Added SW57
Wait For (SenderFilter) MoveOp_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
If Crsr.NextRow Then
If Crsr.GetString("RESULT").As(String).Contains("SUCCESS") Then
SchedSaved = True
LVTarget = TargetMap.Get("ListView")
LVSource = MapSource.Get("ListView")
MapSource.Put("SchO_Order", IIf(Order > 0, Order, LVTarget.Items.Size) + 1) 'Note that we haven't set the item yet so it is plus 1
MapSource.Put("SchO_SchMTID", TargetMap.Get("SchM_ID"))
MapSource.Put("SchM_Machine", Crsr.GetString("SchM_Machine"))
MapSource.Put("SchM_HrsPerWk", Crsr.GetString("SchM_HrsPerWk"))
MapSource.Put("SchM_ID", TargetMap.Get("SchM_ID"))
LVTarget = TargetMap.Get("ListView")
LVSource = MapSource.Get("ListView")
MapSource.Remove("ListView") 'remove and re-add - might be a different machine
MapSource.Put("ListView", LVTarget)
Dim ND As Node
If Order = 0 Then 'at the end so no need to reorder
ND = FormatOpData(TASource.Tag)
LVTarget.Items.Add(ND)
Else
ND = FormatOpData(TASource.Tag)
LVTarget.Items.InsertAt(LVTarget.Items.IndexOf(TATarget), ND)
ReOrderList(LVTarget)
Order = LVTarget.Items.IndexOf(TATarget)
End If
Dim HP As Double = MachinesSP.VPosition
LVSource.Items.RemoveAt(LVSource.Items.IndexOf(TASource))
ReOrderList(LVSource)
Sleep(1)
'7/10/24 - made MovePicture return boolean so we know if ther is a node 1
If MovePicture(TASource, ND.As(Pane)) Then ND.As(Pane).GetNode(1).Alpha = TextAlpha
' Canv.Alpha = PicAlpha
' PPane.GetNode(1).Alpha = TextAlpha
Sleep(1)
' If SchedInfoRB.Selected Then ShowGaps Else ShowGapsAboveLV
Wait For (DADMod.TestAndShowGaps(SchedInfoRB.Selected, ShowGapsStatusAbove, MapSource.Get("ListView").As(ListView).Parent.as(Pane).GetNode(2).Tag, MapSource, Me)) Complete (CCC As Boolean)
ResizeLists(MachinesFrm.Width)
MachinesSP.VPosition = HP
LoadGraphs($"'${LVSource.Id}'${IIf(LVSource.Id.EqualsIgnoreCase(LVTarget.Id), "", $", '${LVTarget.Id}'"$)}"$)
#Region Debug1
' #If Debug
' 'For TESTING
' Log("Drop Completed")
' Dim SQLStr As String = $"SELECT SchO_ID, SchO_OSId, SchO_SchMTID, SchO_Order FROM ScheduledOps WHERE SchO_SchMTID = ${TargetMap.Get("SchM_ID")} ORDER BY SchO_Order;"$
' Dim SenderFilter As Object = Main.SKSQL.ExecQueryAsync ("MoveOp", SQLStr, Null) '1/30/19 - Added SW57
' Wait For (SenderFilter) MoveOp_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
' If Success Then
' Dim ZZX As Int = 0, MMM As Map
' Do While Crsr.NextRow
' MMM = LVTarget.Items.Get(ZZX).As(Pane).Tag
' If Not(MMM.ContainsKey("GapItem")) Then
' ' Log($"${ZZX +1} - ${Crsr.GetInt("SchO_Order")}"$)
' ' Log($"${MMM.Get("SchO_ID")} - ${Crsr.GetInt("SchO_ID")}"$)
' If (MapSourceMachHOLD = TargetMap.Get("SchM_ID")) And LVTarget.Items.Size = (ZZX +1) Then Exit
' If ((ZZX +1) <> Crsr.GetInt("SchO_Order")) Or (Crsr.GetInt("SchO_ID") <> MMM.Get("SchO_ID")) Then 'ignore
' xui.MsgboxAsync($"${ZZX +1} - ${Crsr.GetInt("SchO_Order")}${CRLF}${MMM.Get("SchO_ID")} - ${Crsr.GetInt("SchO_ID")}"$, "")
' End If
' ZZX = ZZX + 1
' End If
' Loop
' End If
' If MapSourceMachHOLD <> TargetMap.Get("SchM_ID") Then 'we only check this if it is different machines
' Dim SQLStr As String = $"SELECT SchO_ID, SchO_OSId, SchO_SchMTID, SchO_Order FROM ScheduledOps WHERE SchO_SchMTID = ${MapSourceMachHOLD} ORDER BY SchO_Order;"$
' Dim SenderFilter As Object = Main.SKSQL.ExecQueryAsync ("MoveOp", SQLStr, Null) '1/30/19 - Added SW57
' Wait For (SenderFilter) MoveOp_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
' If Success Then
' Dim ZZX As Int = - 1, MMM As Map
' Do While Crsr.NextRow
' ZZX = ZZX + 1
' MMM = LVSource.Items.Get(ZZX).As(Pane).Tag
'' Log($"${ZZX +1} - ${Crsr.GetInt("SchO_Order")}"$)
'' Log($"${MMM.Get("SchO_ID")} - ${Crsr.GetInt("SchO_ID")}"$)
' If ((ZZX +1) <> Crsr.GetInt("SchO_Order")) Or (Crsr.GetInt("SchO_ID") <> MMM.Get("SchO_ID")) Then 'ignore
' xui.MsgboxAsync($"${ZZX +1} - ${Crsr.GetInt("SchO_Order")}${CRLF}${MMM.Get("SchO_ID")} - ${Crsr.GetInt("SchO_ID")}"$, "")
' End If
' Loop
' End If
' End If
' #End if
#End Region
Else
xui.MsgboxAsync("SQL Error: " & CRLF & Crsr.GetString("RESULT"), "Error in MToMMoveT_DragDropped (MoveJob)")
End If
Else
xui.MsgboxAsync("Query executed but did not return Rowcount. Failed To perform move", "Error in MToMMoveT_DragDropped (MoveJob)")
End If
Else
xui.MsgboxAsync("Query Failed to execute. Failed To perform move", "Error in MToMMoveT_DragDropped (MoveJob)")
End If
e.SetDropCompleted(True)
Else If e.GetDragboard.HasContent("AddNewOP") Then
#If Debug
Log("InsertAddNewOP")
#End If
Dim Db As Dragboard = e.GetDragboard
' Dim T As Pane, LV As ListView, M As Map
' T = e.GetGestureTarget
' M = T.Tag
'We pass the [ScheduleOp] @SchO_SchMTID, @InsertOs_ID, @SchO_Order, @RemoveSchO_ID , @MoveSchO_ID
Dim SQLStr As String = "ScheduleOp " & TargetMap.Get("SchM_ID") & ", " & Db.GetContent("Os_ID") & ", " & Order
Dim SenderFilter As Object = Main.SKSQL.ExecQueryAsync ("InsertOp", SQLStr, Null) '1/30/19 - Added SW57
Wait For (SenderFilter) InsertOp_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
If Crsr.NextRow Then
If Crsr.GetString("RESULT").EqualsIgnoreCase("SUCCESS") Then
'Remove this code after a
Try
SQLStr = Crsr.GetString("Pmp_PictureName")
Catch
xui.MsgboxAsync("Pmp_PictureName is missing! Contact Insite Software. Run ScheduleOp.sql.", "Server update required")
Wait For Msgbox_Result (Result As Int)
End Try
SchedSaved = True
LV = TargetMap.Get("ListView")
Dim MAdd As Map
DADMod.FillJobMap(Crsr, MAdd, False)
MAdd.Put("ListView", LV)
Dim ND As Node = FormatOpData(MAdd)
If Order = 0 Then
LV.Items.Add(ND)
Else
LV.Items.InsertAt(Order - 1, ND)
ReOrderList(LV)
End If
' If SchedInfoRB.Selected Then ShowGaps Else ShowGapsAboveLV
DADMod.TestAndShowGaps(SchedInfoRB.Selected, ShowGapsStatusAbove, MAdd.Get("ListView").As(ListView).Parent.as(Pane).GetNode(2).Tag, MAdd, Me)
ResizeLists(-1)
e.SetDropCompleted(True)
If .1 < PicAlpha Then
Sleep(10)
Add1Picture(ND)
End If
'If we are draging from JOBopslist rather UnscheduledOPsList we MIGHT not have an ID because we might be on a different list
If Main.ActiveMap.Get("RowId") > -500 Then
Main.UnSchedOpsList.DeleteRow(Main.ActiveMap.Get("RowId"))
End If
'If our opslist is , in fact the job we are scheduling then we need to change the color of the item in Main.JobOpsList
If Main.JobNumLbl.text.EqualsIgnoreCase(MAdd.get("Os_JobNum")) And Main.RelNumLbl.text.EqualsIgnoreCase(MAdd.get("Os_ReleaseNum")) Then
Dim XXX As Int, JOLM As Map
For XXX = 0 To Main.JobOpsList.Size - 1
JOLM = Main.JobOpsList.GetValue(XXX).As(Pane).Tag
If JOLM.Get("Os_ID").As(Int) = MAdd.Get("Os_ID").As(Int) Then
'JOLM.Get("BBLbl").As(BBCodeView).sv.ScrollViewInnerPanel.Color = xui.Color_RGB(255, 255, 167)
JOLM.Put("Scheduled", True)
JOLM.Put("SchM_WCCode", DroppingWC)
JOLM.Put("SchO_ID", Crsr.GetInt("SchO_ID"))
If JOLM.Get("Os_WCCode") <> TargetMachMap.Get("SchM_WCCode") Then 'Red - Scheduled ON THE WRONG WORKCENTER!!
JOLM.Get("BBLbl").As(BBCodeView).sv.ScrollViewInnerPanel.Color = xui.Color_RGB(255, 255, 0) 'Dark Yellow
Else
JOLM.Get("BBLbl").As(BBCodeView).sv.ScrollViewInnerPanel.Color = xui.Color_RGB(255, 255, 167) 'Yellow - Scheduled
End If
Exit
End If
Next
End If
LoadGraphs($"'${MAdd.Get("SchM_Machine")}'"$)
#Region Debug2
' #If Debug
' 'For TESTING
' Dim LVTarget As ListView = M.Get("ListView")
' Dim SQLStr As String = $"SELECT SchO_ID, SchO_OSId, SchO_SchMTID, SchO_Order FROM ScheduledOps WHERE SchO_SchMTID = ${TargetMap.Get("SchM_ID")} ORDER BY SchO_Order;"$
' Dim SenderFilter As Object = Main.SKSQL.ExecQueryAsync ("MoveOp", SQLStr, Null) '1/30/19 - Added SW57
' Wait For (SenderFilter) MoveOp_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
' If Success Then
' Dim ZZX As Int = - 1, MMM As Map
' Do While Crsr.NextRow
' ZZX = ZZX + 1
' MMM = LVTarget.Items.Get(ZZX).As(Pane).Tag
' Log($"${ZZX +1} - ${Crsr.GetInt("SchO_Order")}"$)
' Log($"${MMM.Get("SchO_ID")} - ${Crsr.GetInt("SchO_ID")}"$)
' If ((ZZX +1) <> Crsr.GetInt("SchO_Order")) Or (Crsr.GetInt("SchO_ID") <> MMM.Get("SchO_ID")) Then 'ignore
' xui.MsgboxAsync($"${Crsr.GetInt("SchO_SchMTID")} / ${ZZX +1} - ${Crsr.GetInt("SchO_Order")}${CRLF}${MMM.Get("SchO_ID")} - ${Crsr.GetInt("SchO_ID")}"$, "")
' End If
' Loop
' End If
' #End If
#End Region
Else
xui.MsgboxAsync(Crsr.GetString("RESULT"), "Error in MToMMoveT_DragDropped")
End If
Else
xui.MsgboxAsync("Query executed but did not return Rowcount. Failed To Add Record", "Error in MToMMoveT_DragDropped")
End If
Else
xui.MsgboxAsync("Query Failed to execute. Failed To Add Record", "Error in MToMMoveT_DragDropped")
End If
End If
If Crsr.IsInitialized Then Crsr.Close
'WaitForLastDrag = False
Catch
If Crsr.IsInitialized Then Crsr.Close
If SchedSaved = True Then
Main.MainLTT.Text = $"An error occurred while formatting your date but the changes were made. Refreshing data.${CRLF & LastException.Message.SubString2(0, Min(LastException.Message.Length, 500))}"$
MachErrDlg.Title = "Error in MToMMoveT_DragDropped"
Wait For (MachErrDlg.ShowTemplate(Main.MainLTT, "OK", "", "")) Complete (Result As Int)
Dim MOE As MouseEvent
RefreshDataBtn_MouseClicked(MOE)
Else
Main.MainLTT.Text = LastException.Message
MachErrDlg.Title = "Error in MToMMoveT_DragDropped"
Wait For (MachErrDlg.ShowTemplate(Main.MainLTT, "OK", "", "")) Complete (Result As Int)
End If
End Try
End Sub
Sub ReOrderList(LV As ListView)
Dim X As Int, T As Pane, M As Map, Y As Int
Y = 1
For X = 0 To LV.Items.Size - 1
T = LV.Items.Get(X)
M = T.Tag
If M.ContainsKey("GapItem") Then
'DON'T INCREMENT!!!
M.Put("GapItem", Y)
Else
M.Put("SchO_Order", Y)
Y= Y + 1
End If
Next
End Sub