Esempio n. 1
0
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            cmdAdd.Enabled = false;

            if (txtSplitPrice.Text == "" || !Regex.IsMatch(txtSplitPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmCustomDebt_cmdAdd_Click_请填写正确的客户欠款金额_, Application.ProductName,
                                MessageBoxButtons.OK);
                cmdAdd.Enabled = true;
                return;
            }

            if (MessageBox.Show(
                    Resources.frmSplitDebt_cmdAdd_Click_ + Resources.frmSplitDebt_cmdAdd_Click_还款日期_ +
                    dtpSplitDate.Value.Year +
                    dtpSplitDate.Value.Month.ToString().PadLeft(2, '0') +
                    dtpSplitDate.Value.Day.ToString().PadLeft(2, '0') + Resources.frmSplitDebt_cmdAdd_Click_ +
                    txtSplitPrice.Text + Resources.frmSplitDebt_cmdAdd_Click_ +
                    txtBackup.Text, Application.ProductName, MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                var iSplitDebt = new MysqlController.LXSplitDebt();
                iSplitDebt.SplitDebtID     = int.Parse(lblID.Text);
                iSplitDebt.SplitDebtType   = cmbSplitType.SelectedIndex;
                iSplitDebt.SplitDebtPrice  = double.Parse(txtSplitPrice.Text);
                iSplitDebt.SplitDebtBackup = txtBackup.Text;
                iSplitDebt.SplitDebtDate   = dtpSplitDate.Value.Year + dtpSplitDate.Value.Month.ToString().PadLeft(2, '0') +
                                             dtpSplitDate.Value.Day.ToString().PadLeft(2, '0');
                isBusy.Visible = true;
                DelegateAddSplitDebt dn = MysqlControl.AddSplitDebt;

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

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

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

                isBusy.Visible = false;
                if (iResult.isSuccess)
                {
                    MessageBox.Show(Resources.frmSplitDebt_cmdAdd_Click_增加用户分期付款成功_, Application.ProductName,
                                    MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show(Resources.frmSplitDebt_cmdAdd_Click_增加用户分期付款失败__错误原因_ + iResult.ErrDesc,
                                    Application.ProductName, MessageBoxButtons.OK);
                }
                RefreshSplitDebt();
            }
            cmdAdd.Enabled = true;
            isHaveChange   = true;
        }
Esempio n. 2
0
        private void RefreshSplitDebt()
        {
            lsvSplit.Items.Clear();

            isBusy.Visible = true;

            var iSplitDebt = new MysqlController.LXSplitDebt[50];

            DelegateReadSplitDebt dn = MysqlControl.ReadSplitDebt;

            IAsyncResult iar = dn.BeginInvoke(int.Parse(lblID.Text), null, null);

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

            iSplitDebt = dn.EndInvoke(iar);

            isBusy.Visible = false;

            if (iSplitDebt != null)
            {
                if (iSplitDebt.Length > 0)
                {
                    double SplitAllPrice = 0;
                    for (int i = 0; i < iSplitDebt.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(iSplitDebt[i].SplitDebtDate))
                        {
                            lsvSplit.Items.Add(iSplitDebt[i].SplitID.ToString());
                            lsvSplit.Items[i].SubItems.Add(iSplitDebt[i].SplitDebtDate);
                            iLastFixDate = iSplitDebt[i].SplitDebtDate;
                            lsvSplit.Items[i].SubItems.Add(iSplitDebt[i].SplitDebtPrice.ToString());
                            lsvSplit.Items[i].SubItems.Add(iSplitDebt[i].SplitDebtBackup);
                            switch (iSplitDebt[i].SplitDebtType)
                            {
                            case 0:
                                lsvSplit.Items[i].SubItems.Add("转帐还款");
                                break;

                            case 1:
                                lsvSplit.Items[i].SubItems.Add("现金还款");
                                break;

                            case 2:
                                lsvSplit.Items[i].SubItems.Add("支付宝还款");
                                break;
                            }
                            SplitAllPrice = SplitAllPrice + iSplitDebt[i].SplitDebtPrice;
                        }
                    }
                    iUnFixPrice =
                        (double.Parse(lblPrice.Text.Replace(Resources.frmSplitDebt_frmSplitDebt_Load_元, "")) -
                         SplitAllPrice).ToString();
                    if (double.Parse(iUnFixPrice) < 0)
                    {
                        button1.Enabled = false;
                        lblUnPrice.Text = Resources.frmSplitDebt_RefreshSplitDebt_金额错误;
                        MessageBox.Show(Resources.frmSplitDebt_RefreshSplitDebt_分期付款的金额超出总额_请检查录入__确认键将在修改成正确金额后恢复_,
                                        Application.ProductName, MessageBoxButtons.OK);
                    }
                    else
                    {
                        button1.Enabled = true;
                        lblUnPrice.Text = iUnFixPrice;
                    }
                }
            }
            else
            {
                MessageBox.Show(Resources.frmSplitDebt_RefreshSplitDebt_读取分期付款数据失败_);
            }
        }