Пример #1
0
        private void DepositSearchButton_Click(object sender, EventArgs e)
        {
            try
            {
                Int64 tempDepositSerial = Int64.Parse(DepositSerialTextBox.Text.Trim());
                DepositDataGridView.Rows.Clear();
                CDepositManager tempDepositManager = new CDepositManager();
                CDeposit tempDeposit = new CDeposit();
                CResult oResult = tempDepositManager.DepositGetByDepositID(tempDepositSerial);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempDeposit = (CDeposit)oResult.Data;
                }
                if (tempDeposit.DepositBalance != 0)
                {

                    string[] newRow ={
                tempDeposit.DepositID.ToString(),
                new DateTime(tempDeposit.DepositTime).ToShortDateString(),
                tempDeposit.DepositTotalAmount.ToString("F02"),
                tempDeposit.DepositBalance.ToString("F02"),
                tempDeposit.DepositType
                };

                    CCustomerManager tempCustomerManager = new CCustomerManager();
                    CCustomerInfo tempCustomerInfo = new CCustomerInfo();
                    oResult = tempCustomerManager.CustomerInfoGetByCustomerID(tempDeposit.CustomerID);
                    if (oResult.IsSuccess && oResult.Data != null)
                    {
                        tempCustomerInfo = (CCustomerInfo)oResult.Data;
                    }
                    CustomerLabel.Text = tempCustomerInfo.CustomerName;
                    PhoneLabel.Text = tempCustomerInfo.CustomerPhone;

                    DepositDataGridView.Rows.Add(newRow);
                }
                else
                {
                    MessageBox.Show("No deposit information found. This deposit may be already used or never existed.", "Info",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                DepositDataGridView.RowCount = 13;

            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Пример #2
0
        private void g_UseDepositButton_Click(object sender, EventArgs e)
        {
            CCalculatorForm tempCalculatorForm = new CCalculatorForm("Use Deposit", "Enter Deposit Serial Number");
            tempCalculatorForm.ShowDialog();

            if (CCalculatorForm.inputResult.Equals("Cancel") || CCalculatorForm.inputResult.Equals(""))
            {
                return;
            }
            Int64 tempDepositSerial = Int64.Parse(CCalculatorForm.inputResult);
            CDepositManager tempDepositManager = new CDepositManager();
            CDeposit tempDeposit = new CDeposit();
            CResult oResult = tempDepositManager.DepositGetByDepositID(tempDepositSerial);
            if (oResult.IsSuccess && oResult.Data != null)
            {
                tempDeposit = (CDeposit)oResult.Data;

                if (tempDeposit.DepositID != 0)
                {

                    CUseDepositForm tempUseDepositForm = new CUseDepositForm(tempDeposit);
                    DialogResult dResult = tempUseDepositForm.ShowDialog();
                    if (dResult.Equals(DialogResult.Cancel))
                        return;
                    else if (dResult.Equals(DialogResult.OK))
                    {
                        if (CUseDepositForm.usedAmount > m_dBalance)
                        {
                            tempDeposit.DepositBalance = tempDeposit.DepositBalance - m_dBalance;
                        }
                        else
                        {
                            tempDeposit.DepositBalance = tempDeposit.DepositBalance - CUseDepositForm.usedAmount;
                        }
                        m_oDeposit = tempDeposit;

                        if (CUseDepositForm.usedAmount > m_dBalance)
                        {
                            m_dTotalAmount = m_dTotalAmount - m_dBalance;
                        }
                        else
                        {
                            m_dTotalAmount = m_dTotalAmount - CUseDepositForm.usedAmount;
                        }
                        g_BillTotalLabel.Text = "£" + m_dTotalAmount.ToString("F02");

                        g_DepositUsedLabel.Text = "£" + CUseDepositForm.usedAmount.ToString("F02");
                        CurrentPaymentMethod = "Deposit";
                        UpdateCalculation(0);
                        g_UseDepositButton.Enabled = false;
                    }
                }
                else
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Deposit Information not found!");
                    tempMessageBox.ShowDialog();
                }
            }
        }