Exemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("Account Name must have a value.", "New Account", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            clsAccountInfo ac = new clsAccountInfo(Convert.ToInt32(lblAccountId.Text));

            if (ac != null && ac.AccountId > 0)
            {
                ac.CreditLimit = Convert.ToDouble(txtLimit.Text);
            }
            else
            {
                ac.AccountId   = Convert.ToInt32(lblAccountId.Text);
                ac.AccountName = txtName.Text.Trim();
                if (txtLimit.Text.Trim() != "")
                {
                    ac.CreditLimit = Convert.ToDouble(txtLimit.Text);
                }
                else
                {
                    ac.CreditLimit = 0;
                }
            }
            if (ac.Save())
            {
                ClearFields();
            }
            DisplayAccounts();
        }
Exemplo n.º 2
0
        private bool CancelPayment()
        {
            if (!clsUtil.GetApproval(m_user, UserAccess.Manager))
            {
                return(false);
            }
            frmSelectAccounts acct = new frmSelectAccounts(0, m_user);

            if (acct.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                clsAccountInfo a = acct.SelectedAccount;

                frmInput input = new frmInput();
                input.Title         = "Retrieve Payment Info";
                input.Caption       = "Payment Reference";
                input.IsHiddenInput = false;
                input.IsNumericOnly = true;
                input.withDecimal   = false;
                input.Value         = "";
                if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    clsPaymentInfo payment = clsPaymentInfo.GetPayment(Convert.ToInt32(input.Value));
                    if (payment != null)
                    {
                        clsChargedTransaction charges = clsChargedTransaction.GetChargedTransaction(payment.OrNum);

                        if (charges != null && payment.PaymentId != 0 && payment.AccountId == a.AccountId)
                        {
                            if (payment.Remarks.ToLower().Contains("interest"))
                            {
                                MessageBox.Show("Interest payment cancellation not allowed!", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                            else if (MessageBox.Show(string.Format("Are you sure you want to cancel payment?\nRefno:{0}\nRemarks:{1}\nAmount:P {2:0.00}", payment.PaymentId, payment.Remarks, payment.AmountPaid), "Cancel Payment", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                            {
                                if (payment.Remarks.ToLower().Contains("principal"))
                                {
                                    a.PrincipalBalance += payment.AmountPaid;
                                    a.Save();
                                    charges.TransBalance += payment.AmountPaid;
                                    charges.SaveChargeTransaction();

                                    if (clsPaymentInfo.CancelPayment(payment.PaymentId))
                                    {
                                        MessageBox.Show("Payment successfully cancelled!", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Cancel Payment did not succeed!", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Payment Reference not found under this account", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            return(false);
        }