日期:2014-05-18 浏览次数:20969 次
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace HY_New { public partial class frmProCla : Form { public frmProCla() { InitializeComponent(); } private void ChangeEnableState() { proClassTableBindingNavigator.Enabled = !proClassTableBindingNavigator.Enabled; gbEdit.Enabled = !gbEdit.Enabled; foreach (ToolStripButton b in tsControl.Items) { b.Enabled = !b.Enabled; } } private void frmProCla_Load(object sender, EventArgs e) { // TODO: 这行代码将数据加载到表“_DsHY_new.Department”中。您可以根据需要移动或删除它。 this.departmentTableAdapter.Fill(this._DsHY_new.Department); // TODO: 这行代码将数据加载到表“_DsHY_new.ProClassTable”中。您可以根据需要移动或删除它。 this.proClassTableTableAdapter.Fill(this._DsHY_new.ProClassTable); } private void tsbInsert_Click(object sender, EventArgs e) { ChangeEnableState(); proClassTableBindingSource.AddNew(); proClassNameTextBox.Focus(); } private void tsbEdit_Click(object sender, EventArgs e) { ChangeEnableState(); proClassNameTextBox.Focus(); } private void tsbDelete_Click(object sender, EventArgs e) { if (proClassTableBindingSource.Current != null) { if (MessageBox.Show("确实要删除吗?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { proClassTableBindingSource.RemoveCurrent(); [color=#0000FF]this.tableAdapterManager.UpdateAll(this._DsHY_new);[/color] //此处出错 } } } private void tsbSave_Click(object sender, EventArgs e) { ChangeEnableState(); this.Validate(); this.proClassTableBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this._DsHY_new); //此处在新增时保存通过,在修改时保存出错。 } private void tsbCancel_Click(object sender, EventArgs e) { ChangeEnableState(); this.proClassTableBindingSource.CancelEdit(); } } }