private void btnSave_Click(object sender, EventArgs e) { MemberTypeInfoBll bll = new MemberTypeInfoBll(); MemberTypeInfo model = new MemberTypeInfo() { MTitle = txtTitle.Text, MDiscount = Convert.ToDecimal(txtDiscount.Text), }; if (btnSave.Text == "添加") { if (!bll.Add(model)) { MessageBox.Show("添加失败"); } } else { model.MId = Convert.ToInt32(txtId.Text); if (!bll.Update(model)) { MessageBox.Show("修改失败"); } } Reset(); LoadList(); resulted = DialogResult.OK; }
private void btnSave_Click(object sender, EventArgs e) { MemberTypeInfo memberTypeInfo = new MemberTypeInfo(); memberTypeInfo.MDiscount = Convert.ToDecimal(txtDiscount.Text); memberTypeInfo.MTitle = txtTitle.Text; if (btnSave.Text.Equals("添加")) { if (MemberTypeInfoBll.Insert(memberTypeInfo)) { MessageBox.Show("添加成功"); LoadList(); UpdateList(); btnCancel.PerformClick(); } else { MessageBox.Show("添加失败,请稍后重试"); } } else { memberTypeInfo.MId = Convert.ToInt32(txtId.Text); if (MemberTypeInfoBll.Update(memberTypeInfo)) { MessageBox.Show("修改成功"); LoadList(); UpdateList(); btnCancel.PerformClick(); } else { MessageBox.Show("修改失败"); } } }