//
        // GET: /Project/Labor/Create

        public ActionResult Create()
        {
            var ProjectList = this.ProjectService.GetProjectBasedataList(new ProjectRequest());
            this.ViewBag.ProjectBasedataID = new SelectList(ProjectList, "ID", "PName");

            var model = new InsMaterialCost();
            return View("Edit", model);

        }
        public ActionResult Create(FormCollection collection)
        {
           

            var model = new InsMaterialCost();
            this.TryUpdateModel<InsMaterialCost>(model);

            if (model.MSteel != null)
                model.MaterialTotal += (int)model.MSteel;
            if (model.MHose != null)
                model.MaterialTotal += (int)model.MHose;
            if (model.MCement != null)
                model.MaterialTotal += (int)model.MCement;
            if (model.MGrayOil != null)
                model.MaterialTotal += (int)model.MGrayOil;
            if (model.MWire != null)
                model.MaterialTotal += (int)model.MWire;
            if (model.MWood != null)
                model.MaterialTotal += (int)model.MWood;
            if (model.MCeramicTile != null)
                model.MaterialTotal += (int)model.MCeramicTile;
            if (model.MWindowsDoors != null)
                model.MaterialTotal += (int)model.MWindowsDoors;
            if (model.MGalss != null)
                model.MaterialTotal += (int)model.MGalss;
            if (model.MHardware != null)
                model.MaterialTotal += (int)model.MHardware;
            if (model.MElectric != null)
                model.MaterialTotal += (int)model.MElectric;
            if (model.MConcrete != null)
                model.MaterialTotal += (int)model.MConcrete;
            if (model.MBrick != null)
                model.MaterialTotal += (int)model.MBrick;
            if (model.MTemplate != null)
                model.MaterialTotal += (int)model.MTemplate;
            if (model.MAluminum != null)
                model.MaterialTotal += (int)model.MAluminum;

            if (model.MTest != null)
                model.MaterialTotal += (int)model.MTest;
            if (model.MMortar != null)
                model.MaterialTotal += (int)model.MMortar;
            if (model.MFireAirSmoke != null)
                model.MaterialTotal += (int)model.MFireAirSmoke;

            if (model.MTurnoverRent != null)
                model.MaterialTotal += (int)model.MTurnoverRent;
            if (model.MTurnovers != null)
                model.MaterialTotal += (int)model.MTurnovers;
            if (model.MOther != null)
                model.MaterialTotal += (int)model.MOther;

            this.ProjectService.SaveInsMaterialCost(model);
            return this.RefreshParent();
        }
Exemple #3
0
        public void SaveInsMaterialCost(InsMaterialCost insmaterialcost)
        {
            using (var dbContext = new ProjectDbContext())
            {

                if (insmaterialcost.ID > 0)
                {
                    //var budgets = dbContext.Budgets.ToList();
                    //if (insmaterialcost.MaterialTotal > 0)
                    //{
                    //    foreach (var budget in budgets)
                    //    {
                    //        if (budget.ProjectID == insmaterialcost.ProjectID)
                    //        {
                    //            budget.MaterialCostID = insmaterialcost.ID;
                    //            dbContext.Update<BudgetInfo>(budget);
                    //        }
                    //    }
                    //}

                    dbContext.Update<InsMaterialCost>(insmaterialcost);
                }
                else
                {
                    dbContext.Insert<InsMaterialCost>(insmaterialcost);
                }
            }
        }