Пример #1
0
        /// <summary>
        /// 提交修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSave_Click(object sender, EventArgs e)
        {
            //数据校验
            Reader reader = new Reader
            {
                ReaderId      = roleId,
                ReadingCard   = this.txtReadingCard.Text.Trim(),
                ReaderName    = this.txtReaderName.Text.Trim(),
                Gender        = rdoMale.Checked ? "男" : "女",
                ReaderAddress = this.txtAddress.Text.Trim(),
                PostCode      = this.txtPostcode.Text.Trim(),
                PhoneNumber   = this.txtPhone.Text.Trim(),
                RoleId        = Convert.ToInt32(this.cboReaderRole.SelectedValue),
                ReaderImage   = this.pbReaderPhoto.Image == null ? "" : SerializeObjectToString.SerializeObject(this.pbReaderPhoto.Image),
            };

            try
            {
                readerManager.EditReader(reader);
                MessageBox.Show("修改成功!:", "修改提示");
            }
            catch (Exception ex)
            {
                MessageBox.Show("操作异常:" + ex.Message, "异常提示");
            }
        }
Пример #2
0
 private void BtnSave_Click(object sender, EventArgs e)
 {
     #region 数据验证(非空验证)
     if (this.txtReaderName.Text.Trim().Length == 0)
     {
         MessageBox.Show("请输入读者姓名", "提示信息");
         this.txtReaderName.Focus();
         return;
     }
     if (this.txtReadingCard.Text.Trim().Length == 0)
     {
         MessageBox.Show("请输入借阅证编号", "提示信息");
         this.txtReadingCard.Focus();
         return;
     }
     if (!this.rdoMale.Checked && !this.rdoFemale.Checked)
     {
         MessageBox.Show("请选择性别", "提示信息");
         return;
     }
     if (this.cboReaderRole.SelectedIndex == -1)
     {
         MessageBox.Show("请选择会员角色", "提示信息");
         return;
     }
     if (!Common.DataValidate.IsIdentityCard(this.txtIDCard.Text.Trim()))
     {
         MessageBox.Show("请输入正确的身份证号", "提示信息");
         this.txtIDCard.SelectAll();
         this.txtIDCard.Focus();
         return;
     }
     if (this.txtPhone.Text.Trim().Length == 0)
     {
         MessageBox.Show("请输入联系电话", "提示信息");
         this.txtPhone.Focus();
         return;
     }
     #endregion
     #region 重复验证
     try
     {
         if (objReaderManager.IsExistsReadingCard(this.txtReadingCard.Text.Trim(), currentReader.ReaderId.ToString()))
         {
             MessageBox.Show("借阅证号重复,请修改", "提示信息");
             this.txtReadingCard.SelectAll();
             this.txtReadingCard.Focus();
             return;
         }
         if (objReaderManager.IsExistsIDCard(this.txtIDCard.Text.Trim(), currentReader.ReaderId.ToString()))
         {
             MessageBox.Show("身份证号重复,请修改", "提示信息");
             this.txtIDCard.SelectAll();
             this.txtIDCard.Focus();
             return;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("校验数据是否重复时发生异常,请重试:" + ex.Message, "提示信息");
         return;
     }
     #endregion
     #region 封装数据
     Reader objReader = new Reader()
     {
         ReaderName    = this.txtReaderName.Text.Trim(),
         Gender        = this.rdoMale.Checked ? "男" : "女",
         RoleId        = Convert.ToInt32(this.cboReaderRole.SelectedValue),
         IDCard        = this.txtIDCard.Text.Trim(),
         PhoneNumber   = this.txtPhone.Text.Trim(),
         ReaderAddress = this.txtAddress.Text.Trim(),
         PostCode      = this.txtPostcode.Text.Trim(),
         ReaderImage   = this.pbReaderPhoto.Image == null ? "" : new Common.SerializeObjectToString().SerializeObject(this.pbReaderPhoto.Image),
         ReaderId      = this.currentReader.ReaderId
     };
     #endregion
     #region 调用后台方法执行
     try
     {
         objReaderManager.EditReader(objReader);
         MessageBox.Show("修改成功", "提示信息");
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("修改发生异常:" + ex.Message, "异常提示");
     }
     #endregion
 }