public ActionResult Create() { MoveOrderModel model = SessionHelper.MoveOrder; if (model == null) { model = new MoveOrderModel { SOBId = SessionHelper.SOBId, DateRequired = DateTime.Now, MoveOrderDate = DateTime.Now, MoveOrderNo = "New" }; model.CompanyId = AuthenticationHelper.CompanyId.Value; ViewBag.SOBName = SetOfBookHelper.GetSetOfBook(SessionHelper.SOBId.ToString()).Name; SessionHelper.MoveOrder = model; if (SessionHelper.MoveOrder.MoveOrderDetail == null) { SessionHelper.MoveOrder.MoveOrderDetail = new List <MoveOrderDetailModel>(); } } return(View(model)); }
private static MoveOrder GetEntityByModel(MoveOrderModel model) { if (model == null) { return(null); } MoveOrder entity = new MoveOrder(); if (model.Id == 0) { entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; entity.CompanyId = AuthenticationHelper.CompanyId.Value; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; entity.CompanyId = model.CompanyId; } entity.DateRequired = model.DateRequired; entity.Description = model.Description; entity.Id = model.Id; entity.MoveOrderDate = model.MoveOrderDate; entity.MoveOrderNo = model.MoveOrderNo; entity.SOBId = model.SOBId; entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; return(entity); }
public static void DeleteMoveOrderDetail(MoveOrderDetailModel model) { MoveOrderModel moveOrder = SessionHelper.MoveOrder; MoveOrderDetailModel moveOrderDetail = moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id); moveOrder.MoveOrderDetail.Remove(moveOrderDetail); }
public ActionResult Edit(string id) { MoveOrderModel model = MoveOrderHelper.GetMoveOrder(id); model.MoveOrderDetail = MoveOrderHelper.GetMoveOrderLines(id).ToList(); model.SOBId = SessionHelper.SOBId; model.CompanyId = AuthenticationHelper.CompanyId.Value; SessionHelper.MoveOrder = model; return(View("Create", model)); }
public void MoveOrder(string orgCode, int orderNumber, int newEventID, int functionID) { var mymoveOrder = new MoveOrderModel { OrganizationCode = orgCode, OrderNumber = orderNumber, DestinationEventID = newEventID, Function = functionID }; APIUtil.AwaitMoveRegistrationOrder(USISDKClient, mymoveOrder).Wait(); }
/// <summary> /// Move order example /// </summary> /// <param name="orderNumber">Set OrderNumber as an integers of the order number to move</param> /// <param name="newEventID">This is the destination event ID. You can find this attached this to the Events window in Ungerboeck</param> /// <param name="functionID">This is the destination function ID on the destination event. This is required for service orders</param> public void MoveOrder(string orgCode, int orderNumber, int newEventID, int functionID) { var myserviceOrder = new MoveOrderModel { OrganizationCode = orgCode, OrderNumber = orderNumber, DestinationEventID = newEventID, Function = functionID, KeepDateTimes = "N" //If "Y", the original order item start/end date will be preserved. If "N", the moved order will adapt to the function start/end date. }; APIUtil.AwaitMoveServiceOrder(USISDKClient, myserviceOrder).Wait(); }
public static void UpdateMoveOrderDetail(MoveOrderDetailModel model) { MoveOrderModel moveOrder = SessionHelper.MoveOrder; moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id).DateRequired = model.DateRequired; moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id).Id = model.Id; moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id).ItemId = model.ItemId; moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id).LocatorId = model.LocatorId; moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id).LotNo = model.LotNo; moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id).MoveOrderId = model.MoveOrderId; moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id).Quantity = model.Quantity; moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id).SerialNo = model.SerialNo; moveOrder.MoveOrderDetail.FirstOrDefault(x => x.Id == model.Id).WarehouseId = model.WarehouseId; }
public ActionResult Save(MoveOrderModel model) { string message = ""; try { bool saved = false; if (SessionHelper.MoveOrder != null) { SessionHelper.MoveOrder.DateRequired = model.DateRequired; SessionHelper.MoveOrder.Description = model.Description; SessionHelper.MoveOrder.Id = model.Id; SessionHelper.MoveOrder.MoveOrderDate = model.MoveOrderDate; if (model.Id > 0) { SessionHelper.MoveOrder.MoveOrderNo = model.MoveOrderNo; } else { SessionHelper.MoveOrder.MoveOrderNo = MoveOrderHelper.GetDocNo(model.CompanyId, model.SOBId); } MoveOrderHelper.Save(SessionHelper.MoveOrder); SessionHelper.MoveOrder = null; saved = true; } else { message = "No Move Order information available!"; } return(Json(new { success = saved, message = message })); } catch (Exception e) { message = e.Message; return(Json(new { success = false, message = message })); } }
public ActionResult DeletePartial(MoveOrderDetailModel model) { if (ModelState.IsValid) { try { MoveOrderModel moveOrder = SessionHelper.MoveOrder; MoveOrderHelper.DeleteMoveOrderDetail(model); SessionHelper.MoveOrder = moveOrder; IList <MoveOrderDetailModel> moveOrderDetail = MoveOrderHelper.GetMoveOrderLines(); return(PartialView("createPartial", moveOrderDetail)); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial")); }
public static void Save(MoveOrderModel moveOrderModel) { MoveOrder entity = GetEntityByModel(moveOrderModel); string result = string.Empty; if (entity.IsValid()) { if (moveOrderModel.Id > 0) { result = service.Update(entity); } else { result = service.Insert(entity); } if (!string.IsNullOrEmpty(result)) { var savedDetail = GetMoveOrderLines(result); if (savedDetail.Count() > moveOrderModel.MoveOrderDetail.Count()) { var tobeDeleted = savedDetail.Take(savedDetail.Count() - moveOrderModel.MoveOrderDetail.Count()); foreach (var item in tobeDeleted) { service.Delete(item.Id); IEnumerable <LotNumber> lotNum = lotNumService.CheckLotNumAvailability(AuthenticationHelper.CompanyId.Value, item.LotNo, item.ItemId, SessionHelper.SOBId); if (lotNum.Any()) { LotNumberHelper.Delete(lotNum.FirstOrDefault().Id.ToString()); } //IEnumerable<SerialNumber> serialNum = lotNumService.CheckSerialNumAvailability(AuthenticationHelper.CompanyId.Value, item.LotNo, item.SerialNo); //if (serialNum.Any()) //{ // LotNumberHelper.DeleteSerialNumber(serialNum.FirstOrDefault().Id.ToString()); //} } savedDetail = GetMoveOrderLines(result); } foreach (var detail in moveOrderModel.MoveOrderDetail) { MoveOrderDetail detailEntity = GetEntityByModel(detail, savedDetail.Count()); if (detailEntity.IsValid()) { detailEntity.MoveOrderId = Convert.ToInt64(result); if (savedDetail.Count() > 0) { detailEntity.Id = savedDetail.FirstOrDefault().Id; savedDetail.Remove(savedDetail.FirstOrDefault(rec => rec.Id == detailEntity.Id)); service.Update(detailEntity); IEnumerable <LotNumber> lotNum = lotNumService.CheckLotNumAvailability(AuthenticationHelper.CompanyId.Value, detailEntity.LotNo, detailEntity.ItemId, SessionHelper.SOBId); if (lotNum.Any()) { LotNumberHelper.Update(lotNum.FirstOrDefault()); } //IEnumerable<SerialNumber> serialNum = lotNumService.CheckSerialNumAvailability(AuthenticationHelper.CompanyId.Value, detailEntity.LotNo, detailEntity.SerialNo); //if (serialNum.Any()) //{ // LotNumberHelper.UpdateSerialNumber(serialNum.FirstOrDefault()); //} } else { service.Insert(detailEntity); IEnumerable <LotNumber> lotNum = lotNumService.CheckLotNumAvailability(AuthenticationHelper.CompanyId.Value, detailEntity.LotNo, detailEntity.ItemId, SessionHelper.SOBId); if (!lotNum.Any()) { LotNumberHelper.Insert(new MoveOrderDetailModel(detailEntity)); } //IEnumerable<SerialNumber> serialNum = lotNumService.CheckSerialNumAvailability(AuthenticationHelper.CompanyId.Value, detailEntity.LotNo, detailEntity.SerialNo); //if (!serialNum.Any()) //{ // LotNumberHelper.InsertSerialNumber(new MoveOrderDetailModel(detailEntity)); //} } } } } } }
public static void InsertMoveOrderDetail(MoveOrderDetailModel model) { MoveOrderModel moveOrder = SessionHelper.MoveOrder; moveOrder.MoveOrderDetail.Add(model); }
public static MoveOrderModel GetMoveOrder(string id) { MoveOrderModel model = new MoveOrderModel(service.GetSingle(id, AuthenticationHelper.CompanyId.Value)); return(model); }