Пример #1
0
        private void btnEmail_Click(object sender, EventArgs e)
        {
            //Send from Contract Viewer
            try
            {
                myTimer.Stop();
                eMailInputForm.settingsDir = this.appSettingsDir;
                //Israel 10/26/15 -- Removed EMailDomain property setting.
                string fromAddress = ""; // Utils.GetUserNameWithoutDomain(toolbarOrWindowsUserId) + "@" + Properties.Settings.Default.EMailDomain;
                eMailInputForm.InitForm(fromAddress);

                if (eMailInputForm.ShowDialog(this) == DialogResult.OK)
                {
                    fromAddress = eMailInputForm.tedFromAddress.Text;
                    string toAddress = eMailInputForm.tedToAddress.Text;
                    string subject = eMailInputForm.tedSubject.Text;
                    string body = eMailInputForm.memoBody.Text;
                    bool isRtf = eMailInputForm.cedSendAsRTF.Checked;

                    Int32 tradeId = viewContractTradeId;
                    Int32 rqmtId = 0;
                    Int32 rqmtConfirmId = 0;
                    string contractLabel = "";
                    string cptySn = GetTradeSummaryData(tradeId, "CptySn");
                    string tradeSysTicket = GetTradeSummaryData(tradeId, "TradeSysTicket");
                    //int templateId = 0;
                    if (viewContractTradeId > 0)
                    {
                        rqmtConfirmId = viewContractConfirmId;
                        rqmtId = GetConfirmRqmtId(rqmtConfirmId);
                        contractLabel = GetConfirmData(rqmtConfirmId, "ConfirmLabel");
                        //templateId = viewContractTemplateId;
                    }

                    DocumentFormat docFormat = DocumentFormat.OpenXml;
                    byte[] contractBody = WSUtils.GetByteArrayFromDocument(editContractForm.richeditConfirm, docFormat);

                    using (var ts = new TransactionScope())
                    {
                        Vaulter vaulter = new Vaulter(sqlConnectionStr);
                        vaulter.VaultTradeRqmtConfirm(rqmtConfirmId, null);

                        SendToFaxGateway("F", toAddress, contractLabel, contractBody, docFormat, cptySn, tradeId,tradeSysTicket,
                           rqmtId, (Int32)rqmtConfirmId, isRtf, fromAddress, subject, body, false);

                        ts.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while attempting to EMail a Confirm." + Environment.NewLine +
                    "Error CNF-166 in " + FORM_NAME + ".btnEmail_Click(): " + ex.Message,
                  MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                myTimer.Start();
            }
        }
Пример #2
0
        private void SendPaperOrManualSend_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                myTimer.Stop();
                int sent = 0;
                int skipped = 0;

                SendMethod sendMethod;
                if (e.Item.Name == bbtnSendResendPaper.Name)
                    sendMethod = SendMethod.SendPaper;
                else if (e.Item.Name == bbtnManualSend.Name)
                    sendMethod = SendMethod.ManualSend;
                else if (e.Item.Name == bbtnSendResendCoverPage.Name)
                    sendMethod = SendMethod.SendWithCoverPage;
                else
                    throw new Exception("Internal Error: Invalid calling method: " + e.Item.Name);

                string label = "";
                if (sendMethod == SendMethod.SendPaper)
                    label = "Send/Resend Paper";
                else if (sendMethod == SendMethod.ManualSend)
                    label = "Manual Send";
                else if (sendMethod == SendMethod.SendWithCoverPage)
                    label = "Send/Resend w/Cover Page";

                string title = "";
                string message = "";
                bool isCoverPage = false;
                bool isRtf = false;
                DialogResult result = 0;

                if (sendMethod == SendMethod.SendWithCoverPage)
                {
                    faxCoverPageInputForm.settingsDir = this.appSettingsDir;
                    faxCoverPageInputForm.InitForm();
                    result = faxCoverPageInputForm.ShowDialog();
                    if (result == DialogResult.Yes)
                    {
                        title = faxCoverPageInputForm.tedTitle.Text;
                        message = faxCoverPageInputForm.memoMessage.Text;
                        isCoverPage = true;
                        isRtf = faxCoverPageInputForm.cedSendAsRTF.Checked;
                    }
                }
                else
                    result = XtraMessageBox.Show(label + "?", label,
                      MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                if (result == DialogResult.Yes)
                {
                    Cursor.Current = Cursors.WaitCursor;

                    //Get the list ahead of time, since the foreach code changes the list's contents/order 
                    GridView view = gridViewSummary;
                    int[] selectedRows = view.GetSelectedRows();
                    List<DataRow> rows = new List<DataRow>();

                    foreach (int rowHandle in selectedRows)
                        rows.Add(view.GetDataRow(rowHandle));

                    foreach (DataRow row in rows)
                    {
                        long tradeId = long.Parse(row["TradeId"].ToString());
                        string cptySn = row["CptySn"].ToString();
                        string finalApprovalFlag = row["FinalApprovalFlag"].ToString();
                        bool finalApproved = (finalApprovalFlag == "Y");
                        int confirmId = GetContractRowId(tradeId);
                        int confirmRqmtId = GetConfirmRqmtId(confirmId);
                        string status = GetTradeRqmtData(confirmRqmtId, "Status");
                        string faxTelexNumber = GetContractConfirmData(tradeId, "FaxTelexNumber");
                        bool isFaxNumberOk = (sendMethod == SendMethod.ManualSend) || (faxTelexNumber.Trim().Length > 0);

                        bool enableSend = (status == "OK_TO_SEND" || status == "SENT" || status == "FAIL") &&
                            (isFaxNumberOk) &&
                            !finalApproved;
                        if (enableSend)
                        {
                            if (sendMethod == SendMethod.SendPaper || sendMethod == SendMethod.SendWithCoverPage)
                            {
                                using (var ts = new TransactionScope())
                                {
                                    Vaulter vaulter = new Vaulter(sqlConnectionStr);
                                    vaulter.VaultTradeRqmtConfirm(confirmId, null);

                                    SendToFaxGateway(confirmId, cptySn, isRtf, title, message, isCoverPage);

                                    ts.Complete();
                                }
                            }
                            else //Manual send
                            {
                                string reference = GetContractConfirmData(confirmRqmtId, "NextStatusCode");
                                string cmt = GetTradeRqmtData(confirmRqmtId, "Cmt");
                                CallUpdateTradeRqmts(tradeId, confirmRqmtId, SEMPRA_RQMT, "SENT", DateTime.Today, reference, "Manual Send " + cmt, true);
                            }

                            sent++;
                        }
                        else
                            skipped++;
                    }
                    XtraMessageBox.Show(label + ": " + sent.ToString() + Environment.NewLine
                       + "Trades skipped: " + skipped.ToString(),
                       label, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while requesting 'Send Paper or Manual Send'." + Environment.NewLine +
                    "Error CNF-169 in " + FORM_NAME + ".SendPaperOrManualSend_ItemClick(): " + ex.Message,
                  MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                myTimer.Start();
                Cursor.Current = Cursors.Default;
            }
        }
Пример #3
0
        private void ChangeFaxNoSendResend(object sender, ItemClickEventArgs e)
        {
            try
            {
                //5/20/09 Israel - Menu item and handler created to allow change fax number and resend.
                //Get fax number data and send to form
                myTimer.Stop();
                int rowHandle = GetGridViewFocusedRowHandle(gridViewSummary);
                string cptySn = gridViewSummary.GetRowCellDisplayText(rowHandle, "CptySn").ToString();
                string cdtyCode = gridViewSummary.GetRowCellDisplayText(rowHandle, "CdtyCode").ToString();
                string sttlType = gridViewSummary.GetRowCellDisplayText(rowHandle, "SttlType").ToString();

                //Deprecated Israel 6/15/2015
                string oldFaxNo = "";

                //Israel 9/18/2015
                //string[] getCptyFaxNoResult = GetCptyFaxNo(cptySn, cdtyCode, sttlType);
                string newFaxNo = "none@domain_name.com";
                string transMethod = "EMAIL";
                //if (getCptyFaxNoResult[0] != null)
                //    transMethod = getCptyFaxNoResult[0];
                //if (getCptyFaxNoResult[1] != null)
                //    newFaxNo = getCptyFaxNoResult[1];

                GridView view = gridViewConfirm;
                string savedTransInd = view.GetRowCellDisplayText(view.FocusedRowHandle, "FaxTelexInd").ToString();
                string savedFaxNumber = view.GetRowCellDisplayText(view.FocusedRowHandle, "FaxTelexNumber").ToString();
                string savedTransMethod = GetFaxMethodFromInd(savedTransInd);

                frmAssignFaxNo assignFaxNoForm = new frmAssignFaxNo();
                assignFaxNoForm.SetFaxNumbers(newFaxNo, savedFaxNumber);
                if (assignFaxNoForm.ShowDialog(this) == DialogResult.OK)
                {
                    string liveFaxNumber = assignFaxNoForm.teditFaxTelexNumber.Text;
                    //string liveTransMethod = "FAX";
                    string liveTransMethod = liveFaxNumber.Contains("@") ? liveTransMethod = "EMAIL" : liveTransMethod = "FAX";
                    string liveTransInd = GetFaxIndFromMethod(liveTransMethod);


                    Int32 confirmId = Int32.Parse(view.GetRowCellDisplayText(view.FocusedRowHandle, "Id"));
                    Int32 tradeId = Int32.Parse(view.GetRowCellDisplayText(view.FocusedRowHandle, "TradeId"));
                    Int32 rqmtId = Int32.Parse(view.GetRowCellDisplayText(view.FocusedRowHandle, "RqmtId"));
                    //Int32 templateId = Int32.Parse(view.GetRowCellDisplayText(view.FocusedRowHandle, "TemplateId"));
                    string templateName = view.GetRowCellDisplayText(view.FocusedRowHandle, "TemplateName");
                    string confirmLabel = view.GetRowCellDisplayText(view.FocusedRowHandle, "ConfirmLabel");
                    string cmt = view.GetRowCellDisplayText(view.FocusedRowHandle, "ConfirmCmt");
                    string nextStatusCode = view.GetRowCellValue(view.FocusedRowHandle, "NextStatusCode").ToString();
                    string activeFlag = view.GetRowCellValue(view.FocusedRowHandle, "ActiveFlag").ToString();

                    if (liveFaxNumber.Length > 2)
                    {
                        using (var ts = new TransactionScope())
                        {
                            UpdateTradeRqmtConfirmRow(confirmId, tradeId, rqmtId, templateName,
                               liveTransInd, liveFaxNumber, confirmLabel, cmt, nextStatusCode, activeFlag);

                            Vaulter vaulter = new Vaulter(sqlConnectionStr);
                            vaulter.VaultTradeRqmtConfirm(confirmId, null);

                            SendToFaxGateway(confirmId, cptySn, false, "", "SENT", false);

                            ts.Complete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while attempting to 'Change Send-To Address & Send/Resend' a Confirm Document." + Environment.NewLine +
                    "Error CNF-156 in " + FORM_NAME + ".ChangeFaxNoSendResend(): " + ex.Message,
                  MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                myTimer.Start();
            }
        }
Пример #4
0
        private void ResendPaper_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                myTimer.Stop();
                DocSendType docSendType;
                if (e.Item.Name == barBtnConfirmResendPaper.Name)
                    docSendType = DocSendType.PDF;
                else if (e.Item.Name == barBtnConfirmSendResendRTF.Name)
                    docSendType = DocSendType.RTF;
                else
                    throw new Exception("Internal Error: Invalid calling method: " + e.Item.Name);

                bool isRtf = false;
                string label = "";
                if (docSendType == DocSendType.PDF)
                    label = "Resend Paper";
                else if (docSendType == DocSendType.RTF)
                {
                    label = "Send/Resend RTF";
                    isRtf = true;
                }

                DialogResult result = XtraMessageBox.Show(label + "?", label,
                   MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (result == DialogResult.Yes)
                {
                    GridView view = gridViewConfirm;
                    Int32 confirmId = Int32.Parse(view.GetRowCellDisplayText(view.FocusedRowHandle, "Id"));
                    int rowHandle = GetGridViewFocusedRowHandle(gridViewSummary);
                    string cptySn = gridViewSummary.GetRowCellDisplayText(rowHandle, "CptySn").ToString();

                    using (var ts = new TransactionScope())
                    {
                        Vaulter vaulter = new Vaulter(sqlConnectionStr);
                        vaulter.VaultTradeRqmtConfirm(confirmId, null);

                        SendToFaxGateway(confirmId, cptySn, isRtf, "", "", false);

                        ts.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while attempting to Resend a Confirm Document." + Environment.NewLine +
                    "Error CNF-155 in " + FORM_NAME + ".ResendPaper_ItemClick(): " + ex.Message,
                  MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                myTimer.Start();
            }
        }
Пример #5
0
        private void SendPaper_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                myTimer.Stop();
                DialogResult result = XtraMessageBox.Show("Send Paper?", "Send Paper",
                  MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (result == DialogResult.Yes)
                {
                    try
                    {
                        GridView view = gridViewConfirm;

                        //Israel 11/19/2015 -- Replaced by Enable logic at gridViewConfirm_ShowGridMenu 
                        //string activeFlag = view.GetRowCellDisplayText(view.FocusedRowHandle, "ActiveFlag");
                        //if (activeFlag != "Y")
                        //{
                        //    XtraMessageBox.Show("Please select an active row.", "Send Paper", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //    return;
                        //}

                        Int32 confirmId = Int32.Parse(view.GetRowCellDisplayText(view.FocusedRowHandle, "Id"));
                        int rowHandle = GetGridViewFocusedRowHandle(gridViewSummary);
                        string cptySn = gridViewSummary.GetRowCellDisplayText(rowHandle, "CptySn").ToString();
                        using (var ts = new TransactionScope())
                        {
                            Vaulter vaulter = new Vaulter(sqlConnectionStr);
                            vaulter.VaultTradeRqmtConfirm(confirmId, null);

                            SendToFaxGateway(confirmId, cptySn, false, "", "", false);

                            ts.Complete();
                        }
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show("An error occurred while attempting to Send a Confirm Document." + Environment.NewLine +
                            "Error CNF-154 in " + FORM_NAME + ".SendPaper_ItemClick(): " + ex.Message,
                          MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            finally
            {
                myTimer.Start();
            }
        }
Пример #6
0
        private void SendContractForCurrentRqmt(Int32 ATradeId)
        {
            try
            {
                string cptySn = "";
                string tradeSysTicket = "";
                string filterStr = "TradeId = " + ATradeId.ToString();
                foreach (DataRow summaryRow in summaryDataTable.Select(filterStr))
                {
                    cptySn = summaryRow["CptySn"].ToString();
                    tradeSysTicket = summaryRow["TradeSysTicket"].ToString();
                }
                string ticketNo = ATradeId.ToString();
                string transMethodInd = "";
                string faxTelexNumber = "";
                string activeFlag = "";
                Int32 rqmtId = 0;
                Int32 confirmId = 0;
                //Int32 templateId = 0;

                string confirmLabel = "";
                string filterStr2 = "TradeId = " + ticketNo;
                foreach (DataRow row in confirmDataTable.Select(filterStr2))
                {
                    confirmLabel = row["ConfirmLabel"].ToString();

                    //Israel 11/19/2015 -- Added active flag test to prevent GUI-driven errors
                    activeFlag = row["ActiveFlag"].ToString();
                    if (confirmLabel == CONFIRM_LABEL_CONFIRM && activeFlag == "Y")
                    {
                        confirmId = Int32.Parse(row["Id"].ToString());
                        rqmtId = Int32.Parse(row["RqmtId"].ToString());
                        //templateId = Int32.Parse(row["TemplateId"].ToString());
                        transMethodInd = row["FaxTelexInd"].ToString();
                        faxTelexNumber = row["FaxTelexNumber"].ToString();
                        break;
                    }
                }

                //string contractBody = GetContractFromVault(confirmId, 0);
                TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr);
                TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto();
                //Int64 confirmIdLong = Convert.ToInt64(confirmId);
                trcBlobData = trcBlobDal.Get(confirmId);
                DocumentFormat docFormat = Utils.GetDocumentFormat(trcBlobData.ImageFileExt);

                using (var ts = new TransactionScope())
                {
                    Vaulter vaulter = new Vaulter(sqlConnectionStr);
                    vaulter.VaultTradeRqmtConfirm(confirmId, null);

                    if (transMethodInd.Length > 0 && faxTelexNumber.Length > 2)
                        SendToFaxGateway(transMethodInd, faxTelexNumber, CONFIRM_LABEL_CONFIRM, trcBlobData.DocBlob, docFormat,
                              cptySn, ATradeId,tradeSysTicket, rqmtId, confirmId, false, "", "", "", false);

                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred while preparing a Confirm to send to the fax gateway for the following Trade Id:" + ATradeId + Environment.NewLine +
                     "Error CNF-149 in " + FORM_NAME + ".SendContractForCurrentRqmt(): " + ex.Message);
            }
        }
Пример #7
0
        private void CallEditContractForm(byte[] AContractBody, DocumentFormat ADocFormat, string ATemplateName,
           string ASavedTransMethod, string ASavedFaxNumber, Int32 ARqmtConfirmId, string ACmt,
           string ANextStatusCode, string AActiveFlag, string APreparerCanSendFlag)
        {

            try
            {
                //Get summary grid data
                GridView view = gridViewSummary;
                int rowHandle = GetGridViewFocusedRowHandle(view);
                string tradingSystem = view.GetRowCellDisplayText(rowHandle, "TrdSysCode").ToString();
                Int32 tradeId = Int32.Parse(view.GetRowCellDisplayText(rowHandle, "TradeId"));
                string ticketNo = view.GetRowCellDisplayText(rowHandle, "TradeSysTicket").ToString();
                string cptySn = view.GetRowCellDisplayText(rowHandle, "CptySn").ToString();
                string bookingCoSn = view.GetRowCellDisplayText(rowHandle, "BookingCoSn").ToString();
                DateTime dtTradeDt = DateTime.MinValue;
                string faxEmailSendTo = "";
                string faxEmailTypeInd = "";
                try
                {
                    dtTradeDt = (DateTime)view.GetRowCellValue(rowHandle, "TradeDt");
                }
                catch (Exception excep)
                {
                }
                string cdtyCode = view.GetRowCellDisplayText(rowHandle, "CdtyCode").ToString();
                //string cdtyGroupCode = view.GetRowCellDisplayText(rowHandle, "CdtyGrpCode").ToString();
                string sttlType = view.GetRowCellDisplayText(rowHandle, "SttlType").ToString();
                string confirmLabel = "";
                bool insertNewPaper = false;

                //Get rqmt Id from table for existing ones, from row for new ones.
                int rqmtId = 0;
                string currentStatusCode = "";
                if (ARqmtConfirmId > 0)
                {
                    rqmtId = GetConfirmRqmtId(Convert.ToInt32(ARqmtConfirmId));
                    confirmLabel = GetConfirmData(Convert.ToInt32(ARqmtConfirmId), "ConfirmLabel");
                    if (confirmLabel == CONFIRM_LABEL_CONFIRM)
                    {
                        currentStatusCode = GetTradeRqmtData(rqmtId, "Status");
                        insertNewPaper = currentStatusCode == "NEW";
                    }
                    else
                        currentStatusCode = gridViewConfirm.GetRowCellValue(gridViewConfirm.FocusedRowHandle, "NextStatusCode").ToString();

                    faxEmailSendTo = gridViewConfirm.GetRowCellValue(gridViewConfirm.FocusedRowHandle, "FaxTelexNumber").ToString();
                    faxEmailTypeInd = gridViewConfirm.GetRowCellValue(gridViewConfirm.FocusedRowHandle, "FaxTelexInd").ToString();

                }
                else //ARqmtConfirmId == 0
                {
                    rqmtId = int.Parse(gridViewRqmt.GetRowCellDisplayText(gridViewRqmt.FocusedRowHandle, "Id"));
                    insertNewPaper = true;

                    //Set this only for the first one created, i.e., for the contract.
                    if (gridViewConfirm.RowCount == 0)
                    {
                        currentStatusCode = gridViewRqmt.GetRowCellDisplayText(gridViewRqmt.FocusedRowHandle, "Status");
                        confirmLabel = CONFIRM_LABEL_CONFIRM;
                    }
                    else
                    {
                        currentStatusCode = "PREP";
                    }
                }

                //Init EditContractForm with data
                //It must be completely destroyed and re-created each time or bad things happen.

                //Israel 9/2/2015 -- implementing RichEditControl
                //if (editContractForm == null)
                //    editContractForm = new frmEditContract();
                //editContractForm.marginToken = Properties.Settings.Default.MarginToken;
                editContractForm.marginToken = "[MARGIN TOKEN]";
                editContractForm.isContract = confirmLabel == CONFIRM_LABEL_CONFIRM;

                editContractForm.statusbarTemplateName.Caption = ATemplateName;
                editContractForm.Text = "Confirmation: " + tradingSystem + "-" + ticketNo;
                string tradeDt = String.Format("{0:MM/dd/yyyy}", dtTradeDt);
                editContractForm.lblAgreements.Text = CallGetAgreementInfo(cptySn, bookingCoSn, tradeDt);
                editContractForm.barEditWorkflowComments.EditValue = ACmt;
                editContractForm.rqmtStatusColorTable = this.rqmtStatusColorTable;

                //5/19/2009 Israel -- Add economic data to Contract Edit form
                editContractForm.lblEconData.Text = GetEconomicData();

                //5/19/2009 Israel -- Only allow print of existing contracts.
                editContractForm.barBtnWorkflowPrint.Enabled = ARqmtConfirmId > 0;

                //Israel 9/18/2015 
                //Get fax number data and send to form
                //string oldFaxNo = GetInfMgrFaxNo(cptySn);
                //string[] getCptyFaxNoResult = GetCptyFaxNo(cptySn, cdtyCode, sttlType);
                //if (getCptyFaxNoResult[0] != null)
                //    transMethod = getCptyFaxNoResult[0];
                //if (getCptyFaxNoResult[1] != null)
                //    newFaxNo = getCptyFaxNoResult[1];

                editContractForm.SetFaxNumbers(faxEmailSendTo, ASavedFaxNumber);
                editContractForm.settingsDir = this.appSettingsDir;

                //bool isFaxNumber = oldFaxNo.Trim().Length > 1 ||
                //                   newFaxNo.Trim().Length > 1 ||
                //                   ASavedFaxNumber.Trim().Length > 1;

                //Always true since currently fax number = email or fax-- it gets picked apart later.
                bool isFaxNumber = true;

                //Israel 9/16/2015 -- Everyone approves.
                bool isPaperCreator = false;
                frmEditRichContract.p_UserId = p_UserId;

                editContractForm.InitForm(AContractBody, ADocFormat, clauseHeaderTable, clauseBodyTable, tradingSystem,
                   currentStatusCode, isContractApprove, bookingCoSn, cptySn, isFaxNumber, APreparerCanSendFlag);

                if (currentStatusCode == "SENT")
                {
                    editContractForm.richeditConfirm.ReadOnly = true;
                    editContractForm.ChangeBarCommentItemsVisibility(false);
                }
                else
                {
                    editContractForm.richeditConfirm.ReadOnly = false;
                    editContractForm.ChangeBarCommentItemsVisibility(true);
                }

                string transMethodInd = "";
                string faxTelexNumber = "";
                if (editContractForm.ShowDialog(this) == DialogResult.OK)
                {
                    using (var ts = new TransactionScope())
                    {
                        //long tradeRqmtConfirmId = 0;
                        transMethodInd = editContractForm.liveTransMethod.Substring(0, 1);
                        faxTelexNumber = editContractForm.liveFaxNumber;
                        string cmt = editContractForm.barEditWorkflowComments.EditValue.ToString();
                        bool isMarginToken = editContractForm.isMarginToken;
                        string selectedStatusCode = editContractForm.barComboWorkflowStatus.EditValue.ToString();
                        string nextStatusCode = selectedStatusCode;

                        //Send to Credit status if unresolved margin token
                        if (selectedStatusCode != "PREP" && isMarginToken)
                            selectedStatusCode = "CRDT";

                        if (editContractForm.isApproveAndSend)
                        {
                            selectedStatusCode = "OK_TO_SEND";
                            if (!editContractForm.isContract)
                                nextStatusCode = selectedStatusCode;
                        }

                        //Insert/Update trade_rqmt_confirm row
                        long rqmtConfirmIdUpd = UpdateTradeRqmtConfirmRow(ARqmtConfirmId, tradeId, rqmtId, ATemplateName,
                                             transMethodInd, faxTelexNumber, confirmLabel, cmt, nextStatusCode, AActiveFlag);

                        //Update trade_rqmt 
                        if (currentStatusCode != selectedStatusCode &&
                            editContractForm.isContract)
                        {
                            string reference = GetTradeRqmtData(rqmtId, "Reference");
                            string rqmtCmt = GetTradeRqmtData(rqmtId, "Cmt");
                            CallUpdateTradeRqmts(tradeId, rqmtId, SEMPRA_RQMT, selectedStatusCode, DateTime.Today, reference, rqmtCmt, true);
                        }
                        //Store contract in vault
                        string strTradeDt = dtTradeDt.ToString("MM/dd/yyyy");
                        string strToday = DateTime.Today.ToString("MM/dd/yyyy");
                        string trdSysCode = tradingSystem.Substring(0, 1);

                        //Insert or update trade_rqmt_confirm_row
                        TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr);
                        TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto();
                        trcBlobData.ImageFileExt = Utils.GetDocFormatFileExt(ADocFormat);
                        trcBlobData.DocBlob = WSUtils.GetByteArrayFromDocument(editContractForm.richeditConfirm, ADocFormat);
                        trcBlobData.TradeRqmtConfirmId = ARqmtConfirmId;

                        int rowCount = trcBlobDal.GetCount(ARqmtConfirmId);
                        if (rowCount > 0)
                            trcBlobDal.Update(trcBlobData);
                        else
                            trcBlobDal.Insert(trcBlobData);

                        if (currentStatusCode == "SENT")
                        {
                            Vaulter vaulter = new Vaulter(sqlConnectionStr);
                            vaulter.VaultTradeRqmtConfirm(ARqmtConfirmId, null);
                        }

                        if (editContractForm.isApproveAndSend)
                            SendToFaxGateway(transMethodInd, faxTelexNumber, confirmLabel, trcBlobData.DocBlob, ADocFormat,
                               cptySn, tradeId, ticketNo, rqmtId, Convert.ToInt32(ARqmtConfirmId), false,
                               "", "", "", false);

                        ts.Complete();
                    }
                }
                else
                {
                    transMethodInd = editContractForm.liveTransMethod.Substring(0, 1);
                    faxTelexNumber = editContractForm.liveFaxNumber;
                    if (ARqmtConfirmId > 0 &&
                       ((ASavedTransMethod.Substring(0, 1) != transMethodInd) ||
                        (ASavedFaxNumber != faxTelexNumber)))
                    {
                        //Update trade_rqmt_confirm row if contract editor was cancelled but number
                        //was still changed.
                        UpdateTradeRqmtConfirmRow(ARqmtConfirmId, tradeId, rqmtId, ATemplateName,
                           transMethodInd, faxTelexNumber, confirmLabel, ACmt, ANextStatusCode, AActiveFlag);
                    }
                }

                //int rowHandle = 0;
                rowHandle = gridViewSummary.FocusedRowHandle;
                gridViewSummary_FocusedRowChanged(gridViewSummary,
                   new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs(0, rowHandle));
                gridViewSummary.SelectRow(rowHandle);

                //editContractForm.Close();
                //editContractForm.Dispose();
                //editContractForm = null;
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred while attempting to process a confirm document." + Environment.NewLine +
                     "Error CNF-124 in " + FORM_NAME + ".CallEditContractForm(): " + ex.Message);
            }
        }