public ActionResult Edit(DAL.Student std) { var edit = _Bll.Edit(std); return(View(edit)); }
public ActionResult Create(Student student, HttpPostedFileBase upload) { var db = DAL.DbContext.Create(); if (ModelState.IsValid) { if (StudentValidate(student)) { if (upload != null && upload.ContentLength > 0) { using (var reader = new System.IO.BinaryReader(upload.InputStream)) { student.Image = reader.ReadBytes(upload.ContentLength); } var studentId = db.Students.Insert(student); if (studentId.HasValue && studentId.Value > 0) { return RedirectToAction("Index"); } else { return View(student); } } } } //ViewBag.Id = new SelectList(db.GetCourses().Distinct().ToList(), "Id", "CourseAbbv"); ViewBag.CourseID = new SelectList(db.Courses.All(), "Id", "CourseAbbv", student.CourseID); ViewBag.CollegeID = new SelectList(db.Colleges.All(), "Id", "CollegeName", student.CollegeID); return View(student); }
public List<Student> GetStudentList(int moduleID) { //gets list of students linked to a module List<Student> listStudents = null; SqlParameter[] paramaters = new SqlParameter[] { new SqlParameter("@ModuleID", moduleID), }; using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetStudentList", CommandType.StoredProcedure, paramaters)) { if (table.Rows.Count > 0) { listStudents = new List<Student>(); foreach (DataRow row in table.Rows) { Student student = new Student(); student.StudentID = Convert.ToInt32(row["StudentID"]); student.StudentNumber = row["StudentNumber"].ToString(); student.FirstName = row["FirstName"].ToString(); student.Surname = row["Surname"].ToString(); //student.TagID = Convert.ToDateTime(row["TagID"]); listStudents.Add(student); } } } return listStudents; }
public Student GetStudentID(string studentNumber) { Student student = null; SqlParameter[] paramaters = new SqlParameter[] { new SqlParameter("@StudentNumber", studentNumber), }; using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetStudentID", CommandType.StoredProcedure, paramaters)) { if (table.Rows.Count == 1) { DataRow row = table.Rows[0]; student = new Student(); student.StudentID = Convert.ToInt32(row["StudentID"]); student.StudentNumber = row["StudentNumber"].ToString(); student.FirstName = row["FirstName"].ToString(); student.Surname = row["Surname"].ToString(); //student.ModuleID = Convert.ToInt32(row["ModuleID"]); student.TagID = row["TagID"].ToString(); } } return student; }
static void Main(string[] args) { Console.WriteLine("Hello DbConnector"); DAL.Student s1 = new DAL.Student("Moshe ", "Cohen ", "0123 "); s1.PrintTo(); StudentDB studentdb = new StudentDB(); Console.WriteLine(studentdb.AddNewStudent(s1)); Console.ReadKey(); }
public DAL.Student GetModel(StdDTOcs std) { DAL.Student obj = new DAL.Student(); obj.StudentId = std.studentid; obj.FirstName = std.firstnm; obj.LastName = std.lastnm; obj.MobileNo = std.mob; obj.Gender = std.gender; obj.State = std.state; obj.City = std.city; return(obj); }
public bool AddNewStudent(Student student) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@StudentNumber", student.StudentNumber), new SqlParameter("@FirstName", student.FirstName), new SqlParameter("@Surname", student.Surname), new SqlParameter("@ModuleID", student.ModuleID) }; return DBHelper.ExecuteNonQuery("sp_AddNewStudent", CommandType.StoredProcedure, parameters); }
private bool StudentValidate(Student student) { var db = DAL.DbContext.Create(); var existStudent = db.Students.All().FirstOrDefault(s => s.StudentID == student.StudentID); var existEPC = db.Students.All().FirstOrDefault(s => s.EPC == student.EPC); var isValid = true; //validate student no if (existStudent != null) { isValid = false; ModelState.AddModelError("", "Unable to save changes. Student Number already exist."); } //validate EPC if (existEPC != null) { isValid = false; ModelState.AddModelError("", "Unable to save changes. EPC already exist."); } return isValid; }
public ActionResult Add(DAL.Student std) { var Result = _Bll.Add(std); return(View(std)); }
private void DisplayStudentInfo(Student student) { var db = DAL.DbContext.Create(); //get course var stud = db.Students.Get(student.Id); stud.Course = db.Courses.Get(stud.CourseID); stud.College = db.Colleges.Get(stud.CollegeID); if (this.InvokeRequired) { this.Invoke(new Action<Student>(DisplayStudentInfo), stud); return; } //display data Error.Text = ""; StudID.Text = stud.StudentID.ToString(); LName.Text = stud.LastName.ToString(); FName.Text = stud.FirstName.ToString(); MName.Text = stud.MidName.ToString(); CAbbv.Text = stud.Course.CourseAbbv.ToString(); labelCollege.Text = stud.College.CollegeName.ToString(); if(stud.Message != null) { Message.Text = stud.Message.ToString(); } else { Message.Text = ""; } //display image image.Image = byteArrayToImage(stud.Image); }
private bool ValidateEnrollmentDate(Student student, SemSchoolYear semschoolyear) { var db = DAL.DbContext.Create(); DateTime? a = student.EnrollmentDate; DateTime? b = semschoolyear.EnrollmentDateStart; DateTime? c = semschoolyear.SemesterDateEnd; if (a >= b && a <= c) { return true; } return false; }