コード例 #1
0
        //教师列表编辑后保存
        private void dataGridView2_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            TeacherModel teaModelToBeUpdated = new TeacherModel();
            TeacherBusiness teaBusiness = new TeacherBusiness();

            teaModelToBeUpdated.Tid = int.Parse(this.dataGridView2.CurrentRow.Cells["tid"].Value.ToString());

            teaModelToBeUpdated.Tname = this.dataGridView2.CurrentRow.Cells["tname"].Value.ToString();
            teaModelToBeUpdated.Birthday = this.dataGridView2.CurrentRow.Cells["birthday"].Value.ToString();
            teaModelToBeUpdated.Gender = this.dataGridView2.CurrentRow.Cells["tgender"].Value.ToString()=="男"?1:0;
            teaModelToBeUpdated.Phone = this.dataGridView2.CurrentRow.Cells["phone"].Value.ToString();

            int result = teaBusiness.updateteacher(teaModelToBeUpdated);
            if (result != 0)
            {
                MessageBox.Show("更新成功");
            }
            else
            {
                MessageBox.Show("更新失败");
            }
        }