Exemplo n.º 1
0
        private void cmdConvert2Payout_Click(object sender, EventArgs e)
        {
            int tempID = int.Parse(lsvDebt.SelectedItems[0].Text);

            var iPayout = new MysqlController.Payout
            {
                PayoutBackup =
                    lsvDebt.SelectedItems[0].SubItems[1].Text + " " +
                    lsvDebt.SelectedItems[0].SubItems[2].Text + ",欠款原因:" +
                    lsvDebt.SelectedItems[0].SubItems[3].Text,
                PayoutName  = "客户欠款",
                PayoutPrice = lsvDebt.SelectedItems[0].SubItems[4].Text,
                PayoutType  = Resources.frmCustomDebt_CleanUI__0,
                PayoutDate  = DateTime.Now.Year + DateTime.Now.Month.ToString().PadLeft(2, '0') +
                              DateTime.Now.Day.ToString().PadLeft(2, '0')
            };

            isBusy.Visible = true;
            DelegateAddPayout dn = MysqlControl.AddPayout;

            IAsyncResult iar = dn.BeginInvoke(iPayout, null, null);

            while (iar.IsCompleted == false)
            {
                Application.DoEvents();
            }

            MysqlController.ReturnResult iResult = dn.EndInvoke(iar);
            isBusy.Visible = false;
            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.frmPayout_cmdAdd_Click_添加支出记录成功, Application.ProductName, MessageBoxButtons.OK);

                MysqlController.ReturnResult iDResult;
                iDResult.isSuccess = false;
                isBusy.Visible     = true;
                while (iDResult.isSuccess != true)
                {
                    DelegateDeleteCustomDebt dnd = MysqlControl.DeleteCustomDebt;

                    IAsyncResult iard = dnd.BeginInvoke(tempID, null, null);

                    while (iard.IsCompleted == false)
                    {
                        Application.DoEvents();
                    }

                    iDResult = dnd.EndInvoke(iard);
                }
                isBusy.Visible = false;
                RefreshCustom(iSavestrDate, false);
            }
            else
            {
                MessageBox.Show(Resources.frmPayout_cmdAdd_Click_ + iResult.ErrDesc, Application.ProductName,
                                MessageBoxButtons.OK);
            }
            isBusy.Visible = false;
        }
Exemplo n.º 2
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            cmdDelete.Enabled = false;

            try
            {
                for (int i = 0; i < lsvDebt.SelectedItems.Count; i++)
                {
                    int tempID = int.Parse(lsvDebt.SelectedItems[i].Text);

                    isBusy.Visible = true;

                    DelegateDeleteCustomDebt dn = MysqlControl.DeleteCustomDebt;

                    IAsyncResult iar = dn.BeginInvoke(tempID, null, null);

                    while (iar.IsCompleted == false)
                    {
                        Application.DoEvents();
                    }

                    MysqlController.ReturnResult iResult = dn.EndInvoke(iar);

                    isBusy.Visible = false;

                    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_cmdDelete_Click_删除指定欠款成功_, Application.ProductName,
                                        MessageBoxButtons.OK);
                        RefreshCustom(iSavestrDate, false);
                    }
                    else
                    {
                        MessageBox.Show(Resources.frmCustomDebt_cmdDelete_Click_删除指定欠款失败__错误原因_ + iResult.ErrDesc,
                                        Application.ProductName,
                                        MessageBoxButtons.OK);
                    }
                }
            }
            catch (Exception)
            {
                cmdDelete.Enabled = true;
                return;
            }

            cmdDelete.Enabled = true;
        }