Beispiel #1
0
        /// <summary>
        /// 新增学生
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_add_Click(object sender, EventArgs e)
        {
            EditStudent editStudent = new EditStudent();

            editStudent.Text          = "新增学生";
            editStudent.StartPosition = FormStartPosition.CenterParent;
            if (editStudent.ShowDialog() == DialogResult.OK)
            {
                students.Add(editStudent.student);
                this.grid_students.Refresh();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 修改学生
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_update_Click(object sender, EventArgs e)
        {
            if (this.grid_students.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择要修改的行");
                return;
            }
            var         selectRow     = this.grid_students.SelectedRows[0];
            var         studentId     = (int)selectRow.Cells["studentID"].Value;
            var         selectStudent = students.FirstOrDefault(x => x.Id == studentId);
            EditStudent editStudent   = new EditStudent(selectStudent);

            editStudent.Text          = "修改学生";
            editStudent.StartPosition = FormStartPosition.CenterParent;
            if (editStudent.ShowDialog() == DialogResult.OK)
            {
                this.grid_students.Refresh();
            }
        }