Beispiel #1
0
        //修改读者信息
        private void tsbUpdateReader_Click(object sender, EventArgs e)
        {
            CtbReaderInformation      updateReader = new CtbReaderInformation();
            _delegateRefreshAllReader _dlg         = new _delegateRefreshAllReader(RefreshAllReader);

            if (dgvAllReader.CurrentRow != null)
            {
                updateReader.readerID       = int.Parse(dgvAllReader.CurrentRow.Cells["readerID"].Value.ToString());
                updateReader.readerName     = dgvAllReader.CurrentRow.Cells["readerName"].Value.ToString();
                updateReader.readerSex      = dgvAllReader.CurrentRow.Cells["readerSex"].Value.ToString();
                updateReader.readerOffice   = dgvAllReader.CurrentRow.Cells["readerOffice"].Value.ToString();
                updateReader.readerDept     = dgvAllReader.CurrentRow.Cells["readerDept"].Value.ToString();
                updateReader.readerPhone    = dgvAllReader.CurrentRow.Cells["readerPhone"].Value.ToString();
                updateReader.readerHAddress = dgvAllReader.CurrentRow.Cells["readerHAddress"].Value.ToString();
                updateReader.readerEmail    = dgvAllReader.CurrentRow.Cells["readerEmail"].Value.ToString();
                updateReader.readerResDate  = DateTime.Parse(dgvAllReader.CurrentRow.Cells["readerResDate"].Value.ToString());

                //打开修改窗体
                frmReaderAddOrUpdate updateFrm = new frmReaderAddOrUpdate(updateReader, _dlg);
                updateFrm.MdiParent = this.MdiParent;
                updateFrm.Show();
            }
            else
            {
                MessageBox.Show("没有要修改的信息,请选中你要修改的信息再执行修改操作!", "操作提示");
            }
        }
Beispiel #2
0
        private void cbReader_TextChanged(object sender, EventArgs e)
        {
            CtbReaderInformationBLL cReaderBll = new CtbReaderInformationBLL();
            CtbReaderInformation    creader    = cReaderBll.GetModel(int.Parse(cbReader.Text));

            if (creader != null)
            {
                lbRname.Visible  = true;
                lbRname1.Visible = true;
                lbRname1.Text    = creader.readerName;
            }
        }
        public frmReaderAddOrUpdate(CtbReaderInformation cReader, frmReaderManage._delegateRefreshAllReader _dlg)
        {
            //此构造函数用于修改读者信息
            InitializeComponent();
            dlg          = _dlg;
            this.Text    = "修改读者信息";
            btEnter.Text = "保存";

            //将传递过来的读者信息赋值于各个控件以备修改
            tbReaderID.Text        = cReader.readerID.ToString();
            tbReaderName.Text      = cReader.readerName;
            cbReaderSex.Text       = cReader.readerSex;
            tbReaderOffice.Text    = cReader.readerOffice;
            tbReaderDept.Text      = cReader.readerDept;
            tbReaderPhone.Text     = cReader.readerPhone;
            tbReaderEMail.Text     = cReader.readerEmail;
            dtkReaderResDate.Value = cReader.readerResDate;

            //读者编号不能修改
            tbReaderID.ReadOnly = true;
        }
        private void btEnter_Click(object sender, EventArgs e)
        {
            //在这里我们要进行判断我们进行的是添加还是修改
            //判断的方法我们这里只介绍针对我们现在这种情况的方法
            //方法就是判断按钮的TEXT是"添加"还是"保存"
            #region 添加事件代码部分

            if (btEnter.Text == "添加")
            {
                CtbReaderInformation    cReader    = new CtbReaderInformation();
                CtbReaderInformationBLL cReaderBll = new CtbReaderInformationBLL();
                //这里我们允许某些字段为空,但是读者ID,和读者姓名不允许为空
                if (tbReaderID.Text != "" && tbReaderName.Text != "")
                {
                    cReader.readerID   = int.Parse(tbReaderID.Text);
                    cReader.readerName = tbReaderName.Text;

                    //判断控件内容是否为空,为空不赋值,使用类属性的默认值
                    if (cbReaderSex.Text != "")
                    {
                        cReader.readerSex = cbReaderSex.Text;
                    }
                    if (tbReaderOffice.Text != "")
                    {
                        cReader.readerOffice = tbReaderOffice.Text;
                    }
                    if (tbReaderDept.Text != "")
                    {
                        cReader.readerDept = tbReaderDept.Text;
                    }
                    if (tbReaderPhone.Text != "")
                    {
                        cReader.readerPhone = tbReaderPhone.Text;
                    }
                    if (tbReaderAddress.Text != "")
                    {
                        cReader.readerHAddress = tbReaderAddress.Text;
                    }
                    if (tbReaderEMail.Text != "")
                    {
                        cReader.readerEmail = tbReaderEMail.Text;
                    }

                    cReader.readerResDate = dtkReaderResDate.Value;

                    try
                    {
                        //执行添加操作
                        cReaderBll.Add(cReader);
                        if (MessageBox.Show("添加成功!是否继续添加?", "操作提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            dlg();
                            ClearAllContent();
                        }
                        else
                        {
                            dlg();
                            this.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "系统异常提示");
                    }
                }
            }

            #endregion

            #region 修改事件代码
            if (btEnter.Text == "保存")
            {
                CtbReaderInformation    cReader    = new CtbReaderInformation();
                CtbReaderInformationBLL cReaderBll = new CtbReaderInformationBLL();
                //这里我们允许某些字段为空,但是读者姓名不允许为空
                if (tbReaderName.Text != "")
                {
                    cReader.readerID   = int.Parse(tbReaderID.Text);
                    cReader.readerName = tbReaderName.Text;

                    //判断控件内容是否为空,为空不赋值,使用类属性的默认值
                    if (cbReaderSex.Text != "")
                    {
                        cReader.readerSex = cbReaderSex.Text;
                    }
                    if (tbReaderOffice.Text != "")
                    {
                        cReader.readerOffice = tbReaderOffice.Text;
                    }
                    if (tbReaderDept.Text != "")
                    {
                        cReader.readerDept = tbReaderDept.Text;
                    }
                    if (tbReaderPhone.Text != "")
                    {
                        cReader.readerPhone = tbReaderPhone.Text;
                    }
                    if (tbReaderAddress.Text != "")
                    {
                        cReader.readerHAddress = tbReaderAddress.Text;
                    }
                    if (tbReaderEMail.Text != "")
                    {
                        cReader.readerEmail = tbReaderEMail.Text;
                    }

                    cReader.readerResDate = dtkReaderResDate.Value;

                    //执行修改操作
                    try
                    {
                        cReaderBll.Update(cReader);
                        MessageBox.Show("修改成功", "操作提示");
                        dlg();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "系统异常提示");
                    }
                }
            }

            #endregion
        }