Beispiel #1
0
        protected void ADD_BTN_Click(object sender, EventArgs e)
        {
            Student_DBEntities S       = new Student_DBEntities();
            Student            student = new Student();

            student.Name     = TextBoxName.Text;
            student.Phone    = TextBoxPhone.Text;
            student.Email    = TextBoxEmail.Text;
            student.Courses  = TextBoxCourses.Text;
            student.division = TextBoxDivision.Text;
            student.Score    = TextBoxScore.Text;
            student.Job      = TextBoxJob.Text;
            if (TextBoxGradYear.Text != "")
            {
                student.Graduation_Year = Convert.ToInt32(TextBoxGradYear.Text);
            }
            else
            {
                student.Graduation_Year = 0;
            }
            student.Degree = TextBoxDegree.Text;
            S.Students.Add(student);
            S.SaveChanges();
            Response.Redirect("Display");
        }
Beispiel #2
0
        protected void EDIT_BTN_Click(object sender, EventArgs e)
        {
            Student_DBEntities S = new Student_DBEntities();
            int     ID           = Convert.ToInt32(Request.QueryString["ID"]);
            Student student      = S.Students.FirstOrDefault(x => x.Id == ID);

            student.Name            = TextBoxName.Text;
            student.Phone           = TextBoxPhone.Text;
            student.Email           = TextBoxEmail.Text;
            student.Courses         = TextBoxCourses.Text;
            student.division        = TextBoxDivision.Text;
            student.Score           = TextBoxScore.Text;
            student.Job             = TextBoxJob.Text;
            student.Graduation_Year = Convert.ToInt32(TextBoxGradYear.Text);
            student.Degree          = TextBoxDegree.Text;
            S.SaveChanges();
            Response.Redirect("Display");
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string S_Type   = Request.QueryString["S_Type"];
                string Search   = Request.QueryString["S"];
                string RemoveID = Request.QueryString["RemoveID"];

                Student_DBEntities S = new Student_DBEntities();

                if (S_Type != null)
                {
                    SearchTypeDDL.ClearSelection();
                    SearchTypeDDL.Items.FindByText(S_Type).Selected = true;
                }

                if (RemoveID != null)
                {
                    int     R_ID    = Convert.ToInt32(RemoveID);
                    Student student = S.Students.FirstOrDefault(x => x.Id == R_ID);
                    S.Students.Remove(student);
                    S.SaveChanges();
                }

                if (Search == null || Search == "")
                {
                    Students_list = S.Students.ToList();
                }
                else
                {
                    switch (S_Type)
                    {
                    case "الاسم":
                        Students_list = S.Students.ToList().Where(x => x.Name.Contains(Search));
                        break;

                    case "التلفون":
                        Students_list = S.Students.ToList().Where(x => x.Phone == Search);
                        break;

                    case "البريد":
                        Students_list = S.Students.ToList().Where(x => x.Email.Contains(Search));
                        break;

                    case "الدورات التدريبيه":
                        Students_list = S.Students.ToList().Where(x => x.Courses.Contains(Search));
                        break;

                    case "الشعبه":
                        Students_list = S.Students.ToList().Where(x => x.division.Contains(Search));
                        break;

                    case "التقدير":
                        Students_list = S.Students.ToList().Where(x => x.Score.Contains(Search));
                        break;

                    case "الوظيفه":
                        Students_list = S.Students.ToList().Where(x => x.Job.Contains(Search));
                        break;

                    case "سنة التخرج":
                        Students_list = S.Students.ToList().Where(x => x.Graduation_Year == Convert.ToInt32(Search));
                        break;

                    case "الدرجة العلمية":
                        Students_list = S.Students.ToList().Where(x => x.Degree.Contains(Search));
                        break;
                    }
                }
            }
        }