//private delegate MysqlController.ReturnResult DelegateFixCustomDebt(string DebtID, string FixDate); private void cmdSplitFix_Click(object sender, EventArgs e) { cmdSplitFix.Enabled = false; try { if (lsvDebt.SelectedItems[0].SubItems[6].Text == "已到帐") { cmdSplitFix.Enabled = true; return; } int tempID = int.Parse(lsvDebt.SelectedItems[0].Text); var iAdd = new frmSplitDebt(isBusy) { Location = lsvDebt.Location }; MysqlController.LXCustomDebt[] iDebt = MysqlControl.ReadCustomDebt(tempID); if (iDebt != null || iDebt.Length > 0) { Point p = PointToScreen(lsvDebt.Location); iAdd.SetDesktopBounds(p.X + groupBox2.Location.X + groupBox4.Location.X, p.Y + groupBox2.Location.Y + groupBox4.Location.Y, iAdd.Width, iAdd.Height); iAdd.iDebt = iDebt[0]; if (iAdd.ShowDialog() == DialogResult.OK) { isBusy.Visible = true; MysqlController.ReturnResult iDResult; iDResult.isSuccess = false; while (iDResult.isSuccess != true) { DelegateChangeSplitDebt dn = MysqlControl.ChangeSplitDebt; IAsyncResult iar = dn.BeginInvoke(tempID.ToString(), double.Parse(iAdd.iUnFixPrice), null, null); while (iar.IsCompleted == false) { Application.DoEvents(); } iDResult = dn.EndInvoke(iar); } isBusy.Visible = false; if (int.Parse(iAdd.iUnFixPrice) == 0) { //已经没有欠款了.这里需要递交一次还款结束 iDResult.isSuccess = false; isBusy.Visible = true; while (iDResult.isSuccess != true) { DelegateFixCustomDebt dn = MysqlControl.FixCustomDebt; IAsyncResult iar = dn.BeginInvoke(tempID.ToString(), iAdd.iLastFixDate, cmbBackDebtType.SelectedIndex, txtBackDebtBackup.Text, null, null); while (iar.IsCompleted == false) { Application.DoEvents(); } iDResult = dn.EndInvoke(iar); } 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; } switch (iViewType) { case 0: RefreshCustom(dtpFromTime.Value.Year + dtpFromTime.Value.Month.ToString().PadLeft(2, '0') + dtpFromTime.Value.Day.ToString().PadLeft(2, '0'), false); break; case 1: RefreshCustom(dtpFromTime.Value.Year + dtpFromTime.Value.Month.ToString().PadLeft(2, '0'), false); break; case 2: RefreshCustom("20", false); break; } //lsvDebt.SelectedItems[0].SubItems[8].Text = "已到帐"; } } } catch (Exception) { cmdSplitFix.Enabled = true; return; } cmdSplitFix.Enabled = true; }
private void cmdFinish_Click(object sender, EventArgs e) { cmdFinish.Enabled = false; try { for (int i = 0; i < lsvDebt.SelectedItems.Count; i++) { int tempID = int.Parse(lsvDebt.SelectedItems[i].Text); isBusy.Visible = true; DelegateFixCustomDebt dn = MysqlControl.FixCustomDebt; IAsyncResult iar = dn.BeginInvoke(tempID.ToString(), iSavestrDate, cmbBackDebtType.SelectedIndex, txtBackDebtBackup.Text, null, null); while (iar.IsCompleted == false) { Application.DoEvents(); } MysqlController.ReturnResult iResult = dn.EndInvoke(iar); if (iResult.isSuccess) { 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); MessageBox.Show(Resources.frmCustomDebt_cmdFinish_Click_修改指定欠款到帐成功_, Application.ProductName, MessageBoxButtons.OK); RefreshCustom(iSavestrDate, false); } else { MessageBox.Show(Resources.frmCustomDebt_cmdFinish_Click_修改指定欠款到帐失败_, Application.ProductName, MessageBoxButtons.OK); } isBusy.Visible = false; } } catch (Exception) { cmdFinish.Enabled = true; return; } cmdFinish.Enabled = true; }