Example #1
0
        public ActionResult Create([Bind(Include = "AdminCostId,AOtherInput,AOtherInput2,AOtherInput3,ASalandWages,AflBillable,AEmpBenefits,AEmpTravel,AEmpTraining,AOfficeRent,AOfficeUtilities,AFacilityIns,AOfficeSupplies,AEquipment,AOfficeCommunications,AOfficeMaint,AConsulting,AJanitorServices,ADepreciation,ATechSupport,ASecurityServices,AOther,AOther2,AOther3,ATotCosts,Region,Month,SubcontractorId,Year,SubmittedDate")] AdminCosts adminCosts)
        {
            if (ModelState.IsValid)
            {
                var dataexist = from s in db.AdminCosts
                                where s.SubcontractorId == adminCosts.SubcontractorId &&
                                s.Year == adminCosts.Year &&
                                s.Month == adminCosts.Month
                                select s;
                if (dataexist.Count() >= 1)
                {
                    ViewBag.error = "Data already exists. Please change the params or search in the Reports tab for the current Record.";
                }
                else
                {
                    adminCosts.AdminCostId   = Guid.NewGuid();
                    adminCosts.SubmittedDate = System.DateTime.Now;
                    adminCosts.AflBillable   = 0;
                    adminCosts.Region        = db.SubContractors.Where(A => A.SubcontractorId == adminCosts.SubcontractorId).FirstOrDefault().Region;
                    db.AdminCosts.Add(adminCosts);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            var datelist = Enumerable.Range(System.DateTime.Now.Year - 1, 5).ToList();

            ViewBag.Year            = new SelectList(datelist);
            ViewBag.SubcontractorId = new SelectList(db.SubContractors.OrderBy(a => a.OrgName), "SubcontractorId", "OrgName", adminCosts.SubcontractorId);

            return(View(adminCosts));
        }
Example #2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            AdminCosts adminCosts = db.AdminCosts

                                    .Include(a => a.Subcontractor)
                                    .SingleOrDefault(a => a.AdminCostId == id);

            db.AdminCosts.Remove(adminCosts);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
        // GET: AdministrationCost/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AdminCosts adminCosts = db.AdminCosts
                                    .Include(a => a.Subcontractor)
                                    .SingleOrDefault(a => a.AdminCostId == id);

            if (adminCosts == null)
            {
                return(HttpNotFound());
            }
            return(View(adminCosts));
        }
Example #4
0
        public ActionResult Edit([Bind(Include = "AdminCostId,AOtherInput,AOtherInput2,AOtherInput3,ASalandWages,AEmpBenefits,AflBillable,AEmpTravel,AEmpTraining,AOfficeRent,AOfficeUtilities,AFacilityIns,AOfficeSupplies,AEquipment,AOfficeCommunications,AOfficeMaint,AConsulting,AJanitorServices,ADepreciation,ATechSupport,ASecurityServices,AOther,AOther2,AOther3,ATotCosts,Region,Month,SubcontractorId,Year,SubmittedDate")] AdminCosts adminCosts)
        {
            if (ModelState.IsValid)
            {
                adminCosts.SubmittedDate = System.DateTime.Now;

                db.Entry(adminCosts).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            var datelist = Enumerable.Range(System.DateTime.Now.Year - 1, 5).ToList();


            ViewBag.Year            = new SelectList(datelist);
            ViewBag.SubcontractorId = new SelectList(db.SubContractors.Where(s => s.SubcontractorId == adminCosts.SubcontractorId).OrderBy(a => a.OrgName), "SubcontractorId", "OrgName");
            return(View(adminCosts));
        }
Example #5
0
        // GET: AdministrationCost/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AdminCosts adminCosts = db.AdminCosts.Find(id);

            if (adminCosts == null)
            {
                return(HttpNotFound());
            }

            var datelist = Enumerable.Range(System.DateTime.Now.Year - 1, 5).ToList();

            ViewBag.Year            = new SelectList(datelist);
            ViewBag.SubcontractorId = new SelectList(db.SubContractors.Where(a => a.SubcontractorId == adminCosts.SubcontractorId).OrderBy(a => a.OrgName), "SubcontractorId", "OrgName");

            return(View(adminCosts));
        }