private void tsiTonChiTiet_Click(object sender, System.EventArgs e) { if (grvLookUp.FocusedRowHandle < 0) { return; } DMSanPhamBriefInfo sp = (DMSanPhamBriefInfo)grvLookUp.GetRow(grvLookUp.FocusedRowHandle); frmLookUp_HangHoa_TonKho frm = new frmLookUp_HangHoa_TonKho(sp); frm.ShowDialog(); }
public NhapHangTraChiTietHHInfor(DMSanPhamBriefInfo spb) { this.IdSanPham = spb.IdSanPham; this.MaSanPham = spb.MaSanPham; this.TenSanPham = spb.TenSanPham; this.DonViTinh = spb.TenDonViTinh; this.TrungMaVach = spb.TrungMaVach; this.ChietKhau = spb.ChietKhau; this.TyleVAT = spb.TyLeVAT; this.Nganh = spb.NganhHang; this.SoLuong = 1; this.SoLuongTra = 1; }
private void SearchByMaVach() { DMSanPhamBriefInfo spb = null; if (!string.IsNullOrEmpty(txtMaSanPham.Text)) { spb = QLBanHang.Modules.DanhMuc.Providers.DmSanPhamProvider.GetSanPhamBriefByNSDMa(txtMaSanPham.Text.Trim(), (nguoiDung.SupperUser == 1 ? -1 : nguoiDung.IdNhomNguoiDung)); } if (spb == null) { frmLookUp_HangHoa frm = new frmLookUp_HangHoa(false, (Common.Int2Bool(nguoiDung.SupperUser) ? -1 : nguoiDung.IdNhomNguoiDung), 1, -1, -1, -1); if (frm.ShowDialog() == DialogResult.OK) { spb = frm.SelectedItem; } } if (spb == null) { return; } txtTenSanPham.Text = spb.TenSanPham; NhapHangTraChiTietHHInfor ctu = Business.ListChiTietChungTu.Find(delegate(NhapHangTraChiTietHHInfor match) { return(match.MaSanPham == spb.MaSanPham && spb.TrungMaVach == 1); }); if (ctu != null) { ctu.SoLuong += 1; ctu.SoLuongTra += 1; ((BindingList <NhapHangTraChiTietHHInfor>)grcHangBan.DataSource).ResetBindings(); } else { ctu = new NhapHangTraChiTietHHInfor(spb); ctu.IdChungTu = Business.ChungTu.IdChungTu; ((BindingList <NhapHangTraChiTietHHInfor>)grcHangBan.DataSource).Add(ctu); ((BindingList <NhapHangTraChiTietHHInfor>)grcHangBan.DataSource).ResetBindings(); } //UpdateSummariesInfors(); }
private void InputDataFromCode(string code) { try { DMSanPhamBriefInfo sp = DmSanPhamProvider.GetSanPhamBriefByNSDMa(code, nguoiDung.IdNhomNguoiDung); if (sp == null) { frmLookUp_HangHoa frm = new frmLookUp_HangHoa(false, (Common.Int2Bool(nguoiDung.SupperUser) ? -1 : nguoiDung.IdNhomNguoiDung), 1, -1); if (frm.ShowDialog() == DialogResult.OK) { sp = frm.SelectedItem; } } if (sp != null) { BangGiaBanChiTietInfor spb; spb = liBangGiaBan.Find(delegate(BangGiaBanChiTietInfor match) { return(match.MaSanPham.Equals(code)); }); if (spb == null) { spb = BangGiaDataProvider.Instance.GetGiaBan(IdTTamSelected, IdKhoSelected, sp.MaSanPham); } if (spb == null) { MessageBox.Show("Giá chưa thiết lập!"); return; } else if (!DatTruoc && spb.ChietKhau != 1 && GetTonConLai(spb) <= 0) { MessageBox.Show("Hàng đã hết tồn kho!"); return; } liBangGiaBan.Add(spb); int isHangKem = (rdHangBanKem.Checked ? 1 : 0); string tenHangKem = (rdHangBanKem.Checked ? strMuaKem : strKhuyenMai); ChungTuBanHangChiTietInfor ctu = liSanPhamSelected.Find(delegate(ChungTuBanHangChiTietInfor match) { return(match.MaSanPham.Equals(spb.MaSanPham) && match.LoaiHangKem == isHangKem); }); if (ctu != null) { ctu.SoLuong += 1; ctu.TienSauChietKhau += spb.DonGiaChuaVAT; ctu.TienVAT += spb.TienVAT; ctu.ThanhTien += spb.DonGiaCoVAT; ctu.ThuongNong += spb.ThuongNong; ctu.NoKhuyenMai = (spb.TonKho >= ctu.SoLuong || DatTruoc || rdHangBanKem.Checked) ? 0 : ctu.SoLuong - spb.TonKho; ctu.GhiChu = Common.Int2Bool(spb.ChietKhau) ? "CK" : (ctu.NoKhuyenMai > 0 ? "Nợ khuyến mại" : ""); ctu.SoLuongOld = ctu.SoLuong; ((BindingList <ChungTuBanHangChiTietInfor>)gSanPham.DataSource).ResetBindings(); } else { //add san pham ban ChungTuBanHangChiTietInfor ct = null; if (rdHangBanKem.Checked) { ct = BanHangDataProvider.Instance.ConvertBG2SanPhamBan(spb); } else { ct = BanHangDataProvider.Instance.ConvertBG2SanPhamKM(spb); ct.TyleVAT = Common.Int2Bool(spb.ChietKhau) ? spb.TyLeVAT : 0; //if (liSanPhamSelected.Exists(delegate (ChungTuBanHangChiTietInfor match) // { // return // match.MaSanPham.Equals(ct.MaSanPham) && match.LoaiHangKem == 0; // })) //{ // ct.TyleChietKhau = 0; //} } ct.NoKhuyenMai = (spb.TonKho >= ct.SoLuong || DatTruoc || rdHangBanKem.Checked) ? 0 : ct.SoLuong - spb.TonKho; ct.LoaiHangKem = isHangKem; ct.TenLoaiHangKem = tenHangKem; ct.IdSanPhamBan = CTu.IdSanPham; ct.TenSanPhamBan = CTu.TenSanPham; ct.GhiChu = Common.Int2Bool(spb.ChietKhau) ? "CK" : (ct.NoKhuyenMai > 0 ? "Nợ khuyến mại" : ""); ct.SoLuongOld = ct.SoLuong; ((BindingList <ChungTuBanHangChiTietInfor>)gSanPham.DataSource).Add(ct); } //spb.TonKho = spb.TonKho - 1; } } catch (System.Exception ex) { #if DEBUG //MessageBox.Show("Lỗi ngoại lệ: " + ex.ToString(), Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error); #else //MessageBox.Show("Lỗi ngoại lệ: " + ex.Message, Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error); #endif } }
public frmLookUp_HangHoa_TonKho(DMSanPhamBriefInfo sp) { InitializeComponent(); Common.LoadStyle(this); this.SanPham = sp; }