private void dataGridViewZmanProject_CellClick(object sender, DataGridViewCellEventArgs e) { if (cu.is_out_of_dataGridView_range(e.RowIndex, e.ColumnIndex, cu.get_dgv_last_row(dataGridViewZmanProject))) { dataGridViewZmanProject.ClearSelection(); return; } if (!cu.is_dataGridView_colored(dataGridViewMorimProject)) { dataGridViewZmanProject.ClearSelection(); return; } PanuiProject ct = new PanuiProject(); string id = cu.GetID(dataGridViewMorimProject); if (dataGridViewZmanProject.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor == Color.Empty) { dataGridViewZmanProject.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.MediumPurple; ct.Add(id, e.ColumnIndex, e.RowIndex); } else if (dataGridViewZmanProject.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor == Color.MediumPurple) { dataGridViewZmanProject.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.Empty; ct.Delete(id, e.ColumnIndex, e.RowIndex); } dataGridViewZmanProject.ClearSelection(); }
public void panui_create_test_data() { MorimProject mp = new MorimProject(); DataTable morim = mp.GetMorim(); Random ran = new Random(); int top_morim = morim.Rows.Count; PanuiProject pa = new PanuiProject(); for (int i = 0; i < 800; i++) { int morim_row = ran.Next(0, top_morim); string code_more = morim.Rows[morim_row]["id"].ToString(); int day = ran.Next(1, 7); int hour = ran.Next(0, 40); try { pa.Add(code_more, day, hour); } catch { } } }
public void zvaTarich() { if (!cu.is_dataGridView_colored(dataGridViewMorimProject)) { dataGridViewZmanProject.ClearSelection(); return; } cu.clean_dataGridView(dataGridViewZmanProject); DateTime tarich = dateTimePicker1.Value; int misparYom = (int)tarich.DayOfWeek + 1; string id = cu.GetID(dataGridViewMorimProject); PanuiProject pa = new PanuiProject(); DataTable dt = pa.GetPanuiForDay(misparYom, id); foreach (DataRow dr in dt.Rows) { int row = int.Parse(dr["shaa"].ToString()); dataGridViewZmanProject.Rows[row].Cells[1].Style.BackColor = Color.MediumPurple; } BigForm bf = new BigForm(); DataTable lessons = bf.GetLessonTimeDetailsForTeacher(id); foreach (DataRow lesson in lessons.Rows) { int start = int.Parse(lesson["start_time"].ToString()); int end = int.Parse(lesson["end_time"].ToString()); string due = lesson["due_date"].ToString(); if (due.Equals(dateTimePicker1.Value.ToShortDateString())) { for (int i = start; i <= end; i++) { dataGridViewZmanProject.Rows[i].Cells[1].Style.BackColor = Color.Red; } } } }
private void dataGridViewMorimProject_CellClick(object sender, DataGridViewCellEventArgs e) { dataGridViewMorimProject.ClearSelection(); if (cu.is_out_of_dataGridView_range(e.RowIndex, e.ColumnIndex, cu.get_dgv_last_row(dataGridViewMorimProject))) { return; } cu.clean_dataGridView(dataGridViewMorimProject); cu.clean_dataGridView(dataGridViewZmanProject); cu.paint_chosen_row(e.RowIndex, dataGridViewMorimProject); string id = cu.GetID(dataGridViewMorimProject); PanuiProject pl = new PanuiProject(); DataTable dt = pl.GetPanui(id); foreach (DataRow row in dt.Rows) { int yom = int.Parse(row["yom"].ToString()); int shaa = int.Parse(row["shaa"].ToString()); dataGridViewZmanProject.Rows[shaa].Cells[yom].Style.BackColor = Color.MediumPurple; } dataGridViewMorimProject.ClearSelection(); dataGridViewZmanProject.ClearSelection(); }
public void create_lessons() { kita kit = new kita(); levels level = new levels(); MikP mik = new MikP(); BigForm bf = new BigForm(); Student st = new Student(); PanuiProject pp = new PanuiProject(); Lessons les = new Lessons(); DataTable kitot = kit.GetKita(); DataTable ramot = level.GetLevels(); DataTable mikzoot = mik.GetMikzoot(); Random ran = new Random(); int top_kitot = kitot.Rows.Count; int top_ramot = ramot.Rows.Count; int top_mikzoot = mikzoot.Rows.Count; for (int i = 0; i < 800; i++) { int kitot_row = ran.Next(0, top_kitot); int ramot_row = ran.Next(0, top_ramot); int mikzoot_row = ran.Next(0, top_mikzoot); string code_kita = kitot.Rows[kitot_row]["Code"].ToString(); string code_level = ramot.Rows[ramot_row]["code"].ToString(); string mik_code = mikzoot.Rows[mikzoot_row]["mikCode"].ToString(); DataTable morim = bf.GetMorim(int.Parse(mik_code), int.Parse(code_level), int.Parse(code_kita)); if (morim.Rows.Count == 0) { continue; } int teacher_index = ran.Next(0, morim.Rows.Count); string teacher_id = morim.Rows[teacher_index]["id"].ToString(); DataTable students = st.GetStudents(); int student_index = ran.Next(0, students.Rows.Count); string student_id = students.Rows[student_index]["tz"].ToString(); int mon = ran.Next(4, 8); int day = ran.Next(1, 30); string yom, hod; if (day < 10) { yom = "0" + day.ToString(); } else { yom = day.ToString(); } if (mon < 10) { hod = "0" + mon.ToString(); } else { hod = mon.ToString(); } string due = yom + "/" + hod + "/2016"; int in_week = (int)(DateTime.ParseExact(due, "d/M/yyyy", null).DayOfWeek) + 1; DataTable panui = pp.GetPanuiForDay(in_week, teacher_id); if (panui.Rows.Count == 0) { continue; } int panui_index = ran.Next(0, panui.Rows.Count); int start = int.Parse(panui.Rows[panui_index]["shaa"].ToString()); int end = start; int counter = 0; while (counter < panui.Rows.Count) { if (int.Parse(panui.Rows[counter]["shaa"].ToString()) - 1 == end) { end++; } counter++; } DataTable lessons_for_teacher = bf.GetLessonTimeDetailsForTeacher(teacher_id); DataTable lessons_for_student = les.GetLessonsByStudentId(student_id); bool flag = true; if (lessons_for_teacher.Rows.Count != 0) { foreach (DataRow dr in lessons_for_teacher.Rows) { if (dr["due_date"].ToString().Equals(due) && dr["start_time"].ToString().Equals(start) && dr["end_time"].ToString().Equals(end)) { flag = false; } } } if (lessons_for_student.Rows.Count != 0) { foreach (DataRow dr in lessons_for_student.Rows) { if (dr["due_date"].ToString().Equals(due) && dr["start_time"].ToString().Equals(start) && dr["end_time"].ToString().Equals(end)) { flag = false; } } } if (!flag) { continue; } les.AddLessons(teacher_id, student_id, int.Parse(mik_code), int.Parse(code_kita), int.Parse(code_level), due, start, end, ""); } }