Sorry I just pasted chunks of code. I am cramming to meet a deadline and barely had time to even post this.
Here is code to start production: (I posted as a quote so I could bold the lines that change the label)
[quote] 'check to see that we have a valid coil
if PCoilList.ListIndex = -1 or PCoilList.Cell(PCoilList.ListIndex,0) = “” Then
MsgBox “Please select a coil to use for production. You can’t make panels from thin air!”
Return
end if
'check if this is a valid production item
dim t as Integer = Ticks
PWarningUpdate “Starting Production…”
if POrderList.ListIndex > -1 and POrderList.RowTag(POrderList.ListIndex).StringValue <> “” and StartProduction(POrderList.RowTag(POrderList.ListIndex)) Then
dim PID as String = POrderList.RowTag(POrderList.ListIndex)
me.Caption = “Stop Production”
'findout which export method we are using
Select Case ExportType
Case "MRS"
SendToMachineMRS(PID)
Case "Beck"
Case "AMS"
End Select
dim rs as RecordSet = MainDb.SQLSelect("SELECT * FROM Production WHERE ID = '" + PID + "'")
if rs <> nil and rs.RecordCount > 0 Then
'reload the order to show changes to the status
if EditOrderID = rs.Field("OrderID").StringValue Then LoadOrder(rs.Field("OrderID").StringValue,"-1")
'update the status of the order and let everyone know an order has changed
OrderStatusUpdate rs.Field("OrderID").StringValue
'update the ProductionPriority list
SendInfoList.Append "Update:Production" +rs.Field("ProductionType").StringValue
'write to log
SQLps = MainDb.Prepare("INSERT INTO ProductionLog(User,Action,OrderID,ProductionID,LineIDs,TimeStamp) VALUES(?,?,?,?,?,?)")
SQLps.BindAll 2
SQLps.BindType(2,SQLitePreparedStatement.SQLITE_INTEGER)
SQLps.BindType(3,SQLitePreparedStatement.SQLITE_INTEGER)
SQLps.BindType(4,SQLitePreparedStatement.SQLITE_TEXT)
SQLps.BindType(5,SQLitePreparedStatement.SQLITE_TEXT)
dim d as new Date
SQLps.SQLExecute(system.EnvironmentVariable("COMPUTERNAME"),"StartProduction",rs.Field("OrderID").IntegerValue,PID.CLong,"",d.SQLDateTime)
MainDb.ErrCheck "PProductionBtn Action 4"
end if
#if DebugBuild Then dl.Text = cstr((Ticks-t)/60) + " seconds to start production."
end if
[b]PWarningUpdate[/b][/quote]
Here is code that stops production:
[quote] Dim dialog As New MessageDialog
dialog.Message = “Are you sure you want to cancel this production? This will mark all panels in this order as not produced. If any panels have already been produced they could be produced again.”
dialog.ActionButton.Caption = “Stop Production”
dialog.CancelButton.Visible = True
dialog.CancelButton.Caption = “Cancel”
dialog.CancelButton.Default = true
Dim dialogButton As MessageDialogButton
dialogButton = dialog.ShowModalWithin(Self)
dim t as Integer = Ticks
PWarningUpdate “Stopping Production…”
if dialogButton = dialog.ActionButton and POrderList.ListIndex > -1 and POrderList.RowTag(POrderList.ListIndex).StringValue <> "" Then
dim PID as String = POrderList.RowTag(POrderList.ListIndex)
if CheckProduction.Ubound > -1 Then CheckProduction.Remove(0)
MainDb.SQLExecute("UPDATE Production SET Status = '1' WHERE ID = '" + PID + "'")
MainDb.ErrCheck "PProductionBtn Action 1"
MainDb.SQLExecute("DELETE FROM ProductionProgress WHERE ProductionID = '" + PID + "'")
MainDb.ErrCheck "PProductionBtn Action 2"
MainDb.SQLExecute("UPDATE OrderLines SET Status = '1' WHERE ProductionID = '" + PID + "'")
MainDb.ErrCheck "PProductionBtn Action 3"
dim rs as RecordSet = MainDb.SQLSelect("SELECT * FROM Production WHERE ID = '" + PID + "'")
if rs <> nil and rs.RecordCount > 0 Then
'reload the order to show changes to the status
if EditOrderID = rs.Field("OrderID").StringValue Then LoadOrder(rs.Field("OrderID").StringValue,"-1")
'update the status of the order and let everyone know an order has changed
OrderStatusUpdate rs.Field("OrderID").StringValue
'update the ProductionPriority list
SendInfoList.Append "Update:Production" +rs.Field("ProductionType").StringValue
'write to log
SQLps = MainDb.Prepare("INSERT INTO ProductionLog(User,Action,OrderID,ProductionID,LineIDs,TimeStamp) VALUES(?,?,?,?,?,?)")
SQLps.BindAll 2
SQLps.BindType(2,SQLitePreparedStatement.SQLITE_INTEGER)
SQLps.BindType(3,SQLitePreparedStatement.SQLITE_INTEGER)
SQLps.BindType(4,SQLitePreparedStatement.SQLITE_TEXT)
SQLps.BindType(5,SQLitePreparedStatement.SQLITE_TEXT)
dim d as new Date
SQLps.SQLExecute(system.EnvironmentVariable("COMPUTERNAME"),"StopProduction",rs.Field("OrderID").IntegerValue,PID.CLong,"",d.SQLDateTime)
MainDb.ErrCheck "PProductionBtn Action 4"
end if
me.Caption = "Start Production"
#if DebugBuild Then dl.Text = cstr((Ticks-t)/60) + " seconds to stop production."
end if
[b]PWarningUpdate[/b][/quote]
Here is a the label update model I added to try to better trace what all was changing the label: (I tried about everything in the way of refreshing)
PWarningUpdate(T as String = "")
if t = "" Then
PWarning.Text = ""
PWarning.Visible = False
PWarning.Refresh
else
PWarning.text = t
PWarning.Visible = True
PRect.Invalidate
PWarning.Refresh
end if
End Sub