示例#1
0
        public ActionResult SaveFinishedMaster(FinishingUpdateGrid 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 FinishedID = objModel.FinishedID;
            //Save
            var msg = "";
            FinishingManager context = new FinishingManager(new DataContext());

            msg = context.SaveFinishingMaster(objModel);

            //var SubTotal_Finished = 0;
            //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);
            //var Row_Planner_FinishedQty = 0;
            //if (msg == "success")
            //{
            //    //Get Total FinishedQty of FinishedGrid
            //    SubTotal_Finished = context.GetTotalFinishingGrid(objModel.PlannerID);//FinishedQty
            //    //Update Planner Grid FinishedQty
            //    PlannerManager cont_plan = new PlannerManager(new DataContext());
            //    cont_plan.UpdateQty(objModel.PlannerID, SubTotal_Finished);

            //    //Get Total PlannedQty & FinishedQty
            //    SubTotal_Planned = cont_plan.GetTotalPlannerGrid(objModel.ProductID);//PlannedQty,FinishedQty
            //    Row_Planner_FinishedQty = cont_plan.GetRowPlannerGrid(objModel.PlannerID);//PlannedQty,FinishedQty

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

            //objModel.FinishingDate_Display = objModel.FinishingDate == null ? "" : objModel.FinishingDate.Value.ToString("dd-MMM-yy");
            //var obj = new
            //{
            //    obj = objModel,
            //    sub_tot_finishedqty2 = SubTotal_Finished,//FinishedQty of FinishedQty Grid
            //    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_product_plannedqty = Row_Product.Item1,//PlannedQty of selected Product row Grid
            //    row_product_finishedqty = Row_Product.Item2,//FinishedQty of selected Product row of Product Grid
            //    row_plan_finishedqty = Row_Planner_FinishedQty,//FinishedQty of selected planner row of planner Grid

            //    is_Edit = FinishedID > 0 ? true : false,
            //};
            objModel.FinishingDate_Display = objModel.FinishingDate == null ? "" : objModel.FinishingDate.Value.ToString("dd-MMM-yy");

            var model = GetUpdated_FinishedMaster(objModel.FinishedID, objModel.PlannerID, objModel.ProductID, FinishedID > 0 ? true : false, objModel);

            return(Json(new { msg = msg, model = model }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ActionResult AddEditFinishedQty(int FinishedID = 0)
        {
            FinishingManager    context  = new FinishingManager(new DataContext());
            FinishingUpdateGrid objModel = new FinishingUpdateGrid();

            if (FinishedID != 0)
            {
                objModel = context.GetFinishingMasterById(FinishedID);
            }
            else
            {
                objModel = new FinishingUpdateGrid();
            }

            return(PartialView("FinishedMasterCRUD", objModel));
        }
示例#3
0
        public dynamic GetUpdated_FinishedMaster(int FinishedID, int PlannerID, int ProductID, bool is_Edit, FinishingUpdateGrid objModel = null)
        {
            var SubTotal_Finished       = Convert.ToDecimal(0);
            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);
            var Row_Planner_FinishedQty = Convert.ToDecimal(0);

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

            //Get Total FinishedQty of FinishedGrid
            SubTotal_Finished = context.GetTotalFinishingGrid(PlannerID); //FinishedQty
                                                                          //Update Planner Grid FinishedQty
            PlannerManager cont_plan = new PlannerManager(new DataContext());

            cont_plan.UpdateQty(PlannerID, SubTotal_Finished);

            //Get Total PlannedQty & FinishedQty
            SubTotal_Planned        = cont_plan.GetTotalPlannerGrid(ProductID); //PlannedQty,FinishedQty
            Row_Planner_FinishedQty = cont_plan.GetRowPlannerGrid(PlannerID);   //PlannedQty,FinishedQty

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

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

            //Get Total Finished days
            //int finishedDays = 0;
            //cont_plan = new PlannerManager(new DataContext());
            //var lstPlannerID = cont_plan.GetAll(c => c.ProductID == ProductID).Select(c => c.PlannerID).ToList();
            //context = new FinishingManager(new DataContext());
            //var distinctFinishGridCount = context.GetAll(c => lstPlannerID.Contains(c.PlannerID)).ToList().GroupBy(c => c.PlannerID).ToList();
            //finishedDays = distinctFinishGridCount.Count() * 7;

            if (objModel == null)
            {
                objModel = new FinishingUpdateGrid()
                {
                    FinishedID = FinishedID,
                    PlannerID  = PlannerID,
                    ProductID  = ProductID
                };
            }
            var obj = new
            {
                obj = objModel,
                sub_tot_finishedqty2    = SubTotal_Finished,       //FinishedQty of FinishedQty Grid
                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
                tot_balanceqty          = Total_Product.Item3,     //BalanceQty of Product Grid
                row_product_plannedqty  = Row_Product.Item1,       //PlannedQty of selected Product row Grid
                row_product_finishedqty = Row_Product.Item2,       //FinishedQty of selected Product row of Product Grid
                row_product_balanceqty  = Row_Product.Item3,       //BalanceQty of selected Product row of Product Grid
                row_plan_finishedqty    = Row_Planner_FinishedQty, //FinishedQty of selected planner row of planner Grid
                is_Edit = is_Edit
                                                                   //,tot_finishedDays = finishedDays
            };

            return(obj);
        }