@cpelowski, sorry for the delay, been slammed here. There is a lot of code here and much of it was written when i was much greener, so there’s much that could be improved, but it works and who has the time? Anyhow this should give you an idea of one way you can dynamically change the way the End Activity form can look based on the TYPE of activity it is closing (Production, Setup, Indirent, Maitenance, etc, etc) the out of the box solution is a disaster in my opinion, but business needs vary much so who knows. Any questions just ping me. Also, and i can’t recall at the moment, i probably am using Service Connect called work flows from BPM’s for some things as well. You’ll have to dig through it and look (#thepriceoffreecode)
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.UI;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using System.Reflection;
using Erp.BO;
using Erp.Adapters;
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
private EpiDataView edvEnd;
private Ice.Proxy.Lib.BOReaderImpl _bor;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.edvEnd = ((EpiDataView)(this.oTrans.EpiDataViews["End"]));
this.edvEnd.EpiViewNotification += new EpiViewNotification(this.edvEnd_EpiViewNotification);
_bor = WCFServiceSupport.CreateImpl<Ice.Proxy.Lib.BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.btnOK_c.Click += new System.EventHandler(this.btnOK_c_Click);
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.edvEnd.EpiViewNotification -= new EpiViewNotification(this.edvEnd_EpiViewNotification);
this.edvEnd = null;
this.btnOK_c.Click -= new System.EventHandler(this.btnOK_c_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void EndActForm_Load(object sender, EventArgs args)
{
EpiNumericEditor nbrCurrent = default(EpiNumericEditor);
nbrCurrent = (EpiNumericEditor)csm.GetNativeControlReference("f1fdcf24-066d-424e-9b59-319a804854fa");
nbrCurrent.Select();
}
private void edvEnd_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row]["FieldName"]
// args.Row, args.Column, args.Sender, args.NotifyType
// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
EpiNumericEditor nbrSetupComplete = default(EpiNumericEditor);
nbrSetupComplete = (EpiNumericEditor)csm.GetNativeControlReference("31799c26-7331-45b0-a723-9cc464175117");
EpiNumericEditor nbrCurrent = default(EpiNumericEditor);
nbrCurrent = (EpiNumericEditor)csm.GetNativeControlReference("f1fdcf24-066d-424e-9b59-319a804854fa");
EpiLabel lblQty = default(EpiLabel);
lblQty = (EpiLabel)csm.GetNativeControlReference("53d41874-cf29-4443-bb36-11e815fd39b8");
EpiLabel lblComplete = default(EpiLabel);
lblComplete = (EpiLabel)csm.GetNativeControlReference("55820b74-2163-40f4-a07b-1923db92789d");
EpiCheckBox chkComplete = default(EpiCheckBox);
chkComplete = (EpiCheckBox)csm.GetNativeControlReference("6456654a-e39c-486b-bfdb-7a4cc16fe4ec");
EpiLabel lblRequest = default(EpiLabel);
lblRequest = (EpiLabel)csm.GetNativeControlReference("01afa84f-db71-4d05-8b42-a5bf71364846");
EpiCheckBox chkRequest = default(EpiCheckBox);
chkRequest = (EpiCheckBox)csm.GetNativeControlReference("4626a6f0-1447-4643-80ba-fe4a07b36d45");
EpiLabel lblSetupComplete = default(EpiLabel);
lblSetupComplete = (EpiLabel)csm.GetNativeControlReference("36ce8184-b5ef-49de-a726-203cb1f4e6ca");
EpiButton btnTag = default(EpiButton);
btnTag = (EpiButton)csm.GetNativeControlReference("3ef505d1-a726-441b-9587-ccae4bf27426");
EpiButton btnOK = default(EpiButton);
btnOK = (EpiButton)csm.GetNativeControlReference("025fc115-fee3-4973-946e-ba209189d62e");
EpiButton btnInspData = default(EpiButton);
btnInspData = (EpiButton)csm.GetNativeControlReference("f1f42268-64b7-46e8-914e-0f29042aed45");
BAQCombo bcomboTopic = default(BAQCombo);
bcomboTopic = (BAQCombo)csm.GetNativeControlReference("c255dcbd-6bc4-411f-87cd-693b073e6cef");
if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
{
if ((args.Row > -1))
{
if ((Convert.ToString(edvEnd.dataView[args.Row]["LaborType"]) == "I"))
{
chkRequest.Visible = false;
chkRequest.Enabled = false;
lblQty.Width = 0;
nbrCurrent.Width = 0;
lblSetupComplete.Width = 0;
nbrSetupComplete.Width = 0;
chkComplete.Visible = false;
chkComplete.Enabled = false;
lblComplete.Width = 0;
chkComplete.Width = 0;
txtLaborNotes.Visible = true;
txtLaborNotes.Enabled = true;
txtLaborNotes.TabIndex = 1;
txtLaborNotes.Focus();
lblLaborNotes.Enabled = true;
lblLaborNotes.Visible = true;
lblLaborNotes.Text = "Indirect Code:";
lblLaborNotes.Left = 90;
lblLaborNotes.Top = 44;
edvEnd.dataView[edvEnd.Row]["ShortChar02"] = txtLaborNotes.Value;
txtLaborNotes.Left = 196;
txtLaborNotes.Top = 44;
btnInspData.Visible = false;
btnTag.EpiBinding = "";
btnTag.Enabled = false;
btnTag.Visible = false;
chkJobClose.Visible = false;
chkJobClose.Enabled = false;
lblJobClose.Visible = false;
lblJobClose.Enabled = false;
bcomboTopic.Visible = false;
bcomboTopic.Enabled = false;
lblTopic.Visible = false;
lblTopic.Enabled = false;
if (txtLaborNotes.Value == null)
{
edvEnd.dataView[edvEnd.Row]["ShortChar02"] = "";
intMeter.Visible = false;
intMeter.Enabled = false;
lblMeter.Visible = false;
lblMeter.Enabled = false;
}
}
else if ((Convert.ToString(edvEnd.dataView[args.Row]["LaborType"]) == "S") & (Convert.ToString(edvEnd.dataView[args.Row]["JobType"]) == "Manufacture"))
{
//msgbox (edvend.dataview(args.row)("labortype"))
nbrCurrent.Width = 0;
nbrSetupComplete.Focus();
nbrSetupComplete.TabIndex = 1;
nbrCurrent.TabIndex = 900;
lblQty.Visible = false;
nbrCurrent.Enabled = false;
nbrCurrent.Visible = false;
lblComplete.Visible = false;
chkComplete.Visible = false;
lblRequest.Visible = false;
chkRequest.Visible = false;
btnTag.EpiBinding = "";
btnTag.Enabled = false;
btnTag.Visible = false;
txtLaborNotes.Visible = false;
txtLaborNotes.Enabled = false;
lblLaborNotes.Enabled = false;
lblLaborNotes.Visible = false;
chkJobClose.Visible = false;
chkJobClose.Enabled = false;
lblJobClose.Visible = false;
lblJobClose.Enabled = false;
bcomboTopic.Visible = false;
bcomboTopic.Enabled = false;
lblTopic.Visible = false;
lblTopic.Enabled = false;
intMeter.Visible = false;
intMeter.Enabled = false;
lblMeter.Visible = false;
lblMeter.Enabled = false;
}
else if ((Convert.ToString(edvEnd.dataView[args.Row]["LaborType"]) == "P") & (Convert.ToString(edvEnd.dataView[args.Row]["JobType"]) != "Maintenance"))
{
//msgbox (edvend.dataview(args.row)("labortype"))
nbrCurrent.Focus();
btnTag.Refresh();
lblSetupComplete.Width = 0;
lblSetupComplete.Enabled = false;
lblSetupComplete.Visible = false;
nbrSetupComplete.Visible = false;
nbrSetupComplete.Width = 0;
txtLaborNotes.Visible = false;
txtLaborNotes.Enabled = false;
lblLaborNotes.Visible = false;
lblLaborNotes.Enabled = false;
btnTag.Visible = true;
btnTag.Enabled = true;
btnTag.TabIndex = 2;
btnOK.Height = 0;
btnOK.Width = 0;
//btnOK.Visible = false;
chkJobClose.Visible = false;
chkJobClose.Enabled = false;
lblJobClose.Visible = false;
lblJobClose.Enabled = false;
bcomboTopic.Visible = false;
bcomboTopic.Enabled = false;
lblTopic.Visible = false;
lblTopic.Enabled = false;
intMeter.Visible = false;
intMeter.Enabled = false;
lblMeter.Visible = false;
lblMeter.Enabled = false;
}
else if ((Convert.ToString(edvEnd.dataView[args.Row]["LaborType"]) == "S") & (Convert.ToString(edvEnd.dataView[args.Row]["JobType"]) == "Maintenance"))
{
txtLaborNotes.Top = 14;
txtLaborNotes.Left = 320;
txtLaborNotes.Width = 320;
txtLaborNotes.Height = 110;
txtLaborNotes.Visible = true;
txtLaborNotes.Enabled = true;
btnTag.Refresh();
lblSetupComplete.Width = 0;
lblSetupComplete.Enabled = false;
lblSetupComplete.Visible = false;
nbrSetupComplete.Visible = false;
nbrSetupComplete.Width = 0;
btnTag.Visible = true;
btnTag.Enabled = true;
btnTag.TabIndex = 2;
btnTag.EpiBinding = "";
btnTag.Enabled = false;
btnTag.Visible = false;
nbrCurrent.Top = 130;
nbrCurrent.Left = 540;
chkJobClose.Visible = true;
chkJobClose.Enabled = true;
lblJobClose.Visible = true;
lblJobClose.Enabled = true;
bcomboTopic.Visible = true;
bcomboTopic.Enabled = true;
bcomboTopic.Left = 135;
bcomboTopic.Top = 40;
lblTopic.Visible = true;
lblTopic.Enabled = true;
lblLaborNotes.Visible = true;
lblLaborNotes.Enabled = true;
lblLaborNotes.Left = 215;
lblLaborNotes.Top = 15;
intMeter.Visible = true;
intMeter.Enabled = true;
intMeter.Left = 295;
intMeter.Top = 132;
lblMeter.Visible = true;
lblMeter.Enabled = true;
}
}
}
}
private void btnOK_c_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
EpiNumericEditor intQty = (EpiNumericEditor)csm.GetNativeControlReference("f1fdcf24-066d-424e-9b59-319a804854fa");
EpiNumericEditor intSetup = (EpiNumericEditor)csm.GetNativeControlReference("31799c26-7331-45b0-a723-9cc464175117");
if (edvEnd.dataView[edvEnd.Row]["LaborType"].ToString() == "P" & (Convert.ToString(edvEnd.dataView[edvEnd.Row]["JobType"]) == "Manufacture"))
{
string strJobNum = edvEnd.dataView[edvEnd.Row]["JobNum"].ToString();
string intAssy = edvEnd.dataView[edvEnd.Row]["AssemblySeq"].ToString();
string intOprSeq = edvEnd.dataView[edvEnd.Row]["OprSeq"].ToString();
string whereclause = "JobNum = '" + strJobNum + "' and" + " AssemblySeq = " + intAssy + " and OprSeq = " + intOprSeq;
//MessageBox.Show(whereclause);
DataSet dsJobOper = _bor.GetRows("Erp:BO:JobOperSearch", "JobNum = '" + strJobNum + "' and" + " AssemblySeq = " + intAssy + " and OprSeq = " + intOprSeq, "RunQty, QtyCompleted");
if (dsJobOper.Tables[0].Rows.Count > 0)
{
int intRemaining = Convert.ToInt32(dsJobOper.Tables[0].Rows[0]["RunQty"]) - Convert.ToInt32(dsJobOper.Tables[0].Rows[0]["QtyCompleted"]);
int intRunQty = Convert.ToInt32(dsJobOper.Tables[0].Rows[0]["RunQty"]);
int intComplete = Convert.ToInt32(dsJobOper.Tables[0].Rows[0]["QtyCompleted"]);
if (Convert.ToInt32(dsJobOper.Tables[0].Rows[0]["QtyCompleted"]) + Convert.ToInt32(intQty.Value) <= Convert.ToInt32(dsJobOper.Tables[0].Rows[0]["RunQty"]))
{
//MessageBox.Show(dsJobOper.Tables[0].Rows[0]["QtyCompleted"].ToString());
EpiButton btnOK = (EpiButton)csm.GetNativeControlReference("025fc115-fee3-4973-946e-ba209189d62e");
btnOK.PerformClick();
}
else
{
MessageBox.Show("You attempted to claim " + Convert.ToString(intQty.Value) + " Parts. There have been " + Convert.ToString(intComplete)
+ " parts previously completed already. You can only claim up to " + Convert.ToString(intRemaining)
+ " parts. The total required quantity for this operation is " + intRunQty.ToString() + ".");
intQty.Value = 0;
intQty.Focus();
}
}
}
else if ((Convert.ToString(edvEnd.dataView[edvEnd.Row]["LaborType"]) == "S") & (Convert.ToString(edvEnd.dataView[edvEnd.Row]["JobType"]) == "Manufacture"))
{
string strJobNum = edvEnd.dataView[edvEnd.Row]["JobNum"].ToString();
string intAssy = edvEnd.dataView[edvEnd.Row]["AssemblySeq"].ToString();
string intOprSeq = edvEnd.dataView[edvEnd.Row]["OprSeq"].ToString();
DataSet dsJobOperS = _bor.GetRows("Erp:BO:JobOperSearch", "JobNum = '" + strJobNum + "' and" + " AssemblySeq = " + intAssy + " and OprSeq = " + intOprSeq, "SetupPctComplete");
if (dsJobOperS.Tables[0].Rows.Count > 0)
{
int intSetupRemaining = 100 - Convert.ToInt32(dsJobOperS.Tables[0].Rows[0]["SetupPctComplete"]);
//MessageBox.Show(dsJobOperS.Tables[0].Rows[0]["SetupPctComplete"].ToString() + " / " + intSetupRemaining.ToString());
if (Convert.ToInt32(intSetup.Value) >= Convert.ToInt32(dsJobOperS.Tables[0].Rows[0]["SetupPctComplete"]))
{
//MessageBox.Show(dsJobOper.Tables[0].Rows[0]["QtyCompleted"].ToString());
EpiButton btnOK = (EpiButton)csm.GetNativeControlReference("025fc115-fee3-4973-946e-ba209189d62e");
btnOK.PerformClick();
}
else
{
MessageBox.Show("You attempted to claim " + Convert.ToInt32(intSetup.Value) + "% against this setup. This setup was previously claimed as " + Convert.ToInt32(dsJobOperS.Tables[0].Rows[0]["SetupPctComplete"]) + "% complete. You must claim more than the previous value reported.");
intSetup.Value = 0;
intSetup.Focus();
}
}
}
else if ((Convert.ToString(edvEnd.dataView[edvEnd.Row]["LaborType"]) == "I"))
{
EpiButton btnOK = (EpiButton)csm.GetNativeControlReference("025fc115-fee3-4973-946e-ba209189d62e");
btnOK.PerformClick();
}
else if ((Convert.ToString(edvEnd.dataView[edvEnd.Row]["LaborType"]) == "S") & (Convert.ToString(edvEnd.dataView[edvEnd.Row]["JobType"]) == "Maintenance"))
{
if (Convert.ToInt32(intQty.Value) <= 1)
{
EpiButton btnOK = (EpiButton)csm.GetNativeControlReference("025fc115-fee3-4973-946e-ba209189d62e");
if (!(bool)edvEnd.dataView[edvEnd.Row]["CheckBox01"])
{
btnOK.PerformClick();
}
if ((bool)edvEnd.dataView[edvEnd.Row]["CheckBox01"] && (decimal)intQty.Value == 1)
{
btnOK.PerformClick();
claimMaintJobCmplt();
}
if ((bool)edvEnd.dataView[edvEnd.Row]["CheckBox01"] && (decimal)intQty.Value == 0)
{
MessageBox.Show("You must claim Qty of 1 to complete the operation in order to make the job elibible for closing");
return;
}
}
else
{
MessageBox.Show("You can only claim 0 or 1 for Maintenance Operations.");
intQty.Value = 0;
intQty.Focus();
}
}
}
private void claimMaintJobCmplt()
{
int meter = Convert.ToInt32(edvEnd.dataView[edvEnd.Row]["Number03"]);
string resolution = edvEnd.dataView[edvEnd.Row]["ShortChar02"].ToString();
string laborNote = edvEnd.dataView[edvEnd.Row]["LaborNote"].ToString();
string jobNum = edvEnd.dataView[edvEnd.Row]["JobNum"].ToString();
string whereClause = edvEnd.dataView[edvEnd.Row]["JobNum"].ToString();
JobEntryAdapter adpJobEntry = new JobEntryAdapter(oTrans);
adpJobEntry.BOConnect();
JobEntryDataSet jeds;
adpJobEntry.GetByID(whereClause);
jeds = adpJobEntry.JobEntryData;
jeds.JobHead[0].ResTopicID1 = resolution;
jeds.JobHead[0].CommentText = laborNote;
jeds.JobHead[0].NewMeter = meter;
jeds.JobHead[0].JobClosed = true;
jeds.JobHead[0].RowMod = "U";
adpJobEntry.Update();
recordMeter();
}
private void recordMeter()
{
}