Error index was Outside-the Bounds of the array

Asked

Viewed 254 times

0

I am trying to run my application, however, every time I click the record button the screen returns me this error! I’ve tried everything and I still can’t, what can it be?

public void SaveWorkOrderGrid(string param) {

    DataTable dt = ProcessWorkOrderPlannedLabor(FindGrid("GWOReprogram").DataValues, param);

    foreach(DataRow dtRow in dt.Rows) {

        object value = dtRow["worker"];

        if (value != DBNull.Value) {
            InsertWorkerWorkOrder(dtRow);
        }
    }

    SetServerResult(RM.LoadResString("PROCESS_SUCCESS"), ServerResultDisplayMode.MsgBox, ServerResultType.Ok);
}

private void InsertWorkerWorkOrder(DataRow row) {
    int plannedTime = Convert.ToInt32(row["plannedTime"]);
    string worker = String.Empty;
    object value = row["worker"];

    if (value != DBNull.Value)
        worker = row["worker"].ToString();

    HybridDictionary hdWorkOrder = new HybridDictionary(2);
    HybridDictionary hdWorkOrderLabor = new HybridDictionary(7);
    HybridDictionary hd = new HybridDictionary();

    try {
        this.ProcessManager.InitTrans();

        string lineCounter = GetPlannedLaborLineCounter(row["workOrder"].ToString(), row["job"].ToString());

        if (String.IsNullOrEmpty(lineCounter)) {
            Sisteplant.Prisma.Common.PrismaCounter.CounterCode avCode = new Sisteplant.Prisma.Common.PrismaCounter.CounterCode();
            avCode = (Sisteplant.Prisma.Common.PrismaCounter.CounterCode) 60;
            lineCounter = Sisteplant.Prisma.Common.PrismaCounter.CounterNextValue(avCode, this.ProcessManager.SqlE).ToString();
        }

        if (!String.IsNullOrEmpty(worker)) {

            hdWorkOrder.Add("workOrder", Convert.ToInt32(row["workOrder"]));
            hdWorkOrder.Add("reprogramDate", DateTime.Now);
            hd.Add("WorkOrder", hdWorkOrder);

            hdWorkOrderLabor.Add("workOrder", Convert.ToInt32(row["workOrder"]));
            hdWorkOrderLabor.Add("plannedLaborLineCounter", Convert.ToInt32(row["plannedLaborLineCounter"]));
            hdWorkOrderLabor.Add("worker", worker);
            hdWorkOrderLabor.Add("job", row["job"].ToString());

            if (!String.IsNullOrEmpty(row["numOfWorkers"].ToString()))
                hdWorkOrderLabor.Add("numOfWorkers", Convert.ToInt32(row["numOfWorkers"]));
            else
                hdWorkOrderLabor.Add("numOfWorkers", 1);

            if (!String.IsNullOrEmpty(row["initDate"].ToString()))
                hdWorkOrderLabor.Add("initDate", Convert.ToDateTime(row["initDate"]));

            if (!String.IsNullOrEmpty(row["plannedTime"].ToString()))
                hdWorkOrderLabor.Add("plannedTime", Convert.ToInt32(row["plannedTime"]));
            else
                hdWorkOrderLabor.Add("plannedTime", 0);

            hd.Add("WorkOrderPlannedLabor", hdWorkOrderLabor);

            _entitiesHelper.SaveEntitySeveralTables(this.ProcessManager, "WorkOrder", hd);
            this.ProcessManager.CommitTrans();
        }

    } catch (Exception ex) {

        this.ProcessManager.RollbackTrans();
        throw new Exception(ex.Message);
    }
}
  • Which error is returned? What of all you have tried?

  • Netinho, debugged line by line from both front and back-end, and nothing to find the problem, the error that returns is index was Outside-the Bounds of the array

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.