Beispiel #1
0
    public void SortDetailGrid(Object sender, GridViewSortEventArgs e)
    {
        try
        {
            if (hidSort.Attributes["sortType"] != null)
            {
                if (hidSort.Attributes["sortType"].ToString() == "ASC")
                {
                    hidSort.Attributes["sortType"] = "DESC";
                }
                else
                {
                    hidSort.Attributes["sortType"] = "ASC";
                }
            }
            else
            {
                hidSort.Attributes.Add("sortType", "DESC");
            }

            hidSort.Value = e.SortExpression + " " + hidSort.Attributes["sortType"].ToString();

            dt = (DataTable)Session["CPSMData"];
            DataView dv = new DataView(dt, hidRowFilter.Value.ToString(), hidSort.Value.ToString(), DataViewRowState.CurrentRows);
            CPSMGridView.DataSource = dv;
            CPSMGridView.DataBind();
            DetailGridPanel.Height = new Unit(double.Parse(DetailGridHeightHidden.Value), UnitType.Pixel);
            DetailGridPanel.Width  = new Unit(double.Parse(DetailGridWidthHidden.Value), UnitType.Pixel);
        }
        catch (Exception e2)
        {
            lblErrorMessage.Text = "Sort Error " + e2.Message + ", " + e2.ToString();
            MessageUpdatePanel.Update();
        }
    }
Beispiel #2
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        lblErrorMessage.Text   = "";
        lblSuccessMessage.Text = "";
        MessageUpdatePanel.Update();
        string Track = "Timer" + DateTime.Now.ToString("mm:ss");

        if (txtCustNo.Text.Trim().Length == 0)
        {
            lblErrorMessage.Text = "You must enter a Customer Number.";
            MessageUpdatePanel.Update();
        }
        else
        {
            try
            {
                lblErrorMessage.Text = "";
                ClearDisplay();

                //Get the data using pCustPriceGetHist
                Track += "|DataBeg" + DateTime.Now.ToString("mm:ss");
                ds     = SqlHelper.ExecuteDataset(ConnectionString, "pCustPriceGetHist",
                                                  new SqlParameter("@CustNo", txtCustNo.Text.Trim()),
                                                  new SqlParameter("@itemType", (rdoBulk.Checked ? "Bulk" : "Package")));
                Track += "|DataEnd" + DateTime.Now.ToString("mm:ss");
                if (ds.Tables.Count == 2)
                {
                    dt = ds.Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        lblCustName.Text        = dt.Rows[0]["CustomerName"].ToString();
                        lblBranch.Text          = dt.Rows[0]["Branch"].ToString();
                        lblRecType.Text         = "";
                        CPSMRecTypeHidden.Value = dt.Rows[0]["RecType"].ToString();

                        if (CPSMRecTypeHidden.Value.ToString() == "0")
                        {
                            lblRecType.Text = "These are New records wating for Targets.";
                        }
                        if (CPSMRecTypeHidden.Value.ToString() == "1")
                        {
                            lblRecType.Text = "These are Unprocessed waiting for Appproval.";
                        }

                        hidSort.Value = "";
                        hidSort.Attributes["sortType"] = "DESC";
                        hidRowFilter.Value             = "GroupType = 'C'";

                        // Change Target column header based on item type
                        CPSMGridView.Columns[7].HeaderText = (rdoBulk.Checked ? "Target" : "Bulk +");

                        DataView dv = new DataView(dt, hidRowFilter.Value.ToString(), hidSort.Value.ToString(), DataViewRowState.CurrentRows);
                        CPSMGridView.DataSource = dv;
                        Session["CPSMData"]     = dt;
                        Track += "|Session" + DateTime.Now.ToString("mm:ss");
                        CPSMGridView.DataBind();
                        Track += "|DataBind" + DateTime.Now.ToString("mm:ss");

                        if (ApprovalOKHidden.Value.ToUpper() == "TRUE")
                        {
                            ApproveUpdatePanel.Visible = true;
                            SubmitUpdatePanel.Visible  = false;
                        }
                        else
                        {
                            ApproveUpdatePanel.Visible = false;
                            SubmitUpdatePanel.Visible  = true;
                        }

                        if (hidShowCostBasis.Value == "TRUE")
                        {
                            ibtnSetBasis.Visible = true;
                        }
                        else
                        {
                            ibtnSetBasis.Visible = false;
                        }

                        if (hidPriceAnalysis.Value == "TRUE")
                        {
                            btnPriceAnalysis.Visible = true;
                        }
                        else
                        {
                            btnPriceAnalysis.Visible = false
                            ;
                        }
                        ExcelUpdatePanel.Visible = true;
                        SelectorUpdatePanel.Update();
                        DetailUpdatePanel.Update();
                    }
                    else
                    {
                        lblErrorMessage.Text = "No Price Schedule Data For Customer " + txtCustNo.Text.Trim();
                        MessageUpdatePanel.Update();
                        Session["CPSMData"] = null;
                        CPSMGridView.DataBind();
                    }
                    Track += "|HdrBeg" + DateTime.Now.ToString("mm:ss");

                    dtSched = ds.Tables[1];
                    if (dtSched.Rows.Count > 0)
                    {
                        if (string.IsNullOrEmpty(lblCustName.Text.ToString()))
                        {
                            lblCustName.Text = dtSched.Rows[0]["CustomerName"].ToString();
                        }
                        if (string.IsNullOrEmpty(lblBranch.Text.ToString()))
                        {
                            lblBranch.Text = dtSched.Rows[0]["Branch"].ToString();
                        }
                        lblSched1.Text         = dtSched.Rows[0]["ContractSchd1"].ToString();
                        lblSched2.Text         = dtSched.Rows[0]["ContractSchd2"].ToString();
                        lblSched3.Text         = dtSched.Rows[0]["ContractSchd3"].ToString();
                        lblSched4.Text         = dtSched.Rows[0]["ContractSchedule4"].ToString();
                        lblSched5.Text         = dtSched.Rows[0]["ContractSchedule5"].ToString();
                        lblSched6.Text         = dtSched.Rows[0]["ContractSchedule6"].ToString();
                        lblSched7.Text         = dtSched.Rows[0]["ContractSchedule7"].ToString();
                        lblTargetGross.Text    = String.Format("{0:0.0}", dtSched.Rows[0]["TargetGrossMarginPct"]);
                        lblWebDiscPct.Text     = String.Format("{0:0.00}", dtSched.Rows[0]["WebDiscountPct"]);
                        chkWebDiscInd.Checked  = (dtSched.Rows[0]["WebDiscountInd"].ToString().ToUpper().Trim() == "1");
                        lblCustDefPrice.Text   = dtSched.Rows[0]["CustomerDefaultPrice"].ToString();
                        lblCustPriceInd.Text   = dtSched.Rows[0]["CustomerPriceInd"].ToString();
                        lblCreditInd.Text      = dtSched.Rows[0]["CreditInd"].ToString();
                        lblActGrossMgnPct.Text = dtSched.Rows[0]["ActGrossMgnPct"].ToString();
                        lblDefaultCostPct.Text = dtSched.Rows[0]["TargetCostPlusPct"].ToString();
                    }
                    else
                    {
                        lblErrorMessage.Text = "Customer " + txtCustNo.Text.Trim() + " Not On File";
                        MessageUpdatePanel.Update();
                    }

                    Track += "|HdrEnd" + DateTime.Now.ToString("mm:ss");
                    lblSuccessMessage.Text = Track;
                    MessageUpdatePanel.Update();
                }
            }
            catch (Exception e3)
            {
                lblErrorMessage.Text = "pCustPriceGetHist Error " + e3.Message + ", " + e3.ToString();
                MessageUpdatePanel.Update();
            }
        }
    }
Beispiel #3
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();
        }
    }