private void btn_Click(object sender, EventArgs e) { Commodity commodity = new Commodity(); commodity.setId(id); commodity.setName(name.Text); commodity.setSpecification(specification.Text); commodity.setUnit(unit.Text); commodity.setApproval(approval.Text); commodity.setBid(bid.Text); commodity.setPacking(packing.Text); commodity.setPrice(price.Text); commDao info = new commDao(); info.verification(commodity); if (info.updateCommodity(commodity)) { MessageBox.Show("修改成功!"); } else { MessageBox.Show("修改失败!"); } // this.Close(); }
private void addbtn_Click(object sender, EventArgs e) { Commodity commodity = new Commodity(); try { commodity.setName(name.Text); commodity.setBid(bid.Text); commodity.setPrice(price.Text); commodity.setPacking(packing.Text); commodity.setSpecification(specification.Text); commodity.setUnit(unit.Text); commodity.setApproval(approval.Text); } catch { } commDao info = new commDao(); if (info.verification(commodity)) { if (info.saveCommodity(commodity)) { MessageBox.Show("添加成功!"); name.Text = ""; bid.Text = ""; price.Text = ""; packing.Text = ""; specification.Text = ""; unit.Text = ""; approval.Text = ""; } else { MessageBox.Show("添加失败!"); } } }