コード例 #1
0
ファイル: Bank.cs プロジェクト: turnupthesun123/ATMv1
    }//end of function

    ////Constructor for the bank class- initalises instance variables
    //public Bank()
    //{
    //    //creating an instance of DAL1
    //    DAL1 dbAccess = new DAL1();

    //    bankManager = new Dictionary<string, Manager>();
    //    bankCustomer = new Dictionary<string, Customer>();
    //    bankManager = dbAccess.loadManagers();
    //    bankCustomer = dbAccess.loadCustomers();

    //    atmid = "HBOS01";

    //    exchange = 1.12M;

    //    timesused = 0;

    //    withdrawls = 0;

    //    totalbalance = 10000;

    //    failedlogins = 0;

    //    cards = 0;

    //}// end of constructor

    public Bank()
    {

        //creating an instance of DAL1
        DAL2 dbAccess = new DAL2();

        bankManager = new Dictionary<string, Manager>();
        bankCustomer = new Dictionary<string, Customer>();

        dbAccess.loadAllPersonData();

        bankManager = dbAccess.getBankManagers();
        bankCustomer = dbAccess.getBankCustomers();

        atmid = "HBOS01";

        exchange = 1.12M;

        timesused = 0;

        withdrawls = 0;

        totalbalance = 10000;

        failedlogins = 0;

        cards = 0;

    }// end of constructor
コード例 #2
0
    protected void Shutdown_Click(object sender, EventArgs e)
    {
        //retrieving bank from the session
        Bank   BankSys1 = (Bank)Session["Bank"];
        string pin      = (string)Session["pin"];

        //for each loop to insert all Customers accounts in the customers accounts dictionary into the database

        DAL = new DAL2();

        //loop through each each customer
        foreach (KeyValuePair <string, Customer> kvp in BankSys1.getcustomerData())
        {
            c = kvp.Value;
            //loop through cust account
            foreach (KeyValuePair <string, Account> kvp1 in c.getAccounts())
            {
                //run update acc from the DAL
                DAL.updateAccountData(kvp1.Value);
            }
        }
        //Abandoning session and redirecting user the index
        Session.Abandon();
        Response.Redirect("..\\Index.aspx");
    }
コード例 #3
0
    //LoadAllPersonData method which takes the retrieved data from the Person and Account
    //database and assigns it to the Account and Person Classes

    public void LoadAllPersonData()
    {
        string    accountNumber;
        decimal   balance;
        string    pin;
        DAL2      myDB;
        DataTable PersonTable;
        DataTable AccountTable;

        myDB         = new DAL2();
        PersonTable  = myDB.retrieveAllPersonData();
        AccountTable = myDB.retrieveAllAccountData();

        for (int i = 0; i <= PersonTable.Rows.Count - 1; i++)
        {
            string id          = Convert.ToString(PersonTable.Rows[i][0]);
            string fname       = Convert.ToString(PersonTable.Rows[i][1]);
            string sname       = Convert.ToString(PersonTable.Rows[i][2]);
            string homeAddress = Convert.ToString(PersonTable.Rows[i][3]);
            string telNo       = Convert.ToString(PersonTable.Rows[i][4]);
            string email       = Convert.ToString(PersonTable.Rows[i][5]);
            string role        = Convert.ToString(PersonTable.Rows[i][6]);
            string mpin        = Convert.ToString(PersonTable.Rows[i][7]);

            //If the data is for a manager it is loaded into the Manager class
            if (role.Equals("M"))
            {
                Manager newmanager = new Manager(id, fname, sname, homeAddress, telNo, email, mpin);
                bankManagers.Add(id, newmanager);
            }

            //If the data is for a customer it is loaded into the Customer class
            else if (role.Equals("C"))
            {
                Customer newcustomer = new Customer(id, fname, sname, homeAddress, telNo, email);
                BankCustomers.Add(id, newcustomer);

                //Adds account information to Account Class
                for (int j = 0; j <= AccountTable.Rows.Count - 1; j++)
                {
                    accountNumber = Convert.ToString(AccountTable.Rows[j][0]);
                    balance       = Convert.ToDecimal(AccountTable.Rows[j][1]);
                    pin           = Convert.ToString(AccountTable.Rows[j][2]);
                    id            = Convert.ToString(AccountTable.Rows[j][3]);

                    if (newcustomer.getid() == id)
                    {
                        newcustomer.addAccount(new Account(accountNumber, pin, balance));
                    }
                }
            }
        }
    }
コード例 #4
0
    public Bank()
    {
        //
        // TODO: Add constructor logic here
        //
        loadData();
        DAL2 db = new DAL2();

        db.LoadAllPersonData();
        ManagerData  = db.GetManagers();
        customerData = db.GetCustomers();
        atmid        = "ABANK01";
        exchangerate = 1.12m;
        timeused     = 0;
        withdrawls   = 0;
        totalbal     = 10000;
        failedlogins = 0;
        CardsRet     = 0;
    }
コード例 #5
0
    public void loadData()
    {
        DAL2 db = new DAL2();

        db.LoadAllPersonData();
    }
コード例 #6
0
ファイル: DAL2.cs プロジェクト: turnupthesun123/ATMv1
    }//end of retrieveAllAccountData method

    //start if loadAllPersonData Method
    //loads data from database into datatables
    public void loadAllPersonData()
    {
        //initialising variables.
        DAL2 myDB;
        DataTable personTable;
        DataTable accountTable;

        //setting variable values
        myDB = new DAL2();
        personTable = myDB.retrieveAllPersonData();
        accountTable = myDB.retrieveAllAccountData();

        //start of for loop
        //iterates through each row in the table and poplulates 'persontable' with values in
        //bank.accdb
        for( int i =0; i <= personTable.Rows.Count -1; i++)
        {
            //setting variables values using data from table.

            string id = Convert.ToString(personTable.Rows[i][0]);

            string fname = Convert.ToString(personTable.Rows[i][1]);

            string sname = Convert.ToString(personTable.Rows[i][2]);

            string address = Convert.ToString(personTable.Rows[i][3]);

            string email = Convert.ToString(personTable.Rows[i][5]);

            string telno = Convert.ToString(personTable.Rows[i][4]);

            string role = Convert.ToString(personTable.Rows[i][6]);

            string machinepin = Convert.ToString(personTable.Rows[i][7]);

            //start of if
            //if role is manager add new manager to table.
            if (role == "M")
            {
                Manager newManager = new Manager (id, fname, sname, address, email, telno, machinepin);
                bankManagers.Add(id, newManager);
            }
            //else if role is customer add new customer to table.
            else if (role == "C")
            {
                Customer newCustomer = new Customer (id, fname, sname, address, email, telno);
                bankCustomers.Add(id, newCustomer);
            }//end of elseif
          

        }//end of for loop.

        //start of for loop 
        //takes data from account table and populates datatable with it
        //iterates through each row
        for (int i = 0; i <= accountTable.Rows.Count - 1; i++)
        {
            string accountNumber = Convert.ToString(accountTable.Rows[i][0]);
            decimal balance = Convert.ToDecimal(accountTable.Rows[i][1]);
            string pin = Convert.ToString(accountTable.Rows[i][2]);
            string id = Convert.ToString(accountTable.Rows[i][3]);

            //creating instance of account class, customer class
            Account newAccount = new Account(accountNumber, balance, pin);
            Customer accountCustomer = bankCustomers[id];
            accountCustomer.addAccount(newAccount);

        }//end of loop

    }//end of method.