private void InitStatus(ZapsanyKurz zk) { double?avg = ZapsanyKurzTable.GetAvgMark(zk.IdRegistrace); if (avg != null) { AVERAGE_MARK.Text = "Average mark: " + avg; } else { AVERAGE_MARK.Text = "Average mark: no marks yet"; } string dateOfSign = zk.DatumZapisu.ToShortDateString(); bool? done = zk.Splneno; DATE_OF_SIGN.Text = "Signed: " + dateOfSign; bool done2 = done ?? false; if (done2) { COMPLETED.Text = "Done: YES"; } else { COMPLETED.Text = "DONE: NO"; } }
private void InitView() { MY_COURSES_LISTVIEW.Items.Clear(); AVAIL_COURSES_CB.Items.Clear(); Student s = StudentTable.SelectOne(idStudent); Collection <ZapsanyKurz> signedCourses = ZapsanyKurzTable.SelectCoursesByIdStudent(idStudent); Collection <Kurz> activeCourses = KurzTable.SelectByStudentAndOngoing(idStudent.ToString()); foreach (var c in activeCourses) { AVAIL_COURSES_CB.Items.Add(c.Nazev); } if (signedCourses.Count > 0) { ZapsanyKurz firstCourse = signedCourses[0]; foreach (var c in signedCourses) { ListViewItem i = new ListViewItem(c.IdRegistrace.ToString()); i.SubItems.Add(c.Kurz.Nazev); MY_COURSES_LISTVIEW.Items.Add(i); } InitCourse(firstCourse); } }
private void MY_COURSES_LISTVIEW_SelectedIndexChanged(object sender, EventArgs e) { if (MY_COURSES_LISTVIEW.SelectedItems.Count == 1) { string s = MY_COURSES_LISTVIEW.SelectedItems[0].Text; COURSE_NAME.Text = s; ZapsanyKurz course = ZapsanyKurzTable.SelectOne(Convert.ToInt32(s)); InitCourse(course); } }
private void SIGN_OUT_BUTTON_Click(object sender, EventArgs e) { if (MY_COURSES_LISTVIEW.SelectedItems.Count == 1) { string s = MY_COURSES_LISTVIEW.SelectedItems[0].Text; COURSE_NAME.Text = s; ZapsanyKurzTable.Delete(Convert.ToInt32(s)); InitView(); } }
private void SIGN_COURSE_BUTTON_Click(object sender, EventArgs e) { string courseName = AVAIL_COURSES_CB.Text; int studentsCount = 0, capacity = 0; if (courseName != null && courseName != "") { ZapsanyKurz zk = new ZapsanyKurz(); Kurz k = KurzTable.SelectByCourseName(courseName); if (k == null) { k = KurzTable.SelectLastCourseByName(courseName); } zk.IdKurz = k.IdKurz; studentsCount = KurzTable.GetStudentsCount(k.IdKurz); capacity = k.Kapacita; zk.IdStudent = idStudent; ZapsanyKurzTable.Insert(zk); if (studentsCount < capacity) { InitView(); } else { MessageBox.Show("J*z neni misto. Budete zapsan do fronty na tento kurz. " + "Jakmile se otevre kurz, budete zapsan do kurzu."); } } else { MessageBox.Show("Vyberte kurz z combo boxu!"); } }