private void DgvGrid_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0) { return; } int id = Convert.ToInt32(DgvGrid["ColAction", e.RowIndex].Value.ToString()); // 获取所要修改关联对象的主键。 //用户单击DataGridView“操作”列中的“修改”按钮。 if (DBConfigDataGridViewActionButtonCell.IsModifyButtonClick(sender, e)) { SqlServerConfigInfo dbConfigInfo = SqlServerConfigInfoBLL.CreateInstance().Get(id); FormMain.LoadNewControl(SqlServerConfigEdit.BindJobDetail(dbConfigInfo)); // 载入该模块的修改信息界面至主窗体显示。 } //用户单击DataGridView“操作”列中的“删除”按钮。 if (DBConfigDataGridViewActionButtonCell.IsDeleteButtonClick(sender, e)) { DialogResult dialogResult = FormSysMessage.ShowMessage("确定要删除该项吗?"); if (dialogResult == DialogResult.OK) { SqlServerConfigInfoBLL.CreateInstance().Delete(id); BindDataGrid(); } } }
private void DgvGrid_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0) { return; } int jobId = Convert.ToInt32(DgvGrid["ColAction", e.RowIndex].Value.ToString()); // 获取所要修改关联对象的主键。 string jobIdentity = DgvGrid["ScheduleJobName", e.RowIndex].Value.ToString(); CustomJobDetail jobDetail = CustomJobDetailBLL.CreateInstance().Get(jobId, jobIdentity); #region 修改 //用户单击DataGridView“操作”列中的“修改”按钮。 if (JobDataGridViewActionButtonCell.IsModifyButtonClick(sender, e)) { FormMain.LoadNewControl(ScheduleJobEdit.BindJobDetail(jobDetail)); // 载入该模块的修改信息界面至主窗体显示。 } #endregion #region 除 //用户单击DataGridView“操作”列中的“删除”按钮。 if (JobDataGridViewActionButtonCell.IsDeleteButtonClick(sender, e)) { DialogResult dialogResult = FormSysMessage.ShowMessage("确定要删除该任务计划吗?"); if (dialogResult == DialogResult.OK) { var formSysMessage = FormSysMessage.ShowLoading(); int effected = CustomJobDetailBLL.CreateInstance().Delete(jobId, jobIdentity); if (effected > 0) { CustomJobDetailBLL.CreateInstance().DeleteHostJob( jobHostSite, jobId, jobIdentity, () => { this.Invoke(new RefreshDataGrid(SetLoadingDialog), formSysMessage, "删除任务计划成功。"); }, () => { this.Invoke(new RefreshDataGrid(SetLoadingDialog), formSysMessage, "删除任务计划失败。"); }); } BindDataGrid(); } } #endregion #region 启动任务计划 //用户单击DataGridView“操作”列中的“启动”按钮。 if (JobDataGridViewActionButtonCell.IsStartButtonClick(sender, e)) { var formSysMessage = FormSysMessage.ShowLoading(); CustomJobDetailBLL.CreateInstance().StartHostJob(jobHostSite, jobId, jobIdentity, () => { this.Invoke(new RefreshDataGrid(SetLoadingDialog), formSysMessage, "启动任务计划成功。"); }, () => { this.Invoke(new RefreshDataGrid(SetLoadingDialog), formSysMessage, "启动任务计划失败。"); }); } #endregion #region 停止任务计划 //用户单击DataGridView“操作”列中的“停止”按钮。 if (JobDataGridViewActionButtonCell.IsStopButtonClick(sender, e)) { var formSysMessage = FormSysMessage.ShowLoading(); CustomJobDetailBLL.CreateInstance().StopHostJob(jobHostSite, jobId, jobIdentity, () => { this.Invoke(new RefreshDataGrid(SetLoadingDialog), formSysMessage, "停止任务计划成功。"); }, () => { this.Invoke(new RefreshDataGrid(SetLoadingDialog), formSysMessage, "停止任务计划失败。"); }); } #endregion }