I need to help in debugging now. I have all of the calls in the code, with the appropriate paramters, and it compiles successfully. However, it gives me an error when I try to run it.
Here’s what the error says.
Application Error
Exception caught in: mscorlib
Error Detail
============
Message: Unable to cast object of type 'Infragistics.Win.UltraWinGrid.UltraGridCell' to type 'System.IConvertible'.
Program: CommonLanguageRuntimeLibrary
Method: ToInt32
Client Stack Trace
==================
at System.Convert.ToInt32(Object value)
at Script.StartActivityButton_Click(Object sender, EventArgs args)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButtonBase.OnClick(EventArgs e)
at Ice.Lib.Framework.EpiButton.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButton.OnMouseUp(MouseEventArgs e)
at Ice.Lib.Framework.EpiButton.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I figure it must be something so do with my parameters and variables not being the right type. The problem is, I don’t know for sure how to figure out which one it is. Should I just comment out all of the calls except the first one and keep running it until I find the offending line? Or is there a better way to figure out what is wrong? A trace doesn’t show anything, so I guess I don’t know how far it’s getting.
Here’s my full code if that helps.
// **************************************************
// Custom code for MainController
// Created: 3/12/2018 1:41:56 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
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 **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
EpiUltraGrid WorkGrid;
int RowNum;
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.StartActivityButton.Click += new System.EventHandler(this.StartActivityButton_Click);
// End Wizard Added Custom Method Calls
WorkGrid = (EpiUltraGrid)csm.GetNativeControlReference("994a7055-2964-46f1-8488-0c2359109f4f");
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.StartActivityButton.Click -= new System.EventHandler(this.StartActivityButton_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
WorkGrid = (EpiUltraGrid)csm.GetNativeControlReference("994a7055-2964-46f1-8488-0c2359109f4f");
}
private void StartActivityButton_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
RowNum = -1;
foreach(var row in WorkGrid.Rows)
{
RowNum = RowNum+1;
var LHS = Convert.ToInt32(WorkGrid.Rows[RowNum].Cells["Calculated_CalcLaborHeadSeq"]);
var EmpID = Convert.ToString(WorkGrid.Rows[RowNum].Cells["Calculated_CurrentEmpID"]);
if(row.Selected)
{
var JN = Convert.ToString(WorkGrid.Rows[RowNum].Cells["JobHead_JobNum"]);
var AS = Convert.ToInt32(WorkGrid.Rows[RowNum].Cells["JobAsmbl_AssemblySeq"]);
var OS = Convert.ToInt32(WorkGrid.Rows[RowNum].Cells["JobOper_OprSeq"]);
var RID = Convert.ToString(WorkGrid.Rows[RowNum].Cells["Calculated_ResourceID"]);
var msg = "testing";
var la = new LaborAdapter(oTrans);
la.BOConnect();
la.GetByID(LHS);
la.StartActivity(LHS,"P");
var JobNum = new JobEntryAdapter(oTrans);
JobNum.ValidateJobNum(JN);
la.DefaultJobNum(JN);
la.LaborRateCalc();
la.DefaultAssemblySeq(AS);
la.DefaultOprSeq(OS, out msg);
la.LaborRateCalc();
la.CheckWarnings(out msg);
la.CheckEmployeeActivity(EmpID,LHS,JN,AS,OS,RID, out msg);
la.CheckFirstArticleWarning(out msg);
la.SetClockInAndDisplayTimeMES();
la.Update();
}
}
}
}