private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!cu.is_dataGridView_colored(dataGridViewLevels))
            {
                MessageBox.Show("Nothing is picked on table!");
                return;
            }
            Lessons   les       = new Lessons();
            string    field     = "kod_level";
            string    code      = cu.GetID(dataGridViewLevels);
            DataTable lessonsID = les.GetLessonsByString(field, code);

            foreach (DataRow dr in lessonsID.Rows)
            {
                if (dr[field].ToString().Equals(code) && cu.is_date_in_future(dr["due_date"].ToString()))
                {
                    MessageBox.Show("Cannot delete level with scheduled lessons!");
                    return;
                }
            }
            levels mkk = new levels();

            mkk.Delete(cu.GetID(dataGridViewLevels));
            cu.charge_data_grid_view(mkk.GetLevels(), dataGridViewLevels);
            dataGridViewLevels.ClearSelection();
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!cu.is_dataGridView_colored(dataGridViewMorimProject))
            {
                MessageBox.Show("Nothing is picked on table!");
                return;
            }
            string    a         = cu.GetID(dataGridViewMorimProject);
            Lessons   les       = new Lessons();
            DataTable lessonsID = les.GetLessonsTeachersStudentId();

            foreach (DataRow dr in lessonsID.Rows)
            {
                if (dr["teacher_id"].ToString() == a && cu.is_date_in_future(dr["due_date"].ToString()))
                {
                    MessageBox.Show(dr["due_date"].ToString());
                    MessageBox.Show("Cannot delete teachers with scheduled lessons!");
                    return;
                }
            }
            MorimProject mkk = new MorimProject();

            mkk.DeleteButton(a);
            cu.charge_data_grid_view(mkk.GetMorim(), dataGridViewMorimProject);
            dataGridViewMorimProject.ClearSelection();
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!cu.is_dataGridView_colored(dataGridViewMikP))
            {
                MessageBox.Show("Nothing is picked on teachers!");
                return;
            }
            Lessons   les       = new Lessons();
            string    field     = "kod_mik";
            DataTable lessonsID = les.GetLessonsByString(field, cu.GetID(dataGridViewMikP));
            string    mik_id    = cu.GetID(dataGridViewMikP);

            foreach (DataRow dr in lessonsID.Rows)
            {
                if (dr[field].ToString() == mik_id && cu.is_date_in_future(dr["due_date"].ToString()))
                {
                    MessageBox.Show("Cannot delete mik with scheduled lessons!");
                    return;
                }
            }
            MikP mkk = new MikP();

            mkk.Delete(cu.GetID(dataGridViewMikP));
            cu.charge_data_grid_view(mkk.GetMikzoot(), dataGridViewMikP);
            this.dataGridViewMikP.ClearSelection();
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!cu.is_dataGridView_colored(dataGridViewStudents))
            {
                MessageBox.Show("Nothing is picked on table!");
                return;
            }
            string    a         = cu.GetID(dataGridViewStudents);
            Lessons   les       = new Lessons();
            string    field     = "student_id";
            DataTable lessonsID = les.GetLessonsTeachersStudentId();

            foreach (DataRow dr in lessonsID.Rows)
            {
                if (dr[field].ToString() == a && cu.is_date_in_future(dr["due_date"].ToString()))
                {
                    MessageBox.Show("Cannot delete student with scheduled lessons!");
                    return;
                }
            }
            Student mkk = new Student();

            mkk.Delete(a);
            tan();
            dataGridViewStudents.ClearSelection();
        }
        private void dataGridViewStudents_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridViewStudents.ClearSelection();
            if (cu.is_out_of_dataGridView_range(e.RowIndex, e.ColumnIndex, cu.get_dgv_last_row(dataGridViewStudents)))
            {
                return;
            }
            cu.clean_dataGridView(dataGridViewStudents);
            cu.paint_chosen_row(e.RowIndex, dataGridViewStudents);
            Lessons ls = new Lessons();

            cu.charge_data_grid_view(cu.change_keys_to_values(ls.GetLessonsByStudentId(cu.GetID(dataGridViewStudents))), dataGridViewLessons);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!cu.is_dataGridView_colored(dataGridViewLessons))
            {
                MessageBox.Show("Please choose lesson");
                return;
            }
            string  id  = cu.GetID(dataGridViewLessons);
            Lessons les = new Lessons();

            les.Delete(id);
            cu.charge_data_grid_view(cu.change_keys_to_values(les.GetLessonsByStudentId(cu.GetID(dataGridViewStudents))), dataGridViewLessons);
            dataGridViewLessons.ClearSelection();
        }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!is_three_colored() || !cu.is_dataGridView_colored(dataGridViewStudents) || !cu.is_dataGridView_colored(dataGridViewMorimProject) || !first)
            {
                MessageBox.Show("Not all details are provided. Select on Tables the details of lesson!");
                return;
            }
            int counter = 0;

            while (counter < dataGridViewZmanProject.RowCount && dataGridViewZmanProject.Rows[counter].Cells[1].Style.BackColor != Color.Yellow)
            {
                counter++;
            }
            if (counter == dataGridViewZmanProject.RowCount)
            {
                MessageBox.Show("Lesson time is not picked!");
                return;
            }
            Lessons les = new Lessons();

            les.AddLessons(cu.GetID(dataGridViewMorimProject), cu.GetID(dataGridViewStudents), int.Parse(cu.GetID(dataGridViewMikP)), int.Parse(cu.GetID(dataGridViewKita)), int.Parse(cu.GetID(dataGridViewLevels)), dateTimePicker1.Value.ToShortDateString(), hatchala, siyum, textBoxNotes.Text.ToString());
            zvaTarich();
            first = true;
        }
Exemplo n.º 8
0
        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, "");
            }
        }
Exemplo n.º 9
0
        private void dataGridViewInfo_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (cu.is_out_of_dataGridView_range(e.RowIndex, e.ColumnIndex, cu.get_dgv_last_row(dataGridViewInfo)) || e.ColumnIndex == 0)
            {
                dataGridViewInfo.ClearSelection();
                return;
            }
            if (!cu.is_dataGridView_colored(dataGridViewMorimProject))
            {
                dataGridViewInfo.ClearSelection();
                MessageBox.Show("Please Choose Teacher");
                return;
            }
            string mik         = tabControlMik.SelectedTab.Text;
            string level       = dataGridViewInfo.Rows[e.RowIndex].Cells[0].Value.ToString();
            string kita        = dataGridViewInfo.Columns[e.ColumnIndex].HeaderText;
            int    MikCode     = 0;
            int    kitaCode    = 0;
            int    LevelCode   = 0;
            string TeacherCode = "";

            foreach (DataRow dr in mikzoot.Rows)
            {
                if (dr["mikName"].ToString().Equals(mik))
                {
                    MikCode = int.Parse(dr["mikCode"].ToString());
                }
            }
            foreach (DataRow dr in ramot.Rows)
            {
                if (dr["rama"].ToString().Equals(level))
                {
                    LevelCode = int.Parse(dr["code"].ToString());
                }
            }
            foreach (DataRow dr in kitot.Rows)
            {
                if (dr["class"].ToString().Equals(kita))
                {
                    kitaCode = int.Parse(dr["Code"].ToString());
                }
            }

            for (int d = 0; d < dataGridViewMorimProject.RowCount; d++)
            {
                if (dataGridViewMorimProject.Rows[d].Cells[0].Style.BackColor == Color.MediumPurple)
                {
                    TeacherCode = dataGridViewMorimProject.Rows[d].Cells[0].Value.ToString();
                }
            }
            if (TeacherCode == "")
            {
                dataGridViewInfo.ClearSelection();
                return;
            }

            if (dataGridViewInfo.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor == Color.MediumPurple)
            {
                Lessons   les     = new Lessons();
                DataTable lessons = les.GetLessonsByString("teacher_id", "'" + TeacherCode + "'");
                foreach (DataRow lesson in lessons.Rows)
                {
                    if (cu.is_date_in_future(lesson["due_date"].ToString()) && lesson["kod_mik"].ToString().Equals(MikCode.ToString()) && lesson["kod_kita"].ToString().Equals(kitaCode.ToString()) && lesson["kod_level"].ToString().Equals(LevelCode.ToString()))
                    {
                        dataGridViewInfo.ClearSelection();
                        MessageBox.Show("Cannot delete, Future lesson is scheduled");
                        return;
                    }
                }
                dataGridViewInfo.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.White;
                CanTeachProject x = new CanTeachProject();
                x.DeleteCanTeach(kitaCode, LevelCode, MikCode, TeacherCode);
            }
            else if (dataGridViewInfo.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor == Color.Empty)
            {
                dataGridViewInfo.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.MediumPurple;
                CanTeachProject x = new CanTeachProject();
                x.AddCanTeachProject(kitaCode, LevelCode, MikCode, TeacherCode);
            }
            dataGridViewInfo.ClearSelection();
        }