public JsonResult DiscardLotSerialNumbers(int id) { var rqmt = LotSerialRequirement.Find(id); var qry = from x in LotSerialTracking.Queryable where x.Source == rqmt.Source && x.Reference == rqmt.Reference && x.Warehouse.Id == rqmt.Warehouse.Id && x.Product == rqmt.Product select x; using (var scope = new TransactionScope()) { var entity = new LotSerialTracking { Source = rqmt.Source, Reference = rqmt.Reference, Date = DateTime.Now, Warehouse = rqmt.Warehouse, Product = rqmt.Product, Quantity = rqmt.Quantity }; foreach (var item in qry) { item.Delete(); } entity.Create(); rqmt.DeleteAndFlush(); } return(Json(new { id = id, result = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult PhysicalCountAdjustmentConfirmed(int id) { var entity = InventoryReceipt.Find(id); string sql = @"SELECT s.product ProductId, s.lot_number LotNumber, s.expiration_date ExpirationDate, s.serial_number SerialNumber, SUM(s.quantity) Quantity FROM lot_serial_tracking s INNER JOIN inventory_receipt_detail d ON s.product = d.product WHERE d.receipt = :id AND s.warehouse = :warehouse AND s.date < :date GROUP BY s.product, s.lot_number, s.expiration_date, s.serial_number HAVING SUM(s.quantity) <> 0"; var items = (IList <dynamic>) ActiveRecordMediator <Product> .Execute(delegate(ISession session, object instance) { var query = session.CreateSQLQuery(sql); query.AddScalar("ProductId", NHibernateUtil.Int32); query.AddScalar("LotNumber", NHibernateUtil.String); query.AddScalar("ExpirationDate", NHibernateUtil.Date); query.AddScalar("SerialNumber", NHibernateUtil.String); query.AddScalar("Quantity", NHibernateUtil.Decimal); query.SetInt32("id", entity.Id); query.SetInt32("warehouse", entity.Warehouse.Id); query.SetDateTime("date", entity.ModificationTime); return(query.DynamicList()); }, null); using (var scope = new TransactionScope()) { var dt = entity.ModificationTime.AddMilliseconds(-1); foreach (var x in items) { var item = new LotSerialTracking { Source = TransactionType.InventoryAdjustment, Reference = entity.Id, Date = dt, Warehouse = entity.Warehouse, Product = Product.Find(x.ProductId), Quantity = -x.Quantity, LotNumber = x.LotNumber, ExpirationDate = x.ExpirationDate, SerialNumber = x.SerialNumber }; item.Create(); } scope.Flush(); } return(RedirectToAction("Receipts")); }
static void KardexRegister(TransactionType source, int reference, DateTime dt, Warehouse warehouse, Product product, decimal quantity) { var item = new LotSerialTracking { Source = source, Reference = reference, Date = DateTime.Now, Warehouse = warehouse, Product = product, Quantity = quantity }; item.Create (); }
static void KardexRegister(TransactionType source, int reference, DateTime dt, Warehouse warehouse, Product product, decimal quantity) { var item = new LotSerialTracking { Source = source, Reference = reference, Date = DateTime.Now, Warehouse = warehouse, Product = product, Quantity = quantity }; item.Create(); }
public ActionResult ConfirmLotSerialNumbers(int id) { var entity = LotSerialRequirement.Find(id); var qry = from x in LotSerialTracking.Queryable where x.Source == entity.Source && x.Reference == entity.Reference && x.Warehouse.Id == entity.Warehouse.Id && x.Product.Id == entity.Product.Id select x; decimal sum = qry.Count() > 0 ? qry.Sum(x => x.Quantity) : 0; if (entity.Quantity != sum) { Response.StatusCode = 400; return(Content(Resources.ValidationFailed)); } using (var scope = new TransactionScope()) { if (entity.Source == TransactionType.InventoryTransfer) { var transfer = InventoryTransfer.Find(entity.Reference); foreach (var serial in qry) { var item = new LotSerialTracking { Source = serial.Source, Reference = serial.Reference, Date = serial.Date, Warehouse = transfer.To, Product = serial.Product, Quantity = -serial.Quantity, LotNumber = serial.LotNumber, ExpirationDate = serial.ExpirationDate, SerialNumber = serial.SerialNumber }; item.Create(); } } entity.DeleteAndFlush(); } return(Json(new { id = id, result = true })); }
public ActionResult PhysicalCountAdjustmentConfirmed(int id) { var entity = InventoryReceipt.Find (id); string sql = @"SELECT s.product ProductId, s.lot_number LotNumber, s.expiration_date ExpirationDate, s.serial_number SerialNumber, SUM(s.quantity) Quantity FROM lot_serial_tracking s INNER JOIN inventory_receipt_detail d ON s.product = d.product WHERE d.receipt = :id AND s.warehouse = :warehouse AND s.date < :date GROUP BY s.product, s.lot_number, s.expiration_date, s.serial_number HAVING SUM(s.quantity) <> 0"; var items = (IList<dynamic>) ActiveRecordMediator<Product>.Execute (delegate (ISession session, object instance) { var query = session.CreateSQLQuery (sql); query.AddScalar ("ProductId", NHibernateUtil.Int32); query.AddScalar ("LotNumber", NHibernateUtil.String); query.AddScalar ("ExpirationDate", NHibernateUtil.Date); query.AddScalar ("SerialNumber", NHibernateUtil.String); query.AddScalar ("Quantity", NHibernateUtil.Decimal); query.SetInt32 ("id", entity.Id); query.SetInt32 ("warehouse", entity.Warehouse.Id); query.SetDateTime ("date", entity.ModificationTime); return query.DynamicList (); }, null); using (var scope = new TransactionScope ()) { var dt = entity.ModificationTime.AddMilliseconds (-1); foreach (var x in items) { var item = new LotSerialTracking { Source = TransactionType.InventoryAdjustment, Reference = entity.Id, Date = dt, Warehouse = entity.Warehouse, Product = Product.Find (x.ProductId), Quantity = -x.Quantity, LotNumber = x.LotNumber, ExpirationDate = x.ExpirationDate, SerialNumber = x.SerialNumber }; item.Create (); } scope.Flush (); } return RedirectToAction ("Receipts"); }
public JsonResult DiscardLotSerialNumbers(int id) { var rqmt = LotSerialRequirement.Find (id); var qry = from x in LotSerialTracking.Queryable where x.Source == rqmt.Source && x.Reference == rqmt.Reference && x.Warehouse.Id == rqmt.Warehouse.Id && x.Product == rqmt.Product select x; using (var scope = new TransactionScope ()) { var entity = new LotSerialTracking { Source = rqmt.Source, Reference = rqmt.Reference, Date = DateTime.Now, Warehouse = rqmt.Warehouse, Product = rqmt.Product, Quantity = rqmt.Quantity }; foreach (var item in qry) { item.Delete (); } entity.Create (); rqmt.DeleteAndFlush (); } return Json (new { id = id, result = true }, JsonRequestBehavior.AllowGet); }
public ActionResult ConfirmLotSerialNumbers(int id) { var entity = LotSerialRequirement.Find (id); var qry = from x in LotSerialTracking.Queryable where x.Source == entity.Source && x.Reference == entity.Reference && x.Warehouse.Id == entity.Warehouse.Id && x.Product.Id == entity.Product.Id select x; decimal sum = qry.Count () > 0 ? qry.Sum (x => x.Quantity) : 0; if (entity.Quantity != sum) { Response.StatusCode = 400; return Content (Resources.ValidationFailed); } using (var scope = new TransactionScope ()) { if (entity.Source == TransactionType.InventoryTransfer) { var transfer = InventoryTransfer.Find (entity.Reference); foreach (var serial in qry) { var item = new LotSerialTracking { Source = serial.Source, Reference = serial.Reference, Date = serial.Date, Warehouse = transfer.To, Product = serial.Product, Quantity = -serial.Quantity, LotNumber = serial.LotNumber, ExpirationDate = serial.ExpirationDate, SerialNumber = serial.SerialNumber }; item.Create (); } } entity.DeleteAndFlush (); } return Json (new { id = id, result = true }); }