public void CreateUserComment()
        {
            DataRow dr = null;
            bool deleteUserComment = false;
            //userFlagRequest[] requestArray = new userFlagRequest[gridViewInboundDocs.GetSelectedRows().Length];
            //int counter = 0;
            List<InboundDocUserFlagDto> userFlagList = new List<InboundDocUserFlagDto>();
            InboundDocsView inbDocView = null;
            string userComment = "";
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                foreach (int rowHandle in gridViewInboundDocs.GetSelectedRows())
                {
                    //userFlagRequest request = new userFlagRequest();
                    InboundDocUserFlagDto userFlagData = new InboundDocUserFlagDto();
                    dr = gridViewInboundDocs.GetDataRow(rowHandle);
                    inbDocView = CollectionHelper.CreateObjectFromDataRow<InboundDocsView>(dr);
                    userComment = inbDocView.CommentUser;
                    CommentForm commentForm = new CommentForm();
                    commentForm.Comment = userComment;
                    commentForm.ShowDialog();

                    if (commentForm.DialogResult == DialogResult.OK)
                    {
                        //Israel 9/17/2015
                        userComment = commentForm.Comment;     
                    }

                    deleteUserComment = ((userComment == null) || (userComment.Trim() == ""));

                    //request.inboundDocId = inbDocView.Id;
                    //request.flagType = "COMMENT";
                    //request.userName = (inboundWebServices.userName.Text[0]).ToUpper();
                    //request.comment = userComment;
                    //if (deleteUserComment)
                    //{
                    //    request.updateDeleteFlag = updateUserFlag.Delete;
                    //}
                    //else
                    //{
                    //    request.updateDeleteFlag = updateUserFlag.Update;
                    //}
                    //request.updateDeleteFlagSpecified = true;
                    //requestArray[counter] = request;
                    //counter++;

                    userFlagData.InboundDocId = Convert.ToInt32(inbDocView.Id);
                    userFlagData.FlagType = "COMMENT";
                    userFlagData.InboundUser = p_UserId;
                    userFlagData.Comments = userComment;
                    if (deleteUserComment)
                    {
                        userFlagData.UpdateDeleteInd = USER_FLAG_DELETE;
                    }
                    else
                    {
                        userFlagData.UpdateDeleteInd = USER_FLAG_UPDATE;
                    }
                    userFlagList.Add(userFlagData);
                }
                //SubmitUserCommentRequest(requestArray);
                SubmitUserCommentRequest(userFlagList);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while updating the grid with the User Comment." + Environment.NewLine +
                       "Error CNF-497 in " + FORM_NAME + ".CreateUserComment(): " + ex.Message,
                     FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Beispiel #2
0
        private void bbCancelSempraPaperRqmt_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                myTimer.Stop();
                int cancelsProcessed = 0;
                int skipped = 0;
                string label = "Cancel Our Paper Rqmt?";
                string cancelComments = "";

                //CommentForm commentForm = new CommentForm(label);
                CommentForm commentForm = new CommentForm();
                commentForm.Text = label;
                commentForm.Comment = cancelComments;

                commentForm.ShowDialog();
                DialogResult result = commentForm.DialogResult;

                if (result == DialogResult.OK)
                {
                    cancelComments = commentForm.Comment;
                }

                if (result == DialogResult.OK)
                {
                    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 rowSummary in rows)
                    {
                        long tradeId = long.Parse(rowSummary["TradeId"].ToString());
                        bool foundCancel = false;
                        string finalApprovalFlag = rowSummary["FinalApprovalFlag"].ToString();
                        bool finalApproved = (finalApprovalFlag == "Y");

                        string filterStr = "TradeId = " + tradeId.ToString() + " and Rqmt = '" + SEMPRA_RQMT + "'";
                        foreach (DataRow rowRqmt in rqmtDataTable.Select(filterStr))
                        {
                            long rqmtId = long.Parse(rowRqmt["Id"].ToString());
                            string rqmtStatus = rowRqmt["Status"].ToString();
                            string cmt = "";
                            if (rqmtStatus != "CXL" && !finalApproved)
                            {
                                string reference = rowRqmt["Reference"].ToString();
                                if (cancelComments != "")
                                {
                                    cmt = cancelComments;
                                }
                                else
                                {
                                    cmt = rowRqmt["Cmt"].ToString();
                                }
                                CallUpdateTradeRqmts(tradeId, rqmtId, SEMPRA_RQMT, "CXL", DateTime.Today, reference, cmt, true);
                                cancelsProcessed++;
                                foundCancel = true;
                                break;
                            }
                        }
                        if (!foundCancel)
                            skipped++;
                    }
                    XtraMessageBox.Show(label + ": " + cancelsProcessed.ToString() + Environment.NewLine
                       + "Trades skipped: " + skipped.ToString(),
                       label, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while requesting 'Cancel Our Paper' requirement." + Environment.NewLine +
                    "Error CNF-170 in " + FORM_NAME + ".bbCancelSempraPaperRqmt_ItemClick(): " + ex.Message,
                  MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                myTimer.Start();
                Cursor.Current = Cursors.Default;
            }
        }
        private string GetInboundDocComment(string currentComment)
        {
            try
            {
                CommentForm commentForm = new CommentForm();
                commentForm.Comment = currentComment;
                commentForm.ShowDialog();

                if (commentForm.DialogResult == DialogResult.OK)
                {
                    //Israel 9/17/2015
                    return commentForm.Comment;
                }
                else return currentComment;
            }
            catch(Exception ex)
            {
                //throw ex;
                throw new Exception("An error occurred while retrieving the document comment with the following value:" + Environment.NewLine +
                    "Comment: " + currentComment + Environment.NewLine +
                     "Error CNF-504 in " + FORM_NAME + ".GetInboundDocComment(): " + ex.Message);
            }
        }