/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_add_Click(object sender, EventArgs e) { //创建药品信息类Drug的对象(使用带参构造器) Drug drug = new Drug(key, tb_name.Text, (int)cb_unit.SelectedValue, tb_spec.Text, tb_origin.Text, tb_lot_num.Text, double.Parse(nud_reserve.Value.ToString()), double.Parse(tb_w_price.Text), double.Parse(tb_r_price.Text.ToString())); if (btn_add.Text == "添加") { int result = drug.addDrug(); if (result == 1) { MessageBox.Show("添加成功!", "温馨提示"); } else { MessageBox.Show("添加失败,请检查输入信息!", "温馨提示"); } } else if (btn_add.Text == "修改") { int result = drug.changeDrug(); if (result == 1) { MessageBox.Show("修改信息成功!", "温馨提示"); } else { MessageBox.Show("修改信息失败,请检查药品是否已经存在!", "温馨提示"); } } Close(); }