private void btnSave_Click(object sender, EventArgs e) { ManagerInfo mi = new ManagerInfo() { MName = txtName.Text, MPwd = txtPwd.Text, MType = rb1.Checked ? 1 : 0, //经理为1,店员为0 }; if (txtId.Text.Equals("添加时无编号")) { if (miBll.Add(mi)) { LoadList(); } else { MessageBox.Show("添加失败"); } } else { MessageBox.Show("cuowu"); } txtName.Text = ""; txtPwd.Text = ""; rb2.Checked = true; btnSave.Text = "添加"; txtId.Text = "添加时无编号"; }
private void bt_add_Click(object sender, EventArgs e) { ManagerInfo mi = new ManagerInfo() { Mname = tb_uname.Text, Mpwd = MD5Helper.Md5_Encrypt(tb_pwd.Text), Mtype = rb_1.Checked ? 1 : 0 }; if (mbll.Add(mi)) { MessageBox.Show("succse", "tip"); this.load_list(); } else { MessageBox.Show("error", "tip"); } }
public object Put([FromBody] ManagerInfo model) { if (string.IsNullOrWhiteSpace(model.AdminAccount)) { return(new { result = Result.ValueCanNotBeNull }); } if (string.IsNullOrWhiteSpace(model.AdminPasswd)) { return(new { result = Result.ValueCanNotBeNull }); } //if (Utils.IsValidate(model.AdminAccount)) //{ // return new { result = Result.ValueCanNotBeNull }; //} if (!Regex.IsMatch(model.AdminAccount, @"^[a-zA-Z_]\w{3,16}")) { return(new { result = Result.AccountOnlyConsistOfLettersAndNumbers }); } ManagerInfo mi = ManagerInfoBLL.GetModel(model); if (mi != null) { return(new { result = Result.AccountHasBeenRegistered }); } model.AdminMasterRight = 0; model.AdminPasswd = Utils.MD5(model.AdminPasswd); model.CreateDate = DateTime.Now; int result = ManagerInfoBLL.Add(model); if (result > 0) { return(new { result = 0 }); } return(new { result = 4 }); }
private void btnSave_Click(object sender, EventArgs e) { ManagerInfo mi = new ManagerInfo(); //1、构造ManagerInfo对象 mi.MName = txtName.Text; mi.MPwd = txtPwd.Text; mi.MType = rb1.Checked ? 1 : 0; if (txtId.Text.Equals("添加时无编号"))//表示增加数据 { //表示增加成功 if (miBll.Add(mi)) { LoadList(); ClearText(); } //表示增加失败 else { MessageBox.Show("添加失败,请稍后重试!"); } } else//表示修改数据 { mi.MId = Convert.ToInt32(txtId.Text); if (miBll.Edit(mi)) { LoadList(); ClearText(); } else { MessageBox.Show("修改失败,请稍后再试!"); } } }
private void button2_Click(object sender, EventArgs e) { if (button2.Text == "添加") { ManagerInfo InsertData = new ManagerInfo() { MName = textBox3.Text.Trim(), MPwd = textBox2.Text.Trim(), MType = radioButton1.Checked ? 1 : 0 }; if (miBll.Add(InsertData)) { LoadList(); } else { MessageBox.Show("添加失败"); } } else { ManagerInfo ModifierData = new ManagerInfo() { MName = textBox3.Text.Trim(), MPwd = textBox2.Text.Trim(), MType = radioButton1.Checked ? 1 : 0, Mid = Convert.ToInt32(textBox1.Text.Trim()) }; if (miBll.Modifier(ModifierData)) { MessageBox.Show("修改成功!"); LoadList(); } ; } }