Ejemplo n.º 1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (txtHoTen.Text == "" || txtSDT.Text == "" || txtDiaChi.Text == "")
            {
                Response.Write("<script>alert('phải điền đầy đủ thông tin khách hàng');</script>");
                return;
            }

            Orders o = new Orders();

            o.receive  = DateTime.Now;
            o.confirm  = DateTime.Now;
            o.state    = false;
            o.tenkh    = txtHoTen.Text;
            o.sdtkh    = txtSDT.Text;
            o.diachikh = txtDiaChi.Text;
            xuly.insertOrder(o);
            List <Watch> list = (List <Watch>)Session["Cart"];

            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    OrderDetail od = new OrderDetail();
                    od.orderid   = (xuly.getIdAfter("orders") - 1);
                    od.productid = list[i].id;
                    od.gia       = (int)Math.Round((list[i].gia - list[i].gia * list[i].giamgia / 100.0) / 100000, 0) * 100000;
                    od.soluong   = list[i].soluong;
                    xuly.insertOrderDetail(od);
                }
                Session["Cart"] = null;
                Response.Redirect(Request.RawUrl);
            }
        }