Example #1
0
        public BankAccountsVO getAccountInfo(int _id)
        {
            BankAccountsVO _newBankAccVo = new BankAccountsVO();
            DataTable      dataTable     = new DataTable();

            try
            {
                dataTable = _accountDAO.searchByIdAcc(_id);
                foreach (DataRow dr in dataTable.Rows)
                {
                    _newBankAccVo.idAcc    = Int32.Parse(dr["idAcc"].ToString());
                    _newBankAccVo.idClient = Int32.Parse(dr["idClient"].ToString());
                    _newBankAccVo.type     = dr["Type"].ToString();
                    _newBankAccVo.amount   = Int32.Parse(dr["Amount of money"].ToString());
                    _newBankAccVo.date     = DateTime.Parse(dr["Date_Created"].ToString());
                }
            }
            catch (NullReferenceException e)
            {
                Console.Write("Error:", e.ToString());
                Console.ReadLine();
            }

            return(_newBankAccVo);
        }
Example #2
0
 //Constructor
 public FormClient()
 {
     InitializeComponent();
     _bankAccBus    = new BankAccountsBUS();
     _listBankAccVO = new List <BankAccountsVO>();
     _bankAccDAO    = new BankAccountDAO();
     _bankAccVO     = new BankAccountsVO();
     _tranzDAO      = new TranzactionsDAO();
     _tranzVO       = new TranzactionsVO();
     _listTranzVO   = new List <TranzactionsVO>();
     _tranzBUS      = new TranzactionsBUS();
 }
Example #3
0
        //------------------------TransferMoneyPanel
        private void buttonSubmTM_Click(object sender, EventArgs e)
        {
            DateTime _dt         = System.DateTime.Now;
            int      idSrc       = Int32.Parse(this.comboTransferSrc.Text);
            int      idDst       = Int32.Parse(this.comboTransferDest.Text);
            int      inputAmount = Int32.Parse(textBoxTMoney.Text);

            //Reading Account's money stored of the source and the destination account
            _bankAccVO = this._bankAccBus.getAccountInfo(idSrc);
            int srcAmount = _bankAccVO.amount;

            _bankAccVO = this._bankAccBus.getAccountInfo(idDst);
            int dstAmount = _bankAccVO.amount;

            //Update of account's money stored
            if (srcAmount >= inputAmount)
            {
                srcAmount -= inputAmount;
                dstAmount += inputAmount;

                if (idSrc != idDst)
                {
                    if (_bankAccDAO.updateByIdTransfer(idSrc, srcAmount) && _bankAccDAO.updateByIdTransfer(idDst, dstAmount))
                    {
                        MessageBox.Show(inputAmount.ToString(), "Update Succeded!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Update failed!", "Value has not changed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    if (_tranzDAO.insertByIdAcc(idSrc, "Withdraw", inputAmount, _dt) && _tranzDAO.insertByIdAcc(idDst, "Deposit", inputAmount, _dt))
                    {
                        MessageBox.Show("Tranzaction Added!", "Well Done!");
                    }
                    else
                    {
                        MessageBox.Show("Tranzaction aborted!", "Tranzaction failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Wrong destination account!", "Value has not changed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Not enough money!", "Transfer failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #4
0
        private void buttonPay_Click(object sender, EventArgs e)
        {
            int idSrc       = Int32.Parse(this.comboPaySelectAcc.Text);
            int inputAmount = Int32.Parse(textBoxPayAmount.Text);

            _bankAccVO = this._bankAccBus.getAccountInfo(idSrc);
            int srcAmount = _bankAccVO.amount;

            if (srcAmount >= inputAmount)
            {
                srcAmount -= inputAmount;
                DialogResult dr  = new DialogResult();
                DateTime     _dt = System.DateTime.Now;

                dr = MessageBox.Show("Are you sure you want to proceed?", "Payment Incomming!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (this.listBoxPay.SelectedItem != null)
                {
                    if (dr == DialogResult.Yes)
                    {
                        if (_bankAccDAO.updateByIdTransfer(idSrc, srcAmount))
                        {
                            MessageBox.Show("Payment Succeeded!", "Well Done!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Payment Aborted!", "Value has not changed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    if (_tranzDAO.insertByIdAcc(idSrc, this.listBoxPay.Text, inputAmount, _dt))
                    {
                        MessageBox.Show("Tranzaction Added!", "Well Done!");
                    }
                    else
                    {
                        MessageBox.Show("Tranzaction aborted!", "Tranzaction failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Select an utility darling!", "Payment Aborted!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Not enough money!", "Payment Aborted!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #5
0
        //Update Account
        public bool updateAcc(BankAccountsVO _accountVO)
        {
            string _query = "update dbo.bankaccounts set idClient=@idClient, Type = @Type, [Amount of money] = @amount,Date_Created=@dateCreated where idAcc=@idAcc";

            SqlParameter[] sqlParameters = new SqlParameter[5];
            sqlParameters[0]       = new SqlParameter("@idAcc", SqlDbType.Int);
            sqlParameters[0].Value = Convert.ToInt32(_accountVO.idAcc);
            sqlParameters[1]       = new SqlParameter("@idClient", SqlDbType.Int);
            sqlParameters[1].Value = Convert.ToInt32(_accountVO.idClient);
            sqlParameters[2]       = new SqlParameter("@Type", SqlDbType.VarChar);
            sqlParameters[2].Value = Convert.ToString(_accountVO.type);
            sqlParameters[3]       = new SqlParameter("@amount", SqlDbType.Int);
            sqlParameters[3].Value = Convert.ToInt32(_accountVO.amount);
            sqlParameters[4]       = new SqlParameter("@dateCreated", SqlDbType.DateTime);
            sqlParameters[4].Value = Convert.ToDateTime(_accountVO.date);
            return(conn.executeUpdateQuery(_query, sqlParameters));
        }
Example #6
0
        //Insert
        public bool insertAccount(BankAccountsVO _accountVO)
        {
            string _query = "insert into dbo.bankaccounts(idClient,Type,[Amount of money],Date_Created) values(@idClient,@Type,@amount,@dateCreated)";

            SqlParameter[] sqlParameters = new SqlParameter[4];

            sqlParameters[0]       = new SqlParameter("@idClient", SqlDbType.Int);
            sqlParameters[0].Value = Convert.ToInt32(_accountVO.idClient);
            sqlParameters[1]       = new SqlParameter("@Type", SqlDbType.VarChar);
            sqlParameters[1].Value = Convert.ToString(_accountVO.type);
            sqlParameters[2]       = new SqlParameter("@amount", SqlDbType.Int);
            sqlParameters[2].Value = Convert.ToInt32(_accountVO.amount);
            sqlParameters[3]       = new SqlParameter("@dateCreated", SqlDbType.DateTime);
            sqlParameters[3].Value = Convert.ToDateTime(_accountVO.date);

            return(conn.executeInsertQuery(_query, sqlParameters));
        }
Example #7
0
 public BankAccountDAO()
 {
     conn       = new Connection();
     _accountVO = new BankAccountsVO();
 }