Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Disable Add Products button to provent the user
            //using it while in edit mode.
            btnAddProducts.Enabled = false;

            if (!Page.IsPostBack)
            {
                //Check query string status
                if (!String.IsNullOrEmpty(Request["QuoteDetailsID"]))
                {
                    //Edit mode
                    //Get quote details id of quote being edited
                    int           qteID = Convert.ToInt32(Request["QuoteDetailsID"]);
                    Quote_Details qid   = db.Quote_Details.Where(a => a.Quote_Details_ID == qteID).FirstOrDefault();
                    if (qid != null)
                    {
                        //Display existing quote in panel
                        pnlExistingQuote.Visible = true;

                        //Controls set for edit mode
                        btnAddProducts.Enabled = true;
                        btnSaveConfirm.Enabled = false;

                        //Set hidden field values
                        //Display the dimensions of quote
                        SlabHeight.Value       = qid.Cap_Height.ToString();
                        lblCapHeightPanel.Text = qid.Cap_Height.ToString();

                        SlabWidth.Value       = qid.Cap_Width.ToString();
                        lblCapWidthPanel.Text = qid.Cap_Width.ToString();

                        SlabLength.Value       = qid.Cap_Length.ToString();
                        lblCapLengthPanel.Text = qid.Cap_Length.ToString();

                        PryHeight.Value       = qid.Cap_Point.ToString();
                        lblCapPointPanel.Text = qid.Cap_Point.ToString();

                        DisplayStoneType.Value       = qid.Stone_ID.ToString();
                        lblQuantityCaptionPanel.Text = qid.Quantity.ToString();

                        lblDisplayStoneType.Text = qid.Stone.StoneType;

                        txtInvisibleTotal.Text = qid.Quote.Quote_Price.ToString();

                        //If this value is null then there is no pllar car quotes in the database.
                        //This can only happen if the Quote_Details table has been cleared.
                        //The default values are then applied.
                        if (SlabHeight.Value == "")
                        {
                            DefaultDemensions();
                        }
                    }
                    else
                    {
                        DefaultDemensions();
                    }
                }

                else
                {
                    DefaultDemensions();
                }
            }
        }
Пример #2
0
        //Save user inputs
        protected void btnSaveConfirm_Click(object sender, EventArgs e)
        {
            //generate a random alphanumeric string for Quote Reference
            string qRef = Guid.NewGuid().ToString("N").Substring(0, 6).ToUpper();


            if (Page.IsValid)
            {
                Quote qte;

                if ((Session["quote"] != null))
                {
                    qte = (Quote)Session["quote"];
                    if (qte != null)
                    {
                        //Add dimensions of newly added product to session
                        qte.Quote_Details.Add(new Quote_Details()
                        {
                            Cap_Height        = float.Parse(SlabHeight.Value),
                            Cap_Width         = float.Parse(SlabWidth.Value),
                            Cap_Length        = float.Parse(SlabLength.Value),
                            Cap_Point         = float.Parse(PryHeight.Value),
                            Stone_ID          = Convert.ToInt32(DisplayStoneType.Value),
                            Product_Option_ID = 1,
                            Item_Price        = Convert.ToDecimal(lblCalculateAnswer.Text),
                            Quantity          = Convert.ToInt16(txtQuantity.Text)
                        });


                        int qteID = Convert.ToInt32(Request["QuoteDetailsID"]);

                        Quote qid = db.Quotes.Where(a => a.QuoteId == qteID).FirstOrDefault();
                        Session["quote"] = qte;

                        //Send qoute id to quote page
                        if (qid != null)
                        {
                            Response.Redirect("Quote.aspx?QuoteDetailsID=" + qid.QuoteId);
                        }
                        else
                        {
                            Response.Redirect("Quote.aspx");
                        }
                    }
                }
                else
                {
                    qte = new Quote()
                    {
                        Quote_Ref = qRef
                    };

                    //Save dimensions of cap
                    qte.Quote_Details.Add(new Quote_Details()
                    {
                        Cap_Height        = float.Parse(SlabHeight.Value),
                        Cap_Width         = float.Parse(SlabWidth.Value),
                        Cap_Length        = float.Parse(SlabLength.Value),
                        Cap_Point         = float.Parse(PryHeight.Value),
                        Stone_ID          = Convert.ToInt32(DisplayStoneType.Value),
                        Product_Option_ID = 1,
                        Item_Price        = Convert.ToDecimal(lblCalculateAnswer.Text),
                        Quantity          = Convert.ToInt16(txtQuantity.Text)
                    });

                    Session.Add("quote", qte);

                    //Get quote details id and send it to quote page
                    int           qteID = Convert.ToInt32(Request["QuoteDetailsID"]);
                    Quote_Details qid   = db.Quote_Details.Where(a => a.Quote_Details_ID == qteID).FirstOrDefault();

                    if (qid == null)
                    {
                        Response.Redirect("Quote.aspx");
                    }
                    else
                    {
                        Response.Redirect("Quote.aspx?QuoteDetailsID=" + qid.Quote_ID);
                    }
                }
            }
        }
Пример #3
0
        protected void btnAddProducts_Click(object sender, EventArgs e)
        {
            Quote qte;

            if ((Session["quote"] != null))
            {
                qte = (Quote)Session["quote"];
                if (qte != null)
                {
                    //Add dimensions when quote is edited
                    qte.Quote_Details.Add(new Quote_Details()
                    {
                        Cap_Height        = float.Parse(SlabHeight.Value),
                        Cap_Width         = float.Parse(SlabWidth.Value),
                        Cap_Length        = float.Parse(SlabLength.Value),
                        Cap_Point         = float.Parse(PryHeight.Value),
                        Stone_ID          = Convert.ToInt32(DisplayStoneType.Value),
                        Product_Option_ID = 1,
                        Item_Price        = Convert.ToDecimal(lblCalculateAnswer.Text),
                        Quantity          = Convert.ToInt16(txtQuantity.Text)
                    });


                    Session["quote"] = qte;
                }
            }
            else
            {
                string qRef = Guid.NewGuid().ToString("N").Substring(0, 6).ToUpper();
                qte = new Quote()
                {
                    Quote_Ref = qRef
                };

                //Check if quantity as a value.  If not use the value from label.  They're the same
                if (txtQuantity.Text == "")
                {
                    qte.Quote_Details.Add(new Quote_Details()

                    {
                        Cap_Height        = float.Parse(SlabHeight.Value),
                        Cap_Width         = float.Parse(SlabWidth.Value),
                        Cap_Length        = float.Parse(SlabLength.Value),
                        Cap_Point         = float.Parse(PryHeight.Value),
                        Stone_ID          = Convert.ToInt32(DisplayStoneType.Value),
                        Product_Option_ID = 1,
                        Item_Price        = Convert.ToDecimal(txtInvisibleTotal.Text),
                        Quantity          = Convert.ToInt16(lblQuantityCaptionPanel.Text)
                    });
                }
                else
                {
                    //Check if text box quantity as a value.
                    qte.Quote_Details.Add(new Quote_Details()

                    {
                        Cap_Height        = float.Parse(SlabHeight.Value),
                        Cap_Width         = float.Parse(SlabWidth.Value),
                        Cap_Length        = float.Parse(SlabLength.Value),
                        Cap_Point         = float.Parse(PryHeight.Value),
                        Stone_ID          = Convert.ToInt32(DisplayStoneType.Value),
                        Product_Option_ID = 1,
                        Item_Price        = Convert.ToDecimal(lblCalculateAnswer.Text),
                        Quantity          = Convert.ToInt16(txtQuantity.Text)
                    });
                }

                Session.Add("quote", qte);
            }

            //Send quote id back to landing page.
            //This is needed so customer info can be used on quote page
            int           qteID = Convert.ToInt32(Request["QuoteDetailsID"]);
            Quote_Details qid   = db.Quote_Details.Where(a => a.Quote_Details_ID == qteID).FirstOrDefault();

            if (qid != null)
            {
                Response.Redirect("LandingPage.aspx?QuoteDetailsID=" + qid.Quote_ID);
            }
            else
            {
                Response.Redirect("LandingPage.aspx");
            }
        }
Пример #4
0
        protected void btnSaveConfirm_Click(object sender, EventArgs e)
        {
            //generate a random alphanumeric string for Quote Reference
            string qRef = Guid.NewGuid().ToString("N").Substring(0, 6).ToUpper();

            //This is for editing a quote which is implemented yet
            if (Page.IsValid)
            {
                Quote qte;

                if ((Session["quote"] != null))
                {
                    qte = (Quote)Session["quote"];
                    if (qte != null)
                    {
                        //Add dimensions of newly added product to session
                        qte.Quote_Details.Add(new Quote_Details()
                        {
                            Fireplace_Base_Height = float.Parse(BaseHeight.Value),
                            Fireplace_Base_Width  = float.Parse(BaseWidth.Value),

                            Fireplace_Top_Height = float.Parse(TopHeight.Value),
                            Fireplace_Top_Width  = float.Parse(TopWidth.Value),
                            Stone_ID             = Convert.ToInt32(HF_MarbleSelection.Value),

                            Fireplace_Depth   = float.Parse(Depth.Value),
                            Product_Option_ID = 4,
                            Item_Price        = Convert.ToDecimal(lblCalculateAnswer.Text),
                            Quantity          = Convert.ToInt16(txtQuantity.Text)
                        });

                        int qteID = Convert.ToInt32(Request["QuoteDetailsID"]);

                        Quote qid = db.Quotes.Where(a => a.QuoteId == qteID).FirstOrDefault();
                        Session["quote"] = qte;

                        //Send qoute id to landing page
                        if (qid != null)
                        {
                            Response.Redirect("Quote.aspx?QuoteDetailsID=" + qid.QuoteId);
                        }
                        else
                        {
                            Response.Redirect("Quote.aspx");
                        }
                    }
                }
                else
                {
                    qte = new Quote()
                    {
                        Quote_Ref = qRef
                    };

                    //Save dimensions
                    qte.Quote_Details.Add(new Quote_Details()
                    {
                        Fireplace_Base_Height = float.Parse(BaseHeight.Value),
                        Fireplace_Base_Width  = float.Parse(BaseWidth.Value),

                        Fireplace_Top_Height = float.Parse(TopHeight.Value),
                        Fireplace_Top_Width  = float.Parse(TopWidth.Value),
                        Fireplace_Depth      = float.Parse(Depth.Value),
                        Stone_ID             = Convert.ToInt32(HF_MarbleSelection.Value),

                        Product_Option_ID = 4,
                        Item_Price        = Convert.ToDecimal(lblCalculateAnswer.Text),
                        Quantity          = Convert.ToInt16(txtQuantity.Text)
                    });

                    Session.Add("quote", qte);
                    int           qteID = Convert.ToInt32(Request["QuoteDetailsID"]);
                    Quote_Details qid   = db.Quote_Details.Where(a => a.Quote_Details_ID == qteID).FirstOrDefault();

                    //Send qoute id to quote page
                    if (qid == null)
                    {
                        Response.Redirect("Quote.aspx");
                    }
                    else
                    {
                        Response.Redirect("Quote.aspx?QuoteDetailsID=" + qid.Quote_ID);
                    }
                }
            }
        }