private void cmdDeltePhone_Click(object sender, EventArgs e) { DelegateDeletePhoneSell dn = MysqlControl.DeletePhoneSell; IAsyncResult iar = dn.BeginInvoke(int.Parse(lblID.Text), null, null); while (iar.IsCompleted == false) { Application.DoEvents(); } MysqlController.ReturnResult iResult = dn.EndInvoke(iar); if (iResult.isSuccess) { MessageBox.Show(Resources.frmEditPhone_cmdDeltePhone_Click_删除该部手机成功_, Application.ProductName, MessageBoxButtons.OK); var iCustem = new frmEditPhone(isBusy, iLoginUser) { TopLevel = false, Dock = DockStyle.Fill, Parent = Parent }; iCustem.Show(); iCustem.BringToFront(); Parent.BringToFront(); } else { MessageBox.Show(Resources.frmEditPhone_cmdDeltePhone_Click_删除该部手机失败__错误原因_ + iResult.ErrDesc, Application.ProductName, MessageBoxButtons.OK); } }
private void cmdDelete_Click(object sender, EventArgs e) { cmdDelete.Enabled = false; try { int tempID = int.Parse(lsvPhones.SelectedItems[0].Text); if (tempID.ToString() != "") { isBusy.Visible = true; DelegateDeletePhoneSell dn = MysqlControl.DeletePhoneSell; IAsyncResult iar = dn.BeginInvoke(tempID, null, null); while (iar.IsCompleted == false) { Application.DoEvents(); } MysqlController.ReturnResult iResult = dn.EndInvoke(iar); if (iResult.isSuccess) { var iDResult = new MysqlController.ReturnResult { isSuccess = false }; while (!iDResult.isSuccess) { DelegateDeleteCustomDebtByPhoneID dn1 = MysqlControl.DeleteCustomDebtByPhoneID; IAsyncResult iar1 = dn1.BeginInvoke(tempID, null, null); while (iar1.IsCompleted == false) { Application.DoEvents(); } iDResult = dn1.EndInvoke(iar1); } MessageBox.Show("删除销售记录成功!", Application.ProductName, MessageBoxButtons.OK); RefreshCustom(dtpDaily.Value.Year + dtpDaily.Value.Month.ToString().PadLeft(2, '0') + dtpDaily.Value.Day.ToString().PadLeft(2, '0')); } else { MessageBox.Show("删除销售记录失败!错误原因" + iResult.ErrDesc, Application.ProductName, MessageBoxButtons.OK); } } } catch (Exception) { isBusy.Visible = false; cmdDelete.Enabled = true; return; } isBusy.Visible = false; cmdDelete.Enabled = true; }