예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            StudentListView view = new StudentListView();

            view.Show();
            this.Close();
        }
예제 #2
0
        protected void Add_Student_Click(object sender, EventArgs e)
        {
            MessageLabel.Text = "StudentID = " + StudentID.Text + " Name = " + StudentName.Text;
            if (Page.IsValid)
            {
                bool found = false;
                foreach (var item in StudentsList)
                {
                    if (item.StudentID == int.Parse(StudentID.Text))
                    {
                        found = true;
                    }
                }
                if (found)
                {
                    MessageLabel.Text = "Record already exists.";
                }
                else
                {
                    Student newstudent = new Student(int.Parse(StudentID.Text), StudentName.Text, double.Parse(StudentCredits.Text), StudentEmergencyContact.Text);

                    StudentsList.Add(newstudent);
                    StudentListView.DataSource = StudentsList;
                    StudentListView.DataBind();
                }
            }
        }
예제 #3
0
    protected void studentdelete_Click(object sender, EventArgs e)
    {
        int    xh  = Int32.Parse((sender as Button).CommandArgument.ToString());
        string sql = "delete from tb_student where xh ='" + xh + "'";

        try
        {
            if (DBControl.delete(sql) > 0)
            {
                StudentListView.DataSource = null;
                StudentListView.DataBind();
                ScriptManager.RegisterStartupScript(this.student_panel, this.GetType(), "updateScript", "alert('删除成功')", true);
            }
            else
            {
                StudentListView.DataSource = null;
                StudentListView.DataBind();
                ScriptManager.RegisterStartupScript(this.student_panel, this.GetType(), "updateScript", "alert('该学生不存在')", true);
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this.student_panel, this.GetType(), "updateScript", "alert('系统异常')", true);
        }
    }
예제 #4
0
    protected void studenteditsub_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(studenteditage.Text.Trim()))
        {
            ScriptManager.RegisterStartupScript(this.student_panel, this.GetType(), "updateScript", "alert('年龄不能为空!')", true);
        }
        if (Convert.ToInt32(studenteditdept.SelectedValue) == 0)
        {
            ScriptManager.RegisterStartupScript(this.student_panel, this.GetType(), "updateScript", "alert('请选择院系!')", true);
        }
        int    xh  = 0;
        int    nl  = 0;
        string xb  = null;
        string xm  = null;
        int    dno = 0;

        try
        {
            xh = Convert.ToInt32(studentedituser.Text.Trim());
            xm = studenteditname.Text.Trim();
            xb = "男";
            if (studenteditsex2.Checked)
            {
                xb = "女";
            }
            nl  = Convert.ToInt32(studenteditage.Text.Trim());
            dno = Convert.ToInt32(studenteditdept.SelectedValue);
        }
        catch (Exception)
        {
            ScriptManager.RegisterStartupScript(this.student_panel, this.GetType(), "updateScript", "alert('请在年龄中输入数字!')", true);
        }

        string sql = "update tb_student set xm='" + xm + "',xb='" + xb + "',nl='" + nl + "',dno='" + dno + "' where xh ='" + xh + "'";

        try
        {
            DBControl.update(sql);
            ScriptManager.RegisterStartupScript(this.student_panel, this.GetType(), "updateScript", "alert('编辑成功')", true);
            StudentListView.DataSource = null;
            StudentListView.DataBind();

            student_panel.Visible       = true;
            managestudent_panel.Visible = true;
            editstudent_panel.Visible   = false;
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this.student_panel, this.GetType(), "updateScript", "alert('编辑失败')", true);
        }
    }
예제 #5
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            if (StudentListView.SelectedIndices.Count == 0)
            {
                return;
            }

            Student   s        = stud[StudentListView.SelectedIndices[0]];
            EdditForm editForm = new EdditForm(s);

            if (editForm.ShowDialog() == DialogResult.OK)
            {
                StudentListView.Invalidate();
            }
        }
예제 #6
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            Student s = new Student();

            EdditForm editForm = new EdditForm(s);

            if (editForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            stud.Add(s);
            StudentListView.VirtualListSize = stud.Count;
            StudentListView.Invalidate();
        }
예제 #7
0
        public void UpdateSearchBoxItems()
        {
            searchBox.DataSource = null;

            var groups = sgRepo.all()
                         .OrderBy(g => g.name)
                         .ToList();
            var searchList = StudentListView.FromGroupList(groups);

            Students = sRepo.all();
            searchList.AddRange(StudentListView.FromStudentList(Students));

            searchBox.DisplayMember = "dataString";
            searchBox.ValueMember   = "idString";
            searchBox.DataSource    = searchList;
        }