public ActionResult StudentRegister(RegisterStudent regStu) { if (ModelState.IsValid) { if (!db.tbl_Student.Any(x => x.Student_Email == regStu.Student_Email)) { tbl_Student stu = new tbl_Student(); stu.Student_Name = regStu.Student_Name; stu.Student_Email = regStu.Student_Email; stu.Student_Phone = regStu.Student_Phone; stu.Student_Password = regStu.Password; stu.Student_CreatedOn = DateTime.Now; stu.Level_Id = regStu.Level_Id; stu.Department_Id = regStu.Department_ID; stu.IsDeleted = false; db.tbl_Student.Add(stu); db.SaveChanges(); return(RedirectToAction("StudentLogin")); } else { ViewBag.mssg = "هذا الحساب موجود بالفعل"; List <tbl_Level> levlist = db.tbl_Level.ToList(); List <tbl_Department> Deplist = db.tbl_Department.ToList(); ViewData["Levels"] = new SelectList(levlist, "Level_Id", "Level_Name"); ViewData["Departments"] = new SelectList(Deplist, "Department_Id", "Department_Name"); } } return(View(regStu)); }
private void button1_Click(object sender, EventArgs e) { pmsstoreEntities entties = new pmsstoreEntities(); foreach (var j in this.checkedListBox1.CheckedItems) { tbl_Student studentItem = (tbl_Student)j; tbl_CSLecturer lecturerItem = (tbl_CSLecturer)this.listBox1.SelectedItem; int sessionId = Convert.ToInt32(this.comboBox1.SelectedValue); //check if the student has been allocated to any lecturer before in selected session var queryCheck = (from p in entties.tbl_Allocation where p.StudentID == studentItem.GUID && p.SessionID == sessionId select p).FirstOrDefault(); if (queryCheck != null) { //this student is already assigned to this or another lecturer this session, therefore continue to the next student continue; } tbl_Allocation allocation = new tbl_Allocation(); allocation.DateAllocated = DateTime.Now; allocation.LecturerID = lecturerItem.GUID; allocation.SessionID = Convert.ToInt32(this.comboBox1.SelectedValue); allocation.StudentID = studentItem.GUID; entties.tbl_Allocation.Add(allocation); } entties.SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { tbl_Student tbl_Student = db.tbl_Student.Find(id); db.tbl_Student.Remove(tbl_Student); db.SaveChanges(); return RedirectToAction("Index"); }
public IHttpActionResult Puttbl_Student(int id, tbl_Student tbl_Student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbl_Student.StudentID) { return(BadRequest()); } db.Entry(tbl_Student).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tbl_StudentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void DeleteStudent(int id) { tbl_Student st = DbContext.Student.Find(id); DbContext.Entry(st).State = System.Data.Entity.EntityState.Deleted; DbContext.SaveChanges(); }
public ActionResult Edit(tbl_Student std) { var d = Context.tbl_Student.Where(x => x.StudentID == std.StudentID).FirstOrDefault(); d.StudentID = std.StudentID; d.FirstName = std.FirstName; d.LastName = std.LastName; d.FatherName = std.FatherName; d.DateofBirth = Convert.ToDateTime(Session["DOB"]); d.Password = Convert.ToString(Session["Password"]); d.GraduationID = std.GraduationID; d.Percentage = std.Percentage; d.Contact = std.Contact; d.Email = std.Email; d.City = std.City; if (TryUpdateModel(d)) { Context.SaveChanges(); ModelState.Clear(); return(RedirectToAction("PersonalInfo")); } ViewBag.GraduationID = new SelectList(Context.tbl_Graduation, "GraduationID", "GraduationName", std.GraduationID); return(View()); }
public ActionResult AddStudent(tbl_Student model) { if (ModelState.IsValid) { tbl_Student obj = new tbl_Student(); obj.Name = model.Name; obj.Fname = model.Fname; obj.Email = model.Email; obj.Mobile = model.Mobile; obj.Description = model.Description; if (model.ID == 0) { dbObj.tbl_Student.Add(obj); dbObj.SaveChanges(); } else { dbObj.tbl_Student.Add(obj); dbObj.SaveChanges(); } } ModelState.Clear(); return(View("Student")); }
public ActionResult AddStudent(tbl_Student model) { tbl_Student obj = new tbl_Student(); //驗證都為正確 if (ModelState.IsValid) { obj.ID = model.ID; obj.Name = model.Name; obj.Fname = model.Fname; obj.Email = model.Email; obj.Mobile = model.Mobile; obj.Description = model.Description; if (model.ID == 0) { //新增資料 dbObj.tbl_Student.Add(obj); dbObj.SaveChanges(); } else { dbObj.Entry(obj).State = EntityState.Modified; dbObj.SaveChanges(); } } //清空欄位值 ModelState.Clear(); return(View("Student")); }
public Student(tbl_Student s) { ID = s.User_ID; University = s.University; University_ID = s.University_ID; GPA = (double)s.GPA; }
public ActionResult Create(ModelStudent model,string CaptchaText) { if (ModelState.IsValid) { if (Session["CaptchaImageText"]!=null) { if (Session["CaptchaImageText"].ToString() == CaptchaText) { ViewBag.Message = "Catcha Validation Success!"; try { tbl_Student _student = new tbl_Student(); _student.Password = model.Password; _student.StudentId = model.StudentId; _student.Activation = false; _student.ConformPassword = model.ConformPassword; _student.FirstName = model.FirstName; _student.LastName = model.LastName; _student.email_address = model.email_address; _student.ProgramId = model.ProgramId; db.tbl_Student.Add(_student); if (db.SaveChanges() > 0) { ViewBag.Message = "We have created your account. Please contact library to activate."; ModelState.Clear(); } } catch (Exception e) { ViewBag.Message =e.Message; } //tbl_Student.Activation = false; //db.tbl_Student.Add(tbl_Student); //db.SaveChanges(); //tbl_Student=new tbl_Student(); } else { ViewBag.Message = "Catcha Validation Failed!"; } } var ProgramList = new SelectDropDownListManager().GetProgramlist().ToList(); ViewBag.Program = ProgramList; } return View("Create"); }
public ActionResult Edit([Bind(Include = "StudentId,FirstName,LastName,DateJoin,DateReleave,StudentClassId,RollNumber,ParentId,DateAdded,AddedBy,DateModified,ModifiedBy,Active")] tbl_Student tbl_Student) { if (ModelState.IsValid) { db.Entry(tbl_Student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_Student)); }
public ActionResult Delete(int id) { using (TestDBEntities db = new TestDBEntities()) { tbl_Student emp = db.tbl_Student.Where(x => x.Id == id).FirstOrDefault <tbl_Student>(); db.tbl_Student.Remove(emp); db.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully", JsonRequestBehavior.AllowGet })); } }
public ActionResult RegStudent(ModelStudent model, string CaptchaText) { if (ModelState.IsValid) { if (Session["CaptchaImageText"] != null) { if (Session["CaptchaImageText"].ToString() == CaptchaText) { ViewBag.Message = "Catcha Validation Success!"; try { tbl_Student _student = new tbl_Student(); _student.Password = model.Password; _student.StudentId = model.StudentId; _student.Activation = false; _student.ConformPassword = model.ConformPassword; _student.FirstName = model.FirstName; _student.LastName = model.LastName; _student.email_address = model.email_address; _student.ProgramId = model.ProgramId; db.tbl_Student.Add(_student); if (db.SaveChanges() > 0) { ViewBag.Message = "Your registration is successfully completed . after sometimes later you can login when activate your account "; ModelState.Clear(); } } catch (Exception e) { ViewBag.Message = e.Message; } //tbl_Student.Activation = false; //db.tbl_Student.Add(tbl_Student); //db.SaveChanges(); //tbl_Student=new tbl_Student(); } else { ViewBag.Message = "Catcha Validation Failed!"; } } var ProgramList = new SelectDropDownListManager().GetProgramlist().ToList(); ViewBag.Program = ProgramList; } return PartialView("RegStudent"); }
public IHttpActionResult Gettbl_Student(int id) { tbl_Student tbl_Student = db.tbl_Student.Find(id); if (tbl_Student == null) { return(NotFound()); } return(Ok(tbl_Student)); }
public ActionResult Edit([Bind(Include = "Id,StudentId,FirstName,LastName,email_address,Password,Activation")] tbl_Student tbl_Student) { if (ModelState.IsValid) { db.Entry(tbl_Student).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(tbl_Student); }
public ActionResult Edit2([Bind(Include = "JobID,CompanyName,Details,Designation,LocationID,Number_of_Positions")] tbl_Student job) { if (ModelState.IsValid) { db.Entry(job).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GraduationID = new SelectList(db.tbl_Graduation, "GraduationID", "GraduationName", job.GraduationID); return(View(job)); }
public ActionResult Edit([Bind(Include = "FirstName,LastName,FatherName,GraduationID,Percentage,Contact,City")] tbl_Student tbl_Student) { //if (ModelState.IsValid) //{ db.Entry(tbl_Student).State = EntityState.Modified; //tbl_Student.GraduationID = 1; db.SaveChanges(); return(RedirectToAction("Index")); //} //ViewBag.GraduationID = new SelectList(db.tbl_Graduation, "GraduationID", "GraduationName", tbl_Student.GraduationID); //return View(tbl_Student); }
private void btnSave_Click(object sender, EventArgs e) { var student = new tbl_Student(); student.studentName = txtStudentName.Text; student.studentSurname = txtStudentSurname.Text; db.tbl_Student.Add(student); db.SaveChanges(); MessageBox.Show("Öğrenci Listeye Eklenmiştir."); rmvStudentTxt(); dgvRefreshListing(); }
public IHttpActionResult Posttbl_Student(tbl_Student tbl_Student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tbl_Student.Add(tbl_Student); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tbl_Student.StudentID }, tbl_Student)); }
public ActionResult Edit(int?id) { var result = Context.tbl_Student.SingleOrDefault(a => a.StudentID == id); Session["Password"] = result.Password; Session["DOB"] = result.DateofBirth; tbl_Student std = new tbl_Student(); ViewBag.GraduationID = new SelectList(Context.tbl_Graduation, "GraduationID", "GraduationName"); std = Context.tbl_Student.Find(id); return(View(std)); }
// GET: Std/Details/5 public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } tbl_Student tbl_Student = db.tbl_Student.Find(id); if (tbl_Student == null) { return HttpNotFound(); } return View(tbl_Student); }
public ActionResult PersonalInfo() { int a = Convert.ToInt32(Session["StudentID"]); tbl_Student user = Context.tbl_Student.Find(a); if (user == null) { return(HttpNotFound()); } return(View(user)); }
public IHttpActionResult Deletetbl_Student(int id) { tbl_Student tbl_Student = db.tbl_Student.Find(id); if (tbl_Student == null) { return(NotFound()); } db.tbl_Student.Remove(tbl_Student); db.SaveChanges(); return(Ok(tbl_Student)); }
// GET: Student/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbl_Student tbl_Student = db.Student.Find(id); if (tbl_Student == null) { return(HttpNotFound()); } return(View(tbl_Student)); }
public ActionResult AddStudent(tbl_Student model) { tbl_Student student = new tbl_Student(); student.Name = model.Name; student.Fname = model.Fname; student.Email = model.Email; student.Mobile = model.Mobile; student.Description = model.Description; dbObj.tbl_Student.Add(student); dbObj.SaveChanges(); ModelState.Clear(); return(View("Stduent")); }
public ActionResult Edit(int?id) { if (id == null) { return(View("NotFound")); } tbl_Student tbl_Student = db.tbl_Student.Find(id); if (tbl_Student == null) { return(View("NotFound")); } ViewBag.GraduationID = new SelectList(db.tbl_Graduation, "GraduationID", "GraduationName", tbl_Student.GraduationID); return(View(tbl_Student)); }
public new void Add() { base.Add(); LibraryDBDataContext db = new LibraryDBDataContext(); tbl_Student s = new tbl_Student(); s.User_ID = base.ID; s.University = University; s.University_ID = University_ID; s.GPA = GPA; db.tbl_Students.InsertOnSubmit(s); db.SubmitChanges(); }
public ActionResult MyAccount() { int a = Convert.ToInt32(Session["StudentID"]); using (StudentRepositoryEntities1 db = new StudentRepositoryEntities1()) { tbl_Student std = db.tbl_Student.Find(a); if (std == null) { return(View("Details not Found")); } return(View()); } }
// GET: Jobs/Edit/5 public ActionResult Edit2(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbl_Student job = db.tbl_Student.Find(id); if (job == null) { return(HttpNotFound()); } ViewBag.GraduationID = new SelectList(db.tbl_Graduation, "GraduationID", "GraduationName", job.GraduationID); return(View(job)); }
public ActionResult DeleteMe([Bind(Exclude = ("Student_Name,Student_Email,Student_Password,Student_Phone,Level_Id,Department_Id"))] tbl_Student EdStu) { if (Session["Studnet_Id"] == null || Session["Studnet_Name"] == null) { return(RedirectToAction("StudentLogin", "Home")); } else { int id = (int)TempData["StudentId"]; var Stu = db.tbl_Student.Where(a => a.Student_Id == id).FirstOrDefault(); Stu.IsDeleted = true; db.Entry(Stu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Home")); } }