public bool InsertChiTietPhieuNhap(ChiTietPhieuNhap chiTiet) { int result = 0; result = DatabaseDAL.ExecuteNonQuery("exec USP_InsertChitiet_PhieuNhap @sochungtu , @mahang , @soluong , @dongia , @thanhtien , @donvitinh ", new object[] { chiTiet.SoChungTu, chiTiet.MaHang, chiTiet.SoLuongNhap, chiTiet.DonGia, chiTiet.ThanhTien, chiTiet.DonViTinh }); return(result > 0); }
public void delete(String id) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { ChiTietPhieuNhap ctpn = (from item in db.ChiTietPhieuNhaps where item.MaChiTietPhieuNhap == id select item).SingleOrDefault(); db.ChiTietPhieuNhaps.Remove(ctpn); db.SaveChanges(); } }
public bool them(ChiTietPhieuNhap item) { try { ketNoi.ChiTietPhieuNhaps.InsertOnSubmit(item); ketNoi.SubmitChanges(); return(true); } catch (Exception) { return(false); } }
public void insert(DTO_ChiTietPhieuNhap obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaHangHoa = db.Database .SqlQuery <String>("select MaHangHoa from dbo.HangHoa where TenHangHoa = N'" + obj.TenHangHoa + "'") .FirstOrDefault(); ChiTietPhieuNhap ctpn = new ChiTietPhieuNhap(); ctpn.MaChiTietPhieuNhap = obj.MaChiTietPhieuNhap; ctpn.MaHangHoa = resultMaHangHoa; ctpn.MaPhieuNhap = obj.MaPhieuNhap; ctpn.SoLuong = obj.SoLuong; ctpn.GiaNhap = obj.GiaNhap; ctpn.ThanhTien = obj.ThanhTien; db.ChiTietPhieuNhaps.Add(ctpn); db.SaveChanges(); } }
public void update(DTO_ChiTietPhieuNhap obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaHangHoa = db.Database .SqlQuery <String>("select MaHangHoa from dbo.HangHoa where TenHangHoa = N'" + obj.TenHangHoa + "'") .FirstOrDefault(); ChiTietPhieuNhap ctpn = new ChiTietPhieuNhap(); ctpn.MaChiTietPhieuNhap = obj.MaChiTietPhieuNhap; ctpn.MaHangHoa = resultMaHangHoa; ctpn.MaPhieuNhap = obj.MaPhieuNhap; ctpn.SoLuong = obj.SoLuong; ctpn.GiaNhap = obj.GiaNhap; ctpn.ThanhTien = obj.ThanhTien; db.ChiTietPhieuNhaps.Attach(ctpn); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
//Thêm loại chi tiết hóa đơn public Result InsertCTHD(string maPN, string maHang, string giaNhap, string soluong) { if (checkPrimaryKeyMaChiTietHoaDon(maPN, maHang) == false) { return(Result.PRIMARY_KEY); } try { ChiTietPhieuNhap hd = new ChiTietPhieuNhap(); hd.MaPN = maPN; hd.MaHang = maHang; hd.MaKho = "KHO001"; hd.SoLuongNhap = int.Parse(soluong); hd.GiaNhap = decimal.Parse(giaNhap); hd.ThanhTien = hd.SoLuongNhap * hd.GiaNhap; qlch.ChiTietPhieuNhaps.InsertOnSubmit(hd); qlch.SubmitChanges(); return(Result.SUCCESS); } catch { return(Result.FAILED); } }