/// <summary> /// 保存 或者修改按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (btnSave.Text == "添加") { mi.Memtitle = txtTitle.Text; mi.Memdiscount = Convert.ToDouble(txtDiscount.Text); mi.Memisdelete = 0; if (mtib.AddMysql(mi)) { MessageBox.Show("添加成功"); } else { MessageBox.Show("添加失败"); } } else { mi.Memid = Convert.ToInt32(txtId.Text); mi.Memtitle = txtTitle.Text; mi.Memdiscount = Convert.ToDouble(txtDiscount.Text); mi.Memisdelete = 0; if (mtib.ChangeMysql(mi)) { MessageBox.Show("修改成功"); } else { MessageBox.Show("修改失败"); } } ClearBox(); //mi = null; }