コード例 #1
0
        public ActionResult Edit([Bind(Include = "ID,EmailAddress,CCAddress,CompanyID,DepartmentID,SectionID,CriteriaDepSec,ReportCurrentDate,LocationID,TypID,HasTypeOrCat,HasLoc,CatID,UserID")] EmailEntryForm emailentryform)
        {
            //if (Request.Form["CriteriaComp"].ToString() == "C")
            //string compval = Request.Form["CriteriaComp"].ToString();
            //emailentryform.CriteriaComLoc = compval;

            //else
            //    emailentryform.CriteriaComLoc = compval;
            if (ModelState.IsValid)
            {
                EmailEntryForm _emailEmtryForm = db.EmailEntryForms.Where(aa => aa.ID == emailentryform.ID).First();
                _emailEmtryForm.EmailAddress    = emailentryform.EmailAddress;
                _emailEmtryForm.CCAddress       = emailentryform.CCAddress;
                db.Entry(_emailEmtryForm).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.TypID          = new SelectList(db.EmpTypes, "TypeID", "TypeName");
            ViewBag.CompanyID      = new SelectList(db.Companies, "CompID", "CompName", emailentryform.CompanyID);
            ViewBag.DepartmentID   = new SelectList(db.Departments, "DeptID", "DeptName", emailentryform.DepartmentID);
            ViewBag.LocationID     = new SelectList(db.Locations, "LocID", "LocName", emailentryform.LocationID);
            ViewBag.SectionID      = new SelectList(db.Sections, "SectionID", "SectionName", emailentryform.SectionID);
            ViewBag.CatID          = new SelectList(db.Categories, "CatID", "CatName", emailentryform.CatID); ViewBag.CriteriaComp = new SelectList(GetCriteriaComp(), "ID", "Name", emailentryform.CriteriaComLoc);
            ViewBag.CriteriaDepSec = new SelectList(GetCriteriaDeptSec(), "ID", "Name", emailentryform.CriteriaDepSec);
            ViewBag.HasTypeOrCat   = new SelectList(GetCriteriaTypeCat(), "ID", "Name", emailentryform.HasTypeOrCat);
            return(View(emailentryform));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "ID,EmailAddress,CCAddress,CompanyID,DepartmentID,SectionID,CriteriaDepSec,ReportCurrentDate,LocationID,TypID,HasTypeOrCat,HasLoc,CatID")] EmailEntryForm emailentryform)
        {
            User   LoggedInUser = Session["LoggedUser"] as User;
            string compval      = Request.Form["CriteriaComp"].ToString();

            emailentryform.CriteriaComLoc = compval;
            //string depval = Request.Form["Criteria"].ToString();
            //emailentryform.CriteriaDepSec = depval;
            if (ModelState.IsValid)
            {
                emailentryform.UserID = LoggedInUser.UserID;
                db.EmailEntryForms.Add(emailentryform);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TypID          = new SelectList(db.EmpTypes, "TypeID", "TypeName");
            ViewBag.CompanyID      = new SelectList(db.Companies, "CompID", "CompName", emailentryform.CompanyID);
            ViewBag.DepartmentID   = new SelectList(db.Departments, "DeptID", "DeptName", emailentryform.DepartmentID);
            ViewBag.LocationID     = new SelectList(db.Locations, "LocID", "LocName", emailentryform.LocationID);
            ViewBag.SectionID      = new SelectList(db.Sections, "SectionID", "SectionName", emailentryform.SectionID);
            ViewBag.CatID          = new SelectList(db.Categories, "CatID", "CatName", emailentryform.CatID);
            ViewBag.CriteriaComp   = new SelectList(GetCriteriaComp(), "ID", "Name", emailentryform.CriteriaComLoc);
            ViewBag.CriteriaDepSec = new SelectList(GetCriteriaDeptSec(), "ID", "Name", emailentryform.CriteriaDepSec);
            ViewBag.HasTypeOrCat   = new SelectList(GetCriteriaTypeCat(), "ID", "Name", emailentryform.HasTypeOrCat);
            return(View(emailentryform));
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            EmailEntryForm emailentryform = db.EmailEntryForms.Find(id);

            db.EmailEntryForms.Remove(emailentryform);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public ActionResult View(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmailEntryForm emailentryform = db.EmailEntryForms.Find(id);
            List <EmpView> empViews       = new List <EmpView>();

            empViews = db.EmpViews.Where(aa => aa.Status == true).ToList();
            switch (emailentryform.CriteriaComLoc)
            {
            case "C":
                empViews = empViews.Where(aa => aa.CompanyID == emailentryform.CompanyID).ToList();
                break;

            case "L":
                empViews = empViews.Where(aa => aa.LocID == emailentryform.LocationID).ToList();
                break;
            }
            switch (emailentryform.CriteriaDepSec)
            {
            case "S":
                empViews = empViews.Where(aa => aa.SecID == emailentryform.SectionID).ToList();
                break;

            case "D":
                empViews = empViews.Where(aa => aa.DeptID == emailentryform.DepartmentID).ToList();
                break;

            case "A":
                break;
            }
            switch (emailentryform.HasTypeOrCat)
            {
            case "C":
                empViews = empViews.Where(aa => aa.CatID == emailentryform.CatID).ToList();
                break;

            case "T":
                empViews = empViews.Where(aa => aa.TypeID == emailentryform.TypID).ToList();
                break;

            case "A":
                break;
            }
            if (emailentryform == null)
            {
                return(HttpNotFound());
            }
            int pageSize = 500;

            return(View(empViews.ToPagedList(1, pageSize)));
        }
コード例 #5
0
        // GET: /EmailForm/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmailEntryForm emailentryform = db.EmailEntryForms.Find(id);

            if (emailentryform == null)
            {
                return(HttpNotFound());
            }
            return(View(emailentryform));
        }
コード例 #6
0
        // GET: /EmailForm/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmailEntryForm emailentryform = db.EmailEntryForms.Find(id);

            if (emailentryform == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CatID        = new SelectList(db.Categories, "CatID", "CatName", emailentryform.CatID);
            ViewBag.CompanyID    = new SelectList(db.Companies, "CompID", "CompName", emailentryform.CompanyID);
            ViewBag.DepartmentID = new SelectList(db.Departments, "DeptID", "DeptName", emailentryform.DepartmentID);
            ViewBag.LocationID   = new SelectList(db.Locations, "LocID", "LocName", emailentryform.LocationID);
            ViewBag.SectionID    = new SelectList(db.Sections, "SectionID", "SectionName", emailentryform.SectionID);
            return(View(emailentryform));
        }
コード例 #7
0
        public ActionResult Edit([Bind(Include = "ID,EmailAddress,CCAddress,CompanyID,DepartmentID,SectionID,Criteria,ReportCurrentDate,LocationID,CatID,HasCat,HasLoc")] EmailEntryForm emailentryform)
        {
            //if (Request.Form["CriteriaComp"].ToString() == "C")
            //string compval = Request.Form["CriteriaComp"].ToString();
            //emailentryform.CriteriaComLoc = compval;

            //else
            //    emailentryform.CriteriaComLoc = compval;
            if (ModelState.IsValid)
            {
                db.Entry(emailentryform).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CatID        = new SelectList(db.Categories, "CatID", "CatName", emailentryform.CatID);
            ViewBag.CompanyID    = new SelectList(db.Companies, "CompID", "CompName", emailentryform.CompanyID);
            ViewBag.DepartmentID = new SelectList(db.Departments, "DeptID", "DeptName", emailentryform.DepartmentID);
            ViewBag.LocationID   = new SelectList(db.Locations, "LocID", "LocName", emailentryform.LocationID);
            ViewBag.SectionID    = new SelectList(db.Sections, "SectionID", "SectionName", emailentryform.SectionID);
            return(View(emailentryform));
        }
コード例 #8
0
        // GET: /EmailForm/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmailEntryForm emailentryform = db.EmailEntryForms.AsNoTracking().Where(aa => aa.ID == id).First();

            if (emailentryform == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TypID          = new SelectList(db.EmpTypes, "TypeID", "TypeName");
            ViewBag.CompanyID      = new SelectList(db.Companies, "CompID", "CompName", emailentryform.CompanyID);
            ViewBag.DepartmentID   = new SelectList(db.Departments, "DeptID", "DeptName", emailentryform.DepartmentID);
            ViewBag.LocationID     = new SelectList(db.Locations, "LocID", "LocName", emailentryform.LocationID);
            ViewBag.SectionID      = new SelectList(db.Sections, "SectionID", "SectionName", emailentryform.SectionID);
            ViewBag.CatID          = new SelectList(db.Categories, "CatID", "CatName", emailentryform.CatID); ViewBag.CriteriaComp = new SelectList(GetCriteriaComp(), "ID", "Name", emailentryform.CriteriaComLoc);
            ViewBag.CriteriaDepSec = new SelectList(GetCriteriaDeptSec(), "ID", "Name", emailentryform.CriteriaDepSec);
            ViewBag.HasTypeOrCat   = new SelectList(GetCriteriaTypeCat(), "ID", "Name", emailentryform.HasTypeOrCat);
            return(View(emailentryform));
        }