private void cmdDelete_Click(object sender, EventArgs e) { isBusy.Visible = true; cmdDelete.Enabled = false; try { int tempID = int.Parse(lsvPayout.SelectedItems[0].SubItems[5].Text); DelegateDeletePayout dn = MysqlControl.DeletePayout; IAsyncResult iar = dn.BeginInvoke(tempID, null, null); while (iar.IsCompleted == false) { Application.DoEvents(); } MysqlController.ReturnResult iResult = dn.EndInvoke(iar); if (iResult.isSuccess) { MessageBox.Show(Resources.frmViewProfit_cmdDelete_Click_删除支出记录成功_, Application.ProductName, MessageBoxButtons.OK); RefreshPayout(dtpFromTime.Value.Year + dtpFromTime.Value.Month.ToString().PadLeft(2, '0') + dtpFromTime.Value.Day.ToString().PadLeft(2, '0')); } else { MessageBox.Show(Resources.frmViewProfit_cmdDelete_Click_ + iResult.ErrDesc, Application.ProductName, MessageBoxButtons.OK); } } catch (Exception) { isBusy.Visible = false; cmdDelete.Enabled = true; return; } isBusy.Visible = false; cmdDelete.Enabled = true; }
private void cmdDelete_Click(object sender, EventArgs e) { cmdDelete.Enabled = false; isBusy.Visible = true; try { int tempID = int.Parse(lsvPayout.SelectedItems[0].SubItems[5].Text); DelegateDeletePayout dn = MysqlControl.DeletePayout; IAsyncResult iar = dn.BeginInvoke(tempID, null, null); while (iar.IsCompleted == false) { Application.DoEvents(); } MysqlController.ReturnResult iResult = dn.EndInvoke(iar); if (iResult.isSuccess) { isBusy.Visible = true; var iLog = new clsLog.LogPart(); iLog.LogDate = DateTime.Now.Year + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0'); iLog.LogTime = DateTime.Now.Hour + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0'); iLog.LogUser = iLoginUser; iLog.LogDetail = @"删除固定支出 编号为:" + tempID; DelegateAddLog dnlog = LogControl.AddLog; IAsyncResult iarlog = dnlog.BeginInvoke(iLog, null, null); while (iarlog.IsCompleted == false) { Application.DoEvents(); } dnlog.EndInvoke(iarlog); isBusy.Visible = false; MessageBox.Show(Resources.frmPayout_cmdDelete_Click_删除支出记录成功_, Application.ProductName, MessageBoxButtons.OK); RefreshPayout(); } else { MessageBox.Show(Resources.frmPayout_cmdDelete_Click_ + iResult.ErrDesc, Application.ProductName, MessageBoxButtons.OK); } } catch (Exception) { isBusy.Visible = false; cmdDelete.Enabled = true; return; } isBusy.Visible = false; cmdDelete.Enabled = true; }