private void ModifyInvoice()
        {
            ClientConversation.authenticate(_frmAuth.EllipseUser, _frmAuth.EllipsePswd);

            supplierInfo = new SupplierInvoiceInfo();

            var currentRow = TittleRow + 1;

            var proxySheet = new screen.ScreenService();
            var requestSheet = new screen.ScreenSubmitRequestDTO();

            proxySheet.Url = _eFunctions.GetServicesUrl(drpEnviroment.SelectedItem.Label) + "/ScreenService";

            var opSheet = new screen.OperationContext
            {
                district = _frmAuth.EllipseDsct,
                position = _frmAuth.EllipsePost,
                maxInstances = 100,
                maxInstancesSpecified = true,
                returnWarnings = _eFunctions.DebugWarnings
            };
            _cells.GetCell(1, currentRow).Select();

            while (_cells.GetNullIfTrimmedEmpty(_cells.GetCell(1, currentRow).Value) != null)
            {
                try
                {
                    _cells.GetCell(1, currentRow).Select();
                    supplierInfo.Supplier = _cells.GetNullIfTrimmedEmpty(_cells.GetCell(1, currentRow).Value);
                    supplierInfo.Factura = _cells.GetNullIfTrimmedEmpty(_cells.GetCell(2, currentRow).Value);
                    supplierInfo.Fechapagosolicitada = _cells.GetNullIfTrimmedEmpty(_cells.GetCell(3, currentRow).Value);
                    supplierInfo.Fechapagooriginal = _cells.GetNullIfTrimmedEmpty(_cells.GetCell(4, currentRow).Value);
                    supplierInfo.PmtStatus = _cells.GetNullIfTrimmedEmpty(_cells.GetCell(5, currentRow).Value);
                    supplierInfo.Proveedor = _cells.GetNullIfTrimmedEmpty(_cells.GetCell(6, currentRow).Value);
                    supplierInfo.CodigoBancoOriginal = _cells.GetNullIfTrimmedEmpty(_cells.GetCell(7, currentRow).Value);
                    supplierInfo.St = Convert.ToDouble(_cells.GetNullIfTrimmedEmpty(_cells.GetCell(8, currentRow).Value));
                    supplierInfo.Vrtotalfactura = Convert.ToDouble(_cells.GetNullIfTrimmedEmpty(_cells.GetCell(9, currentRow).Value));
                    supplierInfo.VrBasedeDescuento = Convert.ToDouble(_cells.GetNullIfTrimmedEmpty(_cells.GetCell(10, currentRow).Value));
                    supplierInfo.Diferencia = Convert.ToDouble(_cells.GetNullIfTrimmedEmpty(_cells.GetCell(11, currentRow).Value));
                    supplierInfo.Descuentocalculado = Convert.ToDouble(_cells.GetNullIfTrimmedEmpty(_cells.GetCell(12, currentRow).Value));
                    supplierInfo.Vrdescuentoaplicado = Convert.ToDouble(_cells.GetNullIfTrimmedEmpty(_cells.GetCell(13, currentRow).Value));
                    supplierInfo.Fechadepagomodificada = _cells.GetNullIfTrimmedEmpty(_cells.GetCell(14, currentRow).Value);
                    supplierInfo.BancodePagoModificado = _cells.GetNullIfTrimmedEmpty(_cells.GetCell(15, currentRow).Value);

                    _eFunctions.RevertOperation(opSheet, proxySheet);

                    var replySheet = proxySheet.executeScreen(opSheet, "MSO261");

                    if (_eFunctions.CheckReplyError(replySheet))
                    {
                        _cells.GetCell(ResultColumn, currentRow).Style = StyleConstants.Error;
                        _cells.GetCell(ResultColumn, currentRow).Value = replySheet.message;
                    }
                    else
                    {
                        if (replySheet.mapName != "MSM261A") return;
                        var arrayFields = new ArrayScreenNameValue();
                        arrayFields.Add("OPTION1I", "1");
                        arrayFields.Add("DSTRCT_CODE1I", "ICOR");
                        arrayFields.Add("SUPPLIER_NO1I", supplierInfo.Supplier);
                        arrayFields.Add("INV_NO1I", supplierInfo.Factura);
                        requestSheet.screenFields = arrayFields.ToArray();

                        requestSheet.screenKey = "1";
                        replySheet = proxySheet.submit(opSheet, requestSheet);

                        while (_eFunctions.CheckReplyWarning(replySheet) || replySheet.functionKeys.Contains("XMIT-Confirm"))
                            replySheet = proxySheet.submit(opSheet, requestSheet);

                        if (_eFunctions.CheckReplyError(replySheet))
                        {
                            _cells.GetCell(ResultColumn, currentRow).Style = StyleConstants.Error;
                            _cells.GetCell(ResultColumn, currentRow).Value = replySheet.message;
                        }
                        else if (replySheet.mapName == "MSM261B")
                        {
                            arrayFields = new ArrayScreenNameValue();

                            arrayFields.Add("BRANCH_CODE2I", parameters.Branchcode);
                            arrayFields.Add("BANK_ACCT_NO2I", parameters.Bankaccount);
                            arrayFields.Add("SD_AMOUNT2I", supplierInfo.Descuentocalculado.ToString(CultureInfo.InvariantCulture));
                            arrayFields.Add("SD_DATE2I", supplierInfo.Fechapagosolicitada);
                            requestSheet.screenFields = arrayFields.ToArray();

                            requestSheet.screenKey = "1";
                            replySheet = proxySheet.submit(opSheet, requestSheet);

                            while (_eFunctions.CheckReplyWarning(replySheet) || replySheet.functionKeys.Contains("XMIT-Confirm"))
                                replySheet = proxySheet.submit(opSheet, requestSheet);

                            if (_eFunctions.CheckReplyError(replySheet) & !replySheet.message.Contains("X2:3730 - MODIFICATIONS MADE TO INVOICE"))
                            {
                                _cells.GetCell(ResultColumn, currentRow).Style = StyleConstants.Error;
                                _cells.GetCell(ResultColumn, currentRow).Value = replySheet.message;
                            }
                            else
                            {
                                _cells.GetCell(ResultColumn, currentRow).Style = StyleConstants.Success;
                                _cells.GetCell(ResultColumn, currentRow).Value = "Success";

                                _cells.GetCell(13, currentRow).Value = supplierInfo.Vrdescuentoaplicado = supplierInfo.Descuentocalculado;
                                _cells.GetCell(14, currentRow).Value = supplierInfo.Fechadepagomodificada = supplierInfo.Fechapagosolicitada;
                                _cells.GetCell(15, currentRow).Value = supplierInfo.BancodePagoModificado =  parameters.Branchcode+ " - " + parameters.Bankaccount ;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    _cells.GetCell(ResultColumn, currentRow).Style = StyleConstants.Error;
                    _cells.GetCell(ResultColumn, currentRow).Value = ex.Message;
                }
                finally
                {
                    currentRow++;
                }
            }
        }
        private void ExecuteProfile()
        {
            var statType = new List<string>();
            var statEntry = new List<string>();
            var arrayFields = new ArrayScreenNameValue();

            _frmAuth.StartPosition = FormStartPosition.CenterScreen;
            _frmAuth.selectedEnviroment = drpEnviroment.SelectedItem.Label;

            if (_frmAuth.ShowDialog() != DialogResult.OK) return;
            var opSheet = new Screen.OperationContext
            {
                district = _frmAuth.EllipseDsct,
                position = _frmAuth.EllipsePost,
                maxInstances = 100,
                maxInstancesSpecified = true,
                returnWarnings = _eFunctions.DebugWarnings
            };

            ClientConversation.authenticate(_frmAuth.EllipseUser, _frmAuth.EllipsePswd);

            var proxySheet = new Screen.ScreenService();
            var requestSheet = new Screen.ScreenSubmitRequestDTO();
            var replySheet = new Screen.ScreenDTO();

            proxySheet.Url = _eFunctions.GetServicesUrl(drpEnviroment.SelectedItem.Label) + "/ScreenService";

            var currentRow = 5;

            string option1I = _cells.GetEmptyIfNull(_cells.GetCell("A" + currentRow).Value);

            try
            {
                while (!string.IsNullOrEmpty(option1I))
                {
                    string profile;
                    string profileType;
                    switch (option1I)
                    {
                        case "3. Maintain Operating Statistics Profile":
                            string prStatType1I;
                            MaintainStatisticsProfile(ref option1I, statType, statEntry, ref arrayFields, opSheet,
                                proxySheet, requestSheet, ref replySheet, currentRow, out profile, out profileType,
                                out prStatType1I);
                            break;
                        case "4. Maintain General Equipment Profile":
                            string fuelOilType2I;
                            string fuelCapacity2I;
                            ManintainGeneralProfile(ref option1I, ref arrayFields, opSheet, proxySheet, requestSheet,
                                ref replySheet, currentRow, out profile, out profileType, out fuelOilType2I,
                                out fuelCapacity2I);
                            break;
                        case "Delete Profile":
                            DeleteProfile(ref option1I, ref arrayFields, opSheet, proxySheet, requestSheet,
                                ref replySheet, currentRow, out profile, out profileType);
                            break;
                    }
                    currentRow += 1;
                    option1I = "" + _cells.GetCell("A" + currentRow).Value;
                }
            }
            catch (Exception error)
            {
                _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style = _cells.GetStyle(StyleConstants.Error);
                _cells.GetCell("A" + currentRow).AddComment("" + error.Message);
            }
        }