예제 #1
0
        private void CallAddRqmt(string ARqmtCode, string ANoConfReason, string ACmt)
        {
            try
            {
                string finalApproval = "N";
                int finalApprovalIgnored = 0;
                int addRqmtRow = 0;
                GridView view = gridViewSummary;
                if (view.SelectedRowsCount > 0)
                {
                    //Get the list ahead of time, since the foreach code changes the list's contents/order
                    int[] selectedRows = view.GetSelectedRows();
                    List<DataRow> rows = new List<DataRow>();

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

                        foreach (DataRow rowSummary in rows)
                        {
                            finalApproval = rowSummary["FinalApprovalFlag"].ToString();
                            if (finalApproval == "Y")
                            {
                                finalApprovalIgnored++;
                                continue;
                            }

                            TradeRqmtDal tradeRqmtDal = new TradeRqmtDal(sqlConnectionStr);
                            Int32 tradeId = Int32.Parse(rowSummary["TradeId"].ToString());
                            string reason = String.Empty;
                            if (ARqmtCode == "NOCNF")
                                reason = ANoConfReason;
                           Int32 rqmtId= tradeRqmtDal.AddTradeRqmt(tradeId, ARqmtCode, reason, ACmt);
                            //add traderqmtconfirm
                           if (ARqmtCode =="XQCSP")
                            UpdateTradeRqmtConfirmRow(0, tradeId,
                                        rqmtId, null, null, null, CONFIRM_LABEL_CONFIRM, null, null, "Y");
                        }

                    if (finalApprovalIgnored > 0)
                        XtraMessageBox.Show("Final Approved trades ignored: " + finalApprovalIgnored.ToString(), // + Environment.NewLine
                            //+ "Determine Action trades processed: " + determineActionRow.ToString() + Environment.NewLine,
                             "Add Rqmt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred while attempting to add one or more new requirements." + Environment.NewLine +
                    "Rqmt Code: " + ARqmtCode + ", No Confirm Reason: " + ANoConfReason + ", Comment: " + ACmt + Environment.NewLine +
                     "Error CNF-071 in " + FORM_NAME + ".CallAddRqmt(): " + ex.Message);
            }
        }
예제 #2
0
        public void CallUpdateTradeRqmts(long ATradeId, long ARqmtId, string ARqmtCode, string AStatusCode,
           DateTime AStatusDate, string AReference, string AComment, bool AUpdateLocalTableNow)
        {
            try
            {
                TradeRqmtDto tradeRqmtDto = new TradeRqmtDto();
                tradeRqmtDto.TradeId = Convert.ToInt32(ATradeId);
                tradeRqmtDto.Id = Convert.ToInt32(ARqmtId);
                tradeRqmtDto.RqmtCode = ARqmtCode;
                tradeRqmtDto.CompletedDt = AStatusDate;
                tradeRqmtDto.StatusCode = AStatusCode;
                tradeRqmtDto.Cmt = AComment;
                tradeRqmtDto.Reference = AReference;

                List<TradeRqmtDto> tradeRqmtList = new List<TradeRqmtDto>();
                tradeRqmtList.Add(tradeRqmtDto);

                TradeRqmtDal tradeRqmtDal = new TradeRqmtDal(sqlConnectionStr);
                if (AUpdateLocalTableNow)
                {
                    int rowsUpdated = 0;
                    rowsUpdated = tradeRqmtDal.UpdateTradeRqmts(tradeRqmtList);

                    if (rowsUpdated > 0)
                        UpdateLocalRqmtData(tradeRqmtList);
                }
            }
            catch (Exception ex)
            {
                string dateString = String.Empty;
                try
                {
                    dateString = AStatusDate.ToString("dd-MMM-yyyy");
                }
                catch (Exception except)
                {
                    dateString = "[Status Date conversion failed: " + except.Message + "]";
                }

                throw new Exception("An error occurred while attempting to update a Trade Requirment using the following values:" + Environment.NewLine +
                    "Trade Id: " + ATradeId.ToString() + ", Rqmt Id: " + ARqmtId.ToString() + ", Rqmt Code: " + ARqmtCode + ", Status Code: " + AStatusCode + Environment.NewLine +
                    "Status Date: " + dateString + ", Reference: " + AReference + ", Comment: " + AComment + ", UpdateLocalTableNow?: " + AUpdateLocalTableNow + Environment.NewLine +
                     "Error CNF-134 in " + FORM_NAME + ".CallUpdateTradeRqmts(): " + ex.Message);
            }
        }
예제 #3
0
        private void CallUpdateEditRqmt(bool[] AUpdatedRqmts, string[] AStatusCodes, DateTime[] AStatusDates,
                     string[] ASecondChecks, string[] ARefs, string[] ARqmtCmts, bool[,] AChangedFields)
        {
            try
            {
                string filterStr = "";
                int rqmtsToUpdate = 0;
                //Find out how many requirements need to be updated.
                for (int i = 0; i < frmEditRqmt.RQMT_ARRAY_MAX; i++)
                    if (AUpdatedRqmts[i])
                        rqmtsToUpdate++;

                GridView view = gridViewSummary;
                //Calculate how many individual requirements will be updated.
                int rowsToUpdate = view.SelectedRowsCount * rqmtsToUpdate;
                int editRqmtRecIdx = 0;
                //int prelimApprvOverride = 0;
                string finalApproval = "N";
                int finalApprovalIgnored = 0;
                //tradeRqmtRequest[] rqmtRequestArray = new tradeRqmtRequest[rowsToUpdate];
                List<TradeRqmtDto> tradeRqmtDataList = new List<TradeRqmtDto>();

                //int tradeId = 0;
                bool isSingleRow = view.SelectedRowsCount == 1;
                //if (isSingleRow)
                //tradeId = view.GetRowCellDisplayText(rowHandle, "TradeId").ToString();

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

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

                //Read through all selected rows.
                foreach (DataRow rowSummary in rows)
                {
                    //foreach (int rowHandle in view.GetSelectedRows())
                    //{
                    finalApproval = rowSummary["FinalApprovalFlag"].ToString();
                    if (finalApproval == "Y")
                    {
                        finalApprovalIgnored++;
                        continue;
                    }

                    //For each row read through all requirements
                    for (int i = 0; i < frmEditRqmt.RQMT_ARRAY_MAX; i++)
                        //Process only those requirements that have been edited. 
                        if (AUpdatedRqmts[i])
                        {
                            //Set a filter for the edited rqmt
                            string tradeId = rowSummary["TradeId"].ToString();
                            filterStr = "TradeId = " + tradeId +
                               " and Rqmt = '" + editRqmtForm.RQMT_CODES[i] + "'";
                            //Read the RqmtData row
                            foreach (DataRow row in rqmtDataTable.Select(filterStr))
                            {
                                TradeRqmtDto tradeRqmtDto = new TradeRqmtDto();
                                tradeRqmtDto.TradeId = Int32.Parse(tradeId);
                                tradeRqmtDto.Id = Int32.Parse(row["Id"].ToString());
                                tradeRqmtDto.RqmtCode = editRqmtForm.RQMT_CODES[i];
                                tradeRqmtDto.StatusDateSpecified = true;

                                //Single mode- since the current data value is passed to the edit form
                                //             we also get it back so just reload it.
                                //Multi mode- if data was changed on the form get the form data. 
                                //            Otherwise, reload the current data from the row.

                                string statusCode = AStatusCodes[i];
                                //Since there is no way to do data entry validation for multis we need to do it here.
                                //If the same person who prelim approved a trade tries to also approve it we catch
                                //it here and set it back to prelim.
                                //Israel 9/28/2015
                                //if (editRqmtForm.SingleOrMultiMode == frmEditRqmt.MULTI &&
                                //    AStatusCodes[i] == "APPR" &&
                                //    row["SecondCheckFlag"].ToString() == "Y" &&
                                //    toolbarOrWindowsUserId == row["PrelimAppr"].ToString())
                                //{
                                //    statusCode = "PRELIM";
                                //    prelimApprvOverride++;
                                //}

                                //6/9/09 Israel - Don't allow Our Paper status change if still in contract edit mode.
                                bool okToEdit = true;
                                if (row["Rqmt"].ToString() == SEMPRA_RQMT &&
                                    noEditSempraRqmtStatus.IndexOf(row["Status"].ToString()) > -1)
                                    okToEdit = false;

                                if ((editRqmtForm.SingleOrMultiMode == frmEditRqmt.SINGLE ||
                                    (editRqmtForm.SingleOrMultiMode == frmEditRqmt.MULTI && AChangedFields[i, frmEditRqmt.FIELD_STATUS_CODE])) &&
                                    okToEdit)
                                    //rqmtRequestArray[editRqmtRecIdx].status = statusCode;
                                    tradeRqmtDto.StatusCode = statusCode;
                                else
                                    //rqmtRequestArray[editRqmtRecIdx].status = row["Status"].ToString();
                                    tradeRqmtDto.StatusCode = row["Status"].ToString(); ;

                                if (editRqmtForm.SingleOrMultiMode == frmEditRqmt.SINGLE ||
                                   (editRqmtForm.SingleOrMultiMode == frmEditRqmt.MULTI &&
                                    AChangedFields[i, frmEditRqmt.FIELD_STATUS_DATE]))
                                    //rqmtRequestArray[editRqmtRecIdx].statusDate = AStatusDates[i];
                                    tradeRqmtDto.CompletedDt = AStatusDates[i];
                                else
                                    //rqmtRequestArray[editRqmtRecIdx].statusDate = (DateTime)row["CompletedDt"];
                                    tradeRqmtDto.CompletedDt = (DateTime)row["CompletedDt"]; ;

                                if (editRqmtForm.SingleOrMultiMode == frmEditRqmt.SINGLE ||
                                   (editRqmtForm.SingleOrMultiMode == frmEditRqmt.MULTI &&
                                    AChangedFields[i, frmEditRqmt.FIELD_SECOND_CHECK]))
                                    //rqmtRequestArray[editRqmtRecIdx].secondCheck = ASecondChecks[i];
                                    tradeRqmtDto.SecondCheckFlag = ASecondChecks[i];
                                else
                                    //rqmtRequestArray[editRqmtRecIdx].secondCheck = row["SecondCheckFlag"].ToString();
                                    tradeRqmtDto.SecondCheckFlag = row["SecondCheckFlag"].ToString();

                                if (editRqmtForm.SingleOrMultiMode == frmEditRqmt.SINGLE ||
                                   (editRqmtForm.SingleOrMultiMode == frmEditRqmt.MULTI &&
                                    AChangedFields[i, frmEditRqmt.FIELD_REFERENCE]))
                                    //rqmtRequestArray[editRqmtRecIdx].reference = ARefs[i];
                                    tradeRqmtDto.Reference = ARefs[i];
                                else
                                    //rqmtRequestArray[editRqmtRecIdx].reference = row["Reference"].ToString();
                                    tradeRqmtDto.Reference = row["Reference"].ToString();

                                if (editRqmtForm.SingleOrMultiMode == frmEditRqmt.SINGLE ||
                                   (editRqmtForm.SingleOrMultiMode == frmEditRqmt.MULTI &&
                                    AChangedFields[i, frmEditRqmt.FIELD_RQMT_CMT]))
                                    //rqmtRequestArray[editRqmtRecIdx].comment = ARqmtCmts[i];
                                    tradeRqmtDto.Cmt = ARqmtCmts[i];
                                else
                                    //rqmtRequestArray[editRqmtRecIdx].comment = row["Cmt"].ToString();
                                    tradeRqmtDto.Cmt = row["Cmt"].ToString();

                                tradeRqmtDataList.Add(tradeRqmtDto);

                                //Increment rqmtRequestArray index
                                editRqmtRecIdx++;
                                //There may be more than one requirement found so only process the first one.
                                //This situation is sorted out by the update process.
                                break;
                            }
                        }
                }

                TradeRqmtDal tradeRqmtDal = new TradeRqmtDal(sqlConnectionStr);

                //For single row update synchronously and update grids.
                //if (isSingleRow && rqmtRequestArray[0] != null)
                if (isSingleRow && tradeRqmtDataList.Count > 0)
                {
                    int rowsUpdated = 0;
                    rowsUpdated = tradeRqmtDal.UpdateTradeRqmts(tradeRqmtDataList);
                    if (rowsUpdated > 0)
                        UpdateLocalRqmtData(tradeRqmtDataList);
                }

                //Israel 9/28/2015
                //if (prelimApprvOverride > 0 || finalApprovalIgnored > 0)
                if (finalApprovalIgnored > 0)
                    XtraMessageBox.Show("Final Approved trades ignored: " + finalApprovalIgnored.ToString() + Environment.NewLine,
                         "Edit Requirements", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred while attempting to edit a requirement." + Environment.NewLine +
                    "Error CNF-065 in " + FORM_NAME + ".CallUpdateEditRqmt(): " + ex.Message);
            }
        }