示例#1
0
        /// <summary>
        /// 添加/修改 按钮,用于人员信息的添加  或者 修改密码等
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_添加_Click(object sender, EventArgs e)
        {
            if (textBox_账户名.Text == "" || textBox_密码.Text == "")//用户名或密码不能为空
            {
                MessageBox.Show("用户名或密码不能为空");
            }
            else
            {
                if (button_添加.Text == "添加")
                {
                    #region 添加事件,执行过程
                    ManagerInfo mi = new ManagerInfo()
                    {
                        MNam  = textBox_账户名.Text,
                        MPwd  = textBox_密码.Text,
                        MType = radioButton_店员.Checked ? 1 : 0
                    };

                    if (MIBll.Insert(mi))
                    {
                        GetInfo();
                        button_取消.PerformClick();
                    }
                    else
                    {
                        button_取消.PerformClick();
                        MessageBox.Show("添加错误,请重新输入");
                    }
                    #endregion
                }
                else
                {
                    #region 修改事件,执行过程
                    ManagerInfo mi = new ManagerInfo()
                    {
                        MNam  = textBox_账户名.Text,
                        MPwd  = textBox_密码.Text,
                        MType = radioButton_店员.Checked ? 1 : 0,
                        MId   = int.Parse(textBox_编号.Text)
                    };
                    if (MIBll.Update(mi))
                    {
                        GetInfo();
                        button_取消.PerformClick();
                    }
                    else
                    {
                        button_取消.PerformClick();
                        MessageBox.Show("修改错误,请重新输入");
                    }
                    #endregion
                }
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ManagerInfo manager = new ManagerInfo()
            {
                //MId=Convert.ToInt32(txtId.Text),
                MName = txtName.Text,
                MPwd  = txtPwd.Text,
                MType = rb1.Checked ? 1 : 0
            };
            ManagerInfoBll bll = new ManagerInfoBll();

            if (btnSave.Text == "添加")
            {
                if (bll.Insert(manager))
                {
                    LoadList();
                    //MessageBox.Show("添加成功");
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                manager.MId = Convert.ToInt32(txtId.Text);
                if (bll.Update(manager))
                {
                    LoadList();
                    //MessageBox.Show("添加成功");
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
            txtId.Text   = "添加时无编号";
            txtName.Text = "";
            txtPwd.Text  = "";
            rb2.Checked  = true;
            btnSave.Text = "添加";
        }