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);
            }
        }
Ejemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Watch w = new Watch();

            w.name         = txtName.Text;
            w.categoryid   = int.Parse(listThuongHieu.SelectedValue);
            w.soluong      = int.Parse(txtSoLuong.Text);
            w.gia          = int.Parse(txtGia.Text);
            w.giamgia      = int.Parse(txtGiamGia.Text);
            w.baohanh      = txtBaoHanh.Text;
            w.kieumay      = txtKieuMay.Text;
            w.gioitinh     = listGioiTinh.SelectedValue;
            w.kichco       = txtKichCo.Text;
            w.doday        = txtDoDay.Text;
            w.chatlieuvo   = txtChatLieuVo.Text;
            w.chatlieuday  = txtChatLieuDay.Text;
            w.chatlieukinh = txtChatLieuKinh.Text;
            w.chucnang     = txtChucNang.Text;
            w.dochiunuoc   = txtDoChiuNuoc.Text;
            w.mota         = txtMoTa.Value;
            w.type         = int.Parse(listType.SelectedValue);

            string filePath = Server.MapPath("~/Image/Watch/");

            fileUpload.SaveAs(filePath + xuly.getIdAfter("watch") + Path.GetExtension(fileUpload.FileName));
            w.anh = Path.GetExtension(fileUpload.FileName);
            xuly.insertWatch(w);
            Response.Redirect(Request.RawUrl);
        }