//
        // 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 InsMachineryCost();
            return View("Edit", model);

        }
 public ActionResult Create(FormCollection collection)
 {
     var model = new InsMachineryCost();
     this.TryUpdateModel<InsMachineryCost>(model);
     if (model.Transport != null)
         model.MachineryTotal += (int)model.Transport;
     if (model.Operating != null)
         model.MachineryTotal += (int)model.Operating;
     if (model.Repair != null)
         model.MachineryTotal += (int)model.Repair;
     if (model.Fuel != null)
         model.MachineryTotal += (int)model.Fuel;
     if (model.Depreciation != null)
         model.MachineryTotal += (int)model.Depreciation;
     if (model.TravelTax != null)
         model.MachineryTotal += (int)model.TravelTax;
     if (model.OtherFee != null)
         model.MachineryTotal += (int)model.OtherFee;
    
     this.ProjectService.SaveInsMachineryCost(model);
     return this.RefreshParent();
 }
Beispiel #3
0
        public void SaveInsMachineryCost(InsMachineryCost insmachinerycost)
        {
            using (var dbContext = new ProjectDbContext())
            {

                if (insmachinerycost.ID > 0)
                {
                    //var budgets = dbContext.Budgets.ToList();
                    //if (machinerycost.MachineryTotal > 0)
                    //{
                    //    foreach (var budget in budgets)
                    //    {
                    //        if (budget.ProjectID == machinerycost.ProjectID)
                    //        {
                    //            budget.MachineryCostID = machinerycost.ID;
                    //            dbContext.Update<BudgetInfo>(budget);
                    //        }
                    //    }
                    //}
                    dbContext.Update<InsMachineryCost>(insmachinerycost);
                }
                else
                {
                    dbContext.Insert<InsMachineryCost>(insmachinerycost);
                }
            }
        }