public bool UpdateBook(book obj) { using (CTyPHSachEntities db = new CTyPHSachEntities()) { try { Books op = db.Books.Find(obj.ma); op.bookName = obj.ten; op.CategoryID = obj.id_danhmuc; op.PublisherID = obj.id_nxb; op.description = obj.mota; op.price = obj.giaxuat; op.receiptPrice = obj.gianhap; op.author = obj.ten; op.amount = 0; op.img = obj.img; db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }
public bool DeleteBook(int id) { using (CTyPHSachEntities db = new CTyPHSachEntities()) { var obj = db.Books.Find(id); obj.status = 2; db.SaveChanges(); return(true); } }
public bool Insert(phieuxuat obj) { using (CTyPHSachEntities db = new CTyPHSachEntities()) { try { int id = db.DeliveryNotes.Max(x => x.DeliveryNoteID) + 10; var ob = new DeliveryNotes(); ob.DeliveryNoteID = id; ob.deliverName = obj.nguoigia; ob.receiverName = obj.nguoitao; ob.totalPrice = obj.giatri; ob.AgencyID = obj.id_dl; ob.endeliverdate = obj.hanthanhtoan; ob.deliverDateCreated = obj.ngayxuat; db.DeliveryNotes.Add(ob); List <DeliveryDetails> rd = new List <DeliveryDetails>(); foreach (var item in obj.chitiet) { var ct = new DeliveryDetails(); var s = db.Books.Find(item.masach); s.amount = s.amount - item.sl; ct.BookID = item.masach; ct.DeliveryNoteID = id; ct.amount = item.sl; ct.price = s.receiptPrice; rd.Add(ct); } db.DeliveryDetails.AddRange(rd); if (obj.thanhtoan > 0) { var tt = new Debts(); tt.DeliveryNoteID = id; tt.dateCreated = obj.ngayxuat; tt.thanhtoan = obj.thanhtoan; tt.id_dl = obj.id_dl; tt.creatorName = obj.nguoitao; db.Debts.Add(tt); } db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }
public bool Update(daily obj) { using (CTyPHSachEntities db = new CTyPHSachEntities()) { try { var d = db.Agencies.Find(obj.id); d.agencyName = obj.name; d.agencyAddress = obj.address; d.maxdebt = obj.mucno; db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }
public bool insert(phieuchi pt) { using (CTyPHSachEntities db = new CTyPHSachEntities()) { try { var entity = new Payments(); entity.ReceiptNoteID = pt.id_phieunhap; entity.creatorName = pt.nguoithu; entity.dateCreated = pt.ngaylap; entity.price = pt.thanhtoan; db.Payments.Add(entity); db.SaveChanges(); return(true); }catch (Exception ex) { return(false); } } }
public bool insert(phieuthu pt) { using (CTyPHSachEntities db = new CTyPHSachEntities()) { try { var entity = new Debts(); entity.DeliveryNoteID = pt.id_phieuxuat; entity.creatorName = pt.nguoithu; entity.dateCreated = pt.ngaylap; entity.id_dl = pt.id_daily; entity.thanhtoan = pt.thanhtoan; db.Debts.Add(entity); db.SaveChanges(); return(true); }catch (Exception ex) { return(false); } } }
public bool Insert(phieunhap obj) { using (CTyPHSachEntities db = new CTyPHSachEntities()) { try { int id = db.ReceiptNotes.Max(x => x.ReceiptNoteID) + 10; var ob = new ReceiptNotes(); ob.ReceiptNoteID = id; ob.receiptName = obj.nguoigia; ob.senderName = obj.nguoitao; ob.totalPrice = obj.giatri; ob.PublisherID = obj.id_nxb; ob.subid = id; ob.receiptDateCreated = obj.ngayxuat; db.ReceiptNotes.Add(ob); List <ReceiptDetails> rd = new List <ReceiptDetails>(); foreach (var item in obj.chitiet) { var ct = new ReceiptDetails(); var s = db.Books.Find(item.masach); s.amount = s.amount + item.sl; ct.BookID = item.masach; ct.ReceiptNoteID = id; ct.receiptAmount = item.sl; ct.totalPrice = s.receiptPrice; rd.Add(ct); } db.ReceiptDetails.AddRange(rd); db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }