示例#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));
        }