public ActionResult DeleteConfirmed(int id) { Purchase purchase = db.Purchases.Find(id); List <int> list = new List <int>(); foreach (var item in purchase.PurchaseLines.ToList()) { list.Add(item.IdPurchaseLine); } foreach (var elim in list) { PurchaseLine pl = db.PurchaseLines.Find(elim); Product product = db.Products.Find(pl.IdProduct); product.ParcialStock = product.ParcialStock - pl.LineQuantity; product.Stock = product.Stock - pl.LineQuantity; db.Entry(product).State = EntityState.Modified; db.PurchaseLines.Remove(pl); db.SaveChanges(); } db.Purchases.Remove(purchase); db.SaveChanges(); return(RedirectToAction("Index", "Purchases", new { message = 3 })); }
public JsonResult Create(PurchaseVM purchase) { bool status = false; Purchase p = new Purchase(); var idprovider = Int32.Parse(purchase.ProviderName); if (ModelState.IsValid) { p.IdProvider = idprovider; p.PurchaseDate = purchase.PurchaseDate; p.Comments = purchase.PurchaseComments; p.PurchaseTotal = purchase.PurchaseTotal; db.Purchases.Add(p); db.SaveChanges(); foreach (var item in purchase.PurchaseLines) { PurchaseLine purchaseline = new PurchaseLine(); purchaseline.IdPurchase = p.IdPurchase; purchaseline.IdProduct = item.IdProduct; purchaseline.Cost = item.Cost; purchaseline.PurchaseQuantity = item.PurchaseQuantity; purchaseline.LineTotal = item.LineTotal; db.PurchaseLines.Add(purchaseline); db.SaveChanges(); } status = true; } return(new JsonResult { Data = new { status = status } }); }
public BOPurchaseLine(Accountant accountant, Purchase _purchase, PurchaseLine _line, BOContext context) : base(accountant, context) { mObjectID = BOType.BOPurchaseLine; mPurchaseEntity = _purchase; mDataSource = _line; mDataSource.Purchase = _purchase; }
public ActionResult DeleteConfirmed(int id) { PurchaseLine purchaseLine = db.PurchaseLines.Find(id); db.PurchaseLines.Remove(purchaseLine); db.SaveChanges(); return(RedirectToAction("Index")); }
private DbDeleteStatement GetQuery_DeleteQuery(PurchaseLine _obj) { DbDeleteStatement clause = DbMgr.CreateDeleteClause(); clause.DeleteFrom("PurchaseLines").Criteria.IsEqual("PurchaseLines", "PurchaseLineID", _obj.PurchaseLineID); return(clause); }
public ActionResult NewPurchaseLine(PurchaseLine pl) { using (var db = new ExerciseEntities()) { db.PurchaseLines.Add(pl); db.SaveChanges(); } int val = pl.HeadID.Value; return(NewPurchaseLine(val)); }
public ActionResult Edit([Bind(Include = "IdPurchaseLine,IdProduct,LinePrice,LineQuantity,LineTotal,IdPurchase")] PurchaseLine purchaseLine) { if (ModelState.IsValid) { db.Entry(purchaseLine).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdProduct = new SelectList(db.Products, "IdProduct", "ProductDescription", purchaseLine.IdProduct); ViewBag.IdPurchase = new SelectList(db.Purchases, "IdPurchase", "Comments", purchaseLine.IdPurchase); return(View(purchaseLine)); }
public JsonResult CreatePurchase(PurchaseVM O) { //ProviderName contiene el id del proveedor bool status = false; Purchase purchase = new Purchase(); var proid = Int32.Parse(O.ProviderName); if (ModelState.IsValid) { purchase.PurchaseDate = O.PurchaseDate; purchase.Comments = O.Comments; purchase.PurchaseTotal = O.PurchaseTotal; purchase.IdProvider = proid; db.Purchases.Add(purchase); db.SaveChanges(); foreach (var i in O.PurchaseLines) { PurchaseLine purchaseline = new PurchaseLine(); purchaseline.IdProduct = i.IdProduct; purchaseline.LinePrice = i.LinePrice; purchaseline.LineQuantity = i.LineQuantity; purchaseline.LineTotal = i.LineTotal; purchaseline.IdPurchase = purchase.IdPurchase; db.PurchaseLines.Add(purchaseline); db.SaveChanges(); Product prod = new Product(); prod = db.Products.Find(i.IdProduct); prod.Stock = prod.Stock + i.LineQuantity; if (prod.Cost != i.LinePrice) { prod.UploadDate = purchase.PurchaseDate; } prod.ParcialStock = prod.ParcialStock + i.LineQuantity; prod.Cost = i.LinePrice; db.Entry(prod).State = EntityState.Modified; db.SaveChanges(); } status = true; } else { status = false; } return(new JsonResult { Data = new { status = status } }); }
protected void Update(PurchaseLine new_line) { if (RecordContext == BOContext.Record_Create) { mPurchaseEntity.PurchaseLines.Add(new_line); mPurchaseEntity.Evaluate(); } else { mDataSource.AssignFrom(new_line); mPurchaseEntity.Evaluate(); } }
// GET: PurchaseLines/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PurchaseLine purchaseLine = db.PurchaseLines.Find(id); if (purchaseLine == null) { return(HttpNotFound()); } return(View(purchaseLine)); }
protected override OpResult _Delete(PurchaseLine _obj) { if (_obj == null) { return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.ObjectIsNull, _obj, "PurchaseLine object cannot be deleted as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_DeleteQuery(_obj)); return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.ExistsAndDeleted, _obj)); } return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.NotExists, _obj, "PurchaseLine object cannot be deleted as it does not exist")); }
// GET: PurchaseLines/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PurchaseLine purchaseLine = db.PurchaseLines.Find(id); if (purchaseLine == null) { return(HttpNotFound()); } ViewBag.IdProduct = new SelectList(db.Products, "IdProduct", "ProductDescription", purchaseLine.IdProduct); ViewBag.IdPurchase = new SelectList(db.Purchases, "IdPurchase", "Comments", purchaseLine.IdPurchase); return(View(purchaseLine)); }
public async Task <PurchaseViewModel> Insert(PurchaseViewModel model) { var payment = new Payment(); var purchase = new Purchase(); var pLine = new PurchaseLine(); payment.PaymentType = "Purchase"; payment.PaymentMethod = model.PaymentMethod; payment.Amount = model.Amount; payment.BankName = model.BankName; payment.TransactionId = model.TransactionId; payment.PaymentNote = model.PaymentNote; _db.Payments.Add(payment); await _db.SaveChangesAsync(); purchase.ReferenceNo = model.ReferenceNo; purchase.PurchaseStatus = model.PurchaseStatus; purchase.UserId = model.UserId; purchase.PurchaseDate = model.PurchaseDate; purchase.TotalAmount = model.TotalAmount; purchase.VatAmount = model.VatAmount; purchase.DiscountAmount = model.DiscountAmount; purchase.PublisherId = model.PublisherId; //fk m purchase.PaymentId = payment.PaymentId; //fk a _db.Purchases.Add(purchase); await _db.SaveChangesAsync(); model.PurchaseLines.ForEach(ol => { pLine.PurchaseId = purchase.PurchaseId; //fk a pLine.BookId = ol.BookId; pLine.Quantity = ol.Quantity; pLine.Rate = ol.Rate; _db.PurchaseLines.Add(pLine); _db.SaveChanges(); //update stock int stockId = _db.Stocks.Where(a => a.BookId == ol.BookId).Select(s => s.StockId).SingleOrDefault(); Stock stock = _db.Stocks.Find(stockId); stock.Quantity += ol.Quantity; _db.Entry(stock).State = EntityState.Modified; _db.SaveChanges(); }); return(model); }
protected override OpResult _Store(PurchaseLine _obj) { if (_obj == null) { return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "PurchaseLine object cannot be created as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_UpdateQuery(_obj)); return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj)); } ExecuteNonQuery(GetQuery_InsertQuery(_obj)); if (_obj.PurchaseLineID == null) { _obj.PurchaseLineID = DbMgr.GetLastInsertID(); } _obj.FromDb = true; return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj)); }
public JsonResult CreatePurchase(PurchaseVM O) { //ProviderName contiene el id del proveedor bool status = false; Purchase purchase = new Purchase(); var proid = Int32.Parse(O.ProviderName); if (ModelState.IsValid) { purchase.PurchaseDate = O.PurchaseDate; purchase.Comments = O.Comments; purchase.PurchaseTotal = O.PurchaseTotal; purchase.IdProvider = proid; db.Purchases.Add(purchase); db.SaveChanges(); foreach (var i in O.PurchaseLines) { PurchaseLine purchaseline = new PurchaseLine(); purchaseline.IdProduct = i.IdProduct; purchaseline.LineCost = i.LineCost; purchaseline.LineQuantity = i.LineQuantity; purchaseline.LineTotal = i.LineTotal; purchaseline.IdPurchase = purchase.IdPurchase; db.PurchaseLines.Add(purchaseline); db.SaveChanges(); } status = true; } else { status = false; } return(new JsonResult { Data = new { status = status } }); }
/// <summary> /// Create a new PurchaseLine object. /// </summary> /// <param name="id">Initial value of Id.</param> public static PurchaseLine CreatePurchaseLine(int id) { PurchaseLine purchaseLine = new PurchaseLine(); purchaseLine.Id = id; return purchaseLine; }
public bool Exists(PurchaseLine _PurchaseLine, string SessionToken) { object[] results = this.Invoke("Exists", new object[] {_PurchaseLine,SessionToken}); return ((bool)(results[0])); }
public void DeleteObject(PurchaseLine _PurchaseLine, string SessionToken) { this.Invoke("DeleteObject", new object[] {_PurchaseLine,SessionToken}); return; }
public void OpenPurchaseLine(PurchaseLine purchaseLine) { mPurchasePresenter.ShowPurchaseLine(mAccountant.OpenPurchaseLine(purchaseLine)); }
public void CreateObjectFromPurchaseOrder(PurchaseLine _PurchaseLine, Services.Packages.Purchase _PurchaseOrder, string SessionToken) { this.Invoke("CreateObjectFromPurchaseOrder", new object[] {_PurchaseLine,_PurchaseOrder,SessionToken}); return; }
public async Task <IHttpActionResult> Put(PurchaseLine model) { await _irepo.Put(model); return(Content(HttpStatusCode.Accepted, "Record Updated")); }
public void Delete(System.Int32 __Id, string SessionToken) { PurchaseLine _PurchaseLine = new PurchaseLine(__Id); if (!PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Delete")) throw new UnauthorizedAccessException("Access Denied"); PurchaseLine.DeletePurchaseLine(__Id); }
public void CreateObjectFromPurchaseOrder(PurchaseLine _PurchaseLine, Services.Packages.Purchase _PurchaseOrder, string SessionToken) { ModelSession session = PurchaseLineSecureService.CheckSessionImp(SessionToken); //if (!Services.Packages.Security.PurchaseSecureService.CheckAccessImp(_PurchaseOrder, SessionToken, "Create OrderLines")) // throw new UnauthorizedAccessException("Access Denied"); _PurchaseLine.Reload(); if (!_PurchaseLine.Exists && !Services.Packages.Security.PurchaseSecureService.CheckAccessImp(_PurchaseOrder, SessionToken, "Create OrderLines")) throw new UnauthorizedAccessException("Access Denied"); else if (_PurchaseLine.Exists && !PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); _PurchaseLine.Owner = session.User; _PurchaseLine.PurchaseOrder = _PurchaseOrder; _PurchaseLine.Create(); }
public void CreateObject(PurchaseLine _PurchaseLine, string SessionToken) { ModelSession session = PurchaseLineSecureService.CheckSessionImp(SessionToken); if (!PurchaseLineSecureService.CheckUserRightsImp(session.User.Name, "Create " + typeof(PurchaseLine).FullName)) throw new UnauthorizedAccessException("Access Denied"); _PurchaseLine.Owner = session.User; _PurchaseLine.Create(); }
public PurchaseLine CreateFromPurchaseOrder(System.Int32 __Id, Services.Packages.Purchase _PurchaseOrder, string SessionToken) { ModelSession session = PurchaseLineSecureService.CheckSessionImp(SessionToken); PurchaseLine _PurchaseLine = new PurchaseLine(__Id); if (!_PurchaseLine.Exists && !Services.Packages.Security.PurchaseSecureService.CheckAccessImp(_PurchaseOrder, SessionToken, "Create OrderLines")) throw new UnauthorizedAccessException("Access Denied"); else if (_PurchaseLine.Exists && !PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); // PurchaseLine _PurchaseLine = PurchaseLine.CreatePurchaseLine(__Id); _PurchaseLine.Owner = session.User; _PurchaseLine.PurchaseOrder = _PurchaseOrder; _PurchaseLine.Update(); return _PurchaseLine; }
public void SetACLs(PurchaseLine _PurchaseLine, Services.Packages.Security.PurchaseLineAccessControlListCollection _ACLs, string SessionToken) { this.Invoke("GetACLs", new object[] {_PurchaseLine,SessionToken}); return; }
public Services.Packages.Security.PurchaseLineAccessControlListCollection GetACLs(PurchaseLine _PurchaseLine, string SessionToken) { object[] results = this.Invoke("GetACLs", new object[] {_PurchaseLine,SessionToken}); return ((Services.Packages.Security.PurchaseLineAccessControlListCollection)(results[0])); }
private DbUpdateStatement GetQuery_UpdateQuery(PurchaseLine _obj) { return(DbMgr.CreateUpdateClause("PurchaseLines", GetFields(_obj), "PurchaseLineID", _obj.PurchaseLineID)); }
public void SetOwner(PurchaseLine _PurchaseLine, Services.Packages.Security.ModelUser _Owner, string SessionToken) { this.Invoke("GetOwner", new object[] {_PurchaseLine,SessionToken}); return; }
public void DeleteObject(PurchaseLine _PurchaseLine, string SessionToken) { if (!PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Delete")) throw new UnauthorizedAccessException("Access Denied"); _PurchaseLine.Delete(); }
public Services.Packages.Purchase GetPurchaseOrder(PurchaseLine _PurchaseLine, string SessionToken) { object[] results = this.Invoke("GetPurchaseOrder", new object[] {_PurchaseLine,SessionToken}); return ((Services.Packages.Purchase)(results[0])); }
public bool Exists(PurchaseLine _PurchaseLine, string SessionToken) { if (!PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); return _PurchaseLine.Exists; }
private DbInsertStatement GetQuery_InsertQuery(PurchaseLine _obj) { Dictionary <string, DbFieldEntry> fields = GetFields(_obj); return(DbMgr.CreateInsertClause("PurchaseLines", fields)); }
public Services.Packages.Purchase GetPurchaseOrder(PurchaseLine _PurchaseLine, string SessionToken) { _PurchaseLine.Reload(); //* if (!Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ //* if (!Services.Packages.Security.PurchaseSecureService.CheckAccessImp(_PurchaseLine.PurchaseOrder, SessionToken, "Read")) throw new UnauthorizedAccessException("Access Denied"); //*/ return _PurchaseLine.PurchaseOrder; }
public void DeletePurchaseLine(PurchaseLine purchaseLine) { mAccountant.DeletePurchaseLine(purchaseLine); }
public PurchaseLine Read(System.Int32 __Id, string SessionToken) { PurchaseLine _PurchaseLine = new PurchaseLine(__Id); if (!PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Read")) throw new UnauthorizedAccessException("Access Denied"); return _PurchaseLine; }
public PurchaseLine Reload(PurchaseLine _PurchaseLine, string SessionToken) { object[] results = this.Invoke("Reload", new object[] {_PurchaseLine,SessionToken}); return ((PurchaseLine)(results[0])); }
public PurchaseLine Reload(PurchaseLine _PurchaseLine, string SessionToken) { _PurchaseLine.Reload(); if (!PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Read")) throw new UnauthorizedAccessException("Access Denied"); return _PurchaseLine; }
public void SetOwner(PurchaseLine _PurchaseLine, Services.Packages.Security.ModelUser _Owner, string SessionToken) { _PurchaseLine.Reload(); //* if (!Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ //* _Owner.Reload(); if (_Owner.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_Owner, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); else if (!_Owner.Exists && !Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Create PurchaseLineOwning")) throw new UnauthorizedAccessException("Access Denied"); //*/ _PurchaseLine.Owner = _Owner; _PurchaseLine.Update(); }
public void SetACLs(PurchaseLine _PurchaseLine, Services.Packages.Security.PurchaseLineAccessControlListCollection _ACLs, string SessionToken) { _PurchaseLine.Reload(); //* if (!Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ /* _ACLs.Reload(); if (_ACLs.Exists && !Services.Packages.Security.Security.PurchaseLineAccessControlListSecureService.CheckAccessImp(_ACLs, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); else if (!_ACLs.Exists && !Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Create ACLs")) throw new UnauthorizedAccessException("Access Denied"); //*/ _PurchaseLine.ACLs = _ACLs; _PurchaseLine.Update(); }
/// <summary> /// There are no comments for PurchaseLineSet in the schema. /// </summary> public void AddToPurchaseLineSet(PurchaseLine purchaseLine) { base.AddObject("PurchaseLineSet", purchaseLine); }
public void SetPurchaseOrder(PurchaseLine _PurchaseLine, Services.Packages.Purchase _PurchaseOrder, string SessionToken) { this.Invoke("GetPurchaseOrder", new object[] {_PurchaseLine,SessionToken}); return; }
public JsonResult EditPurchases(Purchase purchase) { Purchase p = db.Purchases.Find(purchase.IdPurchase); List <int> list = new List <int>(); foreach (var item in p.PurchaseLines.ToList()) { list.Add(item.IdPurchaseLine); } foreach (var elim in list) { PurchaseLine eline = db.PurchaseLines.Find(elim); Product product = new Product(); product = db.Products.Find(eline.IdProduct); product.ParcialStock = product.ParcialStock - eline.LineQuantity; product.Stock = product.Stock - eline.LineQuantity; db.Entry(product).State = EntityState.Modified; db.PurchaseLines.Remove(eline); db.SaveChanges(); } p.IdProvider = purchase.IdProvider; p.PurchaseDate = purchase.PurchaseDate; p.PurchaseTotal = purchase.PurchaseTotal; p.Comments = purchase.Comments; db.Entry(p).State = EntityState.Modified; db.SaveChanges(); if (purchase.PurchaseLines != null) { foreach (var i in purchase.PurchaseLines) { var pl = new PurchaseLine(); pl.IdPurchase = p.IdPurchase; pl.IdProduct = i.IdProduct; pl.LinePrice = i.LinePrice; pl.LineQuantity = i.LineQuantity; pl.LineTotal = i.LineTotal; Product product = db.Products.Find(i.IdProduct); product.ParcialStock = product.ParcialStock + i.LineQuantity; product.Stock = product.Stock + i.LineQuantity; if (product.Cost != i.LinePrice) { product.UploadDate = purchase.PurchaseDate; } product.Cost = i.LinePrice; if (i.LinePrice > product.WholeSalePrice) { product.WholeSalePrice = i.LinePrice; } db.Entry(product).State = EntityState.Modified; db.PurchaseLines.Add(pl); db.SaveChanges(); } } return(new JsonResult { Data = new { status = true } }); }
public async Task <IHttpActionResult> Post(PurchaseLine model) { await _irepo.Post(model); return(Ok(model)); }
public Services.Packages.Security.PurchaseLineAccessControlListCollection GetACLs(PurchaseLine _PurchaseLine, string SessionToken) { _PurchaseLine.Reload(); //* if (!Services.Packages.Security.PurchaseLineSecureService.CheckAccessImp(_PurchaseLine, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ /* if (!Services.Packages.Security.Security.PurchaseLineAccessControlListSecureService.CheckAccessImp(_PurchaseLine.ACLs, SessionToken, "Read")) throw new UnauthorizedAccessException("Access Denied"); //*/ return _PurchaseLine.ACLs; }
public Services.Packages.Security.ModelUser GetOwner(PurchaseLine _PurchaseLine, string SessionToken) { object[] results = this.Invoke("GetOwner", new object[] {_PurchaseLine,SessionToken}); return ((Services.Packages.Security.ModelUser)(results[0])); }