Exemple #1
0
        public ActionResult EditRO(Model.WarehouseRelease model)
        {
            var wrn = WRFservice.GetWRNs().FirstOrDefault(p => p.Id == model.Id);

            wrn.RequestDate = model.RequestDate;
            wrn.ReceivedBy  = model.ReceivedBy;
            wrn.ApprovedBy  = model.ApprovedBy;
            WRFservice.EditRO(wrn);
            return(this.ViewNRNDetails(model.Id));
        }
Exemple #2
0
        public ActionResult LoadWRF()
        {
            var model = new Model.WarehouseRelease()
            {
                RefNumber     = string.Format("--{0}--", Resources.Global_String_NewWRO),
                RequestDate   = DateTime.Today,
                ReceivedBy    = currentStaff.Id,
                Staffs        = new SelectList(SessionData.CurrentSession.StaffList, "Id", "StaffName"),
                Warehouses    = new SelectList(SessionData.CurrentSession.WarehouseList, "Id", "Name"),
                ApproversList = new SelectList(staffService.GetStaffByApprovalDoc(NotificationHelper.wrnCode, countryProg.Id), "Id", "StaffName"),
                RequestorName = currentStaff.Person.FirstName + " " + currentStaff.Person.OtherNames
            };

            return(View(model));
        }
Exemple #3
0
        private bool AddItems(Model.WarehouseRelease wrEntity, Model.WarehouseReleaseItem entity, SCMSEntities context, TransactionScope scope, bool sendmail = false)
        {
            string itemCategory = context.Inventories.FirstOrDefault(p => p.Id == entity.InventoryId).Item.ItemCategory.CategoryCode;

            if (wrEntity == null)
            {
                wrEntity = context.WarehouseReleases.FirstOrDefault(w => w.Id == entity.WarehouseReleaseId);
            }
            entity.Id = Guid.NewGuid();
            if (itemCategory.Equals("C"))
            {
                entity.AssetId = Guid.Empty; context.WarehouseReleaseItems.Add(entity);
            }
            else
            {
                entity.Quantity = 1;
                Model.Asset ass = context.Assets.FirstOrDefault(p => p.Id == entity.AssetId);
                ass.IsReleased     = true;
                ass.CurrentOwnerId = wrEntity.ReceivedBy;
                ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(ass, System.Data.EntityState.Modified);
                context.WarehouseReleaseItems.Add(entity);
            }
            Model.Inventory inv = context.Inventories.First(p => p.Id == entity.InventoryId);
            inv.Quantity -= (Int64)entity.Quantity;
            ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(inv, System.Data.EntityState.Modified);

            if ((context.SaveChanges() > 0))
            {
                SessionData.CurrentSession.ReleaseOrderList     = null;
                SessionData.CurrentSession.ReleaseOrderItemList = null;
                SessionData.CurrentSession.AssetList            = null;
                SessionData.CurrentSession.InventoryList        = null;
                if (sendmail)
                {
                    NotificationServicee.SendNotification(NotificationServicee.GetApproverEmailAddress(1, NotificationHelper.wrnCode), NotificationHelper.wrnMsgBody, NotificationHelper.wrnsubject);
                }
                scope.Complete();
                return(true);
            }
            else
            {
                scope.Dispose(); return(false);
            }
        }
Exemple #4
0
        public string GenerateUniquNumber(CountryProgramme cp)
        {
            string code      = "WRO/DRC/" + cp.Country.ShortName + "/";
            string refNumber = "";
            long   count     = 1;

            var total = SessionData.CurrentSession.ReleaseOrderList.Where(p => p.IsSubmitted == true).Count();

            count = total;
            Model.WarehouseRelease m = null;
            do
            {
                count++;
                if (count < 100000)
                {
                    if (count < 10)
                    {
                        refNumber = code + "0000" + count;
                    }
                    if (count < 100 && count >= 10)
                    {
                        refNumber = code + "000" + count;
                    }
                    if (count < 1000 && count >= 100)
                    {
                        refNumber = code + "00" + count;
                    }
                    if (count < 10000 && count >= 1000)
                    {
                        refNumber = code + "0" + count;
                    }
                    if (count < 100000 && count >= 10000)
                    {
                        refNumber = code + count;
                    }
                }
                m = SessionData.CurrentSession.ReleaseOrderList.FirstOrDefault(p => p.RefNumber == refNumber);
            } while (m != null);
            return(refNumber);
        }
Exemple #5
0
 public bool SaveWRF(Model.WarehouseRelease WR, Model.WarehouseReleaseItem entity)
 {
     using (var context = new SCMSEntities())
     {
         using (TransactionScope scope = new TransactionScope())
         {
             try
             {
                 if (WR != null)
                 {
                     context.WarehouseReleases.Add(WR);
                     return(AddItems(WR, entity, context, scope, true));
                 }
                 else
                 {
                     if (entity.Id.Equals(Guid.Empty))
                     {
                         return(AddItems(WR, entity, context, scope));
                     }
                     else
                     {
                         ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Modified);
                         if ((context.SaveChanges() > 0))
                         {
                             scope.Complete(); SessionData.CurrentSession.ReleaseOrderItemList = null; return(true);
                         }
                         else
                         {
                             scope.Dispose(); return(false);
                         }
                     }
                 }
             }
             catch (Exception ex) { scope.Dispose(); throw ex; }
         }
     }
 }
Exemple #6
0
        private string ORStatus(Model.WarehouseRelease or, out DateTime StatusDate)
        {
            string orStatus;

            if (or.IsApproved)
            {
                orStatus = Resources.Global_String_StatusAP;
            }
            else if (or.IsRejected)
            {
                orStatus = Resources.Global_String_StatusRJ;
            }
            else if (or.IsSubmitted)
            {
                orStatus = Resources.Global_String_StatusCR;
            }
            else
            {
                orStatus = Resources.Global_String_StatusNEW;
            }

            if (or.IsApproved)
            {
                StatusDate = or.ApprovedOn.Value;
            }
            else if (or.IsRejected)
            {
                StatusDate = or.RejectedOn.Value;
            }
            else
            {
                StatusDate = or.RequestDate;
            }

            return(orStatus);
        }