Ejemplo n.º 1
0
        public ActionResult SaveGRN(Model.GoodsReceivedNote entity)
        {
            entity.Id = Guid.NewGuid();
            entity.CountryProgrammeId = countryProg.Id;
            entity.PreparedBy         = currentStaff.Id;
            entity.Verified           = false;
            entity.PreparedOn         = DateTime.Now;
            entity.IsSubmitted        = false;
            //entity.RefNumber = gRNService.GenerateUniquNumber(countryProg);
            if (!gRNService.SaveGRN(entity))
            {
                ViewBag.Response      = 0;
                ViewBag.msg           = Resources.Global_String_AnErrorOccurred;
                entity.staffs         = new SelectList(SessionData.CurrentSession.StaffList, "Id", "StaffName");
                entity.SupplierId     = gRNService.GetPO(entity.PurchaseOrderId).Supplier.Id;
                entity.PurchaseOrders = new SelectList(gRNService.GetGRNPurchaseOrders(), "Id", "RefNumber");
                entity.SubOffices     = new SelectList(SessionData.CurrentSession.CountrySubOfficeList, "Id", "Name");
                entity.POItemz        = gRNService.GetPOItemsDetails(entity.PurchaseOrderId);
                entity.SupplierName   = gRNService.GetPO(entity.PurchaseOrderId).Supplier.Name;
                return(View("LoadGRN", entity));
            }
            //Send notification
            notificationService.SendToAppropriateApprover(NotificationHelper.grnCode, NotificationHelper.verificationCode, entity.Id);
            ViewBag.Response = 1;
            ViewBag.msg      = Resources.Global_String_ProcessCompleted;

            return(ViewGRNDetails(new GRNDetailsParams {
                GRNId = entity.Id, Verify = false
            }));
        }
Ejemplo n.º 2
0
 public ActionResult VerifyGRN(Guid id)
 {
     Model.GoodsReceivedNote grn = SessionData.CurrentSession.GoodsReceivedNoteList.FirstOrDefault(p => p.Id == id);
     using (var db = new SCMSEntities())
     {
         grn.ReceivedByStaff = db.VStaffDetails.FirstOrDefault(p => p.StaffID == grn.ReceivedBy);
         grn.ItemColl        = grn.GoodsReceivedNoteItems.ToList();
         return(View(grn));
     }
 }
Ejemplo n.º 3
0
 public bool IsGRNVerified(GoodsReceivedNote GRNentity)
 {
     using (var context = new SCMSEntities())
     {
         using (TransactionScope scope = new TransactionScope())
         {
             foreach (GoodsReceivedNoteItem item in GRNentity.ItemColl)
             {
                 GoodsReceivedNoteItem grit = context.GoodsReceivedNoteItems.FirstOrDefault(p => p.Id == item.Id);
                 if (context.Inventories.Count(p => p.ItemId == grit.PurchaseOrderItem.Item.Id && p.WareHouseId == grit.GoodsReceivedNote.WareHouseId) > 0)
                 {
                     if (grit.PurchaseOrderItem.Item.ItemCategory.CategoryCode == "C")
                     {
                         Model.Inventory invt = context.Inventories.FirstOrDefault(p => p.ItemId == grit.PurchaseOrderItem.Item.Id && p.WareHouseId == grit.GoodsReceivedNote.WareHouseId);
                         invt.Quantity += (long)item.QuantityDelivered;
                         ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(invt, System.Data.EntityState.Modified);
                     }
                 }
                 else
                 {
                     long qty = 0;
                     if (grit.PurchaseOrderItem.Item.ItemCategory.CategoryCode == "C")
                     {
                         qty = (long)item.QuantityDelivered;
                     }
                     Model.Inventory newinvetoryEntity =
                         new Model.Inventory()
                     {
                         Id = Guid.NewGuid(), ItemId = grit.PurchaseOrderItem.Item.Id, Quantity = qty, CountryProgrammeId = GRNentity.CountryProgrammeId, WareHouseId = (Guid)grit.GoodsReceivedNote.WareHouseId
                     };
                     context.Inventories.Add(newinvetoryEntity);
                 }
                 Model.GoodsReceivedNoteItem grnitm = context.GoodsReceivedNoteItems.FirstOrDefault(p => p.Id == item.Id);
                 grnitm.QuantityDamaged = item.QuantityDamaged; grnitm.QuantityDelivered = item.QuantityDelivered;
                 ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(grnitm, System.Data.EntityState.Modified);
                 context.SaveChanges();
             }
             Model.GoodsReceivedNote grn = context.GoodsReceivedNotes.FirstOrDefault(p => p.Id == GRNentity.Id);
             grn.Verified            = true;
             grn.ApprovedOn          = DateTime.Now;
             grn.ReceptionApprovedBy = GRNentity.ReceptionApprovedBy;
             ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(grn, System.Data.EntityState.Modified);
             if (context.SaveChanges() > 0)
             {
                 scope.Complete(); return(true);
             }
             else
             {
                 scope.Dispose(); return(false);
             }
         }
     }
 }
Ejemplo n.º 4
0
        public ActionResult EditGRN(Model.GoodsReceivedNote entity)
        {
            var grn = gRNService.GetGRNById(entity.Id);

            grn.DeliverDate         = entity.DeliverDate;
            grn.DnNumber            = entity.DnNumber;
            grn.ReceivedBy          = entity.ReceivedBy;
            grn.CountryOfficeId     = entity.CountryOfficeId;
            grn.WareHouseId         = entity.WareHouseId;
            grn.DeliveredBy         = entity.DeliveredBy;
            grn.DeliveryCompany     = entity.DeliveryCompany;
            grn.VehicleRegNumber    = entity.VehicleRegNumber;
            grn.DriverLicenseNumber = entity.DriverLicenseNumber;
            grn.ReceptionApprovedBy = entity.ReceptionApprovedBy;
            grn.Remarks             = entity.Remarks;
            gRNService.UpdateGRN(grn);
            return(GRNDetailz(entity.Id));
        }
Ejemplo n.º 5
0
        private string GRNStatus(Model.GoodsReceivedNote grn)
        {
            string orStatus;

            if (grn.IsRejected)
            {
                orStatus = Resources.Global_String_StatusRJ;
            }
            else if (grn.Verified)
            {
                orStatus = Resources.Global_String_StatusAP;
            }
            else
            {
                orStatus = Resources.Global_String_StatusCR;
            }

            return(orStatus);
        }
Ejemplo n.º 6
0
        private ActionResult GRNDetailz(Guid GRNId)
        {
            Model.GoodsReceivedNote grn = SessionData.CurrentSession.GoodsReceivedNoteList.FirstOrDefault(p => p.Id == GRNId);
            using (var db = new SCMSEntities()) { grn.ReceivedByStaff = db.VStaffDetails.FirstOrDefault(p => p.StaffID == grn.ReceivedBy); }
            string actionType = null;

            if (grn.IsSubmitted && !grn.Verified && !grn.IsRejected)
            {
                actionType = NotificationHelper.verificationCode;
            }
            if (actionType != null)
            {
                grn.CanApprove = notificationService.CanApprove(currentUser, NotificationHelper.grnCode, actionType, grn.Id);
            }
            else
            {
                grn.CanApprove = false;
            }
            return(View("ViewGRNDetails", grn));
        }
Ejemplo n.º 7
0
        public string GenerateUniquNumber(CountryProgramme cp)
        {
            string code      = "GRN/DRC/" + cp.Country.ShortName + "/";
            string refNumber = "";
            long   count     = 1;

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

            count = total;
            Model.GoodsReceivedNote m = null;
            do
            {
                count++;
                if (count < 10000)
                {
                    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;
                    }
                }
                m = SessionData.CurrentSession.GoodsReceivedNoteList.FirstOrDefault(p => p.RefNumber == refNumber);
            } while (m != null);
            return(refNumber);
        }
Ejemplo n.º 8
0
        //
        // GET: /Reports/GoodsReceived/

        public ActionResult Index(Guid id)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            using (var db = new SCMSEntities())
            {
                Model.GoodsReceivedNote grnentity = db.GoodsReceivedNotes.FirstOrDefault(p => p.Id == id);

                data.Add("{SUPPLIER}", grnentity.Supplier.Name);
                data.Add("{GRN}", grnentity.RefNumber);

                data.Add("{DNN}", grnentity.DnNumber);

                data.Add("{OFFICE}", grnentity.CountrySubOffice.Name);
                data.Add("{LOCATION}", grnentity.CountrySubOffice.Location.Name);

                ICollection <GoodsReceivedNoteItem> grnItems = grnentity.GoodsReceivedNoteItems;

                int    r          = 1;
                String detailHtml = "";

                foreach (GoodsReceivedNoteItem grnitem in grnItems)
                {
                    if (r == 1)
                    {
                        data.Add("{ORNO}", grnitem.PurchaseOrderItem.PurchaseOrder.OrderRequest.RefNumber);
                        data.Add("{PONO}", grnitem.PurchaseOrderItem.PurchaseOrder.RefNumber);
                        DateTime d = (DateTime)grnitem.PurchaseOrderItem.PurchaseOrder.LatestDeliveryDate;
                        data.Add("{DELIVERY_DATE}", d.ToShortDateString());
                    }
                    detailHtml += "<tr><td align=\"center\">" + r++ + "</td><td>";
                    detailHtml += grnitem.PurchaseOrderItem.OrderRequestItem.Item.Name;
                    detailHtml += "</td><td>";
                    detailHtml += grnitem.PurchaseOrderItem.OrderRequestItem.Item.UnitOfMeasure.Code;
                    detailHtml += "</td><td class='central'>";
                    detailHtml += grnitem.PurchaseOrderItem.Quantity.ToString("##,###");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += grnitem.QuantityDelivered.ToString("##,###");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += grnitem.QuantityDamaged.ToString("##,###");
                    detailHtml += "</td><td>";
                    detailHtml += grnitem.Comments;
                }
                while (r < 21)
                {
                    detailHtml += "<tr><td align=\"center\">" + r++ + "</td><td>";
                    detailHtml += "</td><td>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td>";
                }
                data.Add("{DETAILS}", detailHtml);
                data.Add("{ADDITONALRMARKS}", grnentity.Remarks);

                var recBy = db.VStaffDetails.FirstOrDefault(p => p.StaffID == grnentity.ReceivedBy);

                if (grnentity.DeliverDate.HasValue)
                {
                    if (recBy.SignatureImage.IsNotNull())
                    {
                        data.Add("{SIGNATURE2}", string.Format("<img src=\"{0}\" alt=\"\" style=\"max-width: 80px;\" />", "data:image/png;base64," + Convert.ToBase64String(recBy.SignatureImage)));
                    }
                    data.Add("{SIGNATURE_DATE}", grnentity.DeliverDate.FormatDDMMMYYYY());
                }
                else
                {
                    data.Add("{SIGNATURE_DATE}", "N/A");
                }
                data.Add("{TRANSPORTER_NAME}", grnentity.DeliveredBy);
                data.Add("{TRANSPORTER_COMPANY}", grnentity.DeliveryCompany);
                data.Add("{DRIVER_ID}", grnentity.DriverLicenseNumber);
                data.Add("{VEHICLE_PLATE}", grnentity.VehicleRegNumber);

                data.Add("{RECEIVED_BY}", recBy.StaffName);
                data.Add("{TITLE}", recBy.Designation);
            }
            List <String> options = new List <string>();

            options.Add(" --copies 2 ");
            Byte[] output = WkHtml2Pdf.CreateReport(data, "goods-received-note.html", options);

            return(File(output, "application/pdf", "GRN_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }
Ejemplo n.º 9
0
        public ActionResult GRNTemplate(Model.GoodsReceivedNote model)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            using (var db = new SCMSEntities())
            {
                Model.GoodsReceivedNote grnentity = model;

                Model.PurchaseOrder po   = db.PurchaseOrders.FirstOrDefault(p => p.Id == model.PurchaseOrderId);
                CountrySubOffice    csof = db.CountrySubOffices.FirstOrDefault(p => p.Id == model.CountryOfficeId);

                data.Add("{SUPPLIER}", po != null ? po.Supplier.Name : "<sub>________________________________________</sub>");
                data.Add("{GRN}", "<sub>________________________________________</sub>");
                //data.Add("{GRN}", grnentity.RefNumber.IsNotNullOrEmpty() ? grnentity.RefNumber : "<sub>________________________________________</sub>");

                data.Add("{DNN}", grnentity.DnNumber ?? "<sub>________________________________________</sub>");

                data.Add("{OFFICE}", csof != null ? csof.Name : "<sub>________________________________________</sub>");
                data.Add("{LOCATION}", csof != null ? csof.Location.Name : "<sub>________________________________________</sub>");

                data.Add("{ORNO}", po != null ? po.OrderRequest.RefNumber : "<sub>________________________________________</sub>");
                data.Add("{PONO}", po != null ? po.RefNumber : "<sub>________________________________________</sub>");
                data.Add("{DELIVERY_DATE}", "<sub>________________________________________</sub>");

                int    r          = 1;
                String detailHtml = "";

                foreach (POItemsView poItem in model.POItemz)
                {
                    detailHtml += "<tr><td align=\"center\">" + r++ + "</td><td>";
                    detailHtml += poItem.ItemName;
                    detailHtml += "</td><td>";
                    detailHtml += poItem.unitOfMessure;
                    detailHtml += "</td><td class='central'>";
                    detailHtml += poItem.QtyOrdered.ToString("##,###");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += poItem.QtyDelivered.ToString("##,###");
                    detailHtml += "</td><td class='central'>";
                    detailHtml += poItem.QtyDamaged.ToString("##,###");
                    detailHtml += "</td><td>";
                    detailHtml += poItem.comments;
                }
                while (r < 21)
                {
                    detailHtml += "<tr><td align=\"center\">" + r++ + "</td><td>";
                    detailHtml += "</td><td>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td class='central'>";
                    detailHtml += "</td><td>";
                }
                data.Add("{DETAILS}", detailHtml);

                var recBy = db.VStaffDetails.FirstOrDefault(p => p.StaffID == grnentity.ReceivedBy);


                data.Add("{SIGNATURE2}", "<sub>___________________________________________</sub>");
                data.Add("{SIGNATURE_DATE}", grnentity.DeliverDate.Value.ToShortDateString());

                data.Add("{TRANSPORTER_NAME}", grnentity.DeliveredBy.IsNotNullOrWhiteSpace() ? grnentity.DeliveredBy : "<sub>_________________________________________</sub>");
                data.Add("{TRANSPORTER_COMPANY}", grnentity.DeliveryCompany.IsNotNullOrEmpty() ? grnentity.DeliveryCompany : "<sub>_____________________________________</sub>");
                data.Add("{DRIVER_ID}", grnentity.DriverLicenseNumber.IsNotNullOrEmpty() ? grnentity.DriverLicenseNumber : "<sub>________________________________________</sub>");
                data.Add("{VEHICLE_PLATE}", grnentity.VehicleRegNumber.IsNotNullOrEmpty() ? grnentity.VehicleRegNumber : "<sub>_________________________________________</sub>");

                data.Add("{RECEIVED_BY}", recBy != null ? recBy.StaffName : "<sub>_______________________________________________</sub>");
                data.Add("{TITLE}", recBy != null ? recBy.Designation : "<sub>____________________________________________________</sub>");
            }

            Byte[] output = WkHtml2Pdf.CreateReport(data, "goods-received-note.html");

            return(File(output, "application/pdf", "GRN_Template_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }