//Previous Code //public ActionResult Students_Subject_Details(string id) //Subject and Course Details //{ // List<string> studentsDetails = studentModel.StudentDegreeDetail_StudentModel(id); // List<string> subjectNames = studentModel.getAllSubjectNames(id); // ViewBag.degreeName = studentsDetails.Last(); // studentsDetails.RemoveAt(2); // ViewBag.subjects = subjectNames; // ViewBag.student_Details = studentsDetails; // return View(); //} #endregion #region Student Personal // GET: Student //[OutputCache(Duration = 60)] public ActionResult Index() { try { string id = Session["rollno"].ToString(); Student_Profile l = r.Registerations .Where(s => s.Rollno == id).Select(s => s.Student_Profile).FirstOrDefault(); Registeration reg = r.Registerations .Where(s => s.Rollno == id && s.Status.Value == 1).Select(s => s).FirstOrDefault(); IEnumerable <Assign_Subject> assignSubjList = r.Assign_Subject .Where(s => s.Rollno == id && s.Registeration.Status.Value == 1).Select(s => s).ToList(); ViewModelStudentProReg vmProReg = new ViewModelStudentProReg { stdProfile = l, stdRegisteration = reg , AssignedSubjects = assignSubjList }; return(View(vmProReg)); } catch (Exception) { ViewModelStudentProReg vm = new ViewModelStudentProReg { stdProfile = new Student_Profile(), stdRegisteration = new Registeration(), AssignedSubjects = new List <Assign_Subject>() }; return(View(vm)); } } //Profile
public ActionResult History() { var schooldata = context.ApplyColleges.Select(a => a).ToList(); ViewData["History"] = schooldata; List <ApplyCollege> history = new List <ApplyCollege>(); Student_Profile student = Session["StudentProfile"] as Student_Profile; var x = schooldata.Count(); for (int i = 0; i < x; i++) { if (schooldata.ElementAtOrDefault(i).StudentId == student.StudentId) { ApplyCollege his = new ApplyCollege(); his.ApplyCollegeId = schooldata.ElementAtOrDefault(i).ApplyCollegeId; his.StudentId = schooldata.ElementAtOrDefault(i).StudentId; his.SchoolName = schooldata.ElementAtOrDefault(i).SchoolName; his.CollegeEmail = schooldata.ElementAtOrDefault(i).CollegeEmail; his.CourseApplied = schooldata.ElementAtOrDefault(i).CourseApplied; his.Semester = schooldata.ElementAtOrDefault(i).Semester; his.DateApplied = schooldata.ElementAtOrDefault(i).DateApplied; history.Add(his); } } return(View(history)); }
public ActionResult DeleteConfirmed(int id) { Student_Profile student_profile = db.Student_Profile.Find(id); db.Student_Profile.Remove(student_profile); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /Student_Profile/Details/5 public ActionResult Details(int id = 0) { Student_Profile student_profile = db.Student_Profile.Find(id); if (student_profile == null) { return(HttpNotFound()); } return(View(student_profile)); }
public ActionResult Edit(Student_Profile student_profile) { if (ModelState.IsValid) { db.Entry(student_profile).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.School_ID = new SelectList(db.School_Profile, "School_ID", "SchoolAdmin_username", student_profile.School_ID); return(View(student_profile)); }
// // GET: /Student_Profile/Edit/5 public ActionResult Edit(int id = 0) { Student_Profile student_profile = db.Student_Profile.Find(id); if (student_profile == null) { return(HttpNotFound()); } ViewBag.School_ID = new SelectList(db.School_Profile, "School_ID", "SchoolAdmin_username", student_profile.School_ID); return(View(student_profile)); }
public ActionResult ApplyCollege() { var schooldata = context.SchoolDatas.Select(a => a).ToList(); ViewData["SchoolName"] = schooldata; ApplyCollege data = new ApplyCollege(); Student_Profile student = Session["StudentProfile"] as Student_Profile; data.StudentId = student.StudentId; return(View(data)); }
public ActionResult Create(Student_Profile student_profile) { if (ModelState.IsValid) { db.Student_Profile.Add(student_profile); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.School_ID = new SelectList(db.School_Profile, "School_ID", "SchoolAdmin_username", student_profile.School_ID); return(View(student_profile)); }
public ActionResult CreateProfile() { Student_Profile student = Session["StudentProfile"] as Student_Profile; // ViewBag.Studentprofile = ""; if (student != null) { var studentdata = context.Student_Profile.Where(a => a.StudentId == student.StudentId).Select(a => a).FirstOrDefault(); // string[] dob = studentdata.DateOfBirth.ToString().Split(' '); // studentdata.DateOfBirth = dob[0].Date; return(View(studentdata)); } else { return(RedirectToAction("Index")); } }
public void addNewStudent() { if (Page.IsValid) { try { // Retrieve controls TextBox studId = registerStudentForm.FindControl("studId") as TextBox; TextBox password = registerStudentForm.FindControl("password_confirmation") as TextBox; TextBox email = registerStudentForm.FindControl("email") as TextBox; DropDownList programme = registerStudentForm.FindControl("programme") as DropDownList; // First create the user membership MembershipUser newStudent = Membership.CreateUser(studId.Text, password.Text, email.Text); Roles.AddUserToRole(studId.Text, "Student"); // Create the student profile Student_Profile student = new Student_Profile(); student.Id = (Guid)newStudent.ProviderUserKey; TryUpdateModel(student); if (ModelState.IsValid) { // Connect to database to add new staff profile using (OnlineAssessmentDBEntities db = new OnlineAssessmentDBEntities()) { // Create the enrollment records for the new student Enrollment newEnrollment = new Enrollment(); newEnrollment.Id = Guid.NewGuid(); newEnrollment.studId = student.Id; newEnrollment.progId = Guid.Parse(programme.SelectedItem.Value); newEnrollment.enrollmentDateTime = DateTime.Now; // Add the new staff and save it db.Enrollment.Add(newEnrollment); db.Student_Profile.Add(student); db.SaveChanges(); // Set the text to new staff ID newStudID.Text = studId.Text; // Show success label & hide failure label alertSuccess.Visible = true; alertFailure.Visible = false; } } } catch (MembershipCreateUserException ex) { // Match exception code with status code from MembershipCreateStatus class switch (ex.StatusCode) { case MembershipCreateStatus.DuplicateUserName: alertFailureMsg.Text = "There already exists a user with this username."; break; case MembershipCreateStatus.DuplicateEmail: alertFailureMsg.Text = "There already exists a user with this email address."; break; case MembershipCreateStatus.InvalidEmail: alertFailureMsg.Text = "There email address you provided in invalid."; break; case MembershipCreateStatus.InvalidPassword: alertFailureMsg.Text = "The password you provided is invalid. It must be seven characters long and have at least one non-alphanumeric character."; break; default: alertFailureMsg.Text = "There was an unknown error; the user account was NOT created."; break; } // Show failure message alertSuccess.Visible = false; alertFailure.Visible = true; } catch (Exception ex) { // Show failure message alertFailureMsg.Text = "Oops! There was a problem occurred when registering the new student."; alertSuccess.Visible = false; alertFailure.Visible = true; } } }
public ActionResult ApplyCollege(ApplyCollege AppliedCollege, FormCollection form1) { AppliedCollege.DateApplied = DateTime.Now; context.Entry(AppliedCollege).State = System.Data.EntityState.Added; context.SaveChanges(); var Filepath = Server.MapPath("pdf") + "\\" + "First PDF document.pdf"; var Filepath2 = Server.MapPath("pdf") + "\\"; //Process for creating pdf Student_Profile student = Session["StudentProfile"] as Student_Profile; string[] filescollection = Directory.GetFiles(Filepath2, "First PDF document.pdf", SearchOption.AllDirectories); foreach (var item1 in filescollection) { System.IO.File.Delete(item1); } System.IO.FileStream fs = new FileStream(Filepath, FileMode.Create); var doc1 = new Document(); PdfWriter writer = PdfWriter.GetInstance(doc1, fs); doc1.Open(); doc1.Add(new Paragraph("STUDENT APPLICATION FORM ")); PdfPTable table = new PdfPTable(2); PdfPCell cell = new PdfPCell(new Phrase("Student Data")); cell.Colspan = 2; cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right table.AddCell(cell); table.AddCell("First Name"); table.AddCell(student.FirstName); table.AddCell(" Middle Name"); table.AddCell(student.MiddleName); table.AddCell("Last Name"); table.AddCell(student.LastName); table.AddCell("Phone Number"); table.AddCell(student.PhoneNumber); table.AddCell("DateofBirth "); table.AddCell(student.DateOfBirth.Value.ToShortDateString()); table.AddCell("Gender "); table.AddCell(student.Gender); table.AddCell("SSN"); table.AddCell(student.SSN); table.AddCell("Email"); table.AddCell(student.Email); table.AddCell("Country of Birth"); table.AddCell(student.CountryofBirth); PdfPCell cell1 = new PdfPCell(new Phrase("Address Informtion")); cell1.Colspan = 2; cell1.HorizontalAlignment = 1; table.AddCell(cell1); table.AddCell("Street Address"); table.AddCell(student.AddressStudents.ElementAtOrDefault(0).AptStreet); table.AddCell("City"); table.AddCell(student.AddressStudents.ElementAtOrDefault(0).City); table.AddCell("State"); table.AddCell(student.AddressStudents.ElementAtOrDefault(0).State); table.AddCell("ZipCode"); table.AddCell(student.AddressStudents.ElementAtOrDefault(0).ZipCode); table.AddCell("Country"); table.AddCell(student.AddressStudents.ElementAtOrDefault(0).Country); table.AddCell("Address Type"); var x = student.AddressStudents.ElementAtOrDefault(0).Type; if (x == "1") { table.AddCell("Permanent"); } else { table.AddCell("Temporary"); } PdfPCell cell2 = new PdfPCell(new Phrase("Citizenship Informtion")); cell2.Colspan = 2; cell2.HorizontalAlignment = 1; table.AddCell(cell2); table.AddCell("Country of Citizenship"); table.AddCell(student.CitizenShipInfoes.ElementAtOrDefault(0).CountryOfCitizenship); table.AddCell("Ethnicity"); table.AddCell(student.CitizenShipInfoes.ElementAtOrDefault(0).Ethnicity); table.AddCell("I20 required "); table.AddCell(student.CitizenShipInfoes.ElementAtOrDefault(0).I20Required); table.AddCell("Visa Status "); table.AddCell(student.CitizenShipInfoes.ElementAtOrDefault(0).VisaStatus); table.AddCell("Current Location "); table.AddCell(student.CitizenShipInfoes.ElementAtOrDefault(0).CurrentLocation); table.AddCell("Vetran Status "); table.AddCell(student.CitizenShipInfoes.ElementAtOrDefault(0).VeteranStatus); PdfPCell cell3 = new PdfPCell(new Phrase("Information regarding course enrollement")); cell3.Colspan = 2; cell3.HorizontalAlignment = 1; table.AddCell(cell3); table.AddCell("Admission Type"); table.AddCell(student.AcademicInfoes.ElementAtOrDefault(0).AdmissionType); table.AddCell("Semester"); table.AddCell(student.AcademicInfoes.ElementAtOrDefault(0).Semester); table.AddCell("Application Year"); table.AddCell(student.AcademicInfoes.ElementAtOrDefault(0).ApplicationYear); table.AddCell("Major"); table.AddCell(student.AcademicInfoes.ElementAtOrDefault(0).Major); PdfPTable table4 = new PdfPTable(3); PdfPCell cell4 = new PdfPCell(new Phrase("Previous School information")); cell4.Colspan = 2; cell4.HorizontalAlignment = 1; table.AddCell(cell4); table.AddCell("Previous School Name"); table.AddCell(student.PreviousSchoolInfoes.ElementAtOrDefault(0).SchoolName); table.AddCell("Previous School Start Date"); table.AddCell(student.PreviousSchoolInfoes.ElementAtOrDefault(0).DateFrom.Value.ToShortDateString()); table.AddCell("Previous School End Date"); table.AddCell(student.PreviousSchoolInfoes.ElementAtOrDefault(0).DateTo.Value.ToShortDateString()); table.AddCell("Degree"); table.AddCell(student.PreviousSchoolInfoes.ElementAtOrDefault(0).DegreeName); table.AddCell("Major"); table.AddCell(student.PreviousSchoolInfoes.ElementAtOrDefault(0).Major); table.AddCell("School Address"); table.AddCell(student.PreviousSchoolInfoes.ElementAtOrDefault(0).Address); PdfPCell cell5 = new PdfPCell(new Phrase("Exam Information")); cell5.Colspan = 2; cell5.HorizontalAlignment = 1; table.AddCell(cell5); table.AddCell("GRE TAKEN ?"); var y = student.ExamInfoes.ElementAtOrDefault(0).ExamType; if (y == null) { table.AddCell("NO"); } else { table.AddCell("YES"); table.AddCell("GRE SCORE"); table.AddCell(student.ExamInfoes.ElementAtOrDefault(0).Score); table.AddCell("GRE DATE"); table.AddCell(student.ExamInfoes.ElementAtOrDefault(0).DateOfExam.Value.ToShortDateString()); } table.AddCell("TOEFL TAKEN ?"); var z = student.ExamInfoes.ElementAtOrDefault(1).ExamType; if (z == null) { table.AddCell("NO"); } else { table.AddCell("YES"); table.AddCell("TOEFL SCORE"); table.AddCell(student.ExamInfoes.ElementAtOrDefault(1).Score); table.AddCell("TOEFL DATE"); table.AddCell(student.ExamInfoes.ElementAtOrDefault(1).DateOfExam.Value.ToShortDateString()); } table.AddCell("IELTS TAKEN ?"); var p = student.ExamInfoes.ElementAtOrDefault(2).ExamType; if (p == null) { table.AddCell("NO"); } else { table.AddCell("YES"); table.AddCell("IELTS SCORE"); table.AddCell(student.ExamInfoes.ElementAtOrDefault(2).Score); table.AddCell("IELTS DATE"); table.AddCell(student.ExamInfoes.ElementAtOrDefault(2).DateOfExam.Value.ToShortDateString()); } PdfPCell cell6 = new PdfPCell(new Phrase("Work Experience")); cell6.Colspan = 2; cell6.HorizontalAlignment = 1; table.AddCell(cell6); table.AddCell("Work Experience"); var r = student.WorkInfoes.ElementAtOrDefault(0).CompanyName; if (r == null) { table.AddCell("NO"); } else { table.AddCell("YES"); table.AddCell("Company name"); table.AddCell(student.WorkInfoes.ElementAtOrDefault(0).CompanyName); table.AddCell("Start date"); table.AddCell(student.WorkInfoes.ElementAtOrDefault(0).FromDate.Value.ToShortDateString()); table.AddCell("End date"); table.AddCell(student.WorkInfoes.ElementAtOrDefault(0).ToDate.Value.ToShortDateString()); table.AddCell("Description"); table.AddCell(student.WorkInfoes.ElementAtOrDefault(0).Description); table.AddCell("Achievement"); table.AddCell(student.WorkInfoes.ElementAtOrDefault(0).Achievement); } doc1.Add(table); doc1.Close(); EmailHelper cs = new EmailHelper(); string result = cs.SendContactUsEmail(student.StudentId, 0, Filepath); //String Schoolemail = form1["CollegeEmail"].ToString(); //String Senderemail = "*****@*****.**"; return(RedirectToAction("StudentHomePage", new { str = "Your application has been submitted to" + AppliedCollege.SchoolName + " sucessfully!! " })); }
public ActionResult CreateProfile(Student_Profile NewStudentdata) { // var data = Request.Form["studentdata"]; // List<ResultAccoLoanDocAnsDto> documentCollection = new List<ResultAccoLoanDocAnsDto>(); try { List <HttpPostedFileBase> file = new List <HttpPostedFileBase>(); if (Request.Files.Count > 0) { // Get all files from Request object HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/"; //string filename = Path.GetFileName(Request.Files[i].FileName); file.Add(files[i]); } } var path2 = ""; string MaterialName = string.Empty; foreach (var item in file) { if (item.ContentLength > 0) { var studentfiledoc = new SupportingDoc(); studentfiledoc.mimeType = item.ContentType; Stream fileStream = item.InputStream; // string fileName = item.FileName; studentfiledoc.filelength = item.ContentLength.ToString(); byte[] fileData = new byte[item.ContentLength]; fileStream.Read(fileData, 0, item.ContentLength); studentfiledoc.TypeofDoc = item.FileName;//////////////////////////////////////////////////// //var new_path = "~/StudentDoc/"; //path2 = Path.Combine(Server.MapPath(new_path), NewStudentdata.StudentId+"_"+item.FileName); //item.SaveAs(path2); studentfiledoc.StudentId = NewStudentdata.StudentId; studentfiledoc.ServerURL = "~/StudentDoc/" + NewStudentdata.StudentId + "_" + item.FileName; // studentfiledoc.TypeofDoc = item.ContentLength; studentfiledoc.filecontent = fileData; context.Entry(studentfiledoc).State = System.Data.EntityState.Added; context.SaveChanges(); } } if (NewStudentdata.Filefordelete != null) { string[] filenumber = NewStudentdata.Filefordelete.Split('_'); var filestotal = context.SupportingDocs.Where(a => a.StudentId == NewStudentdata.StudentId).Select(a => a).ToList(); foreach (var item in filestotal) { for (int i = 1; i < filenumber.Length; i++) { if (filenumber[i] != "" || filenumber[i] != " ") { if (item.SupportingDocId == int.Parse(filenumber[i])) { context.Entry(item).State = System.Data.EntityState.Deleted; break; } } } } } NewStudentdata.Filefordelete = null; NewStudentdata.WorkInfoes.ElementAtOrDefault(0).Description = NewStudentdata.WorkInfoes.ElementAtOrDefault(0).Description.Trim(); NewStudentdata.WorkInfoes.ElementAtOrDefault(0).Achievement = NewStudentdata.WorkInfoes.ElementAtOrDefault(0).Achievement.Trim(); // var studentdataobj = JsonConvert.DeserializeObject<Student_Profile>(data); NewStudentdata.AddressStudents.ElementAtOrDefault(0).StudentId = NewStudentdata.StudentId; NewStudentdata.CitizenShipInfoes.ElementAtOrDefault(0).StudentId = NewStudentdata.StudentId; NewStudentdata.AcademicInfoes.ElementAtOrDefault(0).StudentId = NewStudentdata.StudentId; NewStudentdata.PreviousSchoolInfoes.ElementAtOrDefault(0).StudentId = NewStudentdata.StudentId; NewStudentdata.ExamInfoes.ElementAtOrDefault(0).StudentId = NewStudentdata.StudentId; NewStudentdata.ExamInfoes.ElementAtOrDefault(1).StudentId = NewStudentdata.StudentId; NewStudentdata.ExamInfoes.ElementAtOrDefault(2).StudentId = NewStudentdata.StudentId; NewStudentdata.WorkInfoes.ElementAtOrDefault(0).StudentId = NewStudentdata.StudentId; // context.Entry(NewStudentdata.AddressStudents.ElementAtOrDefault(0)).State = System.Data.EntityState.Modified; context.Entry(NewStudentdata).State = System.Data.EntityState.Modified; context.Entry(NewStudentdata.AddressStudents.ElementAtOrDefault(0)).State = System.Data.EntityState.Modified; context.Entry(NewStudentdata.CitizenShipInfoes.ElementAtOrDefault(0)).State = System.Data.EntityState.Modified; context.Entry(NewStudentdata.AcademicInfoes.ElementAtOrDefault(0)).State = System.Data.EntityState.Modified; context.Entry(NewStudentdata.PreviousSchoolInfoes.ElementAtOrDefault(0)).State = System.Data.EntityState.Modified; context.Entry(NewStudentdata.ExamInfoes.ElementAtOrDefault(0)).State = System.Data.EntityState.Modified; context.Entry(NewStudentdata.ExamInfoes.ElementAtOrDefault(1)).State = System.Data.EntityState.Modified; context.Entry(NewStudentdata.ExamInfoes.ElementAtOrDefault(2)).State = System.Data.EntityState.Modified; context.Entry(NewStudentdata.WorkInfoes.ElementAtOrDefault(0)).State = System.Data.EntityState.Modified; context.SaveChanges(); // string[] filenumber= NewStudentdata.Filefordelete.Split('_'); // filenumber[filenumber.Length] = "0"; // context.SaveChanges(); // return View(NewStudentdata); // return Json(NewStudentdata, JsonRequestBehavior.AllowGet); return(RedirectToAction("StudentHomePage", new { str = "Your Profile has been be created successfully" })); } catch (DbEntityValidationException dbEx) { StringBuilder str1 = new StringBuilder(); foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { str1.Append(validationErrors.Entry.Entity.GetType().FullName + " " + validationError.PropertyName + " " + validationError.ErrorMessage); } } ViewBag.msg = "Please enter all Fields "; } // ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; // Student_Profile student = Session["StudentProfile"] as Student_Profile; //var studentdata = context.Student_Profile.Where(a =>a.StudentId==student.StudentId).Select(a => a).FirstOrDefault(); // studentdata = NewStudentdata; // context.Student_Profile.(NewStudentdata); // var studentdata=context.Student_Profile.Select(a=>a); /*String firstname = ""; * String Middlename = ""; * String Lastname = ""; * String Phonenumber = ""; * DateTime date; * String Gender = ""; * String SSN = ""; * String COB = ""; * * * student.Firstname= firstname = form["fname"].ToString(); * student.MiddleName= Middlename = form["mname"].ToString(); * student.LastName= Lastname = form["lname"].ToString(); * student.PhoneNumber= Phonenumber = form["phname"].ToString(); * student.DateOfBirth= date = Convert.ToDateTime(form["DOB"].ToString()); * student.Gender= Gender = form["gender"].ToString(); * student.SSN= SSN = form["ssn"].ToString(); * student.CountryofBirth= COB = form["COB"].ToString(); * * * String cs = ConfigurationManager.ConnectionStrings["CEASYS"].ConnectionString; * using (SqlConnection con = new SqlConnection(cs)) * { * try * { * con.Open(); // Does the connection with database * //ViewBag.Message = "Connection is sucessful"; * var insertCommand = "UPDATE Student_Profile SET FirstName='" + firstname + "', MiddleName='" + Middlename + "', LastName='" + Lastname + "', PhoneNumber='" + Phonenumber + "', DateofBirth='" + date + "', Gender='" + Gender + "',SSN='" + SSN + "', CountryofBirth='" + COB + "' where Email='" + student.Email + "';"; * * using (SqlCommand cmd = new SqlCommand(insertCommand, con)) * { * cmd.ExecuteNonQuery(); * ViewBag.Studentprofile = "You data has been saved"; * } * * * } // end try * catch (Exception e) // catches the exception message * { * //ViewBag.Studentprofile = "Please try later!!"; * } // end catch * finally * { * con.Close(); //Closes the connection to database * }*/ return(View(NewStudentdata)); // } }