internal static int DeleteRecord(int inCtr)
        {
            //Delete payroll record from SAP
            int result = 0;

            PTSProject.clsFireUpload cFireUp = Shared.Container.Resolve <clsFireUpload>();

            try
            {
                result = -1;
                if (~cFireUp.GetReconciliationForDelete(inCtr) != 0)
                {
                    //error msg & exit
                    Shared.ViewManager.ShowMessage("DeleteRecordError - '" + UpgradeHelpers.Helpers.Information.Err().Description + "'", "Delete SAP Record", UpgradeHelpers.Helpers.BoxButtons.OK);
                    return(0);
                }

                if (~ConnectToSAP() != 0)
                {
                    //error msg
                    Shared.ViewManager.ShowMessage("Unable to Connect to SAP", "Delete Record in SAP Database", UpgradeHelpers.Helpers.BoxButtons.OK);
                    return(0);
                }
                //set the data entry profile
                Shared.
                profile = "FIRE SCH";

                //create the BOR object for an instance-independent method
                Shared.
                oBORObject = Shared.oBAPICtrl.GetSAPObject("BUS7024", null, null, null, null, null, null, null, null, null, null);

                //create the structure object(s) of the BOR method
                Shared.
                oSAPStruc = Shared.oBAPICtrl.DimAs(Shared.oBORObject, "Delete", "Catsrecords");
                Shared.
                oSAPReturnStruc = Shared.oBAPICtrl.DimAs(Shared.oBORObject, "Delete", "Return");

                //fill the SAP struct and call the BAPI
                //UPGRADE_TODO: (1067) Member AppendRow is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oSAPStruc.AppendRow();

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["COUNTER"] = cFireUp.PRCounter;

                //Alternate method if data type problems occur
                //ctr = cFireUp.PRCounter
                //Set oRow = oSAPStruc.Rows.Item(1)
                //oRow.Value("COUNTER") = ctr


                //call the method (BAPI), import the structure oSAPStruc, get return values
                //and confirmation record
                //UPGRADE_WARNING: (7006) The Named argument Return was not resolved and corresponds to the following expression oSAPReturnStruc More Information: http://www.vbtonet.com/ewis/ewi7006.aspx
                //UPGRADE_WARNING: (7006) The Named argument Catsrecords was not resolved and corresponds to the following expression oSAPStruc More Information: http://www.vbtonet.com/ewis/ewi7006.aspx
                //UPGRADE_WARNING: (7006) The Named argument profile was not resolved and corresponds to the following expression profile More Information: http://www.vbtonet.com/ewis/ewi7006.aspx
                //UPGRADE_TODO: (1067) Member Delete is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oBORObject.Delete(Shared.profile, Shared.oSAPStruc, Shared.oSAPReturnStruc);

                //UPGRADE_TODO: (1067) Member RowCount is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                if (Convert.ToDouble(Shared.oSAPReturnStruc.RowCount) > 0)
                {
                    //    if there are return errors, write those to the return structure
                    //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                    Shared.
                    oRtnRow = Shared.oSAPReturnStruc.Rows.Item(1);
                    //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                    if (Convert.ToString(Shared.oRtnRow.Value("TYPE")) == "E")
                    {
                        //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                        cFireUp.PRReturnmsg = Convert.ToString(Shared.oRtnRow.Value("MESSAGE"));
                        cFireUp.PRStatus    = "X";
                        //UPGRADE_TODO: (1067) Member RowCount is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                        for (int k = 1; k <= Convert.ToDouble(Shared.oSAPReturnStruc.RowCount); k++)
                        {
                            //UPGRADE_TODO: (1067) Member DeleteRow is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                            Shared.
                            oSAPReturnStruc.DeleteRow();
                        }
                        Shared.ViewManager.ShowMessage("Deleting from SAP failed.", System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).ProductName);
                        result = 0;
                    }
                    else
                    {
                        //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                        cFireUp.PRReturnmsg = Convert.ToString(Shared.oRtnRow.Value("MESSAGE"));
                        cFireUp.PRStatus    = "D";
                    }
                }
                else
                {
                    cFireUp.PRReturnmsg = "Record successfully deleted";
                    cFireUp.PRStatus    = "D";
                }
                cFireUp.PRUploadDate = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");

                cFireUp.PPpayroll_status_code = cFireUp.PRStatus;
                cFireUp.PPlast_update_by      = modGlobal.Shared.gUser;

                if (~cFireUp.InsertReconciliation() != 0)
                {
                    //error msg
                    Shared.ViewManager.ShowMessage("Unable to InsertReconciliation", "Delete Record in SAP Database", UpgradeHelpers.Helpers.BoxButtons.OK);
                    result = 0;
                }
                if (~cFireUp.UpdatePersonnelPayrollStatus(inCtr) != 0)
                {
                    //error msg
                }
            }
            catch (System.Exception excep)
            {
                Shared.ViewManager.ShowMessage("Delete Record Error '" + excep.Message + "'", "Delete SAP Record", UpgradeHelpers.Helpers.BoxButtons.OK);
                return(0);
            }

            return(result);
        }
        internal static int InsertRecord(int lSysID)
        {
            //** Insert Payroll record in SAP
            int result = 0;

            PTSProject.clsFireUpload cFireUp = Shared.Container.Resolve <clsFireUpload>();

            try
            {
                if (~ConnectToSAP() != 0)
                {
                    Shared.ViewManager.ShowMessage("Unable to Connect to SAP", "Insert Record to SAP Database", UpgradeHelpers.Helpers.BoxButtons.OK);
                    return(0);
                }


                //set the data entry profile for uploading multiple CATS records
                Shared.
                profile = "FIRE SCH";

                //create the BOR object and set the key values (for an instance-dependent method)
                //Set oTestObject = oBAPICtrl.GetSAPObject("ZISUACCNT", vkont, gpart)

                //create the BOR object for an instance-independent method
                Shared.
                oBORObject = Shared.oBAPICtrl.GetSAPObject("BUS7024", null, null, null, null, null, null, null, null, null, null);

                //create the structure object(s) of the BOR method
                Shared.
                oSAPStruc = Shared.oBAPICtrl.DimAs(Shared.oBORObject, "Insert", "CatsrecordsIn");
                Shared.
                oSAPReturnStruc = Shared.oBAPICtrl.DimAs(Shared.oBORObject, "Insert", "Return");
                Shared.
                oSAPConfirmStruc = Shared.oBAPICtrl.DimAs(Shared.oBORObject, "Insert", "CatsrecordsOut");

                //fill the SAP struc from the SQL resultset (SAP struct's are 1-based
                //and we will only send one row at a time into the BAPI)
                if (~cFireUp.GetPayrollTransferBySysID(lSysID) != 0)
                {
                    //error msg
                    Shared.ViewManager.ShowMessage("Unable to GetPayrollTransferBySysID", "Insert Record to SAP Database", UpgradeHelpers.Helpers.BoxButtons.OK);
                    return(0);
                }

                //UPGRADE_TODO: (1067) Member AppendRow is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oSAPStruc.AppendRow();

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["WORKDATE"] = cFireUp.PayrollRS["workdate"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["ACTTYPE"] = cFireUp.PayrollRS["acttype"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["REC_CCTR"] = cFireUp.PayrollRS["rec_cctr"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["EMPLOYEENUMBER"] = cFireUp.PayrollRS["employeenumber"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["REC_ORDER"] = modGlobal.Clean(cFireUp.PayrollRS["rec_order"]);

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["ACTIVITY"] = cFireUp.PayrollRS["activity"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["WBS_ELEMENT"] = cFireUp.PayrollRS["wbs_element"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["ABS_ATT_TYPE"] = cFireUp.PayrollRS["abs_att_type"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["PAYSCALEGROUP"] = cFireUp.PayrollRS["payscalegroup"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["PAYSCALELEVEL"] = cFireUp.PayrollRS["payscalelevel"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["CATSHOURS"] = cFireUp.PayrollRS["catshours"];

                //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow = Shared.oSAPStruc.Rows.Item(1);
                //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oRow.Value["UNIT"] = cFireUp.PayrollRS["unit"];


                //call the method (BAPI), import the structure oSAPStruc, get return values
                //and confirmation record
                //UPGRADE_WARNING: (7006) The Named argument Return was not resolved and corresponds to the following expression oSAPReturnStruc More Information: http://www.vbtonet.com/ewis/ewi7006.aspx
                //UPGRADE_WARNING: (7006) The Named argument CatsrecordsOut was not resolved and corresponds to the following expression oSAPConfirmStruc More Information: http://www.vbtonet.com/ewis/ewi7006.aspx
                //UPGRADE_WARNING: (7006) The Named argument CatsrecordsIn was not resolved and corresponds to the following expression oSAPStruc More Information: http://www.vbtonet.com/ewis/ewi7006.aspx
                //UPGRADE_WARNING: (7006) The Named argument profile was not resolved and corresponds to the following expression profile More Information: http://www.vbtonet.com/ewis/ewi7006.aspx
                //UPGRADE_TODO: (1067) Member Insert is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oBORObject.Insert(Shared.profile, Shared.oSAPStruc, Shared.oSAPConfirmStruc, Shared.oSAPReturnStruc);

                //UPGRADE_TODO: (1067) Member RowCount is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                if (Convert.ToDouble(Shared.oSAPConfirmStruc.RowCount) < 1)
                {
                    //       if there are return errors, write those to the return structure

                    //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                    Shared.
                    oRtnRow = Shared.oSAPReturnStruc.Rows.Item(1);
                    //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                    cFireUp.PRReturnmsg = Convert.ToString(Shared.oRtnRow.Value("MESSAGE"));
                    cFireUp.PRStatus    = "F";
                    cFireUp.PRCounter   = "";
                    //UPGRADE_TODO: (1067) Member RowCount is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                    for (int k = 1; k <= Convert.ToDouble(Shared.oSAPReturnStruc.RowCount); k++)
                    {
                        //UPGRADE_TODO: (1067) Member DeleteRow is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                        Shared.
                        oSAPReturnStruc.DeleteRow();
                    }
                }
                else
                {
                    //UPGRADE_TODO: (1067) Member Rows is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                    Shared.
                    oConfRow = Shared.oSAPConfirmStruc.Rows.Item(1);
                    //UPGRADE_TODO: (1067) Member Value is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                    cFireUp.PRCounter   = Convert.ToString(Shared.oConfRow.Value("COUNTER"));
                    cFireUp.PRReturnmsg = "Record successfully inserted";
                    cFireUp.PRStatus    = "S";
                    //UPGRADE_TODO: (1067) Member DeleteRow is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                    Shared.
                    oSAPConfirmStruc.DeleteRow();
                    result = -1;
                }
                cFireUp.PRWorkdate       = Convert.ToString(cFireUp.PayrollRS["workdate"]);
                cFireUp.PRActtype        = Convert.ToString(cFireUp.PayrollRS["acttype"]);
                cFireUp.PREmployeenumber = Convert.ToInt32(cFireUp.PayrollRS["employeenumber"]);
                cFireUp.PRRec_order      = Convert.ToString(cFireUp.PayrollRS["rec_order"]);
                cFireUp.PRActivity       = Convert.ToString(cFireUp.PayrollRS["activity"]);
                cFireUp.PRWbs_element    = Convert.ToString(cFireUp.PayrollRS["wbs_element"]);
                cFireUp.PRAbs_att_type   = Convert.ToString(cFireUp.PayrollRS["abs_att_type"]);
                cFireUp.PRPayscalegroup  = Convert.ToString(cFireUp.PayrollRS["payscalegroup"]);
                cFireUp.PRPayscalelevel  = Convert.ToString(cFireUp.PayrollRS["payscalelevel"]);
                cFireUp.PRCatshours      = Convert.ToDouble(cFireUp.PayrollRS["catshours"]);
                cFireUp.PRUnit           = Convert.ToString(cFireUp.PayrollRS["unit"]);
                cFireUp.PRApproved_by    = Convert.ToInt32(cFireUp.PayrollRS["approved_by"]);
                cFireUp.PRUploadDate     = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");
                cFireUp.PRPayroll_sys_id = Convert.ToInt32(cFireUp.PayrollRS["payroll_sys_id"]);

                cFireUp.PPpayroll_status_code = cFireUp.PRStatus;
                cFireUp.PPlast_update_by      = modGlobal.Shared.gUser;

                if (~cFireUp.InsertReconciliation() != 0)
                {
                    //error msg
                    Shared.ViewManager.ShowMessage("Unable to InsertReconciliation", "Insert Record to SAP Database", UpgradeHelpers.Helpers.BoxButtons.OK);
                }
                if (~cFireUp.UpdatePersonnelPayrollStatus(lSysID) != 0)
                {
                    //error msg
                    Shared.ViewManager.ShowMessage("Unable to UpdatePersonnelPayrollStatus", "Insert Record to SAP Database", UpgradeHelpers.Helpers.BoxButtons.OK);
                }

                //UPGRADE_TODO: (1067) Member DeleteRow is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                Shared.
                oSAPStruc.DeleteRow();
            }
            catch (System.Exception excep)
            {
                Shared.ViewManager.ShowMessage("InsertRecordError - '" + excep.Message + "'", "Insert Record into SAP", UpgradeHelpers.Helpers.BoxButtons.OK);
                return(0);
            }
            return(result);
        }