Esempio n. 1
0
        protected void btnCheckOut_Click(object sender, EventArgs e)
        {
            try
            {
                FruitDataDataContext db = new FruitDataDataContext();

                string count = string.Format("{0, 0:D3}", db.DON_HANGs.Count() + 1);
                MaDonHangThanhToan = "DH" + count;
                //Create new order
                var donHang = new DON_HANG();
                donHang.Ma_Don_Hang = "DH" + count;
                donHang.Ngay_Dat    = DateTime.Now;
                donHang.Tinh_Trang  = 0;
                donHang.Tong_Tien   = calculateTongTien();

                //Lưu thông tin chi tiết chuyển hàng xuống db
                donHang.Ho_Ten        = txbTenNguoiNhan.Text;
                donHang.So_Dien_Thoai = txbSDT.Text;
                donHang.Dia_Chi_Nhan  = txbDiaChiNhanHang.Text;

                //Create new order details
                int countCTDH = db.CHI_TIET_DON_HANGs.Count();
                foreach (Chi_Tiet_Gio_Hang item in gioHang)
                {
                    var ctdh = new CHI_TIET_DON_HANG();
                    countCTDH++;
                    ctdh.Ma_Chi_Tiet_DH = "CTDH" + string.Format("{0, 0:D3}", countCTDH);
                    ctdh.Ma_Don_Hang    = donHang.Ma_Don_Hang;
                    ctdh.Ma_Trai_Cay    = item.Ma_Trai_Cay;
                    ctdh.Don_Gia_Xuat   = Int32.Parse(item.Don_Gia_Xuat);
                    ctdh.So_Luong_Xuat  = Int32.Parse(item.So_Luong_Xuat);

                    db.CHI_TIET_DON_HANGs.InsertOnSubmit(ctdh);
                }
                db.DON_HANGs.InsertOnSubmit(donHang);



                db.SubmitChanges();

                //Delete cart cookies
                HttpCookie cookie = new HttpCookie("Gio_Hang");
                cookie.Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(cookie);

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(@"<script language='javascript'>");
                sb.Append(@"$('#modalDatHang').modal('show');");
                sb.Append(@"</script>");


                ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb.ToString());
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
 private void detach_CHI_TIET_DON_HANGs(CHI_TIET_DON_HANG entity)
 {
     this.SendPropertyChanging();
     entity.TRAI_CAY = null;
 }
Esempio n. 3
0
 partial void DeleteCHI_TIET_DON_HANG(CHI_TIET_DON_HANG instance);
Esempio n. 4
0
 partial void UpdateCHI_TIET_DON_HANG(CHI_TIET_DON_HANG instance);
Esempio n. 5
0
 partial void InsertCHI_TIET_DON_HANG(CHI_TIET_DON_HANG instance);
Esempio n. 6
0
 private void attach_CHI_TIET_DON_HANGs(CHI_TIET_DON_HANG entity)
 {
     this.SendPropertyChanging();
     entity.DON_HANG = this;
 }