public FmThongTinNhapHang(NhapHang nh = null, NhapHangController nhctr = null) { InitializeComponent(); if (nhctr == null) NHCtr = new NhapHangController(); else NHCtr = nhctr; SPCTCtr = new SanPham_ChiTietController(NHCtr._db); dtgvChiTietNH.AutoGenerateColumns = false; dtgvChiTietSP.AutoGenerateColumns = false; if (nh == null) { this.nh = new NhapHang(NHCtr._db); this.Text = "Thêm Mới Đơn Nhập Hàng"; LoadDTGV_ChiTietSP(); dtpkNgay.Value = DateTime.Now; } else { ViewMode = true; this.nh = nh; this.nh._set_context(NHCtr._db); ThongTinFormNhapHang = this.nh; btLuu.Enabled = false; btThem.Enabled = false; btXoa.Enabled = false; gbDSSanPham.Enabled = false; LoadDTGV_ChiTietNH(); } }
public Boolean update_tonkho() { //get orginal NhapHangController Or_ctr = new NhapHangController(); NhapHang Or_nh = Or_ctr.get_by_id(this.id); List<ChiTiet_NhapHang> Or_list; if (Or_nh != null) Or_list = Or_nh.ds_chitiet_nhaphang; else Or_list = new List<ChiTiet_NhapHang>(); //get current List<ChiTiet_NhapHang> Cur_list = this.ds_chitiet_nhaphang; //get Added CTNH Items List<ChiTiet_NhapHang> Added_list = Cur_list.Where(cur => Or_list.Where(or => or.sanpham_chitiet.id == cur.sanpham_chitiet.id).FirstOrDefault() == null).ToList(); //do action try { foreach (ChiTiet_NhapHang ctnh in Added_list) { ctnh.sanpham_chitiet.update_tonkho(ctnh.sanpham_chitiet.tonkho + ctnh.soluong, this.ngay); } } catch (Exception) { return false; } return true; }
public NhapHang() { this._ctr = new NhapHangController(); this._Init(); }
public NhapHang(DTDDDbContext context) { this._ctr = new NhapHangController(context); this._Init(); }