Exemplo n.º 1
0
        public ActionResult CreateRequest(DirectPurchaseRequest model)
        {
            if (!ModelState.IsValid)
            {
                FillSO();
                FillJC();
                GetMaterials();
                return(View("Create", model));
            }

            FillSO();
            FillJC();
            model.OrganizationId = OrganizationId;
            model.CreatedDate    = System.DateTime.Now;
            model.CreatedBy      = UserID.ToString();
            string referenceNo = new DirectPurchaseRepository().InsertDirectPurchaseRequest(model);

            if (referenceNo != "")

            //if (new DirectPurchaseRepository().InsertDirectPurchaseRequest(model) > 0)
            {
                TempData["success"] = "Saved successfully. Reference No. is " + referenceNo;
                TempData["error"]   = "";
                return(RedirectToAction("CreateRequest"));
            }
            else
            {
                GetMaterials();
                TempData["success"] = "";
                TempData["error"]   = "Some error occured. Please try again.";
                return(View("Create", model));
            }
        }
Exemplo n.º 2
0
 public ActionResult ViewPurchaseIndent(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 DirectPurchaseRepository().GetPurchaseIndent(id, OrganizationId);
         Session["purchaseIndent"] = model;
         if (model == null)
         {
             TempData["error"] = "Could not find the requested Purchase Indent. Please try again.";
             return(RedirectToAction("Index", "Home"));
         }
         FillPartNo();
         GetMaterials();
         return(View("View", model));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured. Please try again.";
         return(RedirectToAction("PurchaseIndents"));
     }
 }
Exemplo n.º 3
0
        public ActionResult Delete(int Id)
        {
            ViewBag.Title = "Delete";

            var result1 = new DirectPurchaseRepository().CHECK(Id);

            if (result1 > 0)
            {
                TempData["error"]             = "Sorry!!..Already Used!!";
                TempData["PurchaseRequestNo"] = null;
                return(RedirectToAction("Edit", new { id = Id }));
            }

            else
            {
                var result2 = new DirectPurchaseRepository().DeleteDirectPurchaseDT(Id);
                var result3 = new DirectPurchaseRepository().DeleteDirectPurchaseHD(Id, UserID.ToString());

                if (Id > 0)
                {
                    TempData["Success"] = "Deleted Successfully!";
                    //return RedirectToAction("PreviousList");
                    return(RedirectToAction("Index"));
                }

                else
                {
                    TempData["error"]         = "Oops!!..Something Went Wrong!!";
                    TempData["SupplyOrderNo"] = null;
                    return(RedirectToAction("Edit", new { id = Id }));
                }
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit(DirectPurchaseRequest model)
        {
            ViewBag.Title        = "Edit";
            model.OrganizationId = OrganizationId;
            model.CreatedDate    = System.DateTime.Now;
            model.CreatedBy      = UserID.ToString();

            FillSO();
            FillJC();
            GetMaterials();

            var repo = new DirectPurchaseRepository();

            var result1 = new DirectPurchaseRepository().CHECK(model.DirectPurchaseRequestId);

            if (result1 > 0)
            {
                TempData["error"]             = "Sorry!!..Already Used!!";
                TempData["PurchaseRequestNo"] = null;
                return(View("Edit", model));
            }

            else
            {
                try
                {
                    var    result2 = new DirectPurchaseRepository().DeleteDirectPurchaseDT(model.DirectPurchaseRequestId);
                    var    result3 = new DirectPurchaseRepository().DeleteDirectPurchaseHD(model.DirectPurchaseRequestId, UserID.ToString());
                    string id      = new DirectPurchaseRepository().InsertDirectPurchaseRequest(model);

                    TempData["success"] = "Updated successfully. Direct Purchase Request Reference No. is " + id;
                    TempData["error"]   = "";
                    return(RedirectToAction("Index"));
                }
                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(RedirectToAction("CreateRequest"));
            }
        }
Exemplo n.º 5
0
        public JsonResult GetPurchaseLimit()
        {
            string str;

            try
            {
                int organizationId = OrganizationId;
                str = new DirectPurchaseRepository().GetPurchaseLimit(organizationId);
            }
            catch (Exception)
            {
                str = "error";
            }
            return(Json(str, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
 public ActionResult DeletePurchaseIndent(int id = 0)
 {
     try
     {
         if (id == 0)
         {
             return(RedirectToAction("Index", "Home"));
         }
         string result = new DirectPurchaseRepository().DeletePurchaseIndent(id);
         TempData["Success"] = "Deleted Successfully!";
         return(RedirectToAction("PurchaseIndents"));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured while deleting. Please try again.";
         return(RedirectToAction("PurchaseIndent", new { id = id }));
     }
 }
Exemplo n.º 7
0
        public ActionResult Edit(int id = 0)
        {
            try
            {
                if (id != 0)
                {
                    FillSO();
                    FillJC();
                    GetMaterials();
                    FillPartNo();
                    DirectPurchaseRequest DirectPurchaseRequest = new DirectPurchaseRequest();
                    DirectPurchaseRequest       = new DirectPurchaseRepository().GetDirectPurchaseRequest(id);
                    DirectPurchaseRequest.items = new DirectPurchaseRepository().GetDirectPurchaseRequestItems(id);

                    return(View(DirectPurchaseRequest));
                }
                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("CreateRequest"));
        }
Exemplo n.º 8
0
        public JsonResult ValidateForm(string requestNo, int total = 0)
        {
            int    val1 = new DirectPurchaseRepository().isNotExist(requestNo);
            int    val2 = new DirectPurchaseRepository().validateTotal(total);
            string str  = "";

            if (val1 != 1)
            {
                str += "Purchase request number already exists";
            }
            if (val2 != 1)
            {
                str += "|Total amount should not exceed the purchase limit";
            }
            if (str.Length == 0)
            {
                return(Json(new { status = true }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { status = false, message = str }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
 public ActionResult EditPurchaseIndent(DirectPurchaseRequest model)
 {
     try
     {
         model.CreatedBy   = UserID.ToString();
         model.CreatedDate = DateTime.Today;
         var success = new DirectPurchaseRepository().UpdatePurchaseIndent(model);
         if (success <= 0)
         {
             throw new Exception();
         }
         TempData["success"] = "Updated successfully (" + model.PurchaseRequestNo + ")";
         return(RedirectToAction("PurchaseIndents"));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured while saving. Please try again.";
         FillPartNo();
         GetMaterials();
         return(View("PurchaseIndent", model));
     }
 }
Exemplo n.º 10
0
 public ActionResult PurchaseIndent(DirectPurchaseRequest model)
 {
     try
     {
         model.CreatedBy      = UserID.ToString();
         model.OrganizationId = OrganizationId;
         model.CreatedDate    = DateTime.Today;
         string ref_no = new DirectPurchaseRepository().InsertPurchaseIndent(model);
         if (ref_no.Length > 0)
         {
             TempData["success"] = "Saved Successfully. Reference No. is " + model.PurchaseRequestNo;
             return(RedirectToAction("PurchaseIndent"));
         }
         else
         {
             throw new Exception();
         }
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occurred while saving. Please try again.";
         return(View(model));
     }
 }
Exemplo n.º 11
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));
        }