public ActionResult Payment(string tendg, string ten, string sdt, string diachi, string email) { ViewBag.DanhMuc = new DanhMucSanPhamDao().ListSpDauGia(); try { var hd = new HoaDon(); hd.NgayTao = DateTime.Now; hd.TenDN = tendg; hd.Ten_Ship = ten; hd.SDT = sdt; hd.DiaChi = diachi; hd.Email = email; var id = new HoaDonDao().Insert(hd); var cart = (List <CartModel>)Session[CartSession]; var hdct = new HoaDonChiTietDao(); foreach (var item in cart) { var detail_hd = new HoaDon_ChiTiet(); detail_hd.ID_SanPham = item.Product.ID_SanPham; detail_hd.ID_HoaDon = id; detail_hd.Gia = (item.Product.GiaBanRa / 10) + item.Product.GiaBanRa; detail_hd.SoLuong = item.SoLuong; hdct.Insert(detail_hd); } } catch { return(Redirect("/Cart/failure")); } return(Redirect("/Cart/Finish")); }
private void btnChange_Click(object sender, EventArgs e) { if (txtMaHD.Text != "") { MaHD = Convert.ToInt32(txtMaHD.Text); } if (txtMaDV.Text != "") { MaDV = Convert.ToInt32(txtMaDV.Text); } if (txtSL.Text != "") { SoLuong = Convert.ToInt32(txtSL.Text); } if (Hoadon.CheckMaHD(MaHD) && Hoadon.CheckMaDV(MaDV)) { HoaDon_ChiTiet HD = new HoaDon_ChiTiet(MaHD, MaDV, SoLuong, txtTenKH.Text); //string query = "sp_Hoadon_ChiTiet_Update '" + txtMaHD.Text + "', '" + txtMaDV.Text + "','" + txtSL.Text + "',N'" + txtTenKH.Text + "'"; //DataProvider.Instance.ExecuteNonQuery(query); if (Hoadon.HoaDon_ChiTiet_Update(HD)) { LoadHoaDon_ChiTiet(); } else { MessageBox.Show("Thất bại"); } } else { MessageBox.Show("Mã hóa đơn hoặc mã dịch vụ không tồn tại", "Thông báo"); } }
private void btnDelete_Click(object sender, EventArgs e) { if (txtMaHD.Text != "") { MaHD = Convert.ToInt32(txtMaHD.Text); } if (txtMaDV.Text != "") { MaDV = Convert.ToInt32(txtMaDV.Text); } if (MessageBox.Show("Bạn có thực sự muốn xóa??", "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { HoaDon_ChiTiet HD = new HoaDon_ChiTiet(MaHD, MaDV, -1, ""); //string query = "sp_Hoadon_ChiTiet_Delete '" + txtMaHD.Text + "', '" + txtMaDV.Text + "'"; //DataProvider.Instance.ExecuteNonQuery(query); if (Hoadon.HoaDon_ChiTiet_Delete(HD)) { LoadHoaDon_ChiTiet(); } else { MessageBox.Show("Thất bại"); } DemPage(); } }
public bool HoaDon_ChiTiet_Update(HoaDon_ChiTiet HD) { try { string query = "sp_Hoadon_ChiTiet_Update '" + HD.MaHD + "' , '" + HD.MaDV + "','" + HD.SoLuong + "',N'" + HD.TenKH + "'"; int result = DataProvider.Instance.ExecuteNonQuery(query); return(true); } catch (Exception e) { } return(false); }
public bool Insert(HoaDon_ChiTiet hd) { try { db.HoaDon_ChiTiet.Add(hd); db.SaveChanges(); return(true); } catch { return(false); } }
public bool HoaDon_ChiTiet_Update(HoaDon_ChiTiet HD) { return(HoaDon.HoaDon_ChiTiet_Update(HD)); }
public bool HoaDon_ChiTiet_Delete(HoaDon_ChiTiet HD) { return(HoaDon.HoaDon_ChiTiet_Delete(HD)); }
public bool HoaDon_ChiTiet_Insert(HoaDon_ChiTiet HD) { return(HoaDon.HoaDon_ChiTiet_Insert(HD)); }