private void toolSave_Click(object sender, EventArgs e) { if (getPan() == 1) { if (intFalg == 1) { //添加 if (SupplierDAL.checkloginName(supplier.Name)) { MessageBox.Show("登录名称已被占用!"); this.txtCompanyName.Text = ""; txtCompanyName.Focus(); return; } SupplierDAL.AddModel <Supplier>(supplier); intFalg = 0; BindData("", 0); ClearControls(); ControlStatus();; } if (intFalg == 2) { //修改 Supplier model = SupplierDAL.getEntryById <Supplier, long>(supplier.SupplierId); if (model == null) { MessageBox.Show("账号不存在,修改失败"); intFalg = 0; ClearControls(); ControlStatus(); } else { if (SupplierDAL.checkloginName(supplier.Name, supplier.SupplierId)) { MessageBox.Show("供应商名称已存在"); } else { SupplierDAL.EditEntry <Supplier>(supplier, "SupplierId"); MessageBox.Show("修改成功"); BindData("", 0); } ClearControls(); ControlStatus(); } } if (intFalg == 3) { Supplier model = SupplierDAL.getEntryById <Supplier, long>(supplier.SupplierId); //删除 if (model != null) { SupplierDAL.DeleteEntry <Supplier, int>(supplier.SupplierId); MessageBox.Show("删除成功"); BindData("", 0); intFalg = 0; ClearControls(); ControlStatus(); } else { MessageBox.Show("删除失败"); intFalg = 0; ClearControls(); ControlStatus(); } } } }