示例#1
0
        private void ExecPrintFromEditRichContract(int pConfirmId)
        {
            TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr);
            TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto();
            //Int64 confirmIdLong = Convert.ToInt64(pConfirmId);
            trcBlobData = trcBlobDal.Get(pConfirmId);
            DocumentFormat docFormat = Utils.GetDocumentFormat(trcBlobData.ImageFileExt);

            if (trcBlobData.DocBlob.Length > 0)
            {
                //byte[] docBytes = System.Text.Encoding.UTF8.GetBytes(AContractBody);
                using (MemoryStream contractStream = new MemoryStream(trcBlobData.DocBlob))
                {
                    editContractForm.richeditConfirm.LoadDocument(contractStream, docFormat);
                }
            }
            editContractForm.printItem1.PerformClick();
        }
示例#2
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);
            }
        }
示例#3
0
        private void SendToFaxGateway(Int32 AConfirmId, string ACptySn, bool ARtf,
           string ATitle, string AMessage, bool ACoverPage)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                string faxTelexInd = "";
                string faxTelexNumber = "";
                string confirmLabel = "";
                Int32 tradeId = 0;
                string tradeSysTicket = "";
                Int32 rqmtId = 0;
                //Int32 templateId = 0;
                string cptySn = "";

                string filterStr = "Id = " + AConfirmId.ToString();
                foreach (DataRow row in confirmDataTable.Select(filterStr))
                {
                    faxTelexInd = row["FaxTelexInd"].ToString();
                    faxTelexNumber = row["FaxTelexNumber"].ToString();
                    confirmLabel = row["ConfirmLabel"].ToString();
                    tradeId = Int32.Parse(row["TradeId"].ToString());
                    tradeSysTicket = GetTradeSummaryData(tradeId, "TradeSysTicket"); //row["TradeSysTicket"].ToString();
                    rqmtId = Int32.Parse(row["RqmtId"].ToString());
                    //templateId = Int32.Parse(row["TemplateId"].ToString());
                }

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

                string title = "";
                string message = "";
                if (ACoverPage)
                {
                    title = ATitle;
                    message = AMessage;
                }

                SendToFaxGateway(faxTelexInd, faxTelexNumber, confirmLabel, trcBlobData.DocBlob, docFormat, ACptySn, tradeId, tradeSysTicket, rqmtId,
                    Convert.ToInt32(AConfirmId), ARtf, "", title, message, ACoverPage);               

            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred while attempting to prepare then request SendToFaxGateway([14 parms]) using the following values:" + Environment.NewLine +
                    "Confirm Id: " + AConfirmId.ToString() + ", Counterparty Short Name: " + ACptySn + ", IsRtf?: " + ARtf + Environment.NewLine +
                    "Title: " + ATitle + ", Message: " + AMessage + ", IncludeCoverPage?: " + ACoverPage + Environment.NewLine +
                     "Error CNF-144 in " + FORM_NAME + ".SendToFaxGateway([6 parms]): " + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
示例#4
0
        private void DisplayContract(int ATradeRqmtConfirmId, bool AEMailEnabled)
        {
            try
            {
                //Israel 9/21/2015
                //rtfContract.Rtf = AContractBody;
                //rtfContract.SelectAll();
                //rtfContract.SelectionProtected = true;
                //rtfContract.Select(5, 0);

                TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr);
                TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto();
                //Int64 confirmIdLong = Convert.ToInt64(ATradeRqmtConfirmId);
                trcBlobData = trcBlobDal.Get(ATradeRqmtConfirmId);
                DocumentFormat docFormat = Utils.GetDocumentFormat(trcBlobData.ImageFileExt);

                if (trcBlobData.DocBlob.Length > 0)
                {
                    using (MemoryStream contractStream = new MemoryStream(trcBlobData.DocBlob))
                    {
                        richeditConfirmBrowser.LoadDocument(contractStream, docFormat);
                    }
                }

                tabctrlBrowserApps.SelectedTabPage = tabpgContract;
                //barDockControl3.Visible = false;
                //barBrowserStatusBar.Visible = false;
                btnEmail.Enabled = AEMailEnabled;
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred while attempting to display a Confirm using the following values:" + Environment.NewLine +
                     "Confirm Id: " + ATradeRqmtConfirmId.ToString() + ", EMail Option enabled?: " + AEMailEnabled + Environment.NewLine +
                      "Error CNF-143 in " + FORM_NAME + ".DisplayContract(): " + ex.Message);
            }
        }
示例#5
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);
            }
        }
示例#6
0
        private void GetAutoContract(GridView AGridView)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                CGMethod cgMethod = CGMethod.GetContract;
                string tradingSystem = "";
                string trdSysTicket = "";
                string tradeIdStr = "";
                string rqmtId = "";
                string contractType = "NEW";
                //string contractBody = "";
                byte[] contractBody = null;
                string templateName = "";
                string preparerCanSendFlag = "";
                string savedTransMethod = "FAX";
                string savedTransInd = "F";
                string savedFaxNumber = "";
                string cmt = "";
                string nextStatusCode = "";
                string statusCode = "";
                string activeFlag = "Y";
                //Int32 templateId = 0;
                Int32 rqmtConfirmId = 0;
                Int32 tradeId = 0;

                int summaryRowHandle = GetGridViewFocusedRowHandle(gridViewSummary);
                tradingSystem = gridViewSummary.GetRowCellDisplayText(summaryRowHandle, "TrdSysCode").ToString();
                trdSysTicket = gridViewSummary.GetRowCellDisplayText(summaryRowHandle, "TradeSysTicket").ToString();
                tradeIdStr = gridViewSummary.GetRowCellDisplayText(summaryRowHandle, "TradeId").ToString();
                tradeId = Int32.Parse(tradeIdStr);
                //int tradeIdInt = int.Parse(ticketNo);

                //If adding a new confirm row, this will get the correct status. If the focus is on the confirm
                //row and the wrong rqmt row is focused, this bogus status will get replaced by the correct one below.
                statusCode = gridViewRqmt.GetRowCellDisplayText(gridViewRqmt.FocusedRowHandle, "Status").ToString();

                //If only one row they could be accessing it from the rqmt gid
                //If more then one access is only from the confirm grid so we know the focus.
                int rowHandle = 0;
                rowHandle = AGridView.FocusedRowHandle;

                //if (gridViewConfirm.RowCount == 1)
                //   rowHandle = gridViewConfirm.GetVisibleRowHandle(0);
                //else
                //   rowHandle = gridViewConfirm.FocusedRowHandle;

                //if (AGridView.Name == gridViewRqmt.Name)
                if (gridViewConfirm.RowCount > 0)
                {
                    rqmtId = gridViewRqmt.GetRowCellDisplayText(rowHandle, "Id").ToString();
                    rqmtConfirmId = GetContractRowId(tradeId);
                    savedTransInd = GetContractConfirmData(tradeId, "FaxTelexInd");
                    savedFaxNumber = GetContractConfirmData(tradeId, "FaxTelexNumber");
                    savedTransMethod = GetFaxMethodFromInd(savedTransInd);
                    templateName = GetContractConfirmData(tradeId, "TemplateName");
                    preparerCanSendFlag = GetContractConfirmData(tradeId, "PreparerCanSendFlag");
                    //templateId = GetContractTemplateId(tradeId);
                    cmt = GetContractConfirmData(tradeId, "ConfirmCmt");
                    nextStatusCode = GetContractConfirmData(tradeId, "NextStatusCode");
                    statusCode = gridViewRqmt.GetRowCellDisplayText(rowHandle, "Status").ToString();
                }
                else if (gridViewConfirm.RowCount > 0)
                {
                    rqmtId = gridViewConfirm.GetRowCellDisplayText(rowHandle, "RqmtId").ToString();
                    rqmtConfirmId = Int32.Parse(gridViewConfirm.GetRowCellDisplayText(rowHandle, "Id").ToString());
                    savedTransInd = gridViewConfirm.GetRowCellDisplayText(rowHandle, "FaxTelexInd").ToString();
                    savedFaxNumber = gridViewConfirm.GetRowCellDisplayText(rowHandle, "FaxTelexNumber").ToString();
                    savedTransMethod = GetFaxMethodFromInd(savedTransInd);
                    templateName = gridViewConfirm.GetRowCellDisplayText(rowHandle, "TemplateName").ToString();
                    preparerCanSendFlag = GetContractConfirmData(tradeId, "PreparerCanSendFlag");
                    //templateId = Int32.Parse(gridViewConfirm.GetRowCellDisplayText(rowHandle, "TemplateId").ToString());
                    cmt = gridViewConfirm.GetRowCellDisplayText(rowHandle, "ConfirmCmt").ToString();
                    nextStatusCode = gridViewConfirm.GetRowCellValue(rowHandle, "NextStatusCode").ToString();

                    int iRqmtId = int.Parse(rqmtId);
                    statusCode = GetTradeRqmtData(iRqmtId, "Status");
                }

                bool okToCallEditor = false;
                //bool contractExists = rqmtConfirmId > 0;

                string getDocumentUrl = Properties.Settings.Default.ExtSvcAPIBaseUrl;
                string svcUserName = Properties.Settings.Default.ExtSvcAPIUserName;
                string svcPassword = Properties.Settings.Default.ExtSvcAPIPassword;
                ConfirmDocsAPIDal confirmDocsDal = ConfirmDocsAPIDal.Instance(getDocumentUrl, svcUserName, svcPassword);

                string docFileExt = "";
                DocumentFormat docFormat = DocumentFormat.Undefined;
                if (statusCode == "NEW")
                {
                    try
                    {
                        //Israel 12/09/2015 -- Provide cancel when no template given.
                        bool okToCallServer = true;
                        if (String.IsNullOrEmpty(templateName))
                        {
                            DialogResult result = XtraMessageBox.Show("No template has been supplied for this trade. Continue with the request?" + Environment.NewLine +
                                "(If you choose 'No' you can retry by selecting a Manual Contract instead.)", "Missing Template",
                               MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                            if (result == DialogResult.No)
                                okToCallServer = false;
                        }

                        if (okToCallServer)
                        {
                            contractBody = confirmDocsDal.GetConfirm(tradingSystem, trdSysTicket, templateName, out docFileExt);
                            okToCallEditor = true;
                            if (contractBody == null || contractBody.Length < 2)
                            {
                                if (editContractForm.richeditConfirm.Document.Length > 0)
                                {
                                    DocumentRange docRange = editContractForm.richeditConfirm.Document.CreateRange(0, editContractForm.richeditConfirm.Document.Length);
                                    editContractForm.richeditConfirm.Document.Delete(docRange);
                                }
                                MessageBox.Show("The Confirmation Web Service call returned a blank document.", "Empty Confirm", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        okToCallEditor = false;
                        //string message = "An error occurred while requesting a Confirm from the GetConfirmations Web Service." + Environment.NewLine +
                        //    "Error CNF-282 in GetAutoContract: " + ex.Message;
                        //string caption = MAIN_FORM_ERROR_CAPTION;
                        //MessageBoxIcon icon = MessageBoxIcon.Error;
                        //if (ex.Message.IndexOf("Confirm Web Service(s) not available") > -1)
                        //{
                        //    message = "A Confirm Web Service is not available. Please contact ConfirmSupport." + Environment.NewLine;
                        //    message += "When it is available just try again-- no need to restart " + APP_NAME + ".";
                        //    caption = "Confirm Web Service Unavailable";
                        //    icon = MessageBoxIcon.Exclamation;
                        //}
                        //XtraMessageBox.Show(message, caption, MessageBoxButtons.OK, icon);
                        XtraMessageBox.Show("An error occurred while requesting a Confirm from the GetConfirmations Web Service." + Environment.NewLine +
                              "Error CNF-282 in " + FORM_NAME + ".GetAutoContract(): " + ex.Message,
                            MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else //if (contractExists)
                {
                    //Retrieve contract body from vault.
                    //contractBody = GetContractFromVault(rqmtConfirmId, 0);
                    TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto();
                    TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr);
                    trcBlobData = trcBlobDal.Get(rqmtConfirmId);
                    contractBody = trcBlobData.DocBlob;
                    docFileExt = trcBlobData.ImageFileExt;
                    //Israel 11/20/2015 -- Broken rows caused an error when bringing up the screen.
                    if (contractBody != null)
                        okToCallEditor = true;
                }
                //else
                //    XtraMessageBox.Show("Contract doesn't exist. Status must be NEW to add new contract");

                if (nextStatusCode == "")
                    nextStatusCode = "PREP";

                //Israel 11/20/2015 -- Broken rows caused an error when calling GetDocumentFormat.
                //docFormat = Utils.GetDocumentFormat(docFileExt);
                //docFormat = DocumentFormat.OpenXml;
                if (okToCallEditor)
                {
                    docFormat = Utils.GetDocumentFormat(docFileExt);
                    CallEditContractForm(contractBody, docFormat, templateName, savedTransMethod,
                       savedFaxNumber, rqmtConfirmId, cmt, nextStatusCode, activeFlag,preparerCanSendFlag);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while requesting a Confirm from the GetConfirmations Web Service." + Environment.NewLine +
                      "Error CNF-123 in " + FORM_NAME + ".GetAutoContract(): " + ex.Message,
                    MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }