//[HttpGet]
        public ActionResult MaterialRequestApproval(int id = 0)
        {
            try
            {
                if (id == 0)
                {
                    TempData["error"] = "That was an invalid/unknown request. Please try again.";
                    return(RedirectToAction("Index", "Home"));
                }

                var model = new WorkShopRequestRepository().GetDirectMaterialRequest(id, OrganizationId);
                if (model == null)
                {
                    TempData["error"] = "Could not find the requested Purchase Indent. Please try again.";
                    return(RedirectToAction("Index", "Home"));
                }
                FillPartNo();
                GetMaterials();
                return(View("CreateDirectMaterialRequest", model));
            }
            catch (Exception)
            {
                TempData["error"] = "Some error occured. Please try again.";
                return(RedirectToAction("DirectMaterialRequestList"));
            }
        }
        public ActionResult Save(WorkShopRequest model)
        {
            try
            {
                model.OrganizationId = OrganizationId;
                model.CreatedDate    = System.DateTime.Now;
                model.CreatedBy      = UserID.ToString();

                string id = new WorkShopRequestRepository().InsertWorkShopRequest(model);
                if (id.Split('|')[0] != "0")
                {
                    TempData["success"] = "Saved successfully. WorkShop Request Reference No. is " + id.Split('|')[1];
                    TempData["error"]   = "";
                    return(RedirectToAction("Pending", new { model.isProjectBased }));
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (SqlException sx)
            {
                TempData["error"] = "Some error occured while connecting to database. Please check your network connection and try again.|" + sx.Message;
            }
            catch (NullReferenceException nx)
            {
                TempData["error"] = "Some required data was missing. Please try again.|" + nx.Message;
            }
            catch (Exception ex)
            {
                TempData["error"] = "Some error occured. Please try again.|" + ex.Message;
            }
            return(View("Pending", model));
        }
        public ActionResult Create(int?SaleOrderId, int?saleorderitem)
        {
            ItemDropdown();
            ExceptFGItemDropdown();
            WorkShopRequestRepository repo  = new WorkShopRequestRepository();
            WorkShopRequest           model = repo.GetSaleOrderForWorkshopRequest(SaleOrderId ?? 0);

            model.SaleOrderItemId = saleorderitem ?? 0;
            model.WorkDescription = repo.GetCombinedWorkDescriptionSaleOrderForWorkshopRequest(SaleOrderId ?? 0).WorkDescription;
            List <WorkShopRequestItem> WSList = new List <WorkShopRequestItem>();

            if (model.isProjectBased == 1)
            {
                WSList = repo.GetWorkShopRequestDataForProject(saleorderitem ?? 0);
            }
            else
            {
                WSList = repo.GetWorkShopRequestData(SaleOrderId ?? 0, saleorderitem ?? 0);
            }

            model.Items = new List <WorkShopRequestItem>();
            //model.Isused = true;
            foreach (var item in WSList)
            {
                model.Items.Add(new WorkShopRequestItem {
                    PartNo = item.PartNo, ItemName = item.ItemName, Quantity = item.Quantity, UnitName = item.UnitName, ItemId = item.ItemId, ActualQuantity = item.Quantity
                });
            }
            string internalId = "";

            try
            {
                if (model.isProjectBased == 0)
                {
                    internalId = DatabaseCommonRepository.GetNextDocNo(19, OrganizationId);
                }
                else
                {
                    internalId = DatabaseCommonRepository.GetNextDocNo(31, OrganizationId);
                }
            }
            catch (NullReferenceException nx)
            {
                TempData["success"] = "";
                TempData["error"]   = "Some required data was missing. Please try again.|" + nx.Message;
            }
            catch (Exception ex)
            {
                TempData["success"] = "";
                TempData["error"]   = "Some error occurred. Please try again.|" + ex.Message;
            }
            model.WorkShopRequestRefNo = internalId;
            model.WorkShopRequestDate  = System.DateTime.Today;
            model.RequiredDate         = System.DateTime.Today;

            return(View(model));
        }
        public ActionResult Edit(int?id)
        {
            ItemDropdown();
            ExceptFGItemDropdown();
            var             repo  = new WorkShopRequestRepository();
            WorkShopRequest model = repo.GetWorkshopRequestHdData(id ?? 0);

            model.Items = repo.GetWorkShopRequestDtData(id ?? 0);

            return(View("Edit", model));
        }
Ejemplo n.º 5
0
        //public void JobCardDropdown(int isProjectBased, int jobCardId = 0)
        //{

        //    ViewBag.JobCardList = new SelectList(new DropdownRepository().JobCardDropdownforAddtional(jobCardId: jobCardId, organizationId: OrganizationId, isProjectBased: isProjectBased), "Id", "Name");
        //}

        public JsonResult GetJobCardDetails(int jobCardId)
        {
            var data = new WorkShopRequestRepository().GetJobCardDetails(jobCardId);

            return(Json(new
            {
                SaleOrderId = data.SaleOrderId,
                SaleOrderNo = data.SaleOrderRefNo,
                Customer = data.CustomerName,
                CustomerId = data.CustomerId,
                CustomerOrderRef = data.CustomerOrderRef
            }, JsonRequestBehavior.AllowGet));
        }
 public ActionResult Delete(int id = 0, int isProjectBased = 0)
 {
     try
     {
         if (id == 0)
         {
             return(RedirectToAction("Index", "Home"));
         }
         string ref_no = new WorkShopRequestRepository().DeleteWorkShopRequest(id);
         TempData["success"] = "Deleted Successfully (" + ref_no + ")";
         return(RedirectToAction("Index", new { isProjectBased = isProjectBased }));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured while deleting. Please try again.";
         return(RedirectToAction("Edit", new { id = id }));
     }
 }
 public ActionResult DeleteDirectMaterialRequest(int id = 0)
 {
     try
     {
         if (id == 0)
         {
             return(RedirectToAction("Index", "Home"));
         }
         string result = new WorkShopRequestRepository().DeleteWorkShopRequest(id);
         TempData["Success"] = "Deleted Successfully!";
         return(RedirectToAction("DirectMaterialRequestList"));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured while deleting. Please try again.";
         return(RedirectToAction("CreateDirectMaterialRequest", new { id = id }));
     }
 }
Ejemplo n.º 8
0
        public ActionResult Edit(int id = 0)
        {
            try
            {
                if (id != 0)
                {
                    ItemDropdown();
                    FillPartNo();
                    WorkShopRequest WorkShopRequest = new WorkShopRequest();
                    WorkShopRequest = new WorkShopRequestRepository().WorkShopRequestHD(id);
                    JobCardDropdown(WorkShopRequest.isProjectBased);
                    WorkShopRequest.Items = new WorkShopRequestItemRepository().WorkShopRequestDT(id);
                    return(View("Edit", WorkShopRequest));
                }
                else
                {
                    TempData["error"]   = "That was an invalid/unknown request. Please try again.";
                    TempData["success"] = "";
                }
            }
            catch (InvalidOperationException iox)
            {
                TempData["error"] = "Sorry, we could not find the requested item. Please try again.|" + iox.Message;
            }
            catch (SqlException sx)
            {
                TempData["error"] = "Some error occured while connecting to database. Please try again after sometime.|" + sx.Message;
            }
            catch (NullReferenceException nx)
            {
                TempData["error"] = "Some required data was missing. Please try again.|" + nx.Message;
            }
            catch (Exception ex)
            {
                TempData["error"] = "Some error occured. Please try again.|" + ex.Message;
            }

            TempData["success"] = "";
            return(RedirectToAction("Index"));
        }
 public ActionResult EditDirectMaterialRequest(WorkShopRequest model)
 {
     try
     {
         model.CreatedBy   = UserID.ToString();
         model.CreatedDate = DateTime.Today;
         var success = new WorkShopRequestRepository().UpdateDirectMaterialRequest(model);
         if (success <= 0)
         {
             throw new Exception();
         }
         TempData["success"] = "Updated successfully (" + model.WorkShopRequestRefNo + ")";
         return(RedirectToAction("DirectMaterialRequestList"));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured while saving. Please try again.";
         FillPartNo();
         GetMaterials();
         return(View("CreateDirectMaterialRequest", model));
     }
 }
        public ActionResult Edit(WorkShopRequest model)
        {
            model.OrganizationId = OrganizationId;
            model.CreatedDate    = System.DateTime.Now;
            model.CreatedBy      = UserID.ToString();



            var repo = new WorkShopRequestRepository();

            try
            {
                new WorkShopRequestRepository().UpdateWorkShopRequest(model);
                TempData["success"] = "Updated Successfully (" + model.WorkShopRequestRefNo + ")";
                return(RedirectToAction("Index", new { isProjectBased = model.isProjectBased }));
            }
            catch (Exception)
            {
                TempData["error"] = "Some error occurred. Please try again.";
            }

            return(RedirectToAction("Index", new { isProjectBased = model.isProjectBased }));
        }
 public ActionResult CreateDirectMaterialRequest(WorkShopRequest model)
 {
     try
     {
         model.CreatedBy      = UserID.ToString();
         model.OrganizationId = OrganizationId;
         model.CreatedDate    = DateTime.Today;
         string ref_no = new WorkShopRequestRepository().InsertDirectMaterialRequest(model);
         if (ref_no.Length > 0)
         {
             TempData["success"] = "Saved Successfully. Reference No. is " + model.WorkShopRequestRefNo;
             return(RedirectToAction("CreateDirectMaterialRequest"));
         }
         else
         {
             throw new Exception();
         }
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occurred while saving. Please try again.";
         return(View(model));
     }
 }
Ejemplo n.º 12
0
        public ActionResult LoadQuickView()
        {
            if (Session["user"] == null)
            {
                return(RedirectToAction("LogOff", "Account"));
            }
            QuickView view = new QuickView();

            view.PendingDirectPurchaseRequests      = true;
            view.PendingTransQuotations             = true;
            view.PendingProjectQuotations           = true;
            view.PendingSupplyOrders                = true;
            view.PendingWorkshopRequests            = true;
            view.PendingProjectSaleOrdersForJobCard = true;
            view.PendingTransSaleOrdersForJobCard   = true;
            view.MaterialStockBelowMinLevel         = true;
            view.PendingVechicleInpass              = true;
            view.PendingWRForStoreIssue             = true;
            view.PendingJobcardQC      = true;
            view.PendingMaterialReqPRS = true;
            if (view.PendingProjectQuotations)
            {
                SalesQuotationRepository repo = new SalesQuotationRepository();
                var res = repo.GetSalesQuotationApproveList(1, 0, OrganizationId);
                view.NoOfProjectQuotations = res.Count;
            }
            if (view.PendingTransQuotations)
            {
                SalesQuotationRepository repo = new SalesQuotationRepository();
                var res = repo.GetSalesQuotationApproveList(0, 0, OrganizationId);
                view.NoOfTransQuotations = res.Count;
            }
            if (view.PendingSupplyOrders)
            {
                var repo = new GRNRepository();
                var res  = repo.GetGRNPendingList(0);
                view.NoOfSupplyOrders = res.Count();
            }
            if (view.PendingDirectPurchaseRequests)
            {
                var res = new DirectPurchaseRepository().GetUnApprovedRequests(UserID);
                view.NoOfPurchaseRequests = res.Count;
            }
            if (view.PendingWorkshopRequests)
            {
                var rep   = new SaleOrderRepository();
                var slist = rep.GetSaleOrdersPendingWorkshopRequest(OrganizationId, 0);
                view.NoOfWorkShopRequests = slist.Count;
            }
            if (view.PendingProjectSaleOrdersForJobCard)
            {
                var list = new JobCardRepository().GetPendingSO(1, OrganizationId, 0);
                view.NoOfProjectSaleOrdersForJobCard = list.Count();
            }
            if (view.PendingTransSaleOrdersForJobCard)
            {
                var list = new JobCardRepository().GetPendingSO(0, OrganizationId, 0);
                view.NoOfTransSaleOrdersForJobCard = list.Count();
            }
            if (view.MaterialStockBelowMinLevel)
            {
                var list = new ItemRepository().GetCriticalMaterialsBelowMinStock(OrganizationId);
                view.NoOfMaterialStockBelowMinLevel = list.Count();
                //view.NoOfMaterialStockBelowMinLevel = new ItemRepository().GetCriticalMaterialsBelowMinStock(OrganizationId);
            }
            if (view.PendingVechicleInpass)
            {
                var list = new VehicleInPassRepository().PendingVehicleInpassforAlert(OrganizationId);
                view.NoOfVechicleInpass = list.Count();
            }
            if (view.PendingWRForStoreIssue)
            {
                var list = new WorkShopRequestRepository().PendingWorkshopRequests("", "", "", "");
                view.NoOfWRForStoreIssue = list.Count();
            }
            if (view.PendingJobcardQC)
            {
                var list = new DeliveryChallanRepository().PendingDelivery(OrganizationId);
                view.NoOfJobcardQC = list.Count();
            }

            if (view.PendingMaterialReqPRS)
            {
                var list = new PurchaseRequestRepository().GetWorkShopRequestPending(OrganizationId, 0, "", "all");
                view.NoOfPendingMaterialReqPRS = list.Count();
            }

            IEnumerable <ERPAlerts> Alerts;

            if (Session["alertpermissions"] == null)
            {
                UserRepository repo = new UserRepository();
                Alerts = repo.GetAlerts(UserID);
                Session["alertpermissions"] = Alerts;
            }
            else
            {
                Alerts = (IEnumerable <ERPAlerts>)Session["alertpermissions"];
                Session["alertpermissions"] = Alerts;
            }

            AlertPermission alertpermission = new AlertPermission();

            foreach (var item in Alerts)
            {
                if (item.HasPermission == 1)
                {
                    switch (item.AlertId)
                    {
                    case 1:
                        alertpermission.ProjectQuotApproval = true;
                        break;

                    case 2:
                        alertpermission.TransportQuotApproval = true;
                        break;

                    case 3:
                        alertpermission.PendingSupplyOrdForGrn = true;
                        break;

                    case 4:
                        alertpermission.DirectPurchaseReqDorApproval = true;
                        break;

                    case 5:
                        alertpermission.PendingSOForWorkshopReq = true;
                        break;

                    //case 6:
                    //    alertpermission.PendingProjectSaleOrdersForJobCard = true;
                    //    break;
                    //case 7:
                    //    alertpermission.PendingTransSaleOrdersForJobCard = true;
                    //    break;
                    case 6:
                        alertpermission.MaterialStockBelowMinLevel = true;
                        break;

                    case 7:
                        alertpermission.PendingVechicleInpass = true;
                        break;

                    case 8:
                        alertpermission.PendingWRForStoreIssue = true;
                        break;

                    case 9:
                        alertpermission.PendingJobcardQC = true;
                        break;

                    case 10:
                        alertpermission.PendingMaterialReqPRS = true;
                        break;

                    default:
                        break;
                    }
                }
            }
            ViewBag.AlertPermissions = alertpermission;
            return(PartialView("_QuickView", view));
        }
        public ActionResult Print(int Id)
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "WorkShopRequest.rpt"));

            DataSet ds = new DataSet();

            ds.Tables.Add("Head");

            ds.Tables.Add("Items");

            //-------HEAD
            ds.Tables["Head"].Columns.Add("WorkShopRequestRefNo");
            ds.Tables["Head"].Columns.Add("WorkShopRequestDate");
            ds.Tables["Head"].Columns.Add("CustomerName");
            ds.Tables["Head"].Columns.Add("CustomerOrderRef");
            ds.Tables["Head"].Columns.Add("SaleOrderRefNo");
            ds.Tables["Head"].Columns.Add("EDateArrival");
            ds.Tables["Head"].Columns.Add("EDateDelivery");
            ds.Tables["Head"].Columns.Add("WorkDescription");
            ds.Tables["Head"].Columns.Add("SpecialRemarks");
            ds.Tables["Head"].Columns.Add("RequiredDate");
            ds.Tables["Head"].Columns.Add("DoorNo");
            ds.Tables["Head"].Columns.Add("Street");
            ds.Tables["Head"].Columns.Add("State");
            ds.Tables["Head"].Columns.Add("CountryName");
            ds.Tables["Head"].Columns.Add("Zip");
            ds.Tables["Head"].Columns.Add("Fax");
            ds.Tables["Head"].Columns.Add("Email");
            ds.Tables["Head"].Columns.Add("Phone");
            ds.Tables["Head"].Columns.Add("OrganizationName");
            ds.Tables["Head"].Columns.Add("Image1");
            ds.Tables["Head"].Columns.Add("Title");

            //-------DT
            ds.Tables["Items"].Columns.Add("ItemName");
            ds.Tables["Items"].Columns.Add("PartNo");
            ds.Tables["Items"].Columns.Add("Remarks");
            ds.Tables["Items"].Columns.Add("Quantity");
            ds.Tables["Items"].Columns.Add("UnitName");

            WorkShopRequestRepository repo = new WorkShopRequestRepository();
            var Head = repo.GetWorkshopRequestHdDataPrint(Id, OrganizationId);

            DataRow dr = ds.Tables["Head"].NewRow();

            dr["WorkShopRequestRefNo"] = Head.WorkShopRequestRefNo;
            dr["WorkShopRequestDate"]  = Head.WorkShopRequestDate.ToString("dd-MMM-yyyy");
            dr["CustomerName"]         = Head.CustomerName;
            dr["CustomerOrderRef"]     = Head.CustomerOrderRef;
            dr["SaleOrderRefNo"]       = Head.SaleOrderRefNo;
            dr["EDateArrival"]         = Head.EDateArrival.ToString("dd-MMM-yyyy");
            dr["EDateDelivery"]        = Head.EDateDelivery.ToString("dd-MMM-yyyy");
            dr["WorkDescription"]      = Head.WorkDescription;
            dr["SpecialRemarks"]       = Head.SpecialRemarks;
            dr["Title"]            = Head.title;
            dr["RequiredDate"]     = Head.RequiredDate.ToString("dd-MMM-yyyy");
            dr["DoorNo"]           = Head.DoorNo;
            dr["Street"]           = Head.Street;
            dr["State"]            = Head.State;
            dr["CountryName"]      = Head.CountryName;
            dr["Zip"]              = Head.Zip;
            dr["Fax"]              = Head.Fax;
            dr["Email"]            = Head.Email;
            dr["Phone"]            = Head.Phone;
            dr["OrganizationName"] = Head.OrganizationName;
            dr["Image1"]           = Server.MapPath("~/App_images/") + Head.Image1;
            ds.Tables["Head"].Rows.Add(dr);

            WorkShopRequestRepository repo1 = new WorkShopRequestRepository();
            var Items = repo1.GetWorkShopRequestDtDataPrint(Id);

            foreach (var item in Items)
            {
                var pritem = new WorkShopRequestItem
                {
                    ItemName = item.ItemName,
                    PartNo   = item.PartNo,
                    Remarks  = item.Remarks,
                    Quantity = item.Quantity,
                    UnitName = item.UnitName,
                };


                DataRow dri = ds.Tables["Items"].NewRow();
                dri["ItemName"] = pritem.ItemName;
                dri["PartNo"]   = pritem.PartNo;
                dri["Remarks"]  = pritem.Remarks;
                dri["Quantity"] = pritem.Quantity;
                dri["UnitName"] = pritem.UnitName;


                ds.Tables["Items"].Rows.Add(dri);
            }

            ds.WriteXml(Path.Combine(Server.MapPath("~/XML"), "WorkShopRequest.xml"), XmlWriteMode.WriteSchema);

            rd.SetDataSource(ds);

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();


            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf"));//, String.Format("WorkShopRequest{0}.pdf", Id.ToString()));
            }
            catch (Exception ex)
            {
                throw;
            }
        }