Esempio n. 1
0
    public bool Load(CCommand Command, string FileName, string BranchCode, string TaskCode)
    {
        int    LineNum;
        bool   Result = true;
        string DebitAcc, CreditAcc, DebitIBAN, CreditIBAN;

        if (AFileReader == null)
        {
            return(false);
        }
        if (AFileReader.Open(FileName, CAbc.CHARSET_DOS))
        {
            string ShortFileName = CCommon.GetFileName(FileName);
            LineNum = 1;
            while (AFileReader.Read())
            {
                DebitAcc   = AFileReader[CSepAFileInfo.L_DEBITACC].Replace("'", "`").Trim();
                DebitAcc   = CCommon.IsDigit(DebitAcc) ? DebitAcc : AFileReader[CSepAFileInfo.L_DEBITACC_EXT].Replace("'", "`").Trim();
                DebitAcc   = CCommon.IsDigit(DebitAcc) ? DebitAcc : "";
                CreditAcc  = AFileReader[CSepAFileInfo.L_CREDITACC].Replace("'", "`").Trim();
                CreditAcc  = CCommon.IsDigit(CreditAcc) ? CreditAcc : AFileReader[CSepAFileInfo.L_CREDITACC_EXT].Replace("'", "`").Trim();
                CreditAcc  = CCommon.IsDigit(CreditAcc) ? CreditAcc : "";
                DebitIBAN  = AFileReader[CSepAFileInfo.L_DEBITIBAN].Replace("'", "`").Trim();
                DebitIBAN  = CCommon.IsLetter(DebitIBAN) ? DebitIBAN : CAbc.EMPTY;
                CreditIBAN = AFileReader[CSepAFileInfo.L_CREDITIBAN].Replace("'", "`").Trim();
                CreditIBAN = CCommon.IsLetter(CreditIBAN) ? CreditIBAN : CAbc.EMPTY;
                CmdText    = "exec  dbo.pMega_OpenGate_AddPalvis "
                             + " @TaskCode     = '" + TaskCode.Trim() + "'"
                             + ",@BranchCode   = '" + BranchCode.Trim() + "'"
                             + ",@FileName     = '" + ShortFileName + "'"
                             + ",@LineNum      =  " + LineNum.ToString()
                             + ",@Code         = '" + AFileReader[CSepAFileInfo.L_NDOC].Replace("'", "`").Trim() + "'"
                             + ",@Ctrls        = '" + AFileReader[CSepAFileInfo.L_SYMBOL].Replace("'", "`").Trim() + "'"
                             + ",@SourceCode   = '" + AFileReader[CSepAFileInfo.L_DEBITMFO].Replace("'", "`").Trim() + "'"
                             + ",@DebitMoniker = '" + DebitAcc + "'"
                             + ",@DebitName    = '" + AFileReader[CSepAFileInfo.L_DEBITNAME].Replace("'", "`").Trim() + "'"
                             + ",@DebitState   = '" + AFileReader[CSepAFileInfo.L_OKPO1].Replace("'", "`").Trim() + "'"
                             + ",@DebitIBAN    = '" + DebitIBAN + "'"
                             + ",@TargetCode   = '" + AFileReader[CSepAFileInfo.L_CREDITMFO].Replace("'", "`").Trim() + "'"
                             + ",@CreditMoniker= '" + CreditAcc + "'"
                             + ",@CreditName   = '" + AFileReader[CSepAFileInfo.L_CREDITNAME].Replace("'", "`").Trim() + "'"
                             + ",@CreditState  = '" + AFileReader[CSepAFileInfo.L_OKPO2].Replace("'", "`").Trim() + "'"
                             + ",@CreditIBAN   = '" + CreditIBAN + "'"
                             + ",@CrncyAmount  =  " + AFileReader[CSepAFileInfo.L_SUMA].Replace("'", "`").Trim()
                             + ",@CurrencyId   =  " + AFileReader[CSepAFileInfo.L_CURRENCY].Replace("'", "`").Trim()
                             + ",@Purpose      = '" + AFileReader[CSepAFileInfo.L_PURPOSE].Replace("'", "`").Trim() + "'"
                             + ",@OrgDate      =  " + CCommon.StrDate_To_IntDate("20" + AFileReader[CSepAFileInfo.L_DATE2].Trim())
                             + ",@UserName		= '******'"
                ;
                if (Command.Execute(CmdText) != true)
                {
                    Result = false;
                }
                LineNum = LineNum + 1;
                CConsole.ShowBox("", " Загружается строка" + CCommon.StrI(LineNum, 5) + " ", "");
            }
        }
        AFileReader.Close();
        return(Result);
    }
Esempio n. 2
0
 public void ShowFuncInfo()
 {
     Console.WriteLine(LineNum.ToString());
     Console.WriteLine(UsefulStringsNum.ToString());
     Console.WriteLine(KeywordsNum.ToString());
     Console.WriteLine(FuncName);
 }
Esempio n. 3
0
        public override string ToString()
        {
            string value1 = string.Empty;

            if (TokenType == LexerTokenType.KEYWORD)
            {
                value1 = Keyword.ToString();
            }
            else
            {
                value1 = Value;
            }
            StringBuilder sb = new StringBuilder(128);

            sb.Append("Token value:");
            sb.Append(Value);
            sb.Append(", type:");
            sb.Append(TokenType.ToString());
            if (TokenType == LexerTokenType.KEYWORD)
            {
                sb.Append(", key:" + Keyword.ToString());
            }
            sb.Append(", lineNum:");
            sb.Append(LineNum.ToString());
            sb.Append(", position:");
            sb.Append(Position.ToString());
            return(sb.ToString());
        }
Esempio n. 4
0
        public void UpdateDetails(int iOItemID, int iLoadID, int iLineN, string sULOOrgCode, int iValid, string sComments, int iJustification,
                                  string sJustificationAddOn, string sJustificationOther, string sCode, string sCodeComment, string sRWA, int iUpdateUser)
        {
            /*****************************************************************/
            //1. - update Line properties
            /*****************************************************************/
            var objLine              = new LineNum(iOItemID, iLineN);
            var reviewer             = objLine.ReviewerUserID;
            var line_prev_validation = objLine.Valid;

            objLine.Valid              = iValid;
            objLine.Comments           = sComments;
            objLine.JustificationCode  = iJustification;
            objLine.JustificationAddOn = sJustificationAddOn;
            objLine.JustificationOther = sJustificationOther;
            objLine.Code         = sCode;
            objLine.CodeComments = sCodeComment;
            objLine.RWA          = sRWA;
            objLine.Save(iUpdateUser);

            iJustification = objLine.JustificationCode;

            //get Open Item details
            var objItem           = new OpenItem(iOItemID, iLoadID, sULOOrgCode, reviewer);
            var document_valid    = objItem.ValidCode;
            var item_status       = objItem.StatusCode;
            var item_new_status   = objItem.StatusCode;
            var item_orig_orgcode = objItem.OriginalOrgCode;
            var doc_number        = objItem.DocNumber;

            //2. - insert History on update Line Properties
            // OR
            //3. - insert History on update Line Validation if it has been changed
            // (insert only one record to the History due to not duplicate records)
            if (line_prev_validation != iValid)
            {
                History.InsertHistoryOnLineUpdate((int)HistoryActions.haLineValidationUpdate, iLoadID, iOItemID, item_orig_orgcode, sULOOrgCode,
                                                  doc_number, iLineN, item_status, iValid, sCode, sCodeComment, iJustification, sJustificationAddOn, sComments, reviewer, iUpdateUser);
            }
            else
            {
                History.InsertHistoryOnLineUpdate((int)HistoryActions.haLinePropertiesUpdate, iLoadID, iOItemID, item_orig_orgcode, sULOOrgCode,
                                                  doc_number, iLineN, item_status, line_prev_validation, sCode, sCodeComment, iJustification, sJustificationAddOn, sComments, reviewer, iUpdateUser);
            }

            /*****************************************************************/
            //4. - update Item Status if necessary
            /*****************************************************************/
            item_new_status = Item.CalculateItemStatus(iOItemID, sULOOrgCode, reviewer);

            if (item_status != item_new_status)
            {
                Item.UpdateItemStatus(iOItemID, iLoadID, sULOOrgCode, reviewer, item_new_status);

                //5. - insert History on update Item Status
                History.InsertHistoryOnItemUpdate((int)HistoryActions.haItemPropertiesUpdate, iLoadID, iOItemID, item_orig_orgcode, sULOOrgCode,
                                                  doc_number, item_new_status, document_valid, null, reviewer, iUpdateUser);
            }
        }
Esempio n. 5
0
 private void AlignRight()
 {
     LineNum.SelectAll();
     LineNum.SelectionAlignment = HorizontalAlignment.Right;
     LineNum.DeselectAll();
     OutputText.SelectAll();
     OutputText.SelectionAlignment = HorizontalAlignment.Center;
     OutputText.DeselectAll();
 }
Esempio n. 6
0
        private void ProcessFileCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            string result;

            System.Text.RegularExpressions.Regex numeric = new System.Text.RegularExpressions.Regex("^[0-9](\\.?[0-9])+$");

            if ((sender as CheckBox).Checked)
            {
                using (StreamReader sr = new StreamReader(file.Text))
                {
                    // initialize some accumulator variables (for lines of numbers count and average)
                    int numCount = 0;
                    int count    = 0;

                    string line = sr.ReadLine();

                    while (line != null) // null is returned at the end of the file
                    {
                        // Process
                        if (numeric.IsMatch(line))
                        {
                            // process all lines that are numeric
                            numCount++;
                        }

                        // read the next line
                        line = sr.ReadLine();
                        count++;
                    }

                    result           = String.Format($"{openFileDialog1.FileName} contains {numCount} line(s) of numbers ({(double)numCount / count:P0})");
                    OutputText.Text += result;

                    using (StreamWriter writer = new StreamWriter("Result.txt", true))
                    {
                        writer.WriteLine(result);
                    }

                    LineNum.AppendText($"{File.ReadAllLines("Result.txt").Count()}");
                }

                LineNum.Visible        = true;
                OutputGrouping.Visible = true;
                OutputText.Visible     = true;
            }
            else
            {
                OutputText.Text += "\n";
                LineNum.Text    += "\n";
            }
        }
Esempio n. 7
0
        private void LoadLineNumDetails(LineNum line_item, bool EnableForUpdate, bool IsArchived)
        {
            lblLineNum.Text = line_item.LineNumID.ToString();

            lblReviewer.Text       = line_item.Reviewer;
            txtReviewerEmail.Value = Admin.GetEmailByUserID(line_item.ReviewerUserID);

            lblOrganization.Text = line_item.Organization;
            lblOrgCode.Text      = line_item.ULOOrgCode;

            if (IsArchived)
            {
                lblStatus.Text = line_item.Status + " (Archived)";
            }
            else
            {
                lblStatus.Text = line_item.StatusDescription;
            }

            //display Line ULOOrgCode only if it's different from Open Item ULOOrgCode:

            /*
             * if (lblOrgCode.Text != line_item.ULOOrgCode)
             * {
             *  lblLineOrgCode.Text = String.Format(" ({0})", line_item.ULOOrgCode);
             *  lblLineOrgCode.Visible = true;
             * }
             * else
             *  lblLineOrgCode.Visible = false;
             */

            lblValid.Text = line_item.ValidDescription;
            if (line_item.Valid == (int)OpenItemValidation.vlInvalid)
            {
                lblDeobligatedDate.Visible = true;
                lblDeobligatedInfo.Visible = true;
                lblDeobligatedDate.Text    = Utility.DisplayDateFormat(line_item.DeobligatedDate, "MMM dd, yyyy");
            }
            else
            {
                lblDeobligatedInfo.Visible = false;
                lblDeobligatedDate.Visible = false;
            }
            lblTotalLineLine.Text  = Utility.DisplayMoneyFormat(line_item.TotalLine);
            lblProjNum.Text        = line_item.ProjectNumber;
            lblBA.Text             = line_item.BA;
            txtRWA.Text            = line_item.RWA;
            lblAGRE_BLDG.Text      = line_item.AGRE_BLDG;
            lblBuilding.Text       = line_item.Building;
            lblVendCD.Text         = line_item.VendorCD;
            lblVendName.Text       = line_item.VendorName;
            lblACTG_PD.Text        = Utility.DisplayDateFormat(line_item.ACTG_PD, "MMM dd, yyyy");
            lblLastPaidLine.Text   = Utility.DisplayDateFormat(line_item.LastPaid, "MMM dd, yyyy");
            lblBBFY.Text           = line_item.BBFY.ToString();
            lblEBFY.Text           = line_item.EBFY.ToString();
            lblUDOLine.Text        = Utility.DisplayMoneyFormat(line_item.UDO);
            lblFC.Text             = line_item.FC;
            lblOC.Text             = line_item.OC.ToString();
            lblCE.Text             = line_item.CE.ToString();
            lblACCRLine.Text       = Utility.DisplayMoneyFormat(line_item.ACCR);
            lblPENDPYMTLine.Text   = Utility.DisplayMoneyFormat(line_item.PEND_PYMT);
            lblPYMTS_CONFLine.Text = Utility.DisplayMoneyFormat(line_item.PYMTS_CONF);
            lblHOLDBACKSLine.Text  = Utility.DisplayMoneyFormat(line_item.HOLDBACKS);

            txtComment.Text = line_item.Comments;

            if (line_item.LineInfo.Length > 0)
            {
                txtLineInfo.Text    = line_item.LineInfo;
                txtLineInfo.Enabled = false;

                tblLineInfo.Visible = true;
            }
            else
            {
                tblLineInfo.Visible = false;
            }


            ddlCode.SelectedValue = line_item.Code;
            txtCodeComment.Text   = line_item.CodeComments;
            if (line_item.Code != "")
            {
                var drCode = dtCodeList.Select("Code = '" + line_item.Code + "'");
                if (drCode.Length > 0)
                {
                    lblCode.Text = drCode[0]["Code"].ToString();
                }
            }

            ddlValid.SelectedValue = line_item.Valid.ToString();

            //display Justification Value:
            var justifications = Lookups.GetJustificationValues();
            var justification  = justifications.Where(j => j.Justification == line_item.JustificationCode);

            if (justification.Any())
            {
                var firstJustification = justification.First();
                if (firstJustification.InDefaultList)
                {
                    rblJustification.SelectedValue = line_item.JustificationCode.ToString();
                    if (firstJustification.DisplayAddOnField)
                    {
                        lblJustificationExplanation.Text = (string)Utility.GetNotNullValue(firstJustification.AddOnDescription, "String");
                        txtAddJustification.Text         = line_item.JustificationAddOn;
                    }
                    else
                    {
                        lblJustificationExplanation.AddVisibilityHidden();
                        txtAddJustification.AddVisibilityHidden();
                        lblJustAddInfo.AddVisibilityHidden();
                    }
                    txtJustOther.AddVisibilityHidden();
                    lblJustOther.AddVisibilityHidden();
                }
                else
                {
                    rblJustification.SelectedValue = "6";
                    lblJustificationExplanation.AddVisibilityHidden();
                    txtAddJustification.AddVisibilityHidden();
                    txtJustOther.Text = (string)Utility.GetNotNullValue(firstJustification.JustificationDescription, "String");
                }
            }
            else
            {
                lblJustificationExplanation.AddVisibilityHidden();
                txtAddJustification.AddVisibilityHidden();
                lblJustAddInfo.AddVisibilityHidden();
                txtJustOther.AddVisibilityHidden();
                lblJustOther.AddVisibilityHidden();
            }

            var sb = new StringBuilder();

            sb.Append("<script type='text/javascript' >");
            sb.Append("var original_selected_just = '");
            sb.Append(rblJustification.SelectedValue);
            sb.Append("';");
            sb.Append("var original_add_on = '");
            sb.Append(txtAddJustification.Text);
            sb.Append("';");
            sb.Append("</script>");
            Page.RegisterStartupScript("orig_just", sb.ToString());


            if (!EnableForUpdate)
            {
                txtRWA.Enabled              = false;
                txtComment.Enabled          = false;
                ddlValid.Enabled            = false;
                ddlCode.Enabled             = false;
                txtCodeComment.Enabled      = false;
                rblJustification.Enabled    = false;
                txtAddJustification.Enabled = false;
                txtJustOther.Enabled        = false;
            }
            else
            {
                //check if there are values for UDO & DO Should Be fields:
                var str_msg = "";
                if (lblCompletionDate.Text == "")
                {
                    str_msg = str_msg + "Expected Completion Date.<br />";
                }
                if (lblUDOShouldBe.Text.Trim() == "$" || lblUDOShouldBe.Text.Trim().Length == 0)
                {
                    str_msg = str_msg + "UDO Should Be.<br />";
                }
                if (lblDOShouldBe.Text.Trim() == "$" || lblDOShouldBe.Text.Trim().Length == 0)
                {
                    str_msg = str_msg + "DO Should Be.<br />";
                }

                if (str_msg.Length > 0)
                {
                    str_msg = "The following fields are required:<br />" + str_msg + "Please fill these fields before Line validation. <br/>";

                    lblMsgValidation.Visible    = true;
                    lblMsgValidation.Text       = str_msg;
                    ddlValid.Enabled            = false;
                    ddlCode.Enabled             = false;
                    txtCodeComment.Enabled      = false;
                    rblJustification.Enabled    = false;
                    txtAddJustification.Enabled = false;
                    txtJustOther.Enabled        = false;
                }
            }
        }
Esempio n. 8
0
        private void InitControlsByItem(int OItemID, string Lines, string ULOOrgCode, string PrevReviewer)
        {
            txtItemID.Value = OItemID.ToString();

            if (Lines == "" || Lines == "0")
            {
                //init by item properties:
                lblLines.Text = "all";

                int reviewer_id;
                if (PrevReviewer == "" || PrevReviewer == "0")
                {
                    reviewer_id = 0;
                }
                else
                {
                    reviewer_id = Int32.Parse(PrevReviewer);
                }
                var item = new OpenItem(OItemID, (new PageBase()).LoadID, ULOOrgCode, reviewer_id);

                txtCurrentReviewer.Value = item.ReviewerUserID.ToString();
                lblPrevReviewer.Text     = item.Reviewer;
                lblDocNumber.Text        = item.DocNumber;
                lblOrgCode.Text          = item.ULOOrgCode;

                InitAssignUsersList(OItemID, ULOOrgCode, 0);
            }
            else
            {
                //init by lines properties:
                lblLines.Text = Lines;

                var line_num = 0;
                Int32.TryParse(Lines, out line_num);
                if (line_num == 0)
                {
                    //we have multiline selection:
                    lblDocNumber.Text = Request.QueryString["doc"];

                    var str_org   = "";
                    var str_names = "";
                    var ds        = Item.GetULOOrganizationsByItemLines(OItemID, Lines);

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (str_org.IndexOf((string)dr["ULOOrgCode"]) == -1)
                        {
                            str_org = str_org + (string)dr["ULOOrgCode"] + ", ";
                        }

                        if (str_names.IndexOf((string)dr["ReviewerName"]) == -1)
                        {
                            str_names = str_names + (string)dr["ReviewerName"] + "<br/>";
                        }
                    }

                    lblOrgCode.Text      = str_org.Substring(0, str_org.Length - 2);
                    lblPrevReviewer.Text = str_names;

                    InitAssignUsersList(OItemID, ULOOrgCode, 0);
                }
                else
                {
                    //one line selected
                    var line = new LineNum(OItemID, line_num);

                    txtCurrentReviewer.Value = line.ReviewerUserID.ToString();
                    lblPrevReviewer.Text     = line.Reviewer;
                    lblDocNumber.Text        = line.DocNumber;
                    lblOrgCode.Text          = line.ULOOrgCode;

                    InitAssignUsersList(OItemID, line.ULOOrgCode, 0);
                }
            }

            //init with default settings:
            InitUsersOrganizationsList("", 0);
        }
Esempio n. 9
0
        private void InitControlsByItem(int OItemID, string Lines, string ULOOrgCode, string PrevReviewer)
        {
            txtItemID.Value = OItemID.ToString();

            if (Lines == "" || Lines == "0")
            {
                //init by item properties:
                lblLines.Text = "all";

                int reviewer_id;
                if (PrevReviewer == "" || PrevReviewer == "0")
                {
                    reviewer_id = 0;
                }
                else
                {
                    reviewer_id = Int32.Parse(PrevReviewer);
                }
                var item = new OpenItem(OItemID, (new PageBase()).LoadID, ULOOrgCode, reviewer_id);

                txtPrevOrganization.Value = item.Organization + " : " + item.ULOOrgCode;
                txtPrevReviewer.Value     = item.ReviewerUserID.ToString();
                lblDocNumber.Text         = item.DocNumber;

                lblPrevOrganization.Text = item.Organization;
                lblPrevOrgCode.Text      = item.ULOOrgCode;
                lblPrevReviewerName.Text = item.Reviewer;
            }
            else
            {
                //init by lines properties:
                lblLines.Text = Lines;

                var line_num = 0;
                Int32.TryParse(Lines, out line_num);
                if (line_num == 0)
                {
                    //we have multiline selection:
                    lblDocNumber.Text = Request.QueryString["doc"];

                    var str_org   = "";
                    var str_names = "";
                    var ds        = Item.GetULOOrganizationsByItemLines(OItemID, Lines);

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (str_org.IndexOf((string)dr["Organization"]) == -1)
                        {
                            str_org = str_org + (string)dr["Organization"] + ", ";
                        }

                        if (str_names.IndexOf((string)dr["ReviewerName"]) == -1)
                        {
                            str_names = str_names + (string)dr["ReviewerName"] + "<br/>";
                        }
                    }

                    lblPrevOrganization.Text = str_org.Substring(0, str_org.Length - 2);
                    lblPrevOrgCode.Style.Add("display", "none");
                    lblPrevReviewerName.Text = str_names;
                }
                else
                {
                    //one line selected
                    var line = new LineNum(OItemID, line_num);

                    txtPrevOrganization.Value = line.Organization + " : " + line.ULOOrgCode;
                    txtPrevReviewer.Value     = line.ReviewerUserID.ToString();
                    lblDocNumber.Text         = line.DocNumber;

                    lblPrevOrganization.Text = line.Organization;
                    lblPrevOrgCode.Text      = line.ULOOrgCode;
                    lblPrevReviewerName.Text = line.Reviewer;
                }
            }

            ctrlOrgUsers.OrganizationLabel = "Select Organization:";
            ctrlOrgUsers.UsersLabel        = "Select Reviewer:";
            ctrlOrgUsers.InitLists();
        }
Esempio n. 10
0
 override public String ToString()
 {
     return(Type.ToString() + ":\t" + Message + "\t@" + LineNum.ToString());
 }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var str_result = "";
            var _page      = new PageBase();
            var user       = _page.CurrentUserID;
            var intLoadID  = _page.LoadID;

            var obj_xml = new XmlDataDocument();

            try
            {
                obj_xml.Load(Request.InputStream);

                if (obj_xml.DocumentElement.Name == "verify_assignment") //action code 4
                {
                    var intOItemID        = 0;
                    var intReviewerUserID = 0;
                    var strOrgCode        = "";
                    var email_request     = 0;

                    var node = obj_xml.DocumentElement.FirstChild;

                    var item_id = node.Attributes.GetNamedItem("item_id").Value;
                    if (item_id.Length > 0)
                    {
                        intOItemID = Int32.Parse(item_id);
                    }
                    strOrgCode = node.Attributes.GetNamedItem("org_code").Value;
                    var reviewer_id = node.Attributes.GetNamedItem("reviewer_id").Value;
                    if (reviewer_id.Length > 0)
                    {
                        intReviewerUserID = Int32.Parse(reviewer_id);
                    }

                    Assign.VerifyAssignment(intOItemID, intLoadID, strOrgCode, intReviewerUserID);

                    // action code 4
                    if (Settings.Default.SendEmailOnAssignVerification)
                    {
                        email_request = Emails.InsertEmailRequest(user, (int)HistoryActions.haAssignmentVerification, false);
                    }

                    History.InsertHistoryOnReasssignment((int)HistoryActions.haAssignmentVerification, intOItemID, intLoadID, strOrgCode, "", 0, intReviewerUserID, "", user, email_request);

                    SendEmailOnReassigRequest(intOItemID, strOrgCode, "", "", "", intReviewerUserID, 0, "", "4");


                    //we made update of data displayed in the items grid, so we will need to reload it:
                    _page.ItemsDataView = null;
                }

                if (obj_xml.DocumentElement.Name == "verify_reroute") //action 10
                {
                    var intRequestID          = 0;
                    var strPrevOrganization   = "";
                    var intPrevReviewerUserID = 0;
                    var intNewReviewerUserID  = 0;
                    var email_request         = 0;

                    var node = obj_xml.DocumentElement.FirstChild;

                    var request_id = node.Attributes.GetNamedItem("request_id").Value;
                    if (request_id.Length > 0)
                    {
                        intRequestID = Int32.Parse(request_id);
                    }
                    var user_id = node.Attributes.GetNamedItem("prev_user").Value;
                    if (user_id.Length > 0)
                    {
                        intPrevReviewerUserID = Int32.Parse(user_id);
                    }
                    strPrevOrganization = node.Attributes.GetNamedItem("prev_org").Value;
                    var new_user_id = node.Attributes.GetNamedItem("new_reviewer").Value;
                    if (new_user_id.Length > 0)
                    {
                        intNewReviewerUserID = Int32.Parse(new_user_id);
                    }

                    var reroute_result = Assign.VerifyReroute(intRequestID);

                    /*
                     * return code 0 - Item was not rerouted (missed case?)
                     **************************************************************
                     * LineNum = 0  --> all lines belong to the item (same ULOOrgCode + ReviewerUserID) were rerouted:
                     * return code 1 - new item (ItemID + NewULOOrgCode + NewReviewerUserID) already exist, lines from original item joined to the new item,
                     *                              original item has been deleted (only if original and new items are not the same)
                     * return code 2 - new item (ItemID + NewULOOrgCode + NewReviewerUserID) doesn't exist, so original item has been updated to be the new one
                     **************************************************************
                     * reroute specific LineNum, there are other Lines in the original item that should not be rerouted --> split item:
                     * -------------------------
                     * return code 3 - new item (ItemID + NewULOOrgCode + NewReviewerUserID) already exist, requested Line from original item joined to the new item
                     * return code 4 - new item (ItemID + NewULOOrgCode + NewReviewerUserID) doesn't exist, requested Line from original item become new item
                     *                              (insert new record into tblOIOrganization)
                     ***************************************************************
                     * reroute specific LineNum, there are NO other Lines in the original item that should not be rerouted --> original item should be deleted or updated:
                     * -------------------------
                     * return code 5 - new item (ItemID + NewULOOrgCode + NewReviewerUserID) already exist, requested Line from original item joined to the new item,
                     *                              original item has been deleted (only if original and new items are not the same)
                     * return code 6 - new item (ItemID + NewULOOrgCode + NewReviewerUserID) doesn't exist, original item has been updated to be the new one
                     */
                    if (reroute_result > 0 && reroute_result < 7)
                    {
                        // action code 10
                        if (Settings.Default.SendEmailOnRerouteAssign)  // 10
                        {
                            email_request = Emails.InsertEmailRequest(user, (int)HistoryActions.haRerouteAssignment, true);
                        }

                        History.InsertHistoryOnRerouteVerification(intRequestID, strPrevOrganization, intPrevReviewerUserID, user, email_request);

                        SendEmailOnReassigRequest(0, "", "", strPrevOrganization, "", intPrevReviewerUserID, intNewReviewerUserID, "", "10"); //////////

                        //update of data displayed in the items grid has been made, so we will need to reload it:
                        _page.ItemsDataView = null;
                    }
                    else
                    {
                        //error on reassign
                        str_result = "<error><err_msg msg='There is a problem to reroute this item. \nPlease contact System Administrator.' /></error>";
                    }
                }



                if (obj_xml.DocumentElement.Name == "add_contact")
                {
                    var strItem        = "";
                    var intOItemID     = 0;
                    var strDocNumber   = "";
                    var strOrgCode     = "";
                    var intPersonnelID = 0;
                    var strRoleDesc    = "";
                    var strContactName = "";

                    var node = obj_xml.DocumentElement.FirstChild;

                    var pid = node.Attributes.GetNamedItem("pid").Value;
                    if (pid.Length > 0)
                    {
                        intPersonnelID = Int32.Parse(pid);
                    }
                    strItem = node.Attributes.GetNamedItem("item").Value;
                    if (strItem.Length > 0)
                    {
                        intOItemID = Int32.Parse(strItem);
                    }
                    strDocNumber   = node.Attributes.GetNamedItem("doc").Value;
                    strOrgCode     = node.Attributes.GetNamedItem("org").Value;
                    strRoleDesc    = node.Attributes.GetNamedItem("role").Value;
                    strContactName = node.Attributes.GetNamedItem("name").Value;

                    var intContactUserID = Item.AddDocumentContact(strDocNumber, strOrgCode, intPersonnelID, strRoleDesc);

                    History.InsertHistoryOnAddItemContact(strDocNumber, intOItemID, intLoadID, strOrgCode, intContactUserID, strContactName, strRoleDesc, user);
                }

                if (obj_xml.DocumentElement.Name == "delete_contact")
                {
                    var strDocNumber   = "";
                    var strOrgCode     = "";
                    var strItem        = "";
                    var intOItemID     = 0;
                    var strContactName = "";
                    var strRoleDesc    = "";

                    var node = obj_xml.DocumentElement.FirstChild;

                    strDocNumber = node.Attributes.GetNamedItem("doc").Value;
                    strOrgCode   = node.Attributes.GetNamedItem("org").Value;
                    strItem      = node.Attributes.GetNamedItem("item").Value;
                    if (strItem.Length > 0)
                    {
                        intOItemID = Int32.Parse(strItem);
                    }
                    strRoleDesc    = node.Attributes.GetNamedItem("role").Value;
                    strContactName = node.Attributes.GetNamedItem("name").Value;

                    string strFirstName;
                    string strLastName;

                    strLastName  = strContactName.Substring(0, strContactName.IndexOf(","));
                    strFirstName = strContactName.Substring(strContactName.IndexOf(",") + 2);

                    var intContactUserID = Item.DeleteDocContact(strDocNumber, strOrgCode, strRoleDesc, strFirstName, strLastName);

                    History.InsertHistoryOnDeleteItemContact(strDocNumber, intOItemID, intLoadID, strOrgCode, intContactUserID, strContactName, strRoleDesc, user);
                }

                if (obj_xml.DocumentElement.Name == "certify_deobl")
                {
                    var node = obj_xml.DocumentElement.FirstChild;

                    var intOItemID = Int32.Parse(node.Attributes.GetNamedItem("item_id").Value);
                    var intItemLN  = Int32.Parse(node.Attributes.GetNamedItem("line_num").Value);
                    var strOrgCode = node.Attributes.GetNamedItem("org").Value;
                    var cert_date  = LineNum.CertifyDeobligation(intOItemID, intItemLN);
                    if (cert_date != DateTime.MinValue)
                    {
                        str_result = "<result_date>" + cert_date.ToString("MMM dd, yyyy") + "</result_date>";
                    }
                    else
                    {
                        str_result = "<result_date></result_date>";
                    }

                    //insert History:
                    History.InsertHistoryOnLineDeobligation(intOItemID, intLoadID, intItemLN, strOrgCode, cert_date, user);

                    //we made update of data displayed in the items grid, so we will need to reload it:
                    _page.ItemsDataView = null;
                }

                if (obj_xml.DocumentElement.Name == "reassign_request")  //5
                {
                    var node = obj_xml.DocumentElement.FirstChild;

                    var strItemID      = node.Attributes.GetNamedItem("item").Value;
                    var strLines       = node.Attributes.GetNamedItem("lines").Value;
                    var strOrgCode     = node.Attributes.GetNamedItem("org_code").Value;
                    var strOrgNewValue = node.Attributes.GetNamedItem("org_new_value").Value;
                    var strUserId      = node.Attributes.GetNamedItem("user_id").Value;
                    var strComments    = node.Attributes.GetNamedItem("com").Value;
                    //string strDocNum = node.Attributes.GetNamedItem("doc_num").Value;

                    var strResponsibleOrganization = Lookups.GetOrganizationByOrgCode(strOrgCode);

                    var strNewOrganization = "";
                    var strNewOrgCode      = "";
                    if (strOrgNewValue.Length > 0)
                    {
                        strNewOrganization = strOrgNewValue.Substring(0, strOrgNewValue.IndexOf(":") - 1);
                        strNewOrgCode      = strOrgNewValue.Substring(strOrgNewValue.IndexOf(":") + 2);
                    }
                    var intItemID = Int32.Parse(strItemID);
                    var intUserID = 0;
                    if (strUserId.Length > 0)
                    {
                        intUserID = Int32.Parse(strUserId);
                    }
                    if (strLines == "")
                    {
                        strLines = "0";
                    }

                    // ***SM
                    var intRequestID = Assign.RequestReassignItem(intItemID, strOrgCode, strLines, user, strResponsibleOrganization,
                                                                  strNewOrganization, strNewOrgCode, intUserID, strComments);

                    if (intRequestID == 0)
                    {
                        str_result = "<error><err_msg msg='This Open Item has been already requested for reroute. \nPlease refresh your items view.' /></error>";
                    }
                    else
                    {
                        var email_request = 0;
                        if (Settings.Default.SendEmailOnRerouteRequest)
                        {
                            email_request = Emails.InsertEmailRequest(user, (int)HistoryActions.haRerouteRequest, true);
                        }

                        History.InsertHistoryOnRerouteRequest(intItemID, strLines, intLoadID, strOrgCode, intRequestID, strOrgNewValue,
                                                              user, intUserID, strComments, user, email_request);
                    }

                    //refresh Items GridResults on the next reload:
                    _page.ItemsDataView = null;


                    SendEmailOnReassigRequest(intItemID, strOrgCode, strNewOrgCode, strResponsibleOrganization, strNewOrganization, user, intUserID, strComments, "5");
                }

                if (obj_xml.DocumentElement.Name == "reassign_reroute") //3
                {
                    var node = obj_xml.DocumentElement.FirstChild;

                    var strItemID                  = node.Attributes.GetNamedItem("item").Value;
                    var strOrgCode                 = node.Attributes.GetNamedItem("org_code").Value;
                    var strLines                   = node.Attributes.GetNamedItem("lines").Value;
                    var strOrgNewValue             = node.Attributes.GetNamedItem("org_new_value").Value;
                    var strAction                  = node.Attributes.GetNamedItem("action").Value;
                    var strPrevUserId              = node.Attributes.GetNamedItem("prev_user_id").Value;
                    var strUserId                  = node.Attributes.GetNamedItem("user_id").Value;
                    var strComments                = node.Attributes.GetNamedItem("com").Value;
                    var strRequestId               = node.Attributes.GetNamedItem("request").Value;
                    var strResponsibleOrganization = "";

                    var strNewOrganization    = "";
                    var strNewOrgCode         = "";
                    var intUserID             = 0;
                    var intPreviousReviewerID = 0;
                    var email_request         = 0;
                    var intRequestID          = 0;

                    if (strUserId.Length > 0)
                    {
                        intUserID = Int32.Parse(strUserId);
                    }
                    if (strPrevUserId.Length > 0)
                    {
                        intPreviousReviewerID = Int32.Parse(strPrevUserId);
                    }

                    if (strOrgNewValue.Length > 0)
                    {
                        strNewOrganization = strOrgNewValue.Substring(0, strOrgNewValue.IndexOf(":") - 1);
                        strNewOrgCode      = strOrgNewValue.Substring(strOrgNewValue.IndexOf(":") + 2);
                    }
                    var intActionCode = Int32.Parse(strAction);
                    var intItemID     = Int32.Parse(strItemID);

                    if (strRequestId != "")
                    {
                        intRequestID = Int32.Parse(strRequestId);
                    }

                    if (intActionCode == (int)HistoryActions.haReviewerAssignment)
                    {
                        //in the case of reviewer reassignment within the same organization,
                        //instead of this:
                        //AssignBO.ReassignItem(intItemID, strOrgCode, intPreviousReviewerID, intUserID, strComments);
                        // we will use direct reroute for item (or specific lines) within the same organization:
                        strResponsibleOrganization = Lookups.GetOrganizationByOrgCode(strOrgCode);

                        /*****************************************************************************************************/
                        //ADD LOG FOR WATCHING RECORDS UPDATE IN THE tblOIOrganization !!!!!!!!!!!
                        /*****************************************************************************************************/
                        var dt = Assign.RerouteItemDirectly(intItemID, strLines, intPreviousReviewerID, strOrgCode, strResponsibleOrganization, strOrgCode, intUserID, strComments);


                        //if we don't have previous Reviewer - it is first time Reviewer Assignment -
                        //we don't need to send immidiately notification email;
                        //if we do have previous Reviewer - it is Re-Assignment within the same organization,
                        //we should send notification email to user immidiately:
                        if (intPreviousReviewerID == 0)
                        {
                            if (Settings.Default.SendEmailOnReviewerAssignment)
                            {
                                email_request = Emails.InsertEmailRequest(user, (int)HistoryActions.haReviewerAssignment, false);
                            }
                            // action code 3
                            History.InsertHistoryOnReasssignment((int)HistoryActions.haReviewerAssignment, intItemID, intLoadID, strOrgCode, strLines,
                                                                 intPreviousReviewerID, intUserID, strComments, user, email_request);
                        }
                        else
                        {
                            if (Settings.Default.SendEmailOnReviewerReassign)
                            {
                                email_request = Emails.InsertEmailRequest(user, (int)HistoryActions.haReviewerReassignment, true);
                            }

                            History.InsertHistoryOnReasssignment((int)HistoryActions.haReviewerReassignment, intItemID, intLoadID, strOrgCode, strLines,
                                                                 intPreviousReviewerID, intUserID, strComments, user, email_request);
                        }

                        //in the case of reroute request by Reviewer, the item has been already reassigned (code above),
                        //we need to cancel reroute request in the tblReassignRequest table:
                        if (intRequestID != 0)
                        {
                            Assign.CancelRerouteRequest(intRequestID);
                        }
                    }
                    else
                    if (intActionCode == (int)HistoryActions.haRerouteRequest)
                    {
                        //in the case of reroute request by Reviewer,
                        //we need to cancel previous reroute request in the tblReassignRequest table,
                        //and then to create new reroute request for BD:
                        if (intRequestID != 0)
                        {
                            Assign.CancelRerouteRequest(intRequestID);
                        }

                        intRequestID = Assign.RequestReassignItem(intItemID, strOrgCode, strLines, intPreviousReviewerID, OIConstants.OpenItemsGridFilter_BDResponsibility,
                                                                  strNewOrganization, strNewOrgCode, intUserID, strComments);

                        if (intRequestID == 0)
                        {
                            str_result = "<error><err_msg msg='This Open Item has been already requested for reroute. \nPlease refresh your items view.' /></error>";
                        }
                        else
                        {
                            //send email only if current logged on user is not "BD Admin"
                            if (!User.IsInRole(((int)UserRoles.urBudgetDivisionAdmin).ToString()) &&
                                Settings.Default.SendEmailOnRerouteRequest)
                            {
                                email_request = Emails.InsertEmailRequest(user, (int)HistoryActions.haRerouteRequest, true);
                            }

                            History.InsertHistoryOnRerouteRequest(intItemID, strLines, intLoadID, strOrgCode, intRequestID, strOrgNewValue,
                                                                  intPreviousReviewerID, intUserID, strComments, user, email_request);
                        }
                    }

                    SendEmailOnReassigRequest(intItemID, strOrgCode, strNewOrgCode, strResponsibleOrganization, strNewOrganization, user, intUserID, strComments, "4");


                    //refresh Items GridResults on the next reload:
                    _page.ItemsDataView = null;
                }

                if (obj_xml.DocumentElement.Name == "group_reroute") //action 16
                {
                    var node      = obj_xml.DocumentElement.FirstChild;
                    var strLoadID = "0";

                    var strItemsArray  = node.Attributes.GetNamedItem("items").Value;
                    var strOrgNewValue = node.Attributes.GetNamedItem("org_new_value").Value;
                    var strUserID      = node.Attributes.GetNamedItem("user").Value;
                    var strComments    = node.Attributes.GetNamedItem("com").Value;

                    var strNewOrganization = "";
                    var strNewOrgCode      = "";
                    var intUserID          = 0;
                    var email_request      = 0;

                    if (strUserID.Length > 0)
                    {
                        intUserID = Int32.Parse(strUserID);
                    }

                    if (strOrgNewValue.Length > 0)
                    {
                        strNewOrganization = strOrgNewValue.Substring(0, strOrgNewValue.IndexOf(":") - 1);
                        strNewOrgCode      = strOrgNewValue.Substring(strOrgNewValue.IndexOf(":") + 2);
                    }

                    if (strItemsArray.Substring(strItemsArray.Length - 1) == ",")
                    {
                        strItemsArray = strItemsArray.Substring(0, strItemsArray.Length - 1);
                    }

                    var       arr = strItemsArray.Split(new char[] { ',' });
                    string    item_id;
                    string    line_num;
                    DataTable dt;
                    LineNum   line_obj = null;

                    foreach (var arr_item in arr)
                    {
                        if (arr_item != "")
                        {
                            item_id  = arr_item.Substring(0, arr_item.IndexOf("_")).Trim();
                            line_num = arr_item.Substring(arr_item.IndexOf("_") + 1).Trim();

                            line_obj = LineNum.GetLineNum(Int32.Parse(item_id), Int32.Parse(line_num));

                            if (intLoadID == 0)
                            {
                                strLoadID = Admin.GetLoadIDByItemID(line_obj.OItemID);
                                if (strLoadID != null && strLoadID.Trim() != "" && strLoadID != "0")
                                {
                                    intLoadID = Convert.ToInt32(strLoadID);
                                }
                            }

                            if (strNewOrganization == "" || line_obj.Organization == strNewOrganization)
                            {
                                //reassignment within the same organization: // corrected by Foram
                                dt = Assign.RerouteItemDirectly(line_obj.OItemID, line_num, line_obj.ReviewerUserID, line_obj.ULOOrgCode, line_obj.Organization, strNewOrgCode, intUserID, strComments);

                                // //action code 16
                                History.InsertHistoryOnReasssignment((int)HistoryActions.haReviewerReassignment, line_obj.OItemID, intLoadID, line_obj.ULOOrgCode, line_num,
                                                                     line_obj.ReviewerUserID, intUserID, strComments, user, 0);
                            }
                            else
                            {
                                //reroute to an other organization:
                                dt = Assign.RerouteItemDirectly(line_obj.OItemID, line_num, line_obj.ReviewerUserID, line_obj.ULOOrgCode, strNewOrganization, strNewOrgCode, intUserID, strComments);

                                History.InsertHistoryOnRerouteReassign(line_obj.OItemID, dt, line_num, intLoadID, line_obj.DocNumber, line_obj.ULOOrgCode,
                                                                       line_obj.Organization, line_obj.ReviewerUserID, strNewOrgCode, strOrgNewValue, intUserID, strComments, user, 0);
                            }
                        }
                    }
                    if (strNewOrganization == "" && line_obj != null)
                    {
                        strNewOrganization = line_obj.Organization;
                        strNewOrgCode      = line_obj.ULOOrgCode;
                    }

                    //insert history for group assignment - for email details,
                    //in the case of group assignment one email only will be sent to the user
                    if (Settings.Default.SendEmailOnGroupAssign)
                    {
                        // action code 19
                        email_request = Emails.InsertEmailRequest(user, (int)HistoryActions.haGroupAssignment, true);
                        //SendEmailOnReassigRequest(intOItemID, strCurrentOrgCode, strNewOrgCode, strCurrentOrganization, strNewOrganization, user, intUserID, strComments, "19");
                    }

                    History.InsertHistoryOnGroupAssign(intLoadID, intUserID, strNewOrganization, strNewOrgCode, strComments, user, email_request);

                    SendEmailOnReassigRequest(0, line_obj.ULOOrgCode, strNewOrgCode, line_obj.Organization, strNewOrganization, user, intUserID, strComments, "16");


                    //refresh Items GridResults on the next reload:
                    _page.ItemsDataView = null;
                }

                if (obj_xml.DocumentElement.Name == "reroute") //10
                {
                    var node = obj_xml.DocumentElement.FirstChild;

                    var strRequestID        = node.Attributes.GetNamedItem("request_id").Value;
                    var strOItemID          = node.Attributes.GetNamedItem("item_id").Value;
                    var strLines            = node.Attributes.GetNamedItem("lines").Value;
                    var strDocNum           = node.Attributes.GetNamedItem("doc_num").Value;
                    var strPrevOrganization = node.Attributes.GetNamedItem("prev_org").Value;
                    var strPrevReviewer     = node.Attributes.GetNamedItem("prev_user").Value;
                    var strOrgNewValue      = node.Attributes.GetNamedItem("org_new_value").Value;
                    var strUserID           = node.Attributes.GetNamedItem("user").Value;
                    var strComments         = node.Attributes.GetNamedItem("com").Value;

                    var strNewOrganization     = "";
                    var strNewOrgCode          = "";
                    var strCurrentOrganization = "";
                    var strCurrentOrgCode      = "";
                    var intOItemID             = 0;
                    var intUserID     = 0;
                    var intRequestID  = 0;
                    var intPrevUserID = 0;
                    var email_request = 0;

                    if (strOItemID.Length > 0)
                    {
                        intOItemID = Int32.Parse(strOItemID);
                    }
                    if (strRequestID.Length > 0)
                    {
                        intRequestID = Int32.Parse(strRequestID);
                    }
                    if (strUserID.Length > 0)
                    {
                        intUserID = Int32.Parse(strUserID);
                    }
                    if (strPrevReviewer.Length > 0)
                    {
                        intPrevUserID = Int32.Parse(strPrevReviewer);
                    }

                    if (strPrevOrganization.Length > 0)
                    {
                        strCurrentOrganization = strPrevOrganization.Substring(0, strPrevOrganization.IndexOf(":") - 1);
                        strCurrentOrgCode      = strPrevOrganization.Substring(strPrevOrganization.IndexOf(":") + 2);
                    }
                    if (strOrgNewValue.Length > 0)
                    {
                        strNewOrganization = strOrgNewValue.Substring(0, strOrgNewValue.IndexOf(":") - 1);
                        strNewOrgCode      = strOrgNewValue.Substring(strOrgNewValue.IndexOf(":") + 2);
                    }

                    if (intRequestID > 0)
                    {
                        //reroute item by request:
                        var RetCode = Assign.RerouteItem(intRequestID, strNewOrganization, strNewOrgCode, intUserID, strComments);

                        if (Settings.Default.SendEmailOnRerouteAssign)
                        {
                            email_request = Emails.InsertEmailRequest(user, (int)HistoryActions.haRerouteAssignment, true);
                        }

                        History.InsertHistoryOnRerouteReassign(intRequestID, strPrevOrganization, intPrevUserID,
                                                               strOrgNewValue, intUserID, strComments, user, email_request);
                    }
                    else
                    {
                        //reroute item directly to user, the action permitted to BD Admin only:
                        var dt = Assign.RerouteItemDirectly(intOItemID, strLines, intPrevUserID, strCurrentOrgCode, strNewOrganization, strNewOrgCode, intUserID, strComments);

                        if (Settings.Default.SendEmailOnRerouteAssign)
                        {
                            email_request = Emails.InsertEmailRequest(user, (int)HistoryActions.haRerouteAssignment, true);
                        }

                        History.InsertHistoryOnRerouteReassign(intOItemID, dt, strLines, intLoadID, strDocNum, strCurrentOrgCode,
                                                               strPrevOrganization, intPrevUserID, strNewOrgCode, strOrgNewValue, intUserID, strComments, user, email_request);



                        //refresh Items GridResults on the next reload:
                        _page.ItemsDataView = null;
                    }

                    SendEmailOnReassigRequest(intOItemID, strCurrentOrgCode, strNewOrgCode, strCurrentOrganization, strNewOrganization, user, intUserID, strComments, "10");
                }

                if (obj_xml.DocumentElement.Name == "select_doc_to_email")
                {
                    var node = obj_xml.DocumentElement.FirstChild;

                    bool bln_selected;
                    int  doc_id;

                    var selected_value = node.Attributes.GetNamedItem("selected").Value;
                    var selected_doc   = node.Attributes.GetNamedItem("doc").Value;

                    if (selected_value != "" && selected_doc != "")
                    {
                        bln_selected = Boolean.Parse(selected_value);
                        doc_id       = Int32.Parse(selected_doc);

                        Document.SelectSendAttachment(_page.DocNumber, doc_id, _page.LoadID, bln_selected);

                        if (Settings.Default.InsertHistory_OnSelectAttachmentToCO)
                        {
                            var doc       = new Document(doc_id);
                            var file_name = doc.FileName;
                            var doc_type  = String.Join(",", doc.DocumentTypeName);
                            History.InsertHistoryOnSelectAttachmentForEmail((int)HistoryActions.haSelectAttachmentForCOEmail, _page.DocNumber, _page.LoadID, bln_selected, doc_id, doc_type, file_name, _page.CurrentUserOrganization, user);
                        }
                    }
                }

                if (obj_xml.DocumentElement.Name == "select_doc_revision_email")
                {
                    var node = obj_xml.DocumentElement.FirstChild;

                    bool bln_selected;
                    int  doc_id;

                    var selected_value = node.Attributes.GetNamedItem("selected").Value;
                    var selected_doc   = node.Attributes.GetNamedItem("doc").Value;

                    if (selected_value != "" && selected_doc != "")
                    {
                        bln_selected = Boolean.Parse(selected_value);
                        doc_id       = Int32.Parse(selected_doc);

                        Document.SelectAttachmentForRevision(_page.DocNumber, doc_id, _page.LoadID, bln_selected);

                        if (Settings.Default.InsertHistory_OnSelectAttachmentToSME)
                        {
                            var doc       = new Document(doc_id);
                            var file_name = doc.FileName;
                            var doc_type  = String.Join(",", doc.DocumentTypeName);
                            History.InsertHistoryOnSelectAttachmentForEmail((int)HistoryActions.haSelectAttachmentForSMEEmail, _page.DocNumber, _page.LoadID, bln_selected, doc_id, doc_type, file_name, _page.CurrentUserOrganization, user);
                        }
                    }
                }

                if (obj_xml.DocumentElement.Name == "select_doc_approved")
                {
                    var node = obj_xml.DocumentElement.FirstChild;

                    Int16 selected;
                    int   doc_id;
                    int   doc_type_code;

                    var selected_value      = node.Attributes.GetNamedItem("selected").Value;
                    var selected_doc        = node.Attributes.GetNamedItem("doc").Value;
                    var doc_type            = node.Attributes.GetNamedItem("doc_type").Value;
                    var doc_type_name       = node.Attributes.GetNamedItem("doc_type_name").Value;
                    var file_name           = node.Attributes.GetNamedItem("file_name").Value;
                    var upload_user_email   = node.Attributes.GetNamedItem("user").Value;
                    var upload_organization = node.Attributes.GetNamedItem("org").Value;

                    if (selected_value != "" && selected_doc != "" && doc_type != "")
                    {
                        selected      = (Boolean.Parse(selected_value)) ? (Int16)DocRevisionStatus.dsApproved : (Int16)DocRevisionStatus.dsNotApproved;
                        doc_id        = Int32.Parse(selected_doc);
                        doc_type_code = Int32.Parse(doc_type);

                        Document.UpdateDocRevision(_page.LoadID, _page.DocNumber, doc_id, doc_type_code, selected);
                        History.InsertHistoryOnDocumentRevision(_page.DocNumber, _page.LoadID, doc_id, file_name, doc_type_name, selected, upload_user_email, upload_organization, user);
                    }
                }

                if (obj_xml.DocumentElement.Name == "save_feedback")
                {
                    var     intItemID   = 0;
                    var     intReviewer = 0;
                    var     intLoad     = 0;
                    var     intValid    = 0;
                    decimal decDO       = 0;
                    decimal decUDO      = 0;
                    var     error_msg   = "";

                    var node = obj_xml.DocumentElement.FirstChild;

                    var item_id = node.Attributes.GetNamedItem("item_id").Value;
                    if (item_id.Length > 0)
                    {
                        intItemID = Int32.Parse(item_id);
                    }
                    var reviewer_id = node.Attributes.GetNamedItem("reviewer_id").Value;
                    if (reviewer_id.Length > 0)
                    {
                        intReviewer = Int32.Parse(reviewer_id);
                    }
                    var load_id = node.Attributes.GetNamedItem("load_id").Value;
                    if (load_id.Length > 0)
                    {
                        intLoad = Int32.Parse(load_id);
                    }
                    var valid = node.Attributes.GetNamedItem("valid").Value;
                    if (valid.Length > 0)
                    {
                        intValid = Int32.Parse(valid);
                    }
                    var udo_should_be = node.Attributes.GetNamedItem("udo").Value;
                    var do_should_be  = node.Attributes.GetNamedItem("do").Value;
                    if (intValid == 0)
                    {
                        error_msg = "Please select the validation value. This is a required field. ";
                    }
                    try
                    {
                        if (udo_should_be.Length > 0 && udo_should_be != "$")
                        {
                            decUDO = Utility.GetDecimalFromDisplayedMoney(udo_should_be);
                        }

                        if (do_should_be.Length > 0 && do_should_be != "$")
                        {
                            decDO = Utility.GetDecimalFromDisplayedMoney(do_should_be);
                        }
                    }
                    catch (Exception exp)
                    {
                        error_msg = error_msg + "Please verify that you have entered the correct money value.";
                    }
                    if (error_msg != "")
                    {
                        str_result = "<error><err_msg msg='" + error_msg + "' /></error>";
                    }
                    else
                    {
                        var response   = node.Attributes.GetNamedItem("response").Value;
                        var doc_number = node.Attributes.GetNamedItem("doc_num").Value;
                        var org_code   = node.Attributes.GetNamedItem("org_code").Value;

                        Item.SaveFeedbackResponse(intItemID, doc_number, intLoad, intValid, response, decUDO, decDO);

                        //update item status:
                        Item.UpdateItemStatus(intItemID, intLoad, org_code, intReviewer, (int)OpenItemStatus.stClosed);

                        History.InsertHistoryOnFeedbackResponse(doc_number, intLoad, intItemID, org_code, intValid, response, decUDO, decDO, (int)OpenItemStatus.stClosed, intReviewer, user);

                        //refresh Items GridResults on the next reload:
                        _page.ItemsDataView = null;
                    }
                }

                if (str_result == "")
                {
                    str_result = "<ok/>";
                }
            }
            catch (Exception ex)
            {
                str_result = "<error><err_msg msg='" + ex.Message + "' /></error>";
            }

            Response.ContentType = "text/xml";
            Response.Write(str_result);
            Response.Flush();
        }