Ejemplo 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;
        }
Ejemplo n.º 2
0
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            isBusy.Visible = true;

            if (txtName.Text == "" || txtCash.Text == "" || cmbPayType.SelectedIndex == -1)
            {
                return;
            }


            if (!Regex.IsMatch(txtCash.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmPayout_cmdAdd_Click_请正确填写金额_, Application.ProductName, MessageBoxButtons.OK);
                return;
            }

            cmdAdd.Enabled = false;

            if (MessageBox.Show(
                    "是否确认如下递交内容?\r\n支出项目:" + txtName.Text + "\r\n支出时间:" + dtpTime.Value.Year +
                    dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                    dtpTime.Value.Day.ToString().PadLeft(2, '0') + "\r\n支出金额:" + txtCash.Text + "元\r\n支出类型:" +
                    cmbPayType.Text + "\r\n备注:" + txtBackup.Text, Application.ProductName, MessageBoxButtons.OKCancel) ==
                DialogResult.OK)
            {
                var iPayout = new MysqlController.Payout
                {
                    PayoutBackup = txtBackup.Text,
                    PayoutName   = txtName.Text,
                    PayoutPrice  = txtCash.Text,
                    PayoutType   = cmbPayType.SelectedIndex.ToString(),
                    PayoutInCase = ckbisInCash.Checked
                };
                if (cmbPayType.SelectedIndex == 2)
                {
                    iPayout.PayoutPrice = "-" + iPayout.PayoutPrice;
                }

                iPayout.PayoutDate = dtpTime.Value.Year + dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                                     dtpTime.Value.Day.ToString().PadLeft(2, '0');

                DelegateAddPayout dn = MysqlControl.AddPayout;

                IAsyncResult iar = dn.BeginInvoke(iPayout, 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 = @"添加固定支出:" + txtName.Text + "支出时间:" + dtpTime.Value.Year +
                                     dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                                     dtpTime.Value.Day.ToString().PadLeft(2, '0') + "支出金额:" + txtCash.Text;

                    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_cmdAdd_Click_添加支出记录成功, Application.ProductName,
                                    MessageBoxButtons.OK);
                    CleanUI();
                    RefreshPayout();
                }
                else
                {
                    MessageBox.Show(Resources.frmPayout_cmdAdd_Click_ + iResult.ErrDesc, Application.ProductName,
                                    MessageBoxButtons.OK);
                }
            }
            isBusy.Visible = false;
            cmdAdd.Enabled = true;
        }