/// <summary> /// 确认修改按键 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSureUpdate_Click(object sender, RoutedEventArgs e) { //CheckInfor这个个方法,改变数据之前的最终验证 if (CheckInfor()) { studentSJ.StudentName = txtName.Text; //姓名 studentSJ.Age = Convert.ToInt32(txtAge.Text); //年龄 studentSJ.Birthday = datePkBirthday.Text.ToString(); //日期 studentSJ.CardNo = txtCardNo.Text; //考勤卡号 studentSJ.ClassId = (int)cmbClassName.SelectedValue; //科目 studentSJ.Gender = (radBoy.IsChecked == true ? "男" : "女"); //性别 studentSJ.PhoneNumber = txtPhoneNumber.Text; //电话 studentSJ.StudentAddress = (string.IsNullOrEmpty(txtAddress.Text) ? null : txtAddress.Text); //住址 studentSJ.StudentIdNo = txtStuNoId.Text; //身份证号 //判断是否重新选择了Image图片;路径 if (stuImg.Source == new BitmapImage(new Uri("/img1/bg/zwzp.jpg", UriKind.RelativeOrAbsolute))) { studentSJ.StuImage = null; } //判断数据库中的图片是否和目前的上传图片一样 else { //证明未修改图片,目前的图片和原来数据库中的一致 if (image != null && img1.Buffer == image.Buffer) { //序列化 studentSJ.StuImage = Common.BinaryStuObjcet.ZBinaryForStu(image); } else { studentSJ.StuImage = Common.BinaryStuObjcet.ZBinaryForStu(img1); } } //UpdateStudentInfor修改的方法,studentSJ把上面赋给他的值全部赋给UpdateStudentInfor这个方法 if (manager.UpdateStudentInfor(studentSJ))//修改的所有值传递进去,如果传递成功则系统提示并关闭 { System.Windows.MessageBox.Show("修改成功!", "提示"); this.Close(); } else { System.Windows.MessageBox.Show("修改失败,请稍后再试!", "提示"); } } }