private void btnSend_Click(object sender, EventArgs e) { HOA_DON hd = HOA_DON_BLL.Instance.getHOADONbyID(ID_HD); List <BillInfo> listtach = new List <BillInfo>(); int dem = 0; List <BillInfo> listbillInfo = BillInfo_BLL.Instance.GetList(Table_BLL.Instance.gettable((int)hd.ID_BAN)); for (int i = 0; i < dtgDetail.Rows.Count - 1; i++) { BillInfo a = new BillInfo(); a.MatHang = dtgDetail.Rows[i].Cells["Ten"].Value.ToString(); if (Convert.ToInt32(dtgDetail.Rows[i].Cells["SL"].Value) < 0 || Convert.ToInt32(dtgDetail.Rows[i].Cells["SL"].Value) > listbillInfo[i].SoLuong) { MessageBox.Show("So luong cua mon " + a.MatHang.ToString() + " khong phu hop"); ++dem; } else { a.SoLuong = Convert.ToInt32(dtgDetail.Rows[i].Cells["SL"].Value); listtach.Add(a); } } if (dem == 0) { TableTach f = new TableTach((int)hd.ID_BAN, listtach, user); f.ShowDialog(); this.Dispose(); } }
public HOA_DON GetDVByMa(int pMa) { HOA_DON result = new HOA_DON(); result = context.HOA_DON.FirstOrDefault(m => m.MA_HD == pMa); return(result); }
private void butLapHD_Click(object sender, EventArgs e) { try { HOA_DON hd = new HOA_DON { MaHoaDon = hdbll.DemHD() + 1, MaPhong = cbbPhongChuaTaoHD.SelectedItem.ToString(), NgayLap = DateTime.Now, }; hdbll.ThemHD(hd); dgvDV.DataSource = null; HoaDon_Load(this, e); cbbPhongChuaTaoHD.Items.Remove(hd.MaPhong); cbbPhongChuaTaoHD.Enabled = true; butSua.Enabled = false; butThem.Enabled = false; butXoaDV.Enabled = false; butLapHD.Enabled = false; } catch (Exception ex) { MessageBox.Show("Kiểm tra lại!"); } }
public void delete(int idBill) { HOA_DON hoadon = HOA_DON_DAL.Instance.Get_HOA_DON(idBill); HOA_DON_DAL.Instance.Delete(hoadon); HOA_DON_DAL.Instance.Sync(); }
public ActionResult DatHang(FormCollection collection) { HOA_DON hd = new HOA_DON(); KHACH_HANG kh = (KHACH_HANG)Session["TaiKhoan"]; List <GioHang> gh = LayGioHang(); //hd.MaHD = "HD" + data.HOA_DONs.Count(); //hd.TaiKhoan = kh.TaiKhoan; hd.ThoiGian = DateTime.Now; //var NgayGiao = String.Format("{0:MM/dd/yyyy}", collection["NgayGiao"]); //dh.NGAYGIAO = DateTime.Parse(NgayGiao); //hd.NGAYGIAO = DateTime.Now.AddDays(2); //hd.TINHTRANGGIAOHANG = "Đang tiếp nhận"; // hd.TINHTRANGTHANHTOAN = "Chưa thanh toán"; data.HOA_DONs.InsertOnSubmit(hd); data.SubmitChanges(); foreach (var item in gh) { CHI_TIET_HOA_DON CTDH = new CHI_TIET_HOA_DON(); CTDH.MaHD = hd.MaHD; CTDH.MaSP = Convert.ToInt32(item.ma); CTDH.SoLuong = item.sl; //Chú ý chỗ này chưa sửa donGia CTDH.GiaBan = (decimal)item.donGia; data.CHI_TIET_HOA_DONs.InsertOnSubmit(CTDH); } data.SubmitChanges(); Session["Giohang"] = null; return(RedirectToAction("XacNhanDonHang", "GioHang")); }
public bool update_HoaDon(HOA_DON hd) { int result = 0; try { SqlConnection con = new SqlConnection(db.connectionStr); SqlCommand cmd = new SqlCommand("update_HoaDon", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@hd_id", SqlDbType.NVarChar, 20); cmd.Parameters.Add("@tn_id", SqlDbType.NVarChar, 15); cmd.Parameters.Add("@nv_id", SqlDbType.Int); cmd.Parameters.Add("@ngay", SqlDbType.DateTime); cmd.Parameters.Add("@lan_tt", SqlDbType.Int); cmd.Parameters.Add("@trangthai", SqlDbType.NVarChar, 50); cmd.Parameters["@hd_id"].Value = hd.Id; cmd.Parameters["@tn_id"].Value = hd.Tn_id; cmd.Parameters["@nv_id"].Value = hd.Nv_id; cmd.Parameters["@ngay"].Value = hd.Ngay; cmd.Parameters["@lan_tt"].Value = hd.Lantt; cmd.Parameters["@trangthai"].Value = hd.Trangthai; con.Open(); result = cmd.ExecuteNonQuery(); con.Close(); } catch { } return(result > 0); }
public ActionResult Checkout1(FormCollection form, HOA_DON Order) { var session = BasketSession.GetSession(); if (session != null && form.Get("KHACH_HANG.TEN_KH") != "" && form.Get("KHACH_HANG.LIEN_HE") != "") { List <SAN_PHAM> ListBasket = new List <SAN_PHAM>(); ViewBag.TongTien = 0; ViewBag.Order = Order; foreach (var item in session) { ListBasket.Add(new SAN_PHAM { TEN_SP = item.TenSP, MA_SP = item.MaSP, GIA_BAN = item.Gia, HINH_ANH = db.SAN_PHAM.Where(p => p.MA_SP == item.MaSP).Select(p => p.HINH_ANH).Single(), SO_LUONG = item.SoLuong }); ViewBag.TongTien += (decimal)(item.Gia * item.SoLuong); } return(View(ListBasket)); } else { if (form.Get("KHACH_HANG.TEN_KH") == "" || form.Get("KHACH_HANG.LIEN_HE") == "" || form.Get("KHACH_HANG.DIA_CHI") == "" || form.Get("KHACH_HANG.TINH") == "") { return(RedirectToAction("Index", "CheckOut")); } else { return(RedirectToAction("Error", "Basket")); } } }
public ActionResult DeleteConfirmed(long id) { HOA_DON hoa_don = db.HOA_DON.Find(id); db.HOA_DON.Remove(hoa_don); db.SaveChanges(); return(RedirectToAction("Index")); }
public List <HOA_DON> GetList() { List <HOA_DON> list = new List <HOA_DON>(); HOA_DON h = new HOA_DON(); list = context.HOA_DON.OrderBy(x => x.MA_HD).ToList(); return(list); }
public ActionResult DeleteConfirmed(int id) { HOA_DON hOA_DON = db.HOA_DON.Find(id); db.HOA_DON.Remove(hOA_DON); db.SaveChanges(); return(RedirectToAction("Index")); }
public int Add(HOA_DON p) { int result = 0; context.HOA_DON.Add(p); result = context.SaveChanges(); return(result); }
public int Delete(int pMa) { int result = 0; HOA_DON k = context.HOA_DON.FirstOrDefault(m => m.MA_HD == pMa); context.HOA_DON.Remove(k); result = context.SaveChanges(); return(result); }
public static int GuiBaoHanh(string imei, string thongTinKhachHang) { HOA_DON hd = TaoBienNhan(thongTinKhachHang); int maHoaDon = HOA_DON.insert(hd); ChiTietHoaDon.NhapHang(maHoaDon, imei, 0); SanPham.GuiBaoHanh(imei); return(maHoaDon); }
public ActionResult Edit([Bind(Include = "MA_HD,USERNAME,IDTT,DIA_CHI,HO_TEN,DIEN_THOAI,NGAYDATHANG,GHI_CHU,TONG_TIEN")] HOA_DON hoa_don) { if (ModelState.IsValid) { db.Entry(hoa_don).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hoa_don)); }
public static HOA_DON LayBienNhan(int maHoaDon) { try { return(HOA_DON.select(" where MA_HOA_DON = " + maHoaDon + " and LOAI_HOA_DON = 3 ")[0]); } catch (Exception) { return(null); } }
private void SETGUI() { HOA_DON hd = HOA_DON_BLL.Instance.getHOADONbyID(ID_HD); CultureInfo culture = new CultureInfo("vi-VN"); List <BillInfo> listbillinfo = BillInfo_BLL.Instance.GetList(Table_BLL.Instance.gettable(hd.ID_BAN.Value)); foreach (BillInfo item in listbillinfo) { this.dtgDetail.Rows.Add(item.MatHang.ToString(), item.SoLuong.ToString()); } }
private HOA_DON CapNhatHoaDon() { HOA_DON h = new HOA_DON(); h.ID_Hoa_Don = _hoaDonBLL.LayIDHoaDonTheoBan(idBan); h.Tien_Khach_Dua = int.Parse(tb_KhachDuaTien.Text); h.Tien_Tra_Lai = int.Parse(tb_TienTraLai.Text); h.Tong_Tien = ThanhToan(); h.Tong_Thanh_Toan = thanhtoan; h.VAT = int.Parse(tb_VAT.Text); return(h); }
public ActionResult Edit([Bind(Include = "MA_HD,MA_KH,MA_NV,NGAY_LAP,TINH_GIAO_HANG,DIA_CHI_GIAO_HANG,GHI_CHU,PHI_GIAO_HANG,THANH_TIEN,TRANG_THAI")] HOA_DON hOA_DON) { if (ModelState.IsValid) { db.Entry(hOA_DON).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MA_KH = new SelectList(db.KHACH_HANG, "MA_KH", "MA_TV", hOA_DON.MA_KH); ViewBag.MA_NV = new SelectList(db.NHAN_VIEN, "MA_NV", "MAT_KHAU", hOA_DON.MA_NV); return(View(hOA_DON)); }
public int Update(HOA_DON p) { int result = 0; HOA_DON k = context.HOA_DON.FirstOrDefault(m => m.MA_HD == p.MA_HD); if (k != null) { k.TONG_TIEN = p.TONG_TIEN; } result = context.SaveChanges(); return(result); }
private void btnHuyTT_Click(object sender, EventArgs e) { try { HOA_DON hoadon = layTTHD(lbHD_ID.Text, int.Parse(txtLanTT.Text), "Đã hủy"); if (daoHD.update_HoaDon(hoadon)) { gcThanhToan.DataSource = daoXT.getHoaDonDaTT(lbId_TNHAN.Text); } } catch { } }
public ActionResult Order(HoaDonVM model) { try { //lấy giỏ hàng List <Item> orders = ((GioHang)(Session["cart"])).List; //lấy người dùng NGUOI_DUNG user = (NGUOI_DUNG)(Session["nguoidung"]); //tạo hóa đơn HOA_DON hd = new HOA_DON { USERNAME = user.USERNAME, IDTT = 0, NGAYDATHANG = DateTime.Now.Date, DIA_CHI = model.DIA_CHI, DIEN_THOAI = model.DIEN_THOAI, GHI_CHU = model.GHI_CHU, HO_TEN = model.HO_TEN, TONG_TIEN = 0 }; db.HOA_DON.Add(hd); db.SaveChanges(); //tạo chi tiết hóa đơn long MaHD = hd.MA_HD; long tongtien = 0; foreach (Item item in orders) { CT_HOA_DON cthd = new CT_HOA_DON { MAHD = MaHD, DON_GIA = item.GiaBan, SO_LUONG = item.SoLuongTrongGio, TENSACH = item.TenSach }; tongtien += (item.SoLuongTrongGio * item.GiaBan); db.CT_HOA_DON.Add(cthd); } var updatedHd = db.HOA_DON.FirstOrDefault(x => x.MA_HD == hd.MA_HD); updatedHd.TONG_TIEN = tongtien; db.SaveChanges(); Session.Remove("cart"); return(RedirectToAction("ThankYou", "Cart")); } catch (Exception) { ModelState.AddModelError("", "Đã xảy ra lỗi"); return(View(model)); } }
public static HOA_DON TaoPhieuXuat(string thonTinKhachHang) { HOA_DON tmp = new HOA_DON(); tmp.MA_HOA_DON = 0; tmp.TONG_CONG = 0; tmp.LOAI_HOA_DON = 2; tmp.TONG_CONG = 0; tmp.THOI_GIAN = DateTime.Now; tmp.MSNV_THUC_HIEN = Init.nhanVien.MSNV; tmp.THONG_TIN_KHACH_HANG = thonTinKhachHang; return(tmp); }
public int ThemHoaDon(string maKH, string maNV, DateTime thoiGian, int giamGia) { HOA_DON hd = new HOA_DON(); hd.MaKH = maKH; hd.MaNV = maNV; hd.ThoiGian = thoiGian; hd.GiamGia = giamGia; hd.TongTien = 0; data.HOA_DONs.InsertOnSubmit(hd); data.SubmitChanges(); return(hd.MaHD); }
public static HOA_DON TaoPhieuNhap(int maDoiTac, int tongCong) { HOA_DON tmp = new HOA_DON(); tmp.MA_HOA_DON = 0; tmp.TONG_CONG = 0; tmp.LOAI_HOA_DON = 1; tmp.TONG_CONG = tongCong; tmp.THOI_GIAN = DateTime.Now; tmp.MSNV_THUC_HIEN = Init.nhanVien.MSNV; tmp.MA_DOI_TAC = maDoiTac; return(tmp); }
private HOA_DON layTTHD(string id, int lan, string trgthai) { string hoadon_id = id; string tn = lbId_TNHAN.Text; int nv = 1; DateTime ngay = DateTime.Now; string trangthai = trgthai; int lantt = lan; HOA_DON hdon = new HOA_DON(hoadon_id, tn, nv, ngay, trangthai, lantt); return(hdon); }
// GET: Admin/Invoice/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HOA_DON hOA_DON = db.HOA_DON.Find(id); if (hOA_DON == null) { return(HttpNotFound()); } return(View(hOA_DON)); }
public ActionResult Checkout(FormCollection form, HOA_DON Order) { var session = BasketSession.GetSession(); if (session != null) { int MaHD = db.HOA_DON.Max(p => p.MA_HD) + 1; int MaKH = db.KHACH_HANG.Max(p => p.MA_KH) + 1; Order.KHACH_HANG.MA_TV = "demo"; Order.KHACH_HANG.MA_KH = MaKH; Order.KHACH_HANG.GIOI_TINH = true; Order.KHACH_HANG.NGAY_SINH = DateTime.Now; Order.MA_HD = MaHD; Order.NGAY_LAP = DateTime.Now; Order.TRANG_THAI = 0; Order.MA_KH = MaKH; Order.GHI_CHU = "Chưa Xem"; if (SessionHelper.GetSession() != null) { var user = SessionHelper.GetSession(); Order.KHACH_HANG.MA_TV = user.UserName; } var res = InsertCustomer(Order.KHACH_HANG); if (res) { db.HOA_DON.Add(Order); foreach (var item in session) { db.CHITIET_HD.Add(new CHITIET_HD { MA_HD = MaHD, SO_LUONG_SP = item.SoLuong, MA_SP = item.MaSP, TONG_GIA = (decimal)(item.SoLuong * item.Gia) }); } db.SaveChanges(); BasketSession.RemoveSession(); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Error", "CheckOut")); } } else { return(RedirectToAction("Error", "Basket")); } }
// GET: /HoaDon/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HOA_DON hoa_don = db.HOA_DON.Find(id); if (hoa_don == null) { return(HttpNotFound()); } return(View(hoa_don)); }
private void icoBtnInphieuthue_Click(object sender, EventArgs e) { try { HOA_DON hd = context.HOA_DON.FirstOrDefault(p => p.MaThuePhong == maThuePhong); if (hd == null) { throw new Exception("Phiếu thuê này chưa thanh toán"); } if (maThuePhong.Equals(string.Empty)) { throw new Exception("Vui lòng chọn phiếu thuê cần xuất"); } ClassReport.ReportInfo info = new ClassReport.ReportInfo(); info.ID = maThuePhong; info.pIDRoom = context.CHI_TIET_PHIEU_THUE_PHONG.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.MaPhong).FirstOrDefault(); info.pName = context.CHI_TIET_PHIEU_THUE_PHONG.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.HoTenKhachHang).FirstOrDefault(); info.pDateFrom = context.CHI_TIET_PHIEU_THUE_PHONG.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.NgayNhan).FirstOrDefault(); info.pDateTo = context.CHI_TIET_PHIEU_THUE_PHONG.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.NgayTra).FirstOrDefault(); info.pTienPhong = double.Parse(context.HOA_DON.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.TongTien).FirstOrDefault().ToString()); FormReport.ReportPhieuThue Frm = new FormReport.ReportPhieuThue(info); Frm.DataSource = context.DANH_SACH_SU_DUNG_DICH_VU.Join ( context.DICH_VU, DS => DS.MaDichVu, DV => DV.MaDichVu, (DS, DV) => new { DS, DV } ) .Where(p => p.DS.MaThuePhong.Equals(maThuePhong)) .Select ( p => new { TenDichVu = p.DV.TenDichVu, SoLuong = p.DS.SoLuong, DonGia = p.DV.DonGia, ThanhTien = p.DV.DonGia * p.DS.SoLuong, } ).ToList(); frmReportViewer Rpv = new frmReportViewer(Frm); Rpv.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Tạo hóa đơn mới private void menu_ToaHD_Click(object sender, EventArgs e) { HOA_DON h = new HOA_DON(); h.ID_Ban = idBan; // h.ID_Nguoi_Dung = h.Ngay_Lap = dt_ThoiGian.DateTime; h.Trang_Thai_Thanh_Toan = 1; XemChiTietHoaDon(_hoaDonBLL.ThemHoaDonMoi(h)); // Cập nhật tình trạng bàn thành đang sử dụng _banBLL.CapNhatTinhTrangBan(1, idBan); LoadDataToListView(); }