示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Initializing AJAX.NET Library
        Ajax.Utility.RegisterTypeForAjax(typeof(CatPriceSchedMaint));
        CPSMScriptManager.SetFocus("txtCustNo");

        if (!IsPostBack)
        {
            SubmitUpdatePanel.Visible  = false;
            ApproveUpdatePanel.Visible = false;
            ExcelUpdatePanel.Visible   = false;

            ApprovalOKHidden.Value = MaintUtil.GetSecurityCode(Session["UserName"].ToString(), MaintenaceTable.CatPriceSchedMaintApproval);
            hidShowCostBasis.Value = MaintUtil.GetSecurityCode(Session["UserName"].ToString(), MaintenaceTable.CatPriceSchedMaintSetCost);
            hidPriceAnalysis.Value = MaintUtil.GetSecurityCode(Session["UserName"].ToString(), MaintenaceTable.PriceAnalysisReportAccess);
            rdoPackage.Visible     = (MaintUtil.GetSecurityCode(Session["UserName"].ToString(), MaintenaceTable.CatPriceSchedulePKGOption) != "" ? true : false);

            if (ApprovalOKHidden.Value.ToString() != "")
            {
                ApprovalOKHidden.Value = "TRUE";
            }

            if (hidShowCostBasis.Value.ToString() != "")
            {
                hidShowCostBasis.Value = "TRUE";
            }
            if (hidPriceAnalysis.Value.ToString() != "")
            {
                hidPriceAnalysis.Value = "TRUE";
            }

            if ((MaintUtil.GetSecurityCode(Session["UserName"].ToString(), MaintenaceTable.CatPriceSchedMaintAccess) == "") && (ApprovalOKHidden.Value.ToUpper() != "TRUE"))
            {
                txtCustNo.Enabled    = false;
                btnSearch.Visible    = false;
                lblErrorMessage.Text = "You do not have sufficient security to access this application.";
                MessageUpdatePanel.Update();
            }

            if (Request.QueryString["CustNo"] != null && Request.QueryString["CustNo"].ToString() != "")
            {
                txtCustNo.Text = Request.QueryString["CustNo"].ToString();
                btnSearch_Click(btnSearch, new EventArgs());
            }
        }
    }
示例#2
0
    public void ProcessWork(string SuccessText, string source)
    {
        try
        {
            ProcessError             = false;
            dt                       = (DataTable)Session["CPSMData"];
            dt.DefaultView.RowFilter = hidRowFilter.Value;
            foreach (DataRow dr in dt.DefaultView.ToTable().Rows)
            {
                string _Action = "";
                if (CPSMRecTypeHidden.Value.ToString() == "0")
                {
                    _Action = "I";
                }

                if (CPSMRecTypeHidden.Value.ToString() == "1")
                {
                    _Action = "U";
                }

                try
                {
                    if (_Action != "")
                    {
                        ds = SqlHelper.ExecuteDataset(ConnectionString, "pCustPriceWorkUnprocessed",
                                                      new SqlParameter("@Action", "I"),
                                                      new SqlParameter("@Branch", dr["Branch"].ToString()),
                                                      new SqlParameter("@CustomerNo", dr["CustomerNo"].ToString()),
                                                      new SqlParameter("@CustomerName", dr["CustomerName"].ToString()),
                                                      new SqlParameter("@GroupType", dr["GroupType"].ToString()),
                                                      new SqlParameter("@GroupNo", dr["GroupNo"].ToString()),
                                                      new SqlParameter("@GroupDesc", dr["GroupDesc"].ToString()),
                                                      new SqlParameter("@BuyGroupNo", dr["BuyGroupNo"].ToString()),
                                                      new SqlParameter("@BuyGroupDesc", dr["BuyGroupDesc"].ToString()),
                                                      new SqlParameter("@SalesHistory", dr["SalesHistory"].ToString()),
                                                      new SqlParameter("@GMPctPriceCost", dr["GMPctPriceCost"].ToString()),
                                                      new SqlParameter("@GMPctAvgCost", dr["GMPctAvgCost"].ToString()),
                                                      new SqlParameter("@SalesHistoryTot", dr["SalesHistoryTot"].ToString()),
                                                      new SqlParameter("@GMPctPriceCostTot", dr["GMPctPriceCostTot"].ToString()),
                                                      new SqlParameter("@GMPctAvgCostTot", dr["GMPctAvgCostTot"].ToString()),
                                                      new SqlParameter("@SalesHistoryEComm", dr["SalesHistoryEComm"].ToString()),
                                                      new SqlParameter("@GMPctPriceCostEComm", dr["GMPctPriceCostEComm"].ToString()),
                                                      new SqlParameter("@GMPctAvgCostEComm", dr["GMPctAvgCostEComm"].ToString()),
                                                      new SqlParameter("@SalesHistory12Mo", dr["SalesHistory12Mo"].ToString()),
                                                      new SqlParameter("@GMPctPriceCost12Mo", dr["GMPctPriceCost12Mo"].ToString()),
                                                      new SqlParameter("@GMPctAvgCost12Mo", dr["GMPctAvgCost12Mo"].ToString()),
                                                      new SqlParameter("@TargetGMPct", dr["TargetGMPct"].ToString()),
                                                      new SqlParameter("@ExistingCustPricePct", dr["ExistingCustPricePct"].ToString()),
                                                      new SqlParameter("@Approved", dr["Approved"].ToString()),
                                                      new SqlParameter("@EntryID", Session["UserName"].ToString()),
                                                      new SqlParameter("@priceMethod", (rdoPackage.Checked == true ? "M" : "G")),
                                                      new SqlParameter("@GMPctSmthAvgCost", dr["GMPctSmthAvgCost"].ToString()),
                                                      new SqlParameter("@GMPctReplCost", dr["GMPctReplCost"].ToString()),
                                                      new SqlParameter("@contractSales", dr["ContractSales"].ToString()),
                                                      new SqlParameter("@nonContractSales", dr["NonContractSales"].ToString()),
                                                      new SqlParameter("@contractGMPct", dr["ContractGMPct"].ToString()),
                                                      new SqlParameter("@nonContractGMPct", dr["NonContractGMPct"].ToString()));
                    }
                }
                catch (SqlException ex)
                {
                    StringBuilder errorMessages = new StringBuilder();
                    for (int i = 0; i < ex.Errors.Count; i++)
                    {
                        errorMessages.Append("Index #" + i + "\n" +
                                             "Message: " + ex.Errors[i].Message + "\n" +
                                             "LineNumber: " + ex.Errors[i].LineNumber + "\n" +
                                             "Source: " + ex.Errors[i].Source + "\n" +
                                             "Procedure: " + ex.Errors[i].Procedure + "\n");
                    }
                    lblErrorMessage.Text = "pCustPriceWorkUnprocessed Error " + errorMessages.ToString();
                    MessageUpdatePanel.Update();
                    ProcessError = true;
                    break;
                }
            }
            if (!ProcessError)
            {
                if (source == "submit")
                {
                    bool result = SendCPMAwaitingApprovalEmail();
                }

                lblErrorMessage.Text   = "";
                lblSuccessMessage.Text = SuccessText;
                MessageUpdatePanel.Update();

                txtCustNo.Text = "";
                ClearDisplay();

                CPSMScriptManager.SetFocus("txtCustNo");
                CPSMGridView.DataBind();
            }
        }
        catch (NullReferenceException ex0)
        {
            lblErrorMessage.Text = "Null Reference " + ex0.ToString();
            MessageUpdatePanel.Update();
        }
        catch (Exception ex1)
        {
            lblErrorMessage.Text = ex1.ToString();
            MessageUpdatePanel.Update();
        }
    }