public ActionResult SRequestAcceptEnd(StudentViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); int i = StudentIdGlobal; var student = db.Students.Where(x => x.Id == StudentIdGlobal).First(); student.UserName = collection.UserName; student.Password = collection.Password; student.Status = 1; db.SaveChanges(); //Sending mail to Student with his/her UserName and Password using (MailMessage mailMessage = new MailMessage(MailUserName, student.Email)) { mailMessage.Subject = "Hi!"; mailMessage.Body = "This mail is from Smart School Web Portal admin! Your User Name is " + collection.UserName + " and Password is " + collection.Password; mailMessage.IsBodyHtml = false; using (SmtpClient smtp = new SmtpClient()) { smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(MailUserName, MailPassword); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mailMessage); } } string message = "Email Sent to " + student.UserName + " !"; return(RedirectToAction("STudentRequests", "Management", new { Message = message })); }
public ActionResult GenerateReportFees(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var student = db.Students.Where(x => x.Id == id).First(); var fees = db.StudentFees.Where(x => x.StudentId == id).ToList(); List <StudentFeeViewModel> PassList = new List <StudentFeeViewModel>(); foreach (var i in fees) { StudentFeeViewModel sf = new StudentFeeViewModel(); sf.Amount = Convert.ToInt32(i.Amount); sf.Date = Convert.ToDateTime(i.Date); sf.Status = i.Status; sf.Id = i.Id; PassList.Add(sf); } ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CrystalReportFees.rpt")); rd.SetDataSource(PassList); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "FeesList.pdf")); } catch { throw; } }
public ActionResult MAddHostels(HostelViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); Hostel hostel = new Hostel(); hostel.Name = collection.HostelName; hostel.Location = collection.HostelLocation; hostel.Details = collection.HostelDetails; hostel.Rent = collection.HostelRent; if (collection.Image != null) { string filename = Path.GetFileNameWithoutExtension(collection.Image.FileName); string ext = Path.GetExtension(collection.Image.FileName); filename = filename + DateTime.Now.Millisecond.ToString(); filename = filename + ext; string filetodb = "/img/Hostels/" + filename; filename = Path.Combine(Server.MapPath("~/img/Hostels"), filename); collection.Image.SaveAs(filename); collection.ImagePath = filetodb; } else { collection.ImagePath = "/img/Hostels/MumtazHall.jpg"; } hostel.ImagePath = collection.ImagePath; db.Hostels.Add(hostel); db.SaveChanges(); return(View()); }
public ActionResult GenerateReportComplains() { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var List = db.Complaints.ToList(); List <ComplainViewModel> PassList = new List <ComplainViewModel>(); foreach (var i in List) { ComplainViewModel c = new ComplainViewModel(); c.Details = i.Details; c.Id = i.Id; c.Date = Convert.ToDateTime(i.Date); PassList.Add(c); } ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CrystalReportComplains.rpt")); rd.SetDataSource(PassList); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "ComplaintsList.pdf")); } catch { throw; } }
public ActionResult ViewAttendance() { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var studentId = db.Parents.Where(x => x.Id == LoginClass.LoginId).First(); var AttendanceList = db.StudentAttendances.Where(x => x.StudentId == studentId.StudentId).ToList(); List <StudentAttendanceViewModel> PassList = new List <StudentAttendanceViewModel>(); foreach (var i in AttendanceList) { StudentAttendanceViewModel att = new StudentAttendanceViewModel(); var classattendance = db.ClassAttendances.Where(x => x.Id == i.ClassAttendanceId).First(); att.Date = Convert.ToDateTime(classattendance.Date); if (i.Status == 1) { att.Status = "Present"; } else if (i.Status == 2) { att.Status = "Absent"; } else if (i.Status == 3) { att.Status = "Leave"; } else { att.Status = "Late"; } PassList.Add(att); } return(View(PassList)); }
public ActionResult GenerateReportHostels() { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var list = db.Hostels.ToList(); List <HostelViewModel> PassList = new List <HostelViewModel>(); foreach (var i in list) { HostelViewModel h = new HostelViewModel(); h.HostelName = i.Name; h.HostelLocation = i.Location; h.Id = i.Id; h.HostelRent = Convert.ToInt32(i.Rent); h.HostelDetails = i.Details; PassList.Add(h); } ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CrystalReportAllHostels.rpt")); rd.SetDataSource(PassList); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "HostelsList.pdf")); } catch { throw; } }
public ActionResult UpdateParent(int id, ParentViewModel collection) { DBSmartSchoolWebPortalEntities111 ent = new DBSmartSchoolWebPortalEntities111(); var parent = ent.Parents.Where(x => x.Id == id).First(); if (collection.Name == null) { collection.Name = parent.Name; } if (collection.Contact == null) { collection.Contact = parent.Contact; } if (collection.Email == null) { collection.Email = parent.Email; } if (collection.NIC == null) { collection.NIC = parent.NIC; } parent.Name = collection.Name; parent.Contact = collection.Contact; parent.Email = collection.Email; parent.UserName = parent.UserName; parent.Password = parent.Password; parent.NIC = collection.NIC; ent.SaveChanges(); return(RedirectToAction("AllParent")); }
public ActionResult GenerateReportNews() { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); List <NewsViewModel> PassList = new List <NewsViewModel>(); var List = db.News.Where(x => x.Status == 1).ToList(); foreach (var i in List) { NewsViewModel n = new NewsViewModel(); n.Date = Convert.ToDateTime(i.Date); n.Description = i.Description; n.Title = i.Title; PassList.Add(n); } ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CrystalReportNews.rpt")); rd.SetDataSource(PassList); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "NewsList.pdf")); } catch { throw; } }
public ActionResult SLeaveView() { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var parent = db.Parents.Where(x => x.Id == LoginClass.LoginId).First(); var student = db.Students.Where(x => x.Id == parent.StudentId).First(); var List = db.LeavesRequests.Where(x => x.StudentId == student.Id).ToList(); List <LeaveViewModel> PassList = new List <LeaveViewModel>(); foreach (var i in List) { LeaveViewModel l = new LeaveViewModel(); l.Id = i.Id; l.Reason = i.Reason; l.Date = Convert.ToDateTime(i.Date); if (i.Status == 1) { l.Status = "Approved"; } else { l.Status = "Pending"; } PassList.Add(l); } return(View(PassList)); }
//Reports public ActionResult GenerateReportCourses() { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var List = db.RegisteredCourses.Where(x => x.StudentId == LoginClass.LoginId).ToList(); List <RegisteredCourseViewModel> PassList = new List <RegisteredCourseViewModel>(); foreach (var i in List) { RegisteredCourseViewModel r = new RegisteredCourseViewModel(); var c = db.Courses.Where(x => x.Id == i.CourseId).First(); r.Name = c.Title; r.Date = Convert.ToDateTime(i.RegisterationDate); PassList.Add(r); } ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CrystalReportCourses.rpt")); rd.SetDataSource(PassList); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "RegisteredCoursesList.pdf")); } catch { throw; } }
public ActionResult ViewNews() { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); List <NewsViewModel> PassList = new List <NewsViewModel>(); var List = db.News.ToList(); foreach (var i in List) { NewsViewModel n = new NewsViewModel(); n.Date = Convert.ToDateTime(i.Date); n.Description = i.Description; n.Title = i.Title; n.Id = i.Id; if (i.Status != 1) { n.Status = "UnPublished"; } else { n.Status = "Published"; } PassList.Add(n); } return(View(PassList)); }
public ActionResult UpdateHostel(int id, HostelViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var hostel = db.Hostels.Where(x => x.Id == id).First(); if (collection.HostelName == null) { collection.HostelName = hostel.Name; } if (collection.HostelRent == 0) { collection.HostelRent = Convert.ToInt16(hostel.Rent); } if (collection.HostelLocation == null) { collection.HostelLocation = hostel.Location; } hostel.Name = collection.HostelName; hostel.Details = collection.HostelDetails; hostel.Rent = collection.HostelRent; hostel.Location = collection.HostelLocation; db.SaveChanges(); string message = "Hostel Updated!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult LeaveRequestAccept(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var Request = db.LeavesRequests.Where(x => x.Id == id).First(); var Student = db.Students.Where(x => x.Id == Request.StudentId).First(); Request.Status = 1; db.SaveChanges(); //Sending mail to Student that his/her Leave Request is Accepted using (MailMessage mailMessage = new MailMessage(MailUserName, Student.Email)) { mailMessage.Subject = "Hi!"; mailMessage.Body = "This mail is from Smart School Web Portal admin! Your Leave Request for Date " + Request.Date + " is acceptted!"; mailMessage.IsBodyHtml = false; using (SmtpClient smtp = new SmtpClient()) { smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(MailUserName, MailPassword); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mailMessage); } } string message = "Email Sent to " + Student.UserName + " !"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult DeleteFee(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var fee = db.StudentFees.Where(x => x.Id == id).First(); db.Entry(fee).State = System.Data.Entity.EntityState.Deleted; string message = "Student fee Deleted!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult PayFees(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var sf = db.StudentFees.Where(x => x.Id == id).First(); sf.Status = "Paid"; db.SaveChanges(); string message = "Student fee Paid!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult DeleteParent(int id) { DBSmartSchoolWebPortalEntities111 ent = new DBSmartSchoolWebPortalEntities111(); var parent = ent.Parents.Where(x => x.Id == id).First(); ent.Entry(parent).State = System.Data.Entity.EntityState.Deleted; ent.SaveChanges(); string message = "Parent is Deleted"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult DeleteHostel(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var hostel = db.Hostels.Where(x => x.Id == id).First(); db.Entry(hostel).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); string message = "Hostel is Deleted"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult ComplainNotice(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var complain = db.Complaints.Where(x => x.Id == id).First(); complain.Status = 1; db.SaveChanges(); string message = "Complain Noticed!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult UnPublishNews(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var news = db.News.Where(x => x.Id == id).First(); news.Status = 2; db.SaveChanges(); string message = "News UnPublished!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult Account(string Message) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var user = db.Parents.Where(x => x.Id == LoginClass.LoginId).First(); ViewBag.Name = user.Name; ViewBag.Contact = user.Contact; ViewBag.Email = user.Email; ViewBag.NIC = user.NIC; ViewBag.Message = Message; return(View()); }
public ActionResult Change(ParentViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var user = db.Parents.Where(x => x.Id == LoginClass.LoginId).First(); user.UserName = collection.UserName; user.Password = collection.Password; db.SaveChanges(); string message = "User Name & Password Updated!"; return(RedirectToAction("Account", "Parent", new { Message = message })); }
public ActionResult UpdateHostel(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var hostel = db.Hostels.Where(x => x.Id == id).First(); HostelViewModel h = new HostelViewModel(); h.HostelName = hostel.Name; h.HostelLocation = hostel.Location; h.HostelRent = Convert.ToInt32(hostel.Rent); h.HostelDetails = hostel.Details; return(View(h)); }
public ActionResult Account(string message) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var admin = db.Managements.First(); ViewBag.Name = admin.Name; ViewBag.Contact = admin.Contact; ViewBag.CNIC = admin.NIC; ViewBag.Email = admin.Email; ViewBag.Message = message; return(View()); }
public ActionResult AddComplaint(ComplainViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); Complaint complaint = new Complaint(); complaint.ParentId = LoginClass.LoginId; complaint.Details = collection.Details; db.Complaints.Add(complaint); db.SaveChanges(); return(RedirectToAction("Account")); }
public ActionResult Register(StudentViewModel Collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); Student s = new Student(); s.Name = Collection.Name; s.Contact = Collection.Contact; s.RegisterationNumber = Collection.RegisterationNumber; s.Email = Collection.Email; db.Students.Add(s); db.SaveChanges(); return(View()); }
public ActionResult GenerateReportAttendance() { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var AttendanceList = db.StudentAttendances.Where(x => x.StudentId == LoginClass.LoginId).ToList(); List <StudentAttendanceViewModel> PassList = new List <StudentAttendanceViewModel>(); foreach (var i in AttendanceList) { StudentAttendanceViewModel att = new StudentAttendanceViewModel(); var classattendance = db.ClassAttendances.Where(x => x.Id == i.ClassAttendanceId).First(); att.Date = Convert.ToDateTime(classattendance.Date); if (i.Status == 1) { att.Status = "Present"; } else if (i.Status == 2) { att.Status = "Absent"; } else if (i.Status == 3) { att.Status = "Leave"; } else { att.Status = "Late"; } PassList.Add(att); } ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CrystalReportAttendance.rpt")); rd.SetDataSource(PassList); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "RegisteredCoursesList.pdf")); } catch { throw; } }
public ActionResult UpdateParent(int id) { DBSmartSchoolWebPortalEntities111 ent = new DBSmartSchoolWebPortalEntities111(); var parent = ent.Parents.Where(x => x.Id == id).First(); ParentViewModel p = new ParentViewModel(); p.Name = parent.Name; p.Contact = parent.Contact; p.Email = parent.Email; p.UserName = parent.UserName; p.Password = parent.Password; p.NIC = parent.NIC; return(View(p)); }
public ActionResult Register() { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); List <string> list = new List <string>(); var students = db.Students.Where(x => x.Status == 1).ToList(); foreach (var i in students) { list.Add(i.RegisterationNumber); } list.Sort(); ViewBag.list = new SelectList(list); return(View()); }
public ActionResult RequestHostel(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); HostelRequest request = new HostelRequest(); request.HostelId = id; request.StudentId = LoginClass.LoginId; db.HostelRequests.Add(request); db.SaveChanges(); string message = "Hostel Requested!"; return(RedirectToAction("Account", "Student", new { Message = message })); }
public ActionResult SLeaveRequests(LeaveViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); LeavesRequest request = new LeavesRequest(); request.Reason = collection.Reason; request.Date = DateTime.Now; request.StudentId = LoginClass.LoginId; db.LeavesRequests.Add(request); db.SaveChanges(); return(View()); }