Isai
(Isaiselvan S)
September 24, 2019, 5:49pm
1
Dear Team,
I’m trying update the record in PartLot db table through receipt entry form. But my record is inserted into table after that i got an issue. Kindly help on this.
I’m trying fix this issue in Convert.ToString() used in every in my code but, i don’t why its coming on this error. Please find the below screen shot for your reference.
tsmith
(Tyler Smith)
September 24, 2019, 6:21pm
2
Can you post the custom code you’re using? It looks like you’re trying to access a datarow before there is any data loaded in the form. Check your EpiViewNotification handler to make sure you’re checking that the current data row index isn’t -1.
Isai
(Isaiselvan S)
September 24, 2019, 6:31pm
3
@tsmith
the below code i used. where i made a mistake kindly give solution
// **************************************************
// Custom code for HHLotNumberForm
// Created: 19/09/2019 19:23:11
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.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;
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 edvpartView;
private EpiDataView edvpartLot;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public string tmpLotNum = string.Empty;
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.edvpartView = ((EpiDataView)(this.oTrans.EpiDataViews["partView"]));
this.edvpartView.EpiViewNotification += new EpiViewNotification(this.edvpartView_EpiViewNotification);
this.edvpartLot = ((EpiDataView)(this.oTrans.EpiDataViews["partLot"]));
this.edvpartLot.EpiViewNotification += new EpiViewNotification(this.edvpartLot_EpiViewNotification);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
SetExtendedProperties();
// 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.edvpartView.EpiViewNotification -= new EpiViewNotification(this.edvpartView_EpiViewNotification);
this.edvpartView = null;
this.edvpartLot.EpiViewNotification -= new EpiViewNotification(this.edvpartLot_EpiViewNotification);
this.edvpartLot = null;
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void HHLotNumberForm_Load(object sender, EventArgs args)
{
// Add Event Handler Code
Ice.Lib.Framework.EpiGroupBox tmpGrpboxLotVal = (Ice.Lib.Framework.EpiGroupBox)csm.GetNativeControlReference("c205404a-5523-4c79-8a60-d9271a99b21d");
string tmplotval = string.Empty;
if( Convert.ToString(tmpGrpboxLotVal.Text) != "" || Convert.ToString(tmpGrpboxLotVal.Text) != string.Empty)
{
tmplotval = Convert.ToString(tmpGrpboxLotVal.Text);
//MessageBox.Show(tmplotval.ToString());
string strlotval = Convert.ToString(tmplotval.Substring(tmplotval.IndexOf("/")+1));
//string resval = strlotval[1].Trim();
//MessageBox.Show(strlotval.ToString());
//string[] tmpLotNum = strlotval.Split('-');
string[] tmpLotNum = strlotval.Split(new[] { '-' }, 3);
string tmpMfg = string.Empty;
string tmpOwn = string.Empty;
string tmpDon = string.Empty;
tmpMfg = tmpLotNum[2].ToString();
tmpOwn = tmpLotNum[0].ToString();
tmpDon = tmpLotNum[1].ToString();
if( Convert.ToString(tmpMfg) != "" && Convert.ToString(tmpOwn) != "" && Convert.ToString(tmpDon) != "")
{
EpiDataView edvpartLot = ((EpiDataView)(this.oTrans.EpiDataViews["partLot"]));
System.Data.DataRow edvpartLotRow = edvpartLot.CurrentDataRow;
edvpartLotRow["MfgBatch"] = Convert.ToString(tmpMfg);
edvpartLotRow["HeatNum"] = Convert.ToString(tmpOwn);
edvpartLotRow["FirmWare"] = Convert.ToString(tmpDon);
}
}
}
private void SetExtendedProperties()
{
// Begin Wizard Added EpiDataView Initialization
EpiDataView edvpartLot = ((EpiDataView)(this.oTrans.EpiDataViews["partLot"]));
// End Wizard Added EpiDataView Initialization
// Begin Wizard Added Conditional Block
if (edvpartLot.dataView.Table.Columns.Contains("MfgBatch"))
{
// Begin Wizard Added ExtendedProperty Settings: edvpartLot-MfgBatch
edvpartLot.dataView.Table.Columns["MfgBatch"].ExtendedProperties["ReadOnly"] = true;
// End Wizard Added ExtendedProperty Settings: edvpartLot-MfgBatch
}
if (edvpartLot.dataView.Table.Columns.Contains("HeatNum"))
{
// Begin Wizard Added ExtendedProperty Settings: edvpartLot-HeatNum
edvpartLot.dataView.Table.Columns["HeatNum"].ExtendedProperties["ReadOnly"] = true;
// End Wizard Added ExtendedProperty Settings: edvpartLot-HeatNum
}
if (edvpartLot.dataView.Table.Columns.Contains("FirmWare"))
{
// Begin Wizard Added ExtendedProperty Settings: edvpartLot-FirmWare
edvpartLot.dataView.Table.Columns["FirmWare"].ExtendedProperties["ReadOnly"] = true;
// End Wizard Added ExtendedProperty Settings: edvpartLot-FirmWare
}
// End Wizard Added Conditional Block
}
private void edvpartView_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
if ((args.NotifyType == EpiTransaction.NotifyType.AddRow))
{
if ((args.Row > -1))
{
}
}
}
private void edvpartLot_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
if ((args.NotifyType == EpiTransaction.NotifyType.AddRow))
{
if ((args.Row > -1))
{
}
}
}
}
tsmith
(Tyler Smith)
September 24, 2019, 7:07pm
4
This is the only thing I can imagine would throw an error related to a DataRow, but I don’t think it would be the IndextOutOfBounds exception you got. Try adding a check after the first line to check if edvpartLotRow is null before accessing its members.
Isai
(Isaiselvan S)
September 24, 2019, 7:44pm
5
@tsmith
I’m getting the same error.
Note: same error in Lot Entry form accessed from Receipt Entry form.
It’s already a string? Why are you trying to convert it to a string again?
This should work just fine, you don't need to convert a string to a string
private void HHLotNumberForm_Load(object sender, EventArgs args)
{
// Add Event Handler Code
Ice.Lib.Framework.EpiGroupBox tmpGrpboxLotVal = (Ice.Lib.Framework.EpiGroupBox)csm.GetNativeControlReference("c205404a-5523-4c79-8a60-d9271a99b21d");
string tmplotval = string.Empty;
if( tmpGrpboxLotVal.Text != "" || tmpGrpboxLotVal.Text != string.Empty)
{
tmplotval = tmpGrpboxLotVal.Text;
//MessageBox.Show(tmplotval.ToString());
string strlotval = tmplotval.Substring(tmplotval.IndexOf("/")+1);
//string resval = strlotval[1].Trim();
//MessageBox.Show(strlotval.ToString());
//string[] tmpLotNum = strlotval.Split('-');
string[] tmpLotNum = strlotval.Split(new[] { '-' }, 3);
string tmpMfg = string.Empty;
string tmpOwn = string.Empty;
string tmpDon = string.Empty;
tmpMfg = tmpLotNum[2].ToString();
tmpOwn = tmpLotNum[0].ToString();
tmpDon = tmpLotNum[1].ToString();
if(tmpMfg) != "" && tmpOwn != "" && tmpDon != "")
{
EpiDataView edvpartLot = ((EpiDataView)(this.oTrans.EpiDataViews["partLot"]));
System.Data.DataRow edvpartLotRow = edvpartLot.CurrentDataRow;
edvpartLotRow["MfgBatch"] = tmpMfg;
edvpartLotRow["HeatNum"] = tmpOwn;
edvpartLotRow["FirmWare"] = tmpDon;
}
}
}
Are you checking to see if args
is null here?
if ((args.NotifyType == EpiTransaction.NotifyType.AddRow))
Also,
In your HHLotNumberForm_Load
you are converting values to string but you aren’t checking if the values are null or not before you do it