public int XoaThongTinPhieuBanHang(string mapbh, string tenkho) { MuaHangBUS muaHangBUS = new MuaHangBUS(); DataTable dt1 = uC_BanHang_TheoChungTuDAO.ChuyenTenKhoThanhMaKho(tenkho); string makho = ""; if (dt1.Rows.Count > 0 && dt1 != null) { makho = dt1.Rows[0]["MaKH"].ToString(); } DataTable kt = uC_BanHang_TheoChungTuDAO.KiemTraXemPhieuNhapHangDaCoPhieuThu(mapbh); if (kt.Rows.Count == 0) { DataTable dt = uC_BanHang_TheoChungTuDAO.LayThongTinCT_PhieuMuaHangTheoMa(mapbh); if (uC_BanHang_TheoChungTuDAO.XoaCT_PhieuMuaHang(mapbh) > 0) { for (int i = 0; i < dt.Rows.Count; i++) { muaHangBUS.CapNhatSoLuongHangHoa(dt.Rows[i]["MaSanPham"].ToString(), int.Parse(dt.Rows[i]["SoLuong"].ToString()), makho); } uC_BanHang_TheoChungTuDAO.XoaPhieuBanHang(mapbh); return(1); } } else { return(-1); } return(0); }
public int XoaPhieuNhapHang(string mapnh, string khohang) { DataTable dt = TheoChungTu_PNH_DAO.LayPhieuChiTheoMaChungTu(mapnh); if (dt.Rows.Count == 0) { DataTable dt1 = TheoChungTu_PNH_DAO.LayThongTinKhoHang(); string temp = ""; for (int i = 0; i < dt1.Rows.Count; i++) { if (dt1.Rows[i]["TenKH"].ToString() == khohang) { temp = dt1.Rows[i]["MaKH"].ToString(); } } MuaHangBUS muaHangBUS = new MuaHangBUS(); if (muaHangBUS.XoaCT_PhieuNhapHang(mapnh, temp) > 0) { TheoChungTu_PNH_DAO.XoaPhieuNhapHang(mapnh); return(1); } } else { return(-1); } return(0); }
public int XoaCT_PhieuBanHangTheoMa(string mapbh, string makho) { DataTable dt = phieuBanHangDAO.LayChiTietPhieuBanHangTheoMa(mapbh); phieuBanHangDAO.XoaCT_PhieuBanHang(mapbh); if (dt.Rows.Count > 0 && dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { MuaHangBUS muaHangBUS = new MuaHangBUS(); muaHangBUS.CapNhatSoLuongHangHoa(dt.Rows[i]["MaSanPham"].ToString(), int.Parse(dt.Rows[i]["SoLuong"].ToString()), makho); } } return(1); }
public int TaoHangHoaMoiChoKho(string mahh, int soluong, string makho, string tensp) { DataTable dt = phieuBanHangDAO.LaySoLuongHangHoaTonKhoTheoMaHangHoa(mahh, makho); if (dt.Rows.Count == 0) { // chưa tồn tại thì thêm hàng hóa mới MuaHangBUS muaHangBUS = new MuaHangBUS(); muaHangBUS.ThemHangHoa(mahh, tensp, makho, 0); } else { return(0); } return(1); }
public int KiemTraHangHoaBanCoVuotTonKhoToiThieu(string mahh, int soluong, string makho, string tensp) { DataTable dt = phieuBanHangDAO.LaySoLuongHangHoaTonKhoTheoMaHangHoa(mahh, makho); if (dt.Rows.Count > 0) { if (int.Parse(dt.Rows[0]["TonKhoHienTai"].ToString()) - soluong >= int.Parse(dt.Rows[0]["TonKhoToiThieu"].ToString())) { return(1); } } else { // chưa tồn tại thì thêm hàng hóa mới MuaHangBUS muaHangBUS = new MuaHangBUS(); muaHangBUS.ThemHangHoa(mahh, tensp, makho, 0); return(1); } return(0); }