Ejemplo n.º 1
0
        private void Set_Info(string id)
        {
            cu.clean_dataGridView(dataGridViewInfo);
            CanTeachProject ct = new CanTeachProject();
            DataTable       x  = ct.GetAll(id);

            foreach (DataRow t in x.Rows)
            {
                int    mik_code = int.Parse(t["MikCode"].ToString());
                int    level_code = int.Parse(t["LevelCode"].ToString());
                int    kita_code = int.Parse(t["KitaCode"].ToString());
                string mik_name = "", level_name = "", kita_name = "";
                foreach (DataRow mikzoa in mikzoot.Rows)
                {
                    if (int.Parse(mikzoa["mikCode"].ToString()) == mik_code)
                    {
                        mik_name = mikzoa["mikName"].ToString();
                    }
                }
                foreach (DataRow kita in kitot.Rows)
                {
                    if (int.Parse(kita["code"].ToString()) == kita_code)
                    {
                        kita_name = kita["class"].ToString();
                    }
                }
                foreach (DataRow rama in ramot.Rows)
                {
                    if (int.Parse(rama["code"].ToString()) == level_code)
                    {
                        level_name = rama["rama"].ToString();
                    }
                }
                if (tabControlMik.SelectedTab.Text.ToString() == mik_name)
                {
                    int row = 0;
                    while (row < dataGridViewInfo.RowCount && dataGridViewInfo.Rows[row].Cells[0].Value.ToString() != level_name)
                    {
                        row++;
                    }
                    int counter = 0, cell = 0;
                    foreach (DataGridViewColumn col in dataGridViewInfo.Columns)
                    {
                        if (col.HeaderText == kita_name)
                        {
                            cell = counter;
                        }
                        counter++;
                    }
                    dataGridViewInfo.Rows[row].Cells[cell].Style.BackColor = Color.MediumPurple;
                }
            }
        }
Ejemplo n.º 2
0
        public void can_teach_create_test_data()
        {
            MorimProject mp    = new MorimProject();
            kita         kit   = new kita();
            levels       level = new levels();
            MikP         mik   = new MikP();

            DataTable morim       = mp.GetMorim();
            DataTable kitot       = kit.GetKita();
            DataTable ramot       = level.GetLevels();
            DataTable mikzoot     = mik.GetMikzoot();
            Random    ran         = new Random();
            int       top_morim   = morim.Rows.Count;
            int       top_kitot   = kitot.Rows.Count;
            int       top_ramot   = ramot.Rows.Count;
            int       top_mikzoot = mikzoot.Rows.Count;

            for (int i = 0; i < 200; i++)
            {
                int morim_row   = ran.Next(0, top_morim);
                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_more  = morim.Rows[morim_row]["id"].ToString();
                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();

                CanTeachProject ct = new CanTeachProject();
                try
                {
                    ct.AddCanTeachProject(int.Parse(code_kita), int.Parse(code_level), int.Parse(mik_code), code_more);
                }
                catch
                { }
            }
        }
Ejemplo n.º 3
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();
        }