using System; using System.Data; using DevExpress.XtraEditors; using UAS_DeviceMonitor.Entity; namespace UAS_DeviceMonitor.CustomerControl.Button { public partial class ButtonSaveGrid : SimpleButton { private AutoDataGridControl.AutoDataGridControl grid; /// /// 设置是否优先处理用户自定义的Click事件 /// private bool handlerOtherFirst = false; public AutoDataGridControl.AutoDataGridControl Grid { get { return grid; } set { grid = value; } } public bool HandlerOtherFirst { get { return handlerOtherFirst; } set { handlerOtherFirst = value; } } public ButtonSaveGrid() { InitializeComponent(); } /// /// 处理完其他Click事件提供回调函数重新触发保存事件 /// public void DoSave() { DataTable dt = ((DataTable)grid.DataSource).GetChanges(); if (dt != null && dt.Rows.Count > 0) { SystemInf.dh.SaveDataTable(dt, grid.TableName, grid.ID, grid.InsertSQL); grid.RefreshData(); XtraMessageBox.Show("保存成功", "提示"); } else { XtraMessageBox.Show("没有修改过的数据", "提示"); } } private void ButtonSaveGrid_Click(object sender, EventArgs e) { if (!handlerOtherFirst) { DoSave(); } } } }