예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ManagerInfo mi = new ManagerInfo()  //根据控件数据实例数据对象
            {
                MName = tbName.Text,
                MPwd  = tbPwd.Text,
                MType = rb1.Checked ? 1 : 0
            };

            if (btnSave.Text.Equals("添加"))   //添加状态
            {
                #region 添加操作
                if (miBll.add(mi))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试!");
                }
                #endregion
            }
            else    //修改状态
            {
                #region 修改操作
                mi.MId = Convert.ToInt32(tbId.Text);
                if (miBll.edit(mi))
                {
                    LoadList();
                }

                #endregion
            }


            tbName.Clear();
            tbPwd.Clear();
            tbId.Text    = "添加时无编号";
            rb2.Checked  = true;
            btnSave.Text = "添加";
        }