public SellGoodsForm(string EmpID) : this() { txtEmpID.Text = EmpID; sellGoods = new tb_SellGoods(); sellGoodsMenthod = new tb_SellGoodsMenthod(); sellGoodsMenthod.Find(dataGridView1); }
//保存按钮 private void saveButton_Click(object sender, EventArgs e) { if (IsComplete()) { if (count == 1) //添加操作 { if (sellGoodsMenthod.Add(sellGoods)) { MessageBox.Show("添加成功"); Clear(); ChangeToolsStatus(); count = 0; sellGoodsMenthod.Find(dataGridView1); //返回操作后的数据库 button1.Enabled = false; Ban(); } else { MessageBox.Show("添加失败"); Clear(); ChangeToolsStatus(); count = 0; button1.Enabled = false; Ban(); } } if (count == 2) //修改操作 { if (sellGoodsMenthod.Update(sellGoods, this.dataGridView1[3, this.dataGridView1.CurrentCell.RowIndex].Value.ToString())) { MessageBox.Show("修改成功"); Clear(); ChangeToolsStatus(); count = 0; sellGoodsMenthod.Find(dataGridView1); Ban(); } else { MessageBox.Show("修改失败"); Clear(); ChangeToolsStatus(); count = 0; Ban(); } } if (count == 3) //删除操作 { if (sellGoodsMenthod.Delete(sellGoods)) { MessageBox.Show("删除成功"); Clear(); ChangeToolsStatus(); count = 0; sellGoodsMenthod.Find(dataGridView1); } else { MessageBox.Show("删除失败"); Clear(); ChangeToolsStatus(); count = 0; } } } }