Exemplo n.º 1
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
                { }
            }
        }
Exemplo n.º 2
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();
        }