private void gridControlClass_MouseClick(object sender, MouseEventArgs e) { try { this.Cursor = Cursors.WaitCursor; int iClassId = 0; int.TryParse("" + gridViewClass.GetFocusedRowCellValue("Id"), out iClassId); if (iClassId > 0) { string sClassName = "" + gridViewClass.GetFocusedRowCellValue("ClassName"); //LoadData_Student_Of_Classes(iClassId); lookUpEditClass.EditValue = iClassId; mClasses.Id = string.IsNullOrEmpty("" + lookUpEditClass.EditValue) ? 0 : int.Parse("" + lookUpEditClass.EditValue); mClasses.ClassName = sClassName; StudentClasses obj = new StudentClasses() { ClassId = mClasses.Id }; LoadData_Student_Of_Classes(obj); } xtraTabControlClass.SelectedTabPage = xtraTabPageStudent; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Cursor = Cursors.Default; } }
void Remove_Student_Of_Classes() { int iStudentId = 0; int.TryParse("" + gridViewStudent.GetFocusedRowCellValue("Id"), out iStudentId); if (iStudentId > 0) { string sFullName = "" + gridViewStudent.GetFocusedRowCellValue("FullName"); DialogResult dr = MessageBox.Show(string.Format("Bạn có chắc muốn đưa học viên: {0} ra khỏi lớp này?", sFullName), "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { StudentClasses oStudent = new StudentClasses { Id = iStudentId }; bool isResult = new StudentClassesBll(mAccount).DeleteElement(oStudent); //MessageBox.Show("- iStudentId: "+ iStudentId); foreach (StudentClasses o in mLisStudentClasses) { if (o.Id == oStudent.Id) { mLisStudentClasses.Remove(o); break; } } gridControlStudent.DataSource = mLisStudentClasses; gridControlStudent.RefreshDataSource(); gridControlStudent.Update(); } } }
private void lookUpEditClass_EditValueChanged(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; int iClassId = 0; int.TryParse("" + lookUpEditClass.EditValue, out iClassId); mClasses.Id = iClassId; if (iClassId > 0) { StudentClasses obj = new StudentClasses() { ClassId = iClassId }; LoadData_Student_Of_Classes(obj); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Cursor = Cursors.Default; } }
public ActionResult DeleteConfirmed(int id) { StudentClasses studentClasses = db.StudentClasses.Find(id); db.StudentClasses.Remove(studentClasses); db.SaveChanges(); return(RedirectToAction("Index")); }
void LoadData_Student_Of_Classes(StudentClasses oStudentClasses) { mLisStudentClasses = new StudentClassesBll(mAccount).CheckElementByObject(oStudentClasses); if (mLisStudentClasses != null) { gridControlStudent.DataSource = mLisStudentClasses; } }
public async Task <IActionResult> OnPostUnenrollStudent(int studentClassId) { StudentClasses classEntry = await _db.StudentClasses.FindAsync(studentClassId); _db.StudentClasses.Remove(classEntry); await _db.SaveChangesAsync(); return(Page()); }
public ActionResult Edit([Bind(Include = "ID,ClassesID,StudentsID")] StudentClasses studentClasses) { if (ModelState.IsValid) { db.Entry(studentClasses).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassesID = new SelectList(db.Classes, "ID", "Title", studentClasses.ClassesID); return(View(studentClasses)); }
public async Task <IActionResult> OnPostEnroll(string studentId) { if (ModelState.IsValid) { StudentClasses enrollment = new StudentClasses(); enrollment.StudentId = studentId; enrollment.ClassId = InstrViewVM.Class.Id; _db.StudentClasses.Add(enrollment); await _db.SaveChangesAsync(); } return(Page()); }
public ActionResult Create([Bind(Include = "ID,ClassesID,StudentsID")] StudentClasses studentClasses) { if (ModelState.IsValid) { db.StudentClasses.Add(studentClasses); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassesID = new SelectList(db.Classes, "ID", "Title", studentClasses.ClassesID); ViewBag.StudentsID = new SelectList(db.Students, "ID", "FName", studentClasses.StudentsID); return(View(studentClasses)); }
public ActionResult Edit([Bind(Include = "ID,StudentID,ClassID,DateOfEnrollment")] StudentClasses studentClasses) { if (ModelState.IsValid) { studentClasses.DateOfEnrollment = DateTime.Now; db.Entry(studentClasses).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassID = new SelectList(db.Classes, "ID", "Details", studentClasses.ClassID); ViewBag.StudentID = new SelectList(db.Students, "ID", "FirstName", studentClasses.StudentID); return(View(studentClasses)); }
// GET: StudentClasses/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StudentClasses studentClasses = db.StudentClasses.Find(id); if (studentClasses == null) { return(HttpNotFound()); } return(View(studentClasses)); }
// student id, class id public async Task Execute(Command command) { StudentClasses studentClasses = new StudentClasses(); Student student = await _context.Students.FirstOrDefaultAsync(x => x.Id == command.id); Class c = await _context.Classes.FirstOrDefaultAsync(x => x.Id == command.classId); studentClasses.Student = student; studentClasses.Class = c; await _context.StudentClasses.AddAsync(studentClasses); await _context.SaveChangesAsync(); }
// Effectively unenrolls a student in a class public async Task <IActionResult> OnPostDelete(string studentId, int classId) { if (studentId == null) { var ClaimsIdentity = (ClaimsIdentity)User.Identity; var claim = ClaimsIdentity.FindFirst(ClaimTypes.NameIdentifier); studentId = claim.Value; } StudentClasses studentClass = _db.StudentClasses.FirstOrDefault(s => (s.StudentId == studentId) && (s.ClassId == classId)); _db.StudentClasses.Remove(studentClass); await _db.SaveChangesAsync(); return(RedirectToPage("Register", new { studentId = studentId })); }
// GET: StudentClasses/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StudentClasses studentClasses = db.StudentClasses.Find(id); if (studentClasses == null) { return(HttpNotFound()); } ViewBag.ClassesID = new SelectList(db.Classes, "ID", "Title", studentClasses.ClassesID); return(View(studentClasses)); }
private void btnThemHocVien_Click(object sender, EventArgs e) { Classes oClasses = new Classes(); oClasses.Id = string.IsNullOrEmpty("" + lookUpEditClass.EditValue) ? 0 : int.Parse("" + lookUpEditClass.EditValue); oClasses.ClassName = "" + lookUpEditClass.Text; if (oClasses.Id > 0) { frmAddStudentIntoClassess ofrm = new frmAddStudentIntoClassess(mAccount, oClasses); ofrm.ShowDialog(); StudentClasses obj = new StudentClasses() { ClassId = oClasses.Id }; LoadData_Student_Of_Classes(obj); } }
public async Task <IActionResult> OnPostEnroll(string studentId, int classId) { if (studentId == null) { var ClaimsIdentity = (ClaimsIdentity)User.Identity; var claim = ClaimsIdentity.FindFirst(ClaimTypes.NameIdentifier); studentId = claim.Value; } StudentClasses studentClass = new StudentClasses { StudentId = studentId, ClassId = classId }; _db.StudentClasses.Add(studentClass); await _db.SaveChangesAsync(); return(RedirectToPage("Register", new { studentId = studentId })); }
static void Main(string[] args) { var control = new StudentControl(); var students = control.GetAllStudents(); Console.WriteLine("Students\n-----------------------------------------------"); foreach (var s in students) { Console.WriteLine("Name: " + s.People.FirstName + " " + s.People.LastName); foreach (var g in s.Grades) { Console.WriteLine("Course: " + g.Courses.CourseName + " Grade: " + g.Grade); Console.WriteLine("--------------------------------------------------------"); } } var peopleCtx = new PeopleControl(); //var people = peopleCtx.GetAllPeople(); //// Insert //peopleCtx.InsertPeople(new People() { FirstName = "Algot", LastName = "Alfredsson", Email = "*****@*****.**" }); //people.ToList().ForEach(x => Console.WriteLine($"{x.Id} {x.FirstName} {x.LastName} {x.Email}")); //Delete //var input = Console.ReadLine(); //var toDelete = peopleCtx.PeopleByID(int.Parse(input)); //peopleCtx.RemovePeople(toDelete); //var newPeople = peopleCtx.GetAllPeople(); //newPeople.ToList().ForEach(x => Console.WriteLine($"{x.Id} {x.FirstName} {x.LastName} {x.Email}")); //Update //Console.WriteLine("id: "); //var nameID = Console.ReadLine(); //Console.WriteLine("New Name:"); //var namechange = Console.ReadLine(); //var nameChangePerson = peopleCtx.PeopleByID(int.Parse(nameID)); //nameChangePerson.FirstName = namechange; //peopleCtx.UpdatePeople(nameChangePerson); //var newPeople2 = peopleCtx.GetAllPeople(); //newPeople2.ToList().ForEach(x => Console.WriteLine($"{x.Id} {x.FirstName} {x.LastName} {x.Email}")); //Insert Student var ppl = new People() { FirstName = "Lisa", LastName = "Sävås", Email = "Lisa@Sävås.se" }; peopleCtx.InsertPeople(ppl); var studentClass = new StudentClasses() { ClassName = "WIN15" }; var studentClassesCtx = new ClassesControl(); studentClassesCtx.InsertorUpdateClass(studentClass); var educationCTX = new EducationsControl(); var education = new Educations() { EducationName = "Administration" }; educationCTX.InsertorUpdateEducation(education); var newStudent = new Students() { PersonId = ppl.Id, StudentClass_Id = studentClass.Id, EducationId = education.Id }; control.InsertStudent(newStudent); var newStudentContext = new StudentControl(); var studentsList = newStudentContext.GetAllStudents().ToList(); Console.WriteLine("Added new student Lisa"); Console.WriteLine("-------Students Again-------"); foreach (var stud in studentsList) { Console.WriteLine("Name: " + stud.People.FirstName + " " + stud.People.LastName); Console.WriteLine("CourseID: " + stud.StudentClasses.Id + " Class: " + stud.StudentClasses.ClassName); Console.WriteLine("ID: " + stud.Educations.Id + " Education Name: " + stud.Educations.EducationName); Console.WriteLine("--------------------------------------------------------------------------------"); } var AttendanceControl = new AttendanceControl(); Attendance att = new Attendance() { Date = new DateTime(2016, 11, 02), StudentID = newStudent.Id, CourseID = 2, Attendance1 = false }; AttendanceControl.InsertAttendance(att); var lisa = newStudentContext.StudentsByID(newStudent.Id); var attendance = new AttendanceControl(); var attendanceObj = attendance.AttendaceByStudentAndCourseID(newStudent.Id, 2); Console.WriteLine("Added new attendance for Lisa"); Console.WriteLine("-----Attendance-----"); Console.WriteLine($"{lisa.People.FirstName} {lisa.People.LastName} Närvaro i {attendanceObj.Courses.CourseName} den {attendanceObj.Date}: {attendanceObj.Attendance1}"); Console.WriteLine(); AttendanceControl.RemoveAttendance(att); //educationCTX.RemoveEducation(education); control.RemoveStudent(newStudent); studentClassesCtx.RemoveClass(studentClass); educationCTX.RemoveEducation(education); peopleCtx.RemovePeople(ppl); Console.ReadKey(); }
private void btnHoanTatChonHv_Click(object sender, EventArgs e) { //try //{ // this.Cursor = Cursors.WaitCursor; // mClasses = new ClassesBll(mAccount).getElementById(mClasses.Id); // List<StudentClasses> lstStudentClasses = new List<StudentClasses>(); // foreach (StudentLists item in lstselected) // { // StudentClasses obj = new StudentClasses // { // ClassId = mClasses.Id, // StudentId = item.Id, // DateStart = DateTime.Parse(mClasses.DateStart.ToString()), // TotalPrice = (int)mClasses.TotalPrice, // FullName = item.FullName // }; // lstStudentClasses.Add(obj); // } // StudentClassesBll mStudentClassesBll = new StudentClassesBll(mAccount); // int i = 0; // foreach (StudentClasses item in lstStudentClasses) // { // if(mStudentClassesBll.InsertElement(item) == false) // { // MessageBox.Show("Thêm học viên" + item.FullName + "Thất bại!"); // i++; // } // } // if(i == 0) // { // MessageBox.Show("Tất cả học viên đã thêm thành công!"); // } // else // { // MessageBox.Show("Các học viên còn lại đã thêm thành công!"); // } // this.Close(); //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} //finally //{ // this.Cursor = Cursors.Default; //} mClasses = new ClassesBll(mAccount).getElementById(mClasses.Id); List <StudentClasses> lstStudentClasses = new List <StudentClasses>(); //MessageBox.Show(mClasses.FromDate.ToString()); foreach (StudentLists item in lstselected) { StudentClasses obj = new StudentClasses(); obj.ClassId = mClasses.Id; obj.StudentId = item.Id; obj.DateStart = DateTime.Parse(mClasses.FromDate.ToString()); if (mClasses.TotalPrice != null) { obj.TotalPrice = (int)mClasses.TotalPrice; } else { obj.TotalPrice = 0; } obj.FullName = item.FullName; lstStudentClasses.Add(obj); } StudentClassesBll mStudentClassesBll = new StudentClassesBll(mAccount); int i = 0; foreach (StudentClasses item in lstStudentClasses) { if (mStudentClassesBll.InsertElement(item) == false) { MessageBox.Show("Thêm học viên" + item.FullName + "Thất bại!"); i++; } } if (i == 0) { MessageBox.Show("Tất cả học viên đã thêm thành công!"); } else { MessageBox.Show("Các học viên còn lại đã thêm thành công!"); } this.Close(); }