public int add(ChiTiet_NhapHang obj) { this._db.ds_chitiet_nhaphang.Add(obj); //commit this.save(); //return ma moi nhat return this._db.ds_chitiet_nhaphang.Max(x => x.id); }
public Boolean delete(ChiTiet_NhapHang obj) { try { //get entity obj = this.get_by_id(obj.id); //remove this._db.ds_chitiet_nhaphang.Remove(obj); //commit return this.save(); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return false; } }
private void btThem_Click(object sender, EventArgs e) { SanPham_ChiTiet spct = (SanPham_ChiTiet)dtgvChiTietSP.SelectedRows[0].DataBoundItem; if (nh.check_exist_spct_in_donnhaphang(spct.id)) { MessageBox.Show("Đơn nhập hàng đã có chứa sản phẩm này rồi."); return; } ChiTiet_NhapHang ctnh = new ChiTiet_NhapHang(NHCtr._db); ctnh.soluong = Int32.Parse(tbSoLuong.Text); if (ctnh.soluong == 0) { MessageBox.Show("Chỉ được nhập số lượng lớn hơn 0."); return; } ctnh.dongia = Int32.Parse(tbDonGia.Text); if (ctnh.dongia == 0) { MessageBox.Show("Chỉ được nhập đơn giá lớn hơn 0."); return; } ctnh.sanpham_chitiet = spct; //set lai tong tien int num = TextLibrary.ToInt(tbTongTien.Text); num += ctnh.soluong * ctnh.dongia; tbTongTien.Text = TextLibrary.ToCommaStringNumber(num); nh.ds_chitiet_nhaphang.Add(ctnh); MessageBox.Show("Thêm thành công."); LoadDTGV_ChiTietNH(); }