public void DeleteBC(DTO_BaoCaoTonKho obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { BaoCaoTonKho bc = (from item in db.BaoCaoTonKhoes where item.MaBaoCao == obj.MaBaoCao select item).SingleOrDefault(); db.BaoCaoTonKhoes.Remove(bc); db.SaveChanges(); } }
public void InsertBC(DTO_BaoCaoTonKho obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var result = db.Database .SqlQuery <String>("select MaHangHoa from dbo.HangHoa where TenHangHoa = N'" + obj.TenHangHoa + "'") .FirstOrDefault(); BaoCaoTonKho bc = new BaoCaoTonKho(); bc.MaBaoCao = obj.MaBaoCao; bc.MaHangHoa = result; bc.Nam = obj.Nam; bc.Thang = obj.Thang; bc.SoLuongNhap = obj.SoLuongNhap; bc.SoLuongXuat = obj.SoLuongXuat; bc.SoLuongTonDau = obj.SoLuongTonDau; bc.SoLuongTonCuoi = obj.SoLuongTonCuoi; db.BaoCaoTonKhoes.Add(bc); db.SaveChanges(); } }