Esempio n. 1
0
        private void FormAdd_Load(object sender, EventArgs e)
        {
            Add_BTN.Image = (Image)(new Bitmap(Add_BTN.Image, new Size(16, 16)));
            switch (Add)
            {
            case true:
                Add_BTN.Visible = true;
                break;

            case false:
                Edit_BTN.Visible = true;
                Student_DBEntities S       = new Student_DBEntities();
                Student            student = S.Students.First(x => x.Id == ID);
                TB_Name.Text      = student.Name;
                TB_Phone.Text     = student.Phone;
                TB_Email.Text     = student.Email;
                TB_Courses.Text   = student.Courses;
                TB_Division.Text  = student.division;
                TB_Score.Text     = student.Score;
                TB_Job.Text       = student.Job;
                TB_Grad_year.Text = student.Graduation_Year.ToString();
                TB_Degree.Text    = student.Degree;
                break;
            }
        }
Esempio n. 2
0
        private void Add_BTN_Click(object sender, EventArgs e)
        {
            Student_DBEntities S       = new Student_DBEntities();
            Student            student = new Student();

            student.Name     = TB_Name.Text;
            student.Phone    = TB_Phone.Text;
            student.Email    = TB_Email.Text;
            student.Courses  = TB_Courses.Text;
            student.division = TB_Division.Text;
            student.Score    = TB_Score.Text;
            student.Job      = TB_Job.Text;
            if (TB_Grad_year.Text != "")
            {
                int i;
                Int32.TryParse(TB_Grad_year.Text, out i);
                student.Graduation_Year = i;
            }
            else
            {
                student.Graduation_Year = 0;
            }
            student.Degree = TB_Degree.Text;
            S.Students.Add(student);
            S.SaveChanges();
            this.Close();
        }
        private void Search_BTN_Click(object sender, EventArgs e)
        {
            Student_DBEntities S = new Student_DBEntities();

            //dataGridView.DataSource = null;
            if (Search_TB.Text == "")
            {
                dataGridView.DataSource = S.Students.ToList();
            }
            else
            {
                switch (SearchType_CB.GetItemText(SearchType_CB.SelectedItem))
                {
                case "الاسم":
                    dataGridView.DataSource = S.Students.Where(x => x.Name.Contains(Search_TB.Text)).OrderBy(x => x.Name).ToList();
                    break;

                case "التلفون":
                    dataGridView.DataSource = S.Students.Where(x => x.Phone.Contains(Search_TB.Text)).OrderBy(x => x.Phone).ToList();
                    break;

                case "البريد":
                    dataGridView.DataSource = S.Students.Where(x => x.Email.Contains(Search_TB.Text)).OrderBy(x => x.Email).ToList();
                    break;

                case "الدورات التدريبيه":
                    dataGridView.DataSource = S.Students.Where(x => x.Courses.Contains(Search_TB.Text)).OrderBy(x => x.Courses).ToList();
                    break;

                case "الشعبه":
                    dataGridView.DataSource = S.Students.Where(x => x.division.Contains(Search_TB.Text)).OrderBy(x => x.division).ToList();
                    break;

                case "التقدير":
                    dataGridView.DataSource = S.Students.Where(x => x.Score.Contains(Search_TB.Text)).OrderBy(x => x.Score).ToList();
                    break;

                case "الوظيفه":
                    dataGridView.DataSource = S.Students.Where(x => x.Job.Contains(Search_TB.Text)).OrderBy(x => x.Job).ToList();
                    break;

                case "سنة التخرج":
                    int i;
                    Int32.TryParse(Search_TB.Text, out i);
                    dataGridView.DataSource = S.Students.Where(x => x.Graduation_Year == i).OrderBy(x => x.Graduation_Year).ToList();
                    break;

                case "الدرجة العلمية":
                    dataGridView.DataSource = S.Students.Where(x => x.Degree.Contains(Search_TB.Text)).OrderBy(x => x.Degree).ToList();
                    break;

                default:
                    dataGridView.DataSource = S.Students.ToList();
                    break;
                }
            }
            DGV_PostProcessing();
            dataGridView.Refresh();
        }
        private void FormTable_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            Search_BTN.Image = (Image)(new Bitmap(Search_BTN.Image, new Size(16, 16)));
            Student_DBEntities S = new Student_DBEntities();

            dataGridView.DataSource = S.Students.ToList();
            DGV_PostProcessing();
        }
        private void FormReport_Load(object sender, EventArgs e)
        {
            Student_DBEntities S = new Student_DBEntities();
            var GYL = S.Students.GroupBy(x => x.Graduation_Year);

            foreach (var i in GYL)
            {
                Year_CB.Items.Add(i.Key.ToString());
            }
            Year_CB.SelectedIndex = 0;
        }
        private void Year_CB_SelectedIndexChanged(object sender, EventArgs e)
        {
            Student_DBEntities S = new Student_DBEntities();
            int Grad_year;

            Int32.TryParse(Year_CB.GetItemText(Year_CB.SelectedItem), out Grad_year);
            int   year_grads_count  = S.Students.ToList().Where(x => x.Graduation_Year == Grad_year).Count();
            int   total_grads_count = S.Students.ToList().Count();
            float ratio             = ((float)year_grads_count / (float)total_grads_count) * 100;

            Count_LBL.Text       = year_grads_count.ToString();
            Total_Count_LBL.Text = total_grads_count.ToString();
            Ratio_LBL.Text       = ratio.ToString() + " %";
        }
        private void dataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int id;

            Int32.TryParse(dataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString(), out id);
            if (dataGridView.Columns[e.ColumnIndex].Name == "Delete")
            {
                Student_DBEntities S       = new Student_DBEntities();
                Student            student = S.Students.FirstOrDefault(x => x.Id == id);
                S.Students.Remove(student);
                S.SaveChanges();
                Form T = new FormTable();
                T.Owner = this.Owner;
                T.Show();
                this.Dispose(false);
            }
            else
            {
                Form T = new FormAdd(id);
                T.Owner = this;
                T.Show();
                this.Hide();
            }
        }