Example #1
0
        public dynamic GetUpdated_PlannedMaster(int PlannerID, int ProductID, bool is_Edit, PlannerUpdateGrid objModel = null)
        {
            var SubTotal_Planned = new Tuple <decimal, decimal>(0, 0);
            var Total_Product    = new Tuple <decimal, decimal, decimal>(0, 0, 0);
            var Row_Product      = new Tuple <decimal, decimal, decimal>(0, 0, 0);

            PlannerManager   context  = new PlannerManager(new DataContext());
            FinishingManager context1 = new FinishingManager(new DataContext());

            //Get Total PlannedQty & FinishedQty
            SubTotal_Planned = context.GetTotalPlannerGrid(ProductID);//PlannedQty,FinishedQty

            //Get Total Planned days
            var lstPlanner  = context.GetAll(c => c.ProductID == ProductID).ToList();
            int plannedDays = lstPlanner.Count() * 7;

            ////Get Total Finished days
            //int finishedDays = 0;
            //var lstPlannerID = lstPlanner.Select(c => c.PlannerID).ToList();
            //var distinctFinishGridCount = context1.GetAll(c => lstPlannerID.Contains(c.PlannerID)).ToList().GroupBy(c=>c.PlannerID).ToList();
            //finishedDays = distinctFinishGridCount.Count() * 7;

            //Update Product Grid PlannedQty & FinishedQty
            ProductManager cont = new ProductManager(new DataContext());

            cont.UpdateQty(ProductID, SubTotal_Planned.Item1, SubTotal_Planned.Item2);
            Total_Product = cont.GetTotalProductGrid(ProductID); //PlannedQty,FinishedQty
            Row_Product   = cont.GetRowProductGrid(ProductID);   //PlannedQty,FinishedQty

            if (objModel == null)
            {
                objModel = new PlannerUpdateGrid()
                {
                    PlannerID = PlannerID,
                    ProductID = ProductID
                };
            }

            var obj = new
            {
                obj = objModel,
                sub_tot_plannedqty  = SubTotal_Planned.Item1, //PlannedQty of PlannedQty Grid
                sub_tot_finishedqty = SubTotal_Planned.Item2, //FinishedQty of PlannedQty Grid
                tot_plannedqty      = Total_Product.Item1,    //PlannedQty of Product Grid
                tot_finishedqty     = Total_Product.Item2,    //FinishedQty of Product Grid
                row_plannedqty      = Row_Product.Item1,      //PlannedQty of selected Product row Grid
                row_finishedqty     = Row_Product.Item2,      //FinishedQty of selected Product row Product Grid
                is_Edit             = is_Edit,
                tot_plannedDays     = plannedDays
                                      //,tot_finishedDays = finishedDays
            };

            return(obj);
        }
Example #2
0
        public ActionResult AddEditPlannedQty(int PlannerID = 0)
        {
            PlannerManager    context  = new PlannerManager(new DataContext());
            PlannerUpdateGrid objModel = new PlannerUpdateGrid();

            if (PlannerID != 0)
            {
                objModel = context.GetPlannerMasterById(PlannerID);
            }
            else
            {
                objModel = new PlannerUpdateGrid();
            }

            return(PartialView("PlannerMasterCRUD", objModel));
        }
Example #3
0
        public ActionResult SavePlannedMaster(PlannerUpdateGrid objModel)
        {
            if (!ModelState.IsValid)
            {
                var message = string.Join("|", ModelState.Values.SelectMany(e => e.Errors).Select(em => em.ErrorMessage));
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, message));
            }
            var PlannerID = objModel.PlannerID;
            //Save
            var            msg     = "";
            PlannerManager context = new PlannerManager(new DataContext());

            msg = context.SavePlannerMaster(objModel);

            //var SubTotal_Planned = new Tuple<int, int>(0, 0);
            //var Total_Product = new Tuple<int, int>(0, 0);
            //var Row_Product = new Tuple<int, int>(0, 0);
            //if (msg == "success")
            //{
            //    //Get Total PlannedQty & FinishedQty
            //    SubTotal_Planned = context.GetTotalPlannerGrid(objModel.ProductID);//PlannedQty,FinishedQty

            //    //Update Product Grid PlannedQty & FinishedQty
            //    ProductManager cont = new ProductManager(new DataContext());
            //    cont.UpdateQty(objModel.ProductID, SubTotal_Planned.Item1, SubTotal_Planned.Item2);
            //    Total_Product = cont.GetTotalProductGrid(objModel.ProductID);//PlannedQty,FinishedQty
            //    Row_Product = cont.GetRowProductGrid(objModel.ProductID);//PlannedQty,FinishedQty
            //}

            //objModel.PlanningDate_Display = objModel.PlanningDate == null ? "" : objModel.PlanningDate.Value.ToString("dd-MMM-yy");
            //var obj = new
            //{
            //    obj = objModel,
            //    sub_tot_plannedqty = SubTotal_Planned.Item1,//PlannedQty of PlannedQty Grid
            //    sub_tot_finishedqty = SubTotal_Planned.Item2,//FinishedQty of PlannedQty Grid
            //    tot_plannedqty = Total_Product.Item1,//PlannedQty of Product Grid
            //    tot_finishedqty = Total_Product.Item2,//FinishedQty of Product Grid
            //    row_plannedqty = Row_Product.Item1,//PlannedQty of selected Product row Grid
            //    row_finishedqty = Row_Product.Item2,//FinishedQty of selected Product row Product Grid
            //    is_Edit = PlannerID > 0 ? true : false,
            //};

            objModel.PlanningDate_Display = objModel.PlanningDate == null ? "" : objModel.PlanningDate.Value.ToString("dd-MMM-yy");
            var model = GetUpdated_PlannedMaster(objModel.PlannerID, objModel.ProductID, PlannerID > 0 ? true : false, objModel);

            return(Json(new { msg = msg, model = model }, JsonRequestBehavior.AllowGet));
        }