public ActionResult Edit(tbl_student t, StudentViewModel obj, HttpPostedFileBase imgfile) { string s = uploadimgfile(imgfile); t.applicant_name = obj.applicant_name; t.father_name = obj.father_name; t.father_occupation = obj.father_occupation; t.home_address = obj.home_address; t.email = obj.email; t.father_student_Cnic = obj.father_student_Cnic; t.cell = obj.cell; t.name_of_college = obj.name_of_college; t.stu_image = obj.stu_image = s; t.groupp = obj.groupp; t.date_of_admission = obj.date_of_admission; t.date_of_payment = obj.date_of_payment; t.class_fk_id = obj.class_fk_id; t.suubject_fk_id = obj.suubject_fk_id; db.tbl_student.Add(t); db.Entry(t).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); return(View()); }
public ActionResult Edit(int?id) { List <tbl_class> Class = db.tbl_class.ToList(); ViewBag.listclass = new SelectList(Class, "class_id", "class_name"); List <tbl_subject> studentclass = db.tbl_subject.ToList(); ViewBag.listsubject = new SelectList(studentclass, "sub_id", "sub_name"); if (id == null) { return(RedirectToAction("Index")); } tbl_student t = db.tbl_student.Where(x => x.stu_id == id).SingleOrDefault(); if (t == null) { return(HttpNotFound()); } return(View(t)); }
private void btn_submit_Click_1(object sender, RoutedEventArgs e) { ObservableCollection <ui_student> custdata; custdata = (ObservableCollection <ui_student>)dg_student.DataContext; int i = 0; foreach (ui_student ss in custdata) { if (ss.Delete == true) { Student.delete(Student.get_single_student(ss.Num)); } if (ss.Update == true) { tbl_student student_update = Student.get_single_student(tablebefore[i].Num); try { student_update.S_Num = ss.Num; student_update.S_Name = ss.Name; student_update.S_Gender = ss.Gender; student_update.S_Birthday = Convert.ToDateTime(ss.Birthday); student_update.S_Department = ss.Department; student_update.S_ClassID = obj_Class.get_classid(ss.className); } catch (Exception ex) { ModernDialog.ShowMessage("Some important data may be change unsuccessful \nsystem message:" + ex.Message + MainWindow.loginuser.U_Power, "User Input ERROR", MessageBoxButton.OK); } Student.update(student_update); } i++; } loadtable(); }
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")); }
private void Button_Click_1(object sender, RoutedEventArgs e) { try { string faileddata = ""; string data = tb_student.Text; data = data.Replace("\r\n", "\n"); string[] students = data.Split('\n'); foreach (var student in students) { string[] atts = student.Split(','); tbl_student ss = new tbl_student(); ss.S_Num = atts[0]; ss.S_Name = atts[1]; ss.S_Gender = atts[2]; ss.S_Birthday = Convert.ToDateTime(atts[3]); ss.S_Department = atts[4]; ss.S_ClassID = obj_Class.get_classid(atts[5]); Err eee = Student.add(ss); if (eee.res == false) { faileddata += student + "\n"; } } ModernDialog.ShowMessage("then the box will show the add failed student", "Operation finished", MessageBoxButton.OK); tb_student.Text = faileddata; } catch (Exception ex) { ModernDialog.ShowMessage("Input data error" + MainWindow.loginuser.U_Power, "Input error", MessageBoxButton.OK); } }
// GET: Student public ActionResult Student(tbl_student obj) { //if (obj != null) //{ // return View(obj); //} //else { return View(); } return(View(obj)); }
public IHttpActionResult Post(tbl_student tutor) { hivetutEntities db = new hivetutEntities(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tbl_student.Add(tutor); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tutor.id }, tutor)); }
public ActionResult AddStudent(tbl_student model) { tbl_student obj = new tbl_student(); obj.Name = model.Name; obj.Email = model.Email; obj.Address = model.Address; dbObj.tbl_student.Add(obj); dbObj.SaveChanges(); return(View("Student")); }
public object DeleteSingleStudent(ParamRegistration PR) { try { tbl_user objuser = db.tbl_user.Where(r => r.UserId == PR.UserId).FirstOrDefault(); if (objuser.Display == 1) { objuser.Display = 0; } else { objuser.Display = 1; } db.SaveChanges(); if (PR.Type == "Student") { tbl_student objstudent = db.tbl_student.Where(r => r.UserId == PR.UserId).FirstOrDefault(); if (objstudent.Display == 1) { objstudent.Display = 0; } else { objstudent.Display = 1; } db.SaveChanges(); } return(new Result() { IsSucess = true, ResultData = "User Deleted Successfully." }); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }
/// <summary> /// add a student to database /// </summary> /// <param name="ss">input student</param> /// <returns>error information</returns> public static Err add(tbl_student ss) { Err e = new Err(); try { var db = new DataBase(); db.tbl_student.AddObject(ss); db.SaveChanges(); return(e); } catch (Exception ex) { e.res = false; e.info = ex.Message; return(e); } }
/// <summary> /// delete a object /// </summary> /// <param name="ss">input a student</param> /// <returns>error information</returns> public static Err delete(tbl_student ss) { Err e = new Err(); try { var db = new DataBase(); var before = (from d in db.tbl_student where d.S_index == ss.S_index select d).Single(); db.DeleteObject(before); db.SaveChanges(); } catch (Exception ex) { e.res = false; e.info = ex.Message; } return(e); }
public object UpdateStudent(ParamRegistration PR) { try { tbl_user objuser = db.tbl_user.Where(r => r.UserId == PR.UserId).FirstOrDefault(); objuser.name = PR.Name; objuser.type = PR.Type; objuser.gender = PR.Gender; objuser.email = PR.Email; objuser.contact = PR.Contact; objuser.modified_date = DateTime.Now; objuser.status = 1; objuser.Islive = 1; db.SaveChanges(); if (PR.Type == "Student") { tbl_student objstudent = db.tbl_student.Where(r => r.UserId == PR.UserId).FirstOrDefault(); objstudent.IsParent = 0; objstudent.modified_date = DateTime.Now; db.SaveChanges(); } return(new Result() { IsSucess = true, ResultData = "User Saved Successfully." }); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }
public ActionResult AddStudent(tbl_student s, Email e) { try { Student st = new Student(); st.Email = s.Email; e.Email1 = s.Email; st.Name = s.Name; st.Registration_Number = s.Registration_Number; LMSEntities db = new LMSEntities(); db.tbl_student.Add(s); db.Emails.Add(e); db.SaveChanges(); return(RedirectToAction("Student")); } catch { return(View()); } }
public HttpResponseMessage Put(string email, [FromBody] tbl_student tutor) { try { using (tutorEntities entities = new tutorEntities()) { var entity = entities.tbl_student.FirstOrDefault(t => t.Email == email); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Student with email=" + email.ToString() + "not found to be updated")); } else { entity.City = tutor.City; entity.Class = tutor.Class; entity.Description = tutor.Description; entity.Subjects = tutor.Subjects; entity.Name = tutor.Name; entity.Gender = tutor.Gender; entity.Email = tutor.Email; entity.Address = tutor.Address; entity.Dob = tutor.Dob; entity.image = tutor.image; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Student with email=" + email.ToString() + " has been successfuly updated")); } } } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e)); } }
public ActionResult getStudentRecors(attendenceviewmodel uvm) { List <tbl_class> li = db.tbl_class.ToList(); ViewBag.list = new SelectList(li, "class_id", "class_name"); tbl_student s = new tbl_student(); List <tbl_student> t = db.tbl_student.Where(x => x.class_fk_id == uvm.Class_id).ToList(); Session["id"] = uvm.Class_id; Session["Date"] = uvm.currentDate; List <string> listdata = new List <string>(); foreach (var item in t) { listdata.Add(item.stu_id.ToString()); listdata.Add(item.applicant_name); } ViewBag.listone = t; return(View()); }
public ActionResult AddStudent(StudentViewModel obj, HttpPostedFileBase imgfile) { try { string s = uploadimgfile(imgfile); if (s.Equals("-1")) { Response.Write("<script>alert('image upload failed...') <script>"); } else { tbl_student t = new tbl_student(); t.applicant_name = obj.applicant_name; t.father_name = obj.father_name; t.father_occupation = obj.father_occupation; t.home_address = obj.home_address; t.email = obj.email; t.father_student_Cnic = obj.father_student_Cnic; t.cell = obj.cell; t.name_of_college = obj.name_of_college; t.stu_image = obj.stu_image = s; t.groupp = obj.groupp; t.date_of_admission = obj.date_of_admission; t.date_of_payment = obj.date_of_payment; t.class_fk_id = obj.class_fk_id; t.suubject_fk_id = obj.suubject_fk_id; db.tbl_student.Add(t); db.SaveChanges(); return(RedirectToAction("Create", "fee")); } } catch (Exception ex) { //throw; } return(View()); }
public object SaveRegistration(ParamRegistration PR) { try { var usercode = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault(); if (usercode != null) { return(new Error() { IsError = true, Message = "User Code Already Exists." }); } tbl_user objuser = new tbl_user(); objuser.name = PR.Name; objuser.UserId = PR.UserId; objuser.type = PR.Type; objuser.gender = PR.Gender; objuser.code = PR.code; objuser.email = PR.Email; objuser.contact = PR.Contact; string EncryptedPassword = CryptIt.Encrypt(PR.Password); objuser.password = EncryptedPassword; objuser.status = 1; objuser.Islive = 1; objuser.Display = 1; objuser.created_date = DateTime.Now; db.tbl_user.Add(objuser); db.SaveChanges(); if (PR.Type == "Student") { tbl_student objstudent = new tbl_student(); objstudent.UserId = PR.UserId; tbl_user obstudent = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault(); objstudent.UserId = obstudent.UserId; objstudent.code = PR.code; objstudent.course_name = PR.CourseName; objstudent.class_name = PR.ClassName; objstudent.IsParent = 0; objstudent.Display = 1; objstudent.created_date = DateTime.Now; db.tbl_student.Add(objstudent); db.SaveChanges(); } else if (PR.Type == "Faculty") { tbl_faculty objfaculty = new tbl_faculty(); objfaculty.UserId = PR.UserId; tbl_user obfaculty = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault(); objfaculty.UserId = obfaculty.UserId; objfaculty.code = PR.code; objfaculty.department = PR.CourseName; objfaculty.designation = PR.Designation; objfaculty.Display = 1; objfaculty.created_date = DateTime.Now; db.tbl_faculty.Add(objfaculty); db.SaveChanges(); } else if (PR.Type == "Parent") { tbl_parent objparent = new tbl_parent(); objparent.UserId = PR.UserId; objparent.relationship = PR.Relationship; tbl_user obstudent = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault(); objparent.UserId = obstudent.UserId; objparent.code = PR.code; objparent.Display = 1; objparent.created_date = DateTime.Now; db.tbl_parent.Add(objparent); db.SaveChanges(); //tbl_student objstudent = db.tbl_student.Where(r => r.UserId == PR.UserId).FirstOrDefault(); //objstudent.IsParent = 1; //db.SaveChanges(); } else if (PR.Type == "Staff") { tbl_staff objstaff = new tbl_staff(); objstaff.UserId = objuser.UserId; tbl_user obstaff = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault(); objstaff.UserId = objstaff.UserId; objstaff.code = PR.code; objstaff.department = PR.CourseName; objstaff.designation = PR.Designation; objstaff.Display = 1; objstaff.created_date = DateTime.Now; db.tbl_staff.Add(objstaff); db.SaveChanges(); } else { return(new Error() { IsError = true, Message = "User Type Not Matched." }); } return(new Result() { IsSucess = true, ResultData = "User Saved Successfully." }); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }
public ActionResult Student(tbl_student obj) { return(View(obj)); }
public object DeleteSingleStudent(ParamRegistration PR) { try { string res = ""; tbl_user objuser = db.tbl_user.Where(r => r.UserId == PR.UserId).FirstOrDefault(); if (objuser.Display == 1) { objuser.Display = 0; } else { objuser.Display = 1; } db.SaveChanges(); if (PR.Type == "Student") { tbl_student objstudent = db.tbl_student.Where(r => r.UserId == PR.UserId).FirstOrDefault(); if (objstudent.Display == 1) { objstudent.Display = 0; } else { objstudent.Display = 1; } db.SaveChanges(); if (objstudent.Display == 1) { if (objuser.name.Length > 0) { string appset = ConfigurationManager.AppSettings["BaseEmailUrl"]; res = " <b>Dear " + objuser.name + "</b>, Your account for griveance redressal system has been activated by the admin,<a href='" + appset + "'>click here</a> to login your account "; } try { Email objemail = new Email(); bool IsDelete; if (objuser.email.Length > 0) { //IsDelete = objSMS.SMSSend(MobNo, res); IsDelete = objemail.SendEmail(objuser.email, res, "Active Status", "", "", "", ""); } return(res); } catch (Exception e) { return(new Error() { IsError = true, Message = e.Message }); } } } return(new Result() { IsSucess = true, ResultData = "User Deleted Successfully." }); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }
public ActionResult Details(int?id) { tbl_student st = db.tbl_student.Find(id); return(View(st)); }