private void btnAdd_Click(object sender, EventArgs e)
        {
            if (cu.is_id_exists(textBoxId.Text, dataGridViewMorimProject) || cu.is_id_belongs_to_strudent_or_teacher(textBoxId.Text, "students") || !cu.is_id_validated(textBoxId.Text))
            {
                MessageBox.Show(string.Format("{0} is alreadt existing ID or not valid ID!", textBoxId.Text));
                return;
            }
            if (cu.is_important_field_empty(textBoxId.Text, textBoxFirstName.Text, textBoxLastName.Text))
            {
                MessageBox.Show("important field is empty!");
                return;
            }
            if (cu.is_one_value_short(textBoxAddress.Text, textBoxFirstName.Text, textBoxLastName.Text, textBoxNum1.Text, textBoxNum2.Text))
            {
                MessageBox.Show("value needs to be at least 2 chars");
                return;
            }
            if (!cu.is_phone_valid(textBoxNum1.Text) || !cu.is_phone_valid(textBoxNum2.Text))
            {
                return;
            }
            MorimProject mik = new MorimProject();

            mik.AddMorim(textBoxId.Text, textBoxFirstName.Text, textBoxLastName.Text, textBoxAddress.Text, textBoxNum1.Text, textBoxNum2.Text);
            cu.charge_data_grid_view(mik.GetMorim(), dataGridViewMorimProject);
            cu.stay_on_added_value(textBoxId.Text, dataGridViewMorimProject, 0);
        }
        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();
        }
예제 #3
0
 public bool is_id_belongs_to_strudent_or_teacher(string id, params string[] to_check)
 {
     for (int counter = 0; counter < to_check.Length; counter++)
     {
         if (to_check[counter].Equals("students"))
         {
             Student   st       = new Student();
             DataTable students = st.GetStudents();
             foreach (DataRow dt in students.Rows)
             {
                 if (id.Equals(dt["tz"].ToString()))
                 {
                     return(true);
                 }
             }
         }
         else if (to_check[counter].Equals("teachers"))
         {
             MorimProject st    = new MorimProject();
             DataTable    morim = st.GetMorim();
             foreach (DataRow dt in morim.Rows)
             {
                 if (id.Equals(dt["id"].ToString()))
                 {
                     return(true);
                 }
             }
         }
         else
         {
             MessageBox.Show("Developer, you do not check ID validation as needed.");
         }
     }
     return(false);
 }
예제 #4
0
        public string Get_Value_of_Morim(string code)
        {
            MorimProject k       = new MorimProject();
            DataTable    classes = k.GetNameById(code);

            return(classes.Rows[0]["FirstName"].ToString() + " " + classes.Rows[0]["LastName"].ToString());
        }
        private void frmMorimProject_Load(object sender, EventArgs e)
        {
            MorimProject mik = new MorimProject();

            cu.charge_data_grid_view(mik.GetMorim(), dataGridViewMorimProject);
            cu.make_dgv_non_sortable(dataGridViewMorimProject);
            dataGridViewMorimProject.ClearSelection();
        }
예제 #6
0
        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 { }
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!cu.is_dataGridView_colored(dataGridViewMorimProject))
            {
                MessageBox.Show("Nothing is picked on table!");
                return;
            }
            if (cu.is_important_field_empty(textBoxId.Text, textBoxFirstName.Text, textBoxLastName.Text))
            {
                MessageBox.Show("One of the Important Field is Empty!");
                return;
            }
            if (cu.is_id_exists(textBoxId.Text, dataGridViewMorimProject) || cu.is_id_belongs_to_strudent_or_teacher(textBoxId.Text, "students"))
            {
                MessageBox.Show(string.Format("you can't change to id {0}, it exists!", textBoxId.Text));
                return;
            }
            if (!cu.is_id_validated(textBoxId.Text))
            {
                MessageBox.Show(string.Format("you can't change to invalid id {0}!", textBoxId.Text));
                return;
            }
            if (cu.is_one_value_short(textBoxAddress.Text, textBoxFirstName.Text, textBoxLastName.Text, textBoxNum1.Text, textBoxNum2.Text))
            {
                MessageBox.Show("value needs to be at least 2 chars");
                return;
            }
            if (!cu.is_phone_valid(textBoxNum1.Text) || !cu.is_phone_valid(textBoxNum2.Text))
            {
                return;
            }
            MorimProject mk = new MorimProject();

            mk.Update(textBoxId.Text, textBoxFirstName.Text, textBoxLastName.Text, textBoxAddress.Text, textBoxNum1.Text, textBoxNum2.Text);
            cu.charge_data_grid_view(mk.GetMorim(), dataGridViewMorimProject);
            dataGridViewMorimProject.ClearSelection();
            cu.stay_on_added_value(textBoxId.Text, dataGridViewMorimProject, 0);
        }
예제 #8
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
                { }
            }
        }
예제 #9
0
        private void frmCanTeachProject_Load(object sender, EventArgs e)
        {
            MorimProject mik = new MorimProject();

            cu.charge_data_grid_view(mik.GetIdAndName(), dataGridViewMorimProject);
            foreach (DataRow mikzoa in mikzoot.Rows)
            {
                string mikzo = mikzoa["mikName"].ToString();
                tabControlMik.TabPages.Add(mikzo);
            }
            foreach (DataRow kita in kitot.Rows)
            {
                string x = kita["class"].ToString();
                dataGridViewInfo.Columns.Add("aa", x);
            }
            foreach (DataRow level in ramot.Rows)
            {
                string x = level["rama"].ToString();
                dataGridViewInfo.Rows.Add(x);
            }
            cu.make_dgv_non_sortable(dataGridViewMorimProject, dataGridViewInfo);
            dataGridViewInfo.ClearSelection();
        }