Пример #1
0
        public ActionResult CreateReport(CourseMonitoringReport acr, String waiting)
        {
            
            if (ModelState.IsValid)
            {
                CRMContext db = new CRMContext();

                if (waiting != null)
                {
                    acr.approveStatusId = 2;
                    var userName = User.Identity.Name;
                    var user = db.Accounts.SingleOrDefault(u => u.userName == userName);
                    var AnnualCourse = db.AnnualCourses.SingleOrDefault(a => a.annualCourseId == acr.annualCourseId);
                    int CMId = (int)AnnualCourse.Course.Faculty.cmAccount;
                    var Cm = db.Accounts.SingleOrDefault(u => u.accountId == CMId);
                    db.CourseMonitoringReports.Add(acr);
                    db.SaveChanges();
                    int ID = db.CourseMonitoringReports.Max(item => item.CourseMonitoringReportId);

                    var body = "<p>Email From: {0} ({1})</p><p>Message: {2}</p><p>Link: {3}</p>";
                    var uri = HttpContext.Request.Url;
                    String url = uri.GetLeftPart(UriPartial.Authority);

                    url = url + "/CM/Detail?reportId=" +ID;
                    var message = string.Format(body, user.Profile.name, user.Profile.email, "There is a report that you need to approve", url);
                    Task.Run(async () => await CustomHtmlHelpers.Helpers.sendMail(Cm.Profile.email, message));

                }else{
                    db.CourseMonitoringReports.Add(acr);
                    db.SaveChanges();
                }
                return RedirectToAction("ReportList");
            }
            return View();
        }
Пример #2
0
        public ActionResult Index(string sortOrder,String currentFilter, String searchString, int? page)
        {
            CRMContext db = new CRMContext();
            var currUser = User.Identity;
            String userName = currUser.Name;
            ViewBag.NameSortParm = sortOrder == "Name" ? "name_desc" : "Name";
            ViewBag.StatusSortParm = sortOrder == "Status" ? "status_desc" : "Status";
            ViewBag.currentSort = sortOrder;

            var courses = (from cmr in db.CourseMonitoringReports
                          join ac in db.AnnualCourses on cmr.annualCourseId equals ac.annualCourseId
                          join c in db.Courses on ac.courseId equals c.courseId
                          join fac in db.Faculties on c.facultyId equals fac.facultyId
                          join a in db.Accounts on fac.cmAccount equals a.accountId
                          where a.userName == userName && cmr.approveStatusId != 1
                          select cmr
                        );

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.currentFilter = searchString;

            if (!String.IsNullOrEmpty(searchString))
            {
                courses = courses.Where(s => s.AnnualCourse.Course.courseName.Contains(searchString));
            }

            switch (sortOrder)
            {
                case "name_desc":
                    courses = courses.OrderByDescending(c => c.AnnualCourse.Course.courseName);
                    break;
                case "Name":
                    courses = courses.OrderBy(c => c.AnnualCourse.Course.courseName);
                    break;
                case "status_desc":
                    courses = courses.OrderByDescending(c => c.approveStatusId);
                    break;
                case "Status":
                    courses = courses.OrderBy(c => c.approveStatusId);
                    break;
                default:
                    courses = courses.OrderBy(c => c.CourseMonitoringReportId);
                    break;
            }

            int pageSize = 10;
            int pageNumber = (page ?? 1);
            return View(courses.ToPagedList(pageNumber, pageSize));
        }
Пример #3
0
 public ActionResult Detail(int reportId)
 {
     CRMContext db = new CRMContext();
     var report = db.CourseMonitoringReports.SingleOrDefault(c => c.CourseMonitoringReportId == reportId);
     if (report == null)
     {
         return HttpNotFound();
     }
     return View(report);
 }
Пример #4
0
 public ActionResult ExceptionReport()
 {
     CRMContext db = new CRMContext();
     List<CourseMonitoringReport> cmrList = db.CourseMonitoringReports.ToList();
     var dictionary1 = new Dictionary<string, StatisticModel>();
     foreach (CourseMonitoringReport a in cmrList)
     {
         string academicYear = Convert.ToString(a.AnnualCourse.academicYear);
         bool isExisted = dictionary1.Keys.Any(k => k.Equals(academicYear));
         if (!isExisted)
         {
             StatisticModel model2 = new StatisticModel();
             model2.academicYear = Convert.ToInt32(academicYear);
             model2.pendingCount = 0;
             dictionary1[academicYear] = model2;
         }
         StatisticModel model = dictionary1[academicYear];
         if (a.ApproveStatu.name.Equals("Pending"))
         {
             model.pendingCount++;
         }
     }
     var dictionary2 = new Dictionary<string, StatisticModel>();
     foreach (CourseMonitoringReport a in cmrList)
     {
         string academicYear = Convert.ToString(a.AnnualCourse.academicYear);
         bool isExisted = dictionary2.Keys.Any(k => k.Equals(academicYear));
         if (!isExisted)
         {
             StatisticModel model2 = new StatisticModel();
             model2.academicYear = Convert.ToInt32(academicYear);
             model2.pendingCount = 0;
             dictionary2[academicYear] = model2;
         }
         StatisticModel model = dictionary2[academicYear];
         if (String.IsNullOrEmpty(a.dltComment))
         {
             model.pendingCount++;
         }
     }
     var dictionary11= new Dictionary<string, StatisticModel>();
     foreach (var item in dictionary1.OrderBy(i => i.Key))
     {
         dictionary11.Add(item.Key, item.Value);
     }
     var dictionary22 = new Dictionary<string, StatisticModel>();
     foreach (var item in dictionary2.OrderBy(i => i.Key))
     {
         dictionary22.Add(item.Key, item.Value);
     }
     ViewBag.dict1 = dictionary11;
     ViewBag.dict2 = dictionary22;
     return View();
 }
Пример #5
0
 public ActionResult Index()
 {
     CRMContext db = new CRMContext();
     var currUser =User.Identity;
     String userName = currUser.Name;
     var course = (from ac in db.AnnualCourses
                  join a in db.Accounts on ac.clAccount equals a.accountId
                  where a.userName == userName
                  select ac).ToList();
     return View(course);
 }
Пример #6
0
        public ActionResult Index()
        {
            CRMContext db = new CRMContext();
            var currUser = User.Identity;
            String userName = currUser.Name;

            var courses = (from cmr in db.CourseMonitoringReports
                           join ac in db.AnnualCourses on cmr.annualCourseId equals ac.annualCourseId
                           join c in db.Courses on ac.courseId equals c.courseId
                           join fac in db.Faculties on c.facultyId equals fac.facultyId
                           join a in db.Accounts on fac.dltAccount equals a.accountId
                           where a.userName == userName && cmr.approveStatusId == 4
                           select cmr
                        );

            return View(courses);
        }
Пример #7
0
        public ActionResult StatisticReport()
        {
            CRMContext db = new CRMContext();
            List<CourseMonitoringReport> cmrList = db.CourseMonitoringReports.ToList();
            var dictionary = new Dictionary<string, StatisticModel>();
            foreach (CourseMonitoringReport a in cmrList)
            {
                string academicYear = Convert.ToString(a.AnnualCourse.academicYear);
                bool isExisted = dictionary.Keys.Any(k => k.Equals(academicYear));
                if (!isExisted)
                {
                    StatisticModel model2 = new StatisticModel();
                    model2.academicYear = Convert.ToInt32(academicYear);
                    model2.approvedCount = 0;
                    model2.pendingCount = 0;
                    model2.rejectedCount = 0;
                    model2.waitingCount = 0;
                    dictionary[academicYear] = model2;
                }
                StatisticModel model = dictionary[academicYear];
                if (a.ApproveStatu.name.Equals("Pending"))
                {
                    model.pendingCount++;
                }
                if (a.ApproveStatu.name.Equals("Approved"))
                {
                    model.approvedCount++;
                }
                if (a.ApproveStatu.name.Equals("Waiting"))
                {
                    model.waitingCount++;
                }
                if (a.ApproveStatu.name.Equals("Rejected"))
                {
                    model.rejectedCount++;
                }
            }
            var dictionary2 = new Dictionary<string, StatisticModel>();
            foreach (var item in dictionary.OrderBy(i => i.Key))
            {
                dictionary2.Add(item.Key,item.Value);
            }

            ViewBag.dict = dictionary2;
            return View();
        }
Пример #8
0
        public ActionResult Detail(int reportId) {
            CRMContext db = new CRMContext();
            var report = db.CourseMonitoringReports.SingleOrDefault(c => c.CourseMonitoringReportId == reportId);
            if (report == null)
            {
                return HttpNotFound();
            }
            List<SelectListItem> items = new List<SelectListItem>();

            items.Add(new SelectListItem { Text = "-- Select One --", Value = "2" });
            items.Add(new SelectListItem { Text = "Approve", Value = "4", Selected = (4 == report.approveStatusId ? true : false) });
            items.Add(new SelectListItem { Text = "Reject", Value = "3", Selected=(3==report.approveStatusId  ? true : false) });

            ViewBag.listEvent = items;

            return View(report);
        }
Пример #9
0
 public ActionResult CreateReport(String annualCourseId)
 {
     ViewBag.annualCourseId = annualCourseId;
     int Id=Int32.Parse(annualCourseId);
     CRMContext db = new CRMContext();
     var students = (from student in db.Students
                    where student.AnnualCourseId == Id
                    select student).ToList();
     int markA=0;
     int markB=0;
     int markC=0;
     int markD=0;
     int total = 0;
     foreach(Student s in students){
         if (s.Mark >= 80)
         {
             markA++;
         }
         if (s.Mark >= 60 && s.Mark <= 79)
         {
             markB++;
         }
         if (s.Mark >= 40 && s.Mark <= 59)
         {
             markC++;
         }
         if (s.Mark < 40)
         {
             markD++;
         }
         total++;
     }
     ViewBag.markA = markA;
     ViewBag.markB = markB;
     ViewBag.markC = markC;
     ViewBag.markD = markD;
     ViewBag.total = total;
     return View();
 }
Пример #10
0
        public ActionResult ResponseComment(int courseMonitoringReportId, String dltComment)
        {
            CRMContext db = new CRMContext();
            var report = db.CourseMonitoringReports.SingleOrDefault(c => c.CourseMonitoringReportId == courseMonitoringReportId);
            if (report != null)
            {
                report.dltComment = dltComment;
                db.Entry(report).State = EntityState.Modified;
                db.SaveChanges();
                var clEmail = report.AnnualCourse.Account.Profile.email;
                var userName = User.Identity.Name;
                var user = db.Accounts.SingleOrDefault(u => u.userName == userName);
                var body = "<p>Email From: {0} ({1})</p><p>Message: {2}</p><p>Content: {3}</p><p>Link: {4}</p>";
                var uri = HttpContext.Request.Url;
                String url = uri.GetLeftPart(UriPartial.Authority);

                url = url + "/CL/ReportDetail?id=" + report.CourseMonitoringReportId;
                var message = string.Format(body, user.Profile.name, user.Profile.email, "Your report has been repsoned.",dltComment,url);
                Task.Run(async () => await CustomHtmlHelpers.Helpers.sendMail(clEmail, message));

            }
            return RedirectToAction("Detail", new { reportId = courseMonitoringReportId });
        }
Пример #11
0
        public ActionResult CreateStatusStatisTicReportChart()
        {
            CRMContext db = new CRMContext();
            List<CourseMonitoringReport> cmrList = db.CourseMonitoringReports.ToList();

            var dictionary = new Dictionary<string, StatisticModel>();
            foreach (CourseMonitoringReport a in cmrList)
            {
                string academicYear = Convert.ToString(a.AnnualCourse.academicYear);
                bool isExisted = dictionary.Keys.Any(k => k.Equals(academicYear));
                if (!isExisted)
                {
                    StatisticModel model2 = new StatisticModel();
                    model2.academicYear = Convert.ToInt32(academicYear);
                    model2.approvedCount = 0;
                    model2.pendingCount = 0;
                    model2.rejectedCount = 0;
                    model2.waitingCount = 0;
                    dictionary[academicYear] = model2;
                }
                StatisticModel model = dictionary[academicYear];
                if (a.ApproveStatu.name.Equals("Pending"))
                {
                    model.pendingCount++;
                }
                if (a.ApproveStatu.name.Equals("Approved"))
                {
                    model.approvedCount++;
                }
                if (a.ApproveStatu.name.Equals("Waiting"))
                {
                    model.waitingCount++;
                }
                if (a.ApproveStatu.name.Equals("Rejected"))
                {
                    model.rejectedCount++;
                }
            }
            var dictionary2 = new Dictionary<string, StatisticModel>();
            foreach (var item in dictionary.OrderBy(i => i.Key))
            {
                dictionary2.Add(item.Key, item.Value);
            }
            String[] academicYears = dictionary2.Keys.ToArray<String>();
            Dictionary<string, string[]> pendingDict = new Dictionary<string, string[]>();
            Dictionary<string, string[]> waitingDict = new Dictionary<string, string[]>();
            Dictionary<string, string[]> approveDict = new Dictionary<string, string[]>();
            Dictionary<string, string[]> rejectDict = new Dictionary<string, string[]>();

            String[] pendingList = null;
            String[] watingList = null;
            String[] approveList = null;
            String[] rejectList = null;

            for (int i = 0; i < academicYears.Count(); i++) {
                String year = academicYears[i];
                StatisticModel theModel = dictionary2[year];

                if (i == 0)
                {
                    pendingList = new String[academicYears.Count()];
                    watingList = new String[academicYears.Count()];
                    approveList = new String[academicYears.Count()];
                    rejectList = new String[academicYears.Count()];

                    pendingDict["something"] = pendingList;
                    waitingDict["something"] = watingList;
                    approveDict["something"] = approveList;
                    rejectDict["something"] = rejectList;
                }

                pendingList[i] = Convert.ToString(theModel.pendingCount);
                watingList[i] = Convert.ToString(theModel.waitingCount);
                approveList[i] = Convert.ToString(theModel.approvedCount);
                rejectList[i] = Convert.ToString(theModel.rejectedCount);

            }
            
            var chart = new Chart(width: 800, height: 400, theme: ChartTheme.Green)
                .AddTitle("Status statistic of Course Monitoring Report Chart")
                .AddLegend()
                .AddSeries(chartType: "StackedColumn",
                                xValue: academicYears,
                                yValues: pendingDict[pendingDict.Keys.ElementAt(0)],
                                name: "Pending")
                .AddSeries(chartType: "StackedColumn",
                                xValue: academicYears,
                                yValues: waitingDict[waitingDict.Keys.ElementAt(0)],
                                name: "Waiting")
                .AddSeries(chartType: "StackedColumn",
                                xValue: academicYears,
                                yValues: rejectDict[rejectDict.Keys.ElementAt(0)],
                                name: "Rejected")
                .AddSeries(chartType: "StackedColumn",
                                xValue: academicYears,
                                yValues: approveDict[approveDict.Keys.ElementAt(0)],
                                name: "Approved")
                .GetBytes("png");

            return File(chart, "image/bytes");
        }
Пример #12
0
        public ActionResult Approve(int courseMonitoringReportId, int status, String approve_desc)
        {
            CRMContext db = new CRMContext();
            
            var report = db.CourseMonitoringReports.SingleOrDefault(c => c.CourseMonitoringReportId == courseMonitoringReportId);
            if (report != null)
            {
                var statusName = "";
                report.approveStatusId = status;
                report.approve_desc = approve_desc;
                db.Entry(report).State = EntityState.Modified;
                db.SaveChanges();
                var userName = User.Identity.Name;
                var user = db.Accounts.SingleOrDefault(u => u.userName == userName);
                var ClEmail = report.AnnualCourse.Account.Profile.email;
                var pvcEmail = report.AnnualCourse.Course.Faculty.Account2.Profile.email;
                var dltEmail = report.AnnualCourse.Course.Faculty.Account1.Profile.email;

                if (status == 3)
                {
                     statusName = "rejected";
                }
                else if (status == 4)
                {
                    statusName = "approved";
                }

                var uri = HttpContext.Request.Url;
                String url = uri.GetLeftPart(UriPartial.Authority);
                String clURL = url + "/CL/ReportDetail?id=" + report.CourseMonitoringReportId;
                
                var body = "<p>Email From: {0} ({1})</p><p>Message: {2}</p><p>Link: {3}</p>";
                var message = string.Format(body, user.Profile.name, user.Profile.email, "Your report have been " + statusName + " by " + user.Profile.name, clURL);
                Task.Run(async () => await CustomHtmlHelpers.Helpers.sendMail(ClEmail, message));

                String dltURL = url + "/DLT/Detail?reportId=" + report.CourseMonitoringReportId;
                var dtlbody = "<p>Email From: {0} ({1})</p><p>Message: {2}</p><p>Link: {3}</p>";
                var dltmessage = string.Format(dtlbody, user.Profile.name, user.Profile.email, "There is a report of " + report.AnnualCourse.Account.Profile.name, dltURL);
                Task.Run(async () => await CustomHtmlHelpers.Helpers.sendMail(dltEmail, dltmessage));

                String pvcURL = url + "/PVC/Detail?reportId=" + report.CourseMonitoringReportId;
                var pvcbody = "<p>Email From: {0} ({1})</p><p>Message: {2}</p><p>Link: {3}</p>";
                var pvcmessage = string.Format(pvcbody, report.AnnualCourse.Account.Profile.name, report.AnnualCourse.Account.Profile.email, "There is a report of " + report.AnnualCourse.Account.Profile.name, pvcURL);
                Task.Run(async () => await CustomHtmlHelpers.Helpers.sendMail(pvcEmail, pvcmessage));
                
            }
            return RedirectToAction("Detail", new { reportId = courseMonitoringReportId });
        }
Пример #13
0
		public ActionResult SubmitComment(int courseMonitoringReportId, String comment_content)
		{
			System.Diagnostics.Debug.WriteLine("SubmitComment " + comment_content);

			if (ModelState.IsValid)
			{
				CRMContext db = new CRMContext();
				Comment cmt = new Comment();
				cmt.content = comment_content;
				var acc = db.Accounts.SingleOrDefault(a => a.userName == User.Identity.Name);
				cmt.accountId = acc.accountId;
				cmt.time = DateTime.Now;
				cmt.monitoringReportId = courseMonitoringReportId;
				db.Comments.Add(cmt);
				db.SaveChanges();
				return RedirectToAction("Detail", new { reportId = courseMonitoringReportId });
			}
			return View();
		}
Пример #14
0
        public async Task<ActionResult> EditReport(CourseMonitoringReport acr, String waiting)
        {
            CRMContext db = new CRMContext();
            if (ModelState.IsValid)
            {
                if (waiting != null)
                {
                    acr.approveStatusId=2;

                    var userName = User.Identity.Name;
                    var user = db.Accounts.SingleOrDefault(u => u.userName == userName);
                    var AnnualCourse = db.AnnualCourses.SingleOrDefault(a => a.annualCourseId == acr.annualCourseId);
                    int CMId =(int) AnnualCourse.Course.Faculty.cmAccount;
                    var Cm = db.Accounts.SingleOrDefault(u => u.accountId == CMId);

                    var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p><p>Link: {3}</p>";
                    var uri = HttpContext.Request.Url;
                    String url = uri.GetLeftPart(UriPartial.Authority);
                    url = url + "/CM/Detail?reportId=" + acr.CourseMonitoringReportId;
                    var message = new MailMessage();
                    message.To.Add(new MailAddress(Cm.Profile.email));
                    message.Subject = "Course Monitoring Report";
                    message.Body = string.Format(body, user.Profile.name, user.Profile.email, "There is a report That you need to approve", url);
                    message.IsBodyHtml = true;
                    using (var smtp = new SmtpClient())
                    {
                        await smtp.SendMailAsync(message);

                    }
                }
                db.Entry(acr).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("ReportList");
            }
            return View(acr);
        }
Пример #15
0
        public List<AnnualCourse> getAnnualCourseSearching(String txtAcademicYearFrom, String txtAcademicYearTo, String txtKeyWord)
        {
            try
            {
                CRMContext db = new CRMContext();
                if (txtAcademicYearFrom != "" && txtAcademicYearTo == "" && txtKeyWord == "")
                {
                    int dt = Int32.Parse(txtAcademicYearFrom);
                    var annualCourses = (from anc in db.AnnualCourses where anc.academicYear >= dt && anc.Status == "Wait" select anc).ToList();
                    return annualCourses;
                }
                if (txtAcademicYearFrom == "" && txtAcademicYearTo != "" && txtKeyWord == "")
                {
                    int dt = Int32.Parse(txtAcademicYearTo);
                    var annualCourses = (from anc in db.AnnualCourses where anc.academicYear <= dt && anc.Status == "Wait" select anc).ToList();
                    return annualCourses;
                }
                if (txtAcademicYearFrom == "" && txtAcademicYearTo == "" && txtKeyWord != "")
                {
                    var annualCourses = (from anc in db.AnnualCourses where anc.Course.courseName.Contains(txtKeyWord) && anc.Status == "Wait" select anc).ToList();
                    return annualCourses;
                }

                if (txtAcademicYearFrom != "" && txtAcademicYearTo != "" && txtKeyWord == "")
                {
                    int dtFrom = Int32.Parse(txtAcademicYearFrom);
                    int dtTo = Int32.Parse(txtAcademicYearTo);
                    var annualCourses = (from anc in db.AnnualCourses where (anc.academicYear >= dtFrom && anc.academicYear <= dtTo) && anc.Status == "Wait" select anc).ToList();
                    return annualCourses;
                }
                if (txtAcademicYearFrom != "" && txtAcademicYearTo == "" && txtKeyWord != "")
                {
                    int dtFrom = Int32.Parse(txtAcademicYearFrom);
                    var annualCourses = (from anc in db.AnnualCourses where anc.academicYear >= dtFrom && anc.Status == "Wait" && anc.Course.courseName.Contains(txtKeyWord) select anc).ToList();
                    return annualCourses;
                }


                if (txtAcademicYearFrom == "" && txtAcademicYearTo != "" && txtKeyWord != "")
                {
                    int dtTo = Int32.Parse(txtAcademicYearTo);
                    var annualCourses = (from anc in db.AnnualCourses where anc.academicYear <= dtTo && anc.Status == "Wait" && anc.Course.courseName.Contains(txtKeyWord) select anc).ToList();
                    return annualCourses;
                }

                if (txtAcademicYearFrom != "" && txtAcademicYearTo != "" && txtKeyWord != "")
                {
                    int dtFrom = Int32.Parse(txtAcademicYearFrom);
                    int dtTo = Int32.Parse(txtAcademicYearTo);
                    var annualCourses = (from anc in db.AnnualCourses where (anc.academicYear >= dtFrom && anc.academicYear <= dtTo) && anc.Status == "Wait" && anc.Course.courseName.Contains(txtKeyWord) select anc).ToList();
                    return annualCourses;
                }

            }
            catch (Exception e)
            {
                
            }
            return null;
            
        }
Пример #16
0
        public ActionResult ViewAvaibleAnnualCourse(String txtAcademicYearFrom, String txtAcademicYearTo, String txtKeyWord,  int? page)
        {
            CRMContext db = new CRMContext();
            List<AnnualCourse> annucalCourses = new List<AnnualCourse>();
            ViewBag.From = txtAcademicYearFrom;
            ViewBag.To = txtAcademicYearTo;
            Regex regex = new Regex(@"^\d{4}$");
            Match from = regex.Match(txtAcademicYearFrom);
            Match to = regex.Match(txtAcademicYearTo);
            int pageSize = 10;
            int pageNumber = (page ?? 1);

            if (from.Success && to.Success) {
                
                if (txtAcademicYearFrom == "" && txtAcademicYearTo == "" && txtKeyWord == "")
                {
                    ModelState.AddModelError("", "Please, typing any field for searching !");
                    var annualCourses = from anc in db.AnnualCourses where anc.Course.courseName == "" select anc;
                    return View(annualCourses.ToPagedList(pageNumber, pageSize));
                }
                else
                {
                    List<AnnualCourse> listAnnualCourse = getAnnualCourseSearching(txtAcademicYearFrom, txtAcademicYearTo, txtKeyWord);
                    return View(listAnnualCourse.ToPagedList(pageNumber, pageSize));

                }

            }
            else
            {
                List<AnnualCourse> listAnnualCourse = getAnnualCourseSearching(txtAcademicYearFrom, txtAcademicYearTo, txtKeyWord);
                if (listAnnualCourse == null)
                {
                    listAnnualCourse = new List<AnnualCourse>();
                }
                ModelState.AddModelError("", "From or To Year is not valid");
                return View(listAnnualCourse.ToPagedList(pageNumber, pageSize));
            }
            
        }
Пример #17
0
 public ActionResult ViewAvaibleAnnualCourse(string sortOrder, String currentFilter, int? page)
 {
     CRMContext db = new CRMContext();
     ViewBag.SortAcademicYear = sortOrder == "Year" ? "year_desc" : "Year";
     ViewBag.SortUserName = sortOrder == "UserName" ? "username_desc" : "UserName";
     ViewBag.SortCourseName = sortOrder == "CourseName" ? "coursename_desc" : "CourseName";
     ViewBag.currentSort = sortOrder;
   
     int pageSize = 10;
     int pageNumber = (page ?? 1);
     
         var anCourses = from anc in db.AnnualCourses where anc.Status.Equals("Wait") select anc;
         switch (sortOrder)
         {
             case "year_desc":
                 anCourses = anCourses.OrderByDescending(ac => ac.academicYear);
                 break;
             case "Year":
                 anCourses = anCourses.OrderBy(c => c.academicYear);
                 break;
             case "username_desc":
                 anCourses = anCourses.OrderByDescending(c => c.Account.userName);
                 break;
             case "UserName":
                 anCourses = anCourses.OrderBy(c => c.Account.userName);
                 break;
             case "coursename_desc":
                 anCourses = anCourses.OrderByDescending(c => c.Course.courseName);
                 break;
             case "CourseName":
                 anCourses = anCourses.OrderBy(c => c.Course.courseName);
                 break;
             default:
                 anCourses = anCourses.OrderBy(c => c.courseId);
                 break;
         }
         return View(anCourses.ToPagedList(pageNumber, pageSize));
     
     
 }
Пример #18
0
        public ActionResult DeleteReport(int id)
        {
            CRMContext db = new CRMContext();
            CourseMonitoringReport acr = db.CourseMonitoringReports.SingleOrDefault(a => a.CourseMonitoringReportId == id);
            if (acr == null)
            {
                return HttpNotFound();
            }
            db.CourseMonitoringReports.Remove(acr);
            db.SaveChanges();

            return RedirectToAction("ReportList");
        }
Пример #19
0
 public ActionResult Index()
 {
     CRMContext db = new CRMContext();
     return View(db.CourseMonitoringReports.ToList());
     //return View();
 }
Пример #20
0
        public ActionResult CreateNoResponseReportChart()
        {
            CRMContext db = new CRMContext();
            List<CourseMonitoringReport> cmrList = db.CourseMonitoringReports.ToList();
            var dictionary = new Dictionary<string, StatisticModel>();
            foreach (CourseMonitoringReport a in cmrList)
            {
                string academicYear = Convert.ToString(a.AnnualCourse.academicYear);
                bool isExisted = dictionary.Keys.Any(k => k.Equals(academicYear));
                if (!isExisted)
                {
                    StatisticModel model2 = new StatisticModel();
                    model2.academicYear = Convert.ToInt32(academicYear);
                    model2.pendingCount = 0;
                    dictionary[academicYear] = model2;
                }
                StatisticModel model = dictionary[academicYear];
                if (String.IsNullOrEmpty(a.dltComment))
                {
                    model.pendingCount++;
                }
            }
            var dictionary2 = new Dictionary<string, StatisticModel>();
            foreach (var item in dictionary.OrderBy(i => i.Key))
            {
                dictionary2.Add(item.Key, item.Value);
            }
            String[] academicYears = dictionary2.Keys.ToArray<String>();
            Dictionary<string, string[]> pendingDict = new Dictionary<string, string[]>();
            String[] pendingList = null;

            for (int i = 0; i < academicYears.Count(); i++)
            {
                String year = academicYears[i];
                StatisticModel theModel = dictionary2[year];

                if (i == 0)
                {
                    pendingList = new String[academicYears.Count()];
                    pendingDict["something"] = pendingList;

                }

                pendingList[i] = Convert.ToString(theModel.pendingCount);
            }

            var chart = new Chart(width: 600, height: 300, theme: ChartTheme.Green)
            .AddTitle("No Response Course Monitoring Report Chart")
            .AddSeries(chartType: "Bar",
                            xValue: academicYears,
                            yValues: pendingDict[pendingDict.Keys.ElementAt(0)])
                            .GetBytes("png");
            return File(chart, "image/bytes");
        }
Пример #21
0
        public ActionResult TakeAnnualCourse(int annualCourseId)
        {
            CRMContext db = new CRMContext();
            AnnualCourse anCourse = db.AnnualCourses.SingleOrDefault(ac => ac.annualCourseId == annualCourseId);
            var currUser = User.Identity;
            String userName = currUser.Name;
            Account a = db.Accounts.SingleOrDefault(u => u.userName == userName);
            anCourse.clAccount = a.accountId;
            anCourse.Status = "Activate";
            db.SaveChanges();

            return RedirectToAction("Index");
        }
Пример #22
0
        public ActionResult ReportList()
        {
            CRMContext db = new CRMContext();
            var currUser = User.Identity;
            String userName = currUser.Name;
            var Reports = (from cmr in db.CourseMonitoringReports
                           select cmr);

            Reports = Reports.Where(s => s.AnnualCourse.Account.userName == userName);
            return View(Reports);
        }
Пример #23
0
        public ActionResult EditReport(int id)
        {
            CRMContext db = new CRMContext();
            CourseMonitoringReport acr = db.CourseMonitoringReports.SingleOrDefault(a => a.CourseMonitoringReportId == id);
            if (acr == null)
            {
                return HttpNotFound();
            }

            return View(acr);
        }