private void tlBtnSave_Click(object sender, EventArgs e) { //判断是添加还是修改数据 if (G_Int_addOrUpdate == 0) { try { //添加数据 unitsInfo.UnitCode = txtUnitCode.Text; unitsInfo.FullName = txtFullName.Text; unitsInfo.Tax = txtTax.Text; unitsInfo.Tel = txtTel.Text; unitsInfo.LinkMan = txtLinkMan.Text; unitsInfo.Address = txtAddress.Text; unitsInfo.Accounts = txtAccounts.Text; //执行添加 int id = baseinfo.AddUnits(unitsInfo); MessageBox.Show("新增--往来单位数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //修改数据 unitsInfo.UnitCode = txtUnitCode.Text; unitsInfo.FullName = txtFullName.Text; unitsInfo.Tax = txtTax.Text; unitsInfo.Tel = txtTel.Text; unitsInfo.LinkMan = txtLinkMan.Text; unitsInfo.Address = txtAddress.Text; unitsInfo.Accounts = txtAccounts.Text; //执行修改 int id = baseinfo.UpdateUnits(unitsInfo); MessageBox.Show("修改--往来单位数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); } dgvUnitsList.DataSource = baseinfo.GetAllUnits("tb_units").Tables[0].DefaultView; SetdgvUnitsListHeadText(); cancelEnabled(); }