Esempio n. 1
0
        protected void SendMail(OrderObject oO)
        {
            string OrderMail = $@"Dear {oO.firstName} {oO.lastName}! {Environment.NewLine}
                           “As we express our gratitude, we must never forget that the highest appreciation is not to utter words, but to live by them.”{Environment.NewLine}
                           –John F. Kennedy.{Environment.NewLine}{Environment.NewLine}
                           Order info
                           Order nummer: {oO.orderId}
                           Total Price: { oO.CalculatePrice().ToString("#.##")}{Environment.NewLine}
                           Best reguards from Group 7  
                           
                           
                           ";


            try
            {
                MailMessage       o       = new MailMessage("*****@*****.**", $"{oO.email}", "Web-Shop Group7", $"{OrderMail}");
                NetworkCredential netCred = new NetworkCredential("*****@*****.**", "olleolle12");
                SmtpClient        smtpobj = new SmtpClient("smtp.live.com", 587);
                smtpobj.EnableSsl   = true;
                smtpobj.Credentials = netCred;
                smtpobj.Send(o);
            }
            catch
            {
                Page.RegisterStartupScript("UserMsg", "<script>alert('Sending Failed...');if(alert){ window.location='SendMail.aspx';}</script>");
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Admin"] == null)                //Kontrollerar om det finns en Admin session.
            {
                Response.Redirect("~/Admin/index.aspx"); //Om inte gå tillbaka till inloggning.
            }

            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("~/Admin/List_Order.aspx");
            }

            OrderObject order = ordDal.GetOrder(int.Parse(Request.QueryString["id"]));

            DataTable dt = ordDal.GetProducts(order);

            ViewState["dt"] = dt;
            this.BindGrid();

            Label_OrderID.Text    = order.orderId.ToString();
            Label_firstname.Text  = order.firstName;
            Label_lastname.Text   = order.lastName;
            Label_company.Text    = order.company;
            Label_adress.Text     = order.adress;
            Label_postalcode.Text = order.postalCode;
            Label_city.Text       = order.city;
            Label_Date.Text       = order.date;

            Label_email.Text     = order.email;
            Label_telephone.Text = order.telephone;
            Label_mobile.Text    = order.mobile;

            Label_Carrier.Text        = order.carrier;
            Label_carrierService.Text = order.carrierService;

            Label_Payment.Text        = order.payment;
            Label_paymentService.Text = order.paymentService;

            Labe_CarrierPrice.Text  = order.carrierPrice.ToString("#.##");
            Label_PaymentPrice.Text = order.paymentPrice.ToString("#.##");
            Label_Sum.Text          = order.CalculatePrice().ToString("#.##");
            decimal tax = order.CalculatePrice() * 0.25M;

            Label_Tax.Text = tax.ToString("#.##");
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            OrderObject order = (OrderObject)Session["Cart"];

            order = ordDal.GetOrder(ordDal.AddOrder(order));
            SendMail(order);
            DataTable dt = ordDal.GetProducts(order);

            ViewState["dt"] = dt;
            this.BindGrid();

            Label_OrderID.Text    = order.orderId.ToString();
            Label_firstname.Text  = order.firstName;
            Label_lastname.Text   = order.lastName;
            Label_company.Text    = order.company;
            Label_adress.Text     = order.adress;
            Label_postalcode.Text = order.postalCode;
            Label_city.Text       = order.city;
            Label_Date.Text       = order.date;

            Label_email.Text     = order.email;
            Label_telephone.Text = order.telephone;
            Label_mobile.Text    = order.mobile;

            Label_Carrier.Text        = order.carrier;
            Label_carrierService.Text = order.carrierService;

            Label_Payment.Text        = order.payment;
            Label_paymentService.Text = order.paymentService;

            Labe_CarrierPrice.Text  = order.carrierPrice.ToString("#.##");
            Label_PaymentPrice.Text = order.paymentPrice.ToString("#.##");
            Label_Sum.Text          = order.CalculatePrice().ToString("#.##");
            decimal tax = order.CalculatePrice() * 0.25M;

            Label_Tax.Text = tax.ToString("#.##");

            Session["Cart"] = new OrderObject();

            HiddenField hdnID   = (HiddenField)Page.Master.FindControl("Cart");
            var         JsonObj = JsonConvert.SerializeObject(Session["Cart"]);

            hdnID.Value = JsonObj;
        }
Esempio n. 4
0
        protected void Button_confirm_Click(object sender, EventArgs e)
        {
            HiddenField hdnID = (HiddenField)Page.Master.FindControl("Cart");
            OrderObject order = (OrderObject)Session["Cart"];


            if (!string.IsNullOrWhiteSpace(hdnID.Value))
            {
                order = JsonConvert.DeserializeObject <OrderObject>(hdnID.Value);

                Session["Cart"] = order;
            }

            if (Session["User"] != null)
            {
                order.userID = (int)Session["User"];
            }


            order.firstName  = TextBox_firstname.Text;
            order.lastName   = TextBox_lastname.Text;
            order.company    = TextBox_company.Text;
            order.adress     = TextBox_adress.Text;
            order.postalCode = TextBox_postalcode.Text;
            order.city       = TextBox_city.Text;
            order.mobile     = TextBox_mobile.Text;
            order.telephone  = TextBox_telephone.Text;
            order.email      = TextBox_email.Text;

            order.priceGroup = pricegroup;
            order.sum        = order.CalculatePrice();

            Session["Cart"] = order;


            var JsonObj = JsonConvert.SerializeObject(new OrderObject());

            hdnID.Value = JsonObj;

            Response.Redirect("~/User/confirm.aspx");
        }
Esempio n. 5
0
        public void BuildCart()
        {
            Product pruDal = new Product();

            tableFill.InnerHtml = @"<h4>Kundkorgen är tom</h4>";

            HiddenField hdnID = (HiddenField)Page.Master.FindControl("Cart");
            OrderObject cart  = (OrderObject)Session["Cart"];

            Button_checkout.Visible = false;
            Button1.Visible         = false;

            if (!string.IsNullOrWhiteSpace(hdnID.Value))
            {
                cart = JsonConvert.DeserializeObject <OrderObject>(hdnID.Value);

                Session["Cart"] = cart;
            }


            List <ProductObject> deletes = new List <ProductObject>();

            cart.priceGroup = pricegroup;

            if (cart.products.Count > 0)
            {
                Button_checkout.Visible = true;
                Button1.Visible         = true;
                Button_upd.Visible      = false;
                StringBuilder str = new StringBuilder();
                str.Append("<table class=\"table table-striped\">");
                str.Append(@"<tr>
                              <th>Art.nr</th>
                                <th>Artikel</th>
                                <th>Attribut</th>
                                <th>Pris</th>
                                <th>Antal</th>
                                <th>Summa</th>
                                <th></th>
                                </tr>");



                foreach (ProductObject product in cart.products)
                {
                    if (product.quantity > 0)
                    {
                        decimal price = product.priceB2C;
                        if (pricegroup != 1)
                        {
                            price = product.priceB2B;
                        }

                        string atr = string.Empty;

                        Dictionary <string, string> atribbut = pruDal.GetAttribute(product);

                        if (atribbut != null)
                        {
                            foreach (KeyValuePair <string, string> val in atribbut)
                            {
                                atr += val.Value + ", ";
                            }
                        }

                        str.Append($@"<tr>
                              <td>{product.artNr}</td>
                                <td>{product.name}</td>
                                <td>{atr}</td>
                                <td>{price.ToString("#.##")}kr</td>
                                <td><input id='{product.ID}' class='quantity btn-p' style='width: 70px;' type='number' value='{product.quantity}' min='0'/></td>
                                <td>{(product.quantity * price).ToString("#.##")}kr</td>
                                <td><button id='{product.ID}' class='delete btn-p'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></button></td>
                                </tr>");
                    }
                    else
                    {
                        deletes.Add(product);
                    }
                }
                str.Append("</table>");
                tableFill.InnerHtml = str.ToString();
            }

            foreach (ProductObject delete in deletes)
            {
                cart.products.Remove(delete);
            }

            if (cart.paymentID > 0)
            {
                Payment       pay       = new Payment();
                PaymentObject payObject = pay.GetPaymentById(cart.paymentID);
                cart.paymentPrice = payObject.price;
            }

            if (cart.carrierID > 0)
            {
                Carrier       car           = new Carrier();
                CarrierObject carrierObject = car.GetCarrierById(cart.carrierID);
                cart.carrierPrice = carrierObject.price;
            }


            cart.priceGroup = pricegroup;
            cart.sum        = cart.CalculatePrice();

            Session["Cart"] = cart;
        }
Esempio n. 6
0
        protected void Button_addtocart_Click(object sender, EventArgs e)
        {
            HiddenField hdnID = (HiddenField)Page.Master.FindControl("Cart");

            OrderObject cart = (OrderObject)Session["Cart"];

            if (!string.IsNullOrWhiteSpace(hdnID.Value))
            {
                cart = JsonConvert.DeserializeObject <OrderObject>(hdnID.Value);
            }


            var attribute1 = "IS NULL";
            var attribute2 = "IS NULL";
            var attribute3 = "IS NULL";
            var attribute4 = "IS NULL";

            if (!string.IsNullOrWhiteSpace(atr1.SelectedValue))
            {
                attribute1 = $"= '{atr1.SelectedValue}'";
            }
            if (!string.IsNullOrWhiteSpace(atr2.SelectedValue))
            {
                attribute2 = $"= '{atr2.SelectedValue}'";
            }
            if (!string.IsNullOrWhiteSpace(atr3.SelectedValue))
            {
                attribute3 = $"= '{atr3.SelectedValue}'";
            }
            if (!string.IsNullOrWhiteSpace(atr4.SelectedValue))
            {
                attribute4 = $"= '{atr4.SelectedValue}'";
            }

            List <ProductObject> prod = proDal.GetProductByWhereList($@"WHERE tbl_Product.ID = '{int.Parse(Request.QueryString["id"])}' AND (AttributeID1 {attribute1} OR AttributeID2 {attribute1} OR AttributeID3 {attribute1} OR AttributeID4 {attribute1})
             AND (AttributeID1 {attribute2} OR AttributeID2 {attribute2} OR AttributeID3 {attribute2} OR AttributeID4 {attribute2})
             AND (AttributeID1 {attribute3} OR AttributeID2 {attribute3} OR AttributeID3 {attribute3} OR AttributeID4 {attribute3})
             AND (AttributeID1 {attribute4} OR AttributeID2 {attribute4} OR AttributeID3 {attribute4} OR AttributeID4 {attribute4})");



            foreach (ProductObject prud in prod)
            {
                bool inCart   = false;
                int  quantity = 0;
                if (cart.products != null)
                {
                    foreach (ProductObject cartProduct in cart.products)
                    {
                        if (cartProduct.ID == prud.ID)
                        {
                            quantity             = cartProduct.quantity + int.Parse(ant.Text);
                            inCart               = true;
                            cartProduct.quantity = quantity;
                        }
                    }
                }

                if (!inCart)
                {
                    prud.quantity = int.Parse(ant.Text);
                    cart.AddProduct(prud);
                }
            }

            cart.priceGroup = pricegroup;
            cart.sum        = cart.CalculatePrice();

            Session["Cart"] = cart;
            var JsonObj = JsonConvert.SerializeObject(cart);

            hdnID.Value = JsonObj;



            (this.Master as SiteMaster).BuildCart();
        }