Exemplo n.º 1
0
        public void AddContactNumber(string ContactNumber)
        {
            DataTable temp       = new DataTable();
            UserDAO   dataAccess = new UserDAO();
            Int64?    customerID = null;
            string    query      = "use ApteanEdgeBank select * from Customer";

            temp = dataAccess.GetData(query, UserDAO.connectionString);

            int i = 0;

            for (; i < (temp.Rows.Count); i++)
            {
                if (firstName == (string)temp.Rows[i]["FirstName"] && lastName == (string)temp.Rows[i]["LastName"] && dateOfBirth.ToString() == Convert.ToString(temp.Rows[i]["DateOfBirth"]))
                {
                    customerID = (Int64)temp.Rows[i]["CustomerID"]; break;
                }
                else
                {
                    continue;
                }
            }
            if (customerID != null)
            {
                dataAccess.InsertData("use ApteanEdgeBank insert into CustomerContact (CustomerID) values(" + customerID + ")", UserDAO.connectionString);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Fatal Error: Customer ID not generated ");
            }
            temp.Clear();
            temp = dataAccess.GetData("use ApteanEdgeBank select * from CustomerContact", UserDAO.connectionString);
            i    = 0;
            for (; i < (temp.Rows.Count); i++)
            {
                if (customerID == (Int64)temp.Rows[i]["CustomerID"])
                {
                    ContactID = temp.Rows[i]["CustomerContactID"].ToString(); break;
                }
                else
                {
                    continue;
                }
            }
            if (ContactID != null)
            {
                // System.Windows.Forms.MessageBox.Show(ContactID);
                dataAccess.InsertData("use ApteanEdgeBank insert into CustomerContactDetails (CustomerContactID,CustomerContactNumber) values(" + ContactID + "," + ContactNumber + ")", UserDAO.connectionString);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Fatal Error: Contact ID not generated");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int years = DateTime.Now.Year - DateTime.Parse(dateOfBirthBox.Text.ToString()).Year;

            if (checkBox1.Checked == true)
            {
                years = 18;
            }
            //  MessageBox.Show(years.ToString());
            if (years < 18)
            {
            }
            else
            {
                validFlag = true;
            }
            firstName   = firstNameBox.Text;
            middleName  = midddleNameBox.Text;
            lastName    = lastNameBox.Text;
            dateOfBirth = dateOfBirthBox.Text;

            if (validFlag == true)
            {
                dataAccess.InsertData(@"use ApteanEdgeBank
update Customer
set FirstName='" + firstName + "'," + "MiddleName='" + middleName + "',LastName='" + lastName + "',DateOfBirth='" + dateOfBirth + "'" +
                                      "where CustomerID=" + customerID, UserDAO.connectionString);
                MessageBox.Show("Cutomer ID:" + customerID + " updated successfully");
            }
            else
            {
                MessageBox.Show("Invalid Date of Birth");
            }
        }
Exemplo n.º 3
0
        public void AddContactNumber(string ContactNumber)
        {
            DataTable temp = new DataTable();
            UserDAO dataAccess = new UserDAO();
            Int64? customerID=null;
            string query = "use ApteanEdgeBank select * from Customer";
            temp = dataAccess.GetData(query, UserDAO.connectionString);

            int i = 0;
            for (; i < (temp.Rows.Count); i++)
            {
                if (firstName == (string)temp.Rows[i]["FirstName"] && lastName == (string)temp.Rows[i]["LastName"] && middleName == (string)temp.Rows[i]["MiddleName"] && dateOfBirth.ToString() == Convert.ToString(temp.Rows[i]["DateOfBirth"]))
                { customerID = (Int64)temp.Rows[i]["CustomerID"]; break; }
                else
                    continue;

            }
            if (customerID != null)
            {
                dataAccess.InsertData("use ApteanEdgeBank insert into CustomerContact (CustomerID) values(" + customerID + ")", UserDAO.connectionString);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Fatal Error: Customer ID not generated ");
            }
            temp.Clear();
            temp = dataAccess.GetData("use ApteanEdgeBank select * from CustomerContact",UserDAO.connectionString);
            i = 0;
            for (; i < (temp.Rows.Count); i++)
            {
                if (customerID == (Int64)temp.Rows[i]["CustomerID"])
                { ContactID = temp.Rows[i]["CustomerContactID"].ToString(); break; }
                else
                    continue;

            }
            if (ContactID != null)
            {
               // System.Windows.Forms.MessageBox.Show(ContactID);
                dataAccess.InsertData("use ApteanEdgeBank insert into CustomerContactDetails (CustomerContactID,CustomerContactNumber) values(" + ContactID + "," + ContactNumber + ")", UserDAO.connectionString);
            }
            else
                System.Windows.Forms.MessageBox.Show("Fatal Error: Contact ID not generated");
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (CustomerAvailabilityCheck())
            {
                CustomerID = textBox1.Text;
                initialBalance = textBox2.Text;

                MessageBox.Show("Account Type is " + AccountType + "For Customer ID " + CustomerID + " With initial Balance " + initialBalance);
                UserDAO udao = new UserDAO();
                DataTable dataTable = new DataTable();
                udao.InsertData("use ApteanEdgeBank insert into Account (AccountType,AccountBalance,DateOfOpening,DateOfClosing) values(" + AccountType + "," + initialBalance + "," + "cast(getdate() as date),null)", UserDAO.connectionString);
                dataTable = udao.GetData("use ApteanEdgeBank select max(AccountID) as max from Account", UserDAO.connectionString);
                AccountID = Convert.ToString(dataTable.Rows[0]["max"]);

                udao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
            }
            else
            {
                MessageBox.Show("Customer Not Fount, Please Create Customer First");
            }
        }
Exemplo n.º 5
0
        public void AddContactNumber2(string ContactNumber2)
        {
            UserDAO dataAccess = new UserDAO();

            if (ContactID != null)
            {
                // System.Windows.Forms.MessageBox.Show(ContactID);
                dataAccess.InsertData("use ApteanEdgeBank insert into CustomerContactDetails (CustomerContactID,CustomerContactNumber) values(" + ContactID + "," + ContactNumber2 + ")", UserDAO.connectionString);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Fatal Error: Contact ID not generated");
            }
        }
 public void AddAccountActivity(int accID, string transType, double amount, DateTime transDate)
 {
     UserDAO dao = new UserDAO();
     string myQuery = "insert into AccountActivityLedger values(" + accID + "," + "'" + transDate + "'" + "," + "'" + transType + "'" + "," + amount + ")";
     string connectionstring = "Data Source=WS003LT1553PRD;Initial Catalog=ApteanEdgeBank;User=sa;Password=abc-123";
        // if (CheckAccountExistence(accID))
     //{
         dao.InsertData(myQuery, connectionstring);
     //}
        /* else
     {
         MessageBox.Show("Account Does not exist!");
     }*/
 }
Exemplo n.º 7
0
 public static void Close(int accId)
 {
     UserDAO dao=new UserDAO();
     DataTable dt=new DataTable();
     BankGeneralAccount bg = new BankGeneralAccount();
     string queryString="Select * from Account where AccountID="+accId;
     try
     {
         /*Balance = 0;
         dateClosed = DateTime.Now;
         Console.WriteLine("Account closed on {0}", dateClosed.ToShortDateString());*/
         dt = dao.GetData(queryString, UserDAO.connectionString);
         if (Convert.ToDouble(dt.Rows[0]["AccountBalance"]) != 0.0)
         {
            DialogResult result= MessageBox.Show("Your account balance is greater than 0! The balance must be 0 to close an account. Would you like to clear your account balance?","Account Balance is not 0!",MessageBoxButtons.YesNo);
            if (result == DialogResult.Yes)
            {
                //set closing date for the account. Deduct the remaining balance from bank general account and set the current balance to 0
                dao.InsertData(@"use ApteanEdgeBank update Account
     set DateOfClosing= cast(getdate() as date)
     where AccountID =" + accId, UserDAO.connectionString);
                bg.BgaWithdraw(Convert.ToDouble(dt.Rows[0]["AccountBalance"]));
                dao.UpdateData("update Account set AccountBalance=0 where AccountID=" + accId, UserDAO.connectionString);
            }
         }
         else
         {
             dao.InsertData(@"use ApteanEdgeBank update Account
     set DateOfClosing= cast(getdate() as date)
     where AccountID =" + accId, UserDAO.connectionString);
         }
     }
     catch (InvalidOperationException e)
     {
         MessageBox.Show("Account closure failed!");
     }
 }
Exemplo n.º 8
0
        //constructor
        public void AddNewCutomer(string firstNameP, string lastNameP, DateTime dateOfBirthP)
        {
            firstName = firstNameP;
            //middleName = middleNameP;
            lastName      = lastNameP;
            dateOfBirth   = dateOfBirthP.Date;
            dateOfJoining = DateTime.Now.Date;
            UserDAO dbAccess = new UserDAO();
            string  myQuery  = @"use ApteanEdgeBank insert into Customer (FirstName,LastName,DateOfJoining,DateOfBirth) values('" + firstNameP + "'" + "," + "'" + lastNameP + "'" + "," + "cast(getdate() as date)" + "," + "'" + dateOfBirth.Date.ToShortDateString() + "')";

            // System.Windows.Forms.MessageBox.Show(myQuery);
            dbAccess.InsertData(myQuery, UserDAO.connectionString);
            //System.Windows.Forms.MessageBox.Show(myQuery);
            System.Windows.Forms.MessageBox.Show("Customer Added successfully");
        }
Exemplo n.º 9
0
        private void button2_Click(object sender, EventArgs e)
        {
            var selectdAccountID = Convert.ToString(listBox1.SelectedItem);

            if (listBox1.SelectedItem == null)
            {
                MessageBox.Show("Please select the account to be ReOpened");
            }
            else
            {
                dataAccess.InsertData(@"use ApteanEdgeBank update Account
set DateOfClosing=null
where AccountID =" + selectdAccountID, UserDAO.connectionString);
            }
            listBox1.Items.RemoveAt(listBox1.SelectedIndex);
        }
Exemplo n.º 10
0
        public void AddAccountActivity(int accID, string transType, double amount, DateTime transDate)
        {
            UserDAO dao              = new UserDAO();
            string  myQuery          = "insert into AccountActivityLedger values(" + accID + "," + "'" + transDate + "'" + "," + "'" + transType + "'" + "," + amount + ")";
            string  connectionstring = "Data Source=WS003LT1553PRD;Initial Catalog=ApteanEdgeBank;User=sa;Password=abc-123";

            // if (CheckAccountExistence(accID))
            //{
            dao.InsertData(myQuery, connectionstring);
            //}

            /* else
             * {
             *   MessageBox.Show("Account Does not exist!");
             * }*/
        }
 public void AddAccountActivity(int accID, string transType, double amount, DateTime transDate)
 {
     UserDAO dao = new UserDAO();
     string queryFetch = "Select * from Account where AccountID=" + accID;
     DataTable dt = new DataTable();
     dt = dao.GetData(queryFetch, UserDAO.connectionString);
     double closingBalance=Convert.ToDouble(dt.Rows[0]["AccountBalance"]);
     string myQuery = "insert into AccountActivityLedger values(" + accID + "," + "'" + transDate + "'" + "," + "'" + transType + "'" + "," + amount + ","+closingBalance+")";
     string connectionstring = "Data Source=WS003LT1553PRD;Initial Catalog=ApteanEdgeBank;User=sa;Password=abc-123";
        // if (CheckAccountExistence(accID))
     //{
         dao.InsertData(myQuery, connectionstring);
     //}
        /* else
     {
         MessageBox.Show("Account Does not exist!");
     }*/
 }
Exemplo n.º 12
0
 public static void Reopen(int accId,double reopeningBalance)
 {
     UserDAO dao = new UserDAO();
     DataTable dt = new DataTable();
     BankGeneralAccount bg = new BankGeneralAccount();
     string queryString = "Select * from Account where AccountID=" + accId;
     try
     {
         dao.InsertData(@"use ApteanEdgeBank update Account
     set DateOfClosing=null
     where AccountID =" + accId, UserDAO.connectionString);
         dao.UpdateData("update Account set AccountBalance=" + reopeningBalance + "where AccountID=" + accId, UserDAO.connectionString);
         bg.BgaDeposit(reopeningBalance);
     }
     catch (InvalidOperationException e)
     {
         MessageBox.Show("Account reopen failed!");
     }
 }
Exemplo n.º 13
0
        public override int Create(string accType, DateTime open, double balance)
        {
            /* accountID=ID;
             * dateOpened=open;
             * Balance=balance;
             * Console.WriteLine("Chequing Acoount:");
             * Console.WriteLine("Account ID:{0}\nDate Opened:{1}\nBalance:{2}", accountID, dateOpened, Balance);*/

            string             myQuery          = "insert into Account values(" + accType + "," + balance + "," + "'" + open + "'" + "," + "null" + ")";
            string             connectionstring = "Data Source=WS003LT1553PRD;Initial Catalog=ApteanEdgeBank;User=sa;Password=abc-123";
            BankGeneralAccount bg  = new BankGeneralAccount();
            UserDAO            dao = new UserDAO();

            dao.InsertData(myQuery, connectionstring);
            bg.BgaDeposit(balance);
            DataTable dataTable = dao.GetData("use ApteanEdgeBank select max(AccountID) as max from Account", UserDAO.connectionString);
            int       AccountID = Convert.ToInt32(dataTable.Rows[0]["max"]);

            return(AccountID);
            //dao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
        }
Exemplo n.º 14
0
        public override int Create(string accType, DateTime open, double balance)
        {
            if (balance <= Limit)
            {
                dateOpened = open;
                Balance    = balance;
                string             myQuery          = "insert into Account values(" + accType + "," + balance + "," + "'" + open + "'" + "," + "null" + ")";
                string             connectionstring = "Data Source=WS003LT1553PRD;Initial Catalog=ApteanEdgeBank;User=sa;Password=abc-123";
                BankGeneralAccount bg  = new BankGeneralAccount();
                UserDAO            dao = new UserDAO();
                dao.InsertData(myQuery, connectionstring);
                bg.BgaDeposit(balance);
                DataTable dataTable = dao.GetData("use ApteanEdgeBank select max(AccountID) as max from Account", UserDAO.connectionString);
                int       AccountID = Convert.ToInt32(dataTable.Rows[0]["max"]);
                return(AccountID);
            }

            else
            {
                MessageBox.Show("Balance is greater than limit!");
                return(0);
            }
        }
Exemplo n.º 15
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (CustomerAvailabilityCheck())
            {
                CustomerID = Convert.ToInt32(textBox1.Text);
                //AccountID=0;
                if (AccountType == "'CA'")
                {
                    try
                    {
                        ChequingAccount A    = new ChequingAccount();
                        bool            flag = A.DoesChequingAccountExist(CustomerID);
                        if (flag == false)
                        {
                            AccountID = A.Create(AccountType, DateTime.Now, Convert.ToDouble(textBox2.Text));
                            UserDAO udao = new UserDAO();
                            udao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
                            MessageBox.Show("Account added successfully!");
                        }
                        else
                        {
                            MessageBox.Show("Chequing account for this cutomer already exists!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Check if the fields are filled properly!");
                    }
                }

                else if (AccountType == "'TFS'")
                {
                    try
                    {
                        TaxFreeSavingsAccount A = new TaxFreeSavingsAccount();
                        bool flag = A.DoesTFSAccountExist(CustomerID);
                        if (flag == false)
                        {
                            AccountID = A.Create(AccountType, DateTime.Now, Convert.ToDouble(textBox2.Text));
                            UserDAO udao = new UserDAO();
                            udao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
                            MessageBox.Show("Account added successfully!");
                        }
                        else
                        {
                            MessageBox.Show("TFS account for this customer already exists!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Check if the fields are filled properly!" + ex);
                    }
                }
                else
                {
                    MessageBox.Show("Not a Valid account Type");
                }

                /*initialBalance = textBox2.Text;
                 *
                 * MessageBox.Show("Account Type is " + AccountType + "For Customer ID " + CustomerID + " With initial Balance " + initialBalance);
                 * UserDAO udao = new UserDAO();
                 * DataTable dataTable = new DataTable();
                 * udao.InsertData("use ApteanEdgeBank insert into Account (AccountType,AccountBalance,DateOfOpening,DateOfClosing) values(" + AccountType + "," + initialBalance + "," + "cast(getdate() as date),null)", UserDAO.connectionString);
                 * dataTable = udao.GetData("use ApteanEdgeBank select max(AccountID) as max from Account", UserDAO.connectionString);
                 * AccountID = Convert.ToString(dataTable.Rows[0]["max"]);*/
            }
            else
            {
                MessageBox.Show("Customer Not Fount, Please Create Customer First");
            }
        }
Exemplo n.º 16
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (CustomerAvailabilityCheck())
            {

                CustomerID = Convert.ToInt32(textBox1.Text);
                //AccountID=0;
                if (AccountType == "'CA'")
                {
                    try
                    {
                        ChequingAccount A = new ChequingAccount();
                        bool flag = A.DoesChequingAccountExist(CustomerID);
                        if (flag == false)
                        {
                            AccountID = A.Create(AccountType, DateTime.Now, Convert.ToDouble(textBox2.Text));
                            UserDAO udao = new UserDAO();
                            udao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
                            MessageBox.Show("Account added successfully!");
                        }
                        else
                        {
                            MessageBox.Show("Chequing account for this cutomer already exists!");
                        }
                    }
                    catch(Exception ex)
                    {
                        MessageBox.Show("Check if the fields are filled properly!");
                    }
                }

                else if (AccountType == "'TFS'")
                {
                    try
                    {
                        TaxFreeSavingsAccount A = new TaxFreeSavingsAccount();
                        bool flag = A.DoesTFSAccountExist(CustomerID);
                        if (flag == false)
                        {
                            AccountID = A.Create(AccountType, DateTime.Now, Convert.ToDouble(textBox2.Text));
                            UserDAO udao = new UserDAO();
                            udao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
                            MessageBox.Show("Account added successfully!");
                        }
                        else
                        {
                            MessageBox.Show("TFS account for this customer already exists!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Check if the fields are filled properly!"+ex);
                    }
                }
                else
                {
                    MessageBox.Show("Not a Valid account Type");
                }
                /*initialBalance = textBox2.Text;

                MessageBox.Show("Account Type is " + AccountType + "For Customer ID " + CustomerID + " With initial Balance " + initialBalance);
                UserDAO udao = new UserDAO();
                DataTable dataTable = new DataTable();
                udao.InsertData("use ApteanEdgeBank insert into Account (AccountType,AccountBalance,DateOfOpening,DateOfClosing) values(" + AccountType + "," + initialBalance + "," + "cast(getdate() as date),null)", UserDAO.connectionString);
                dataTable = udao.GetData("use ApteanEdgeBank select max(AccountID) as max from Account", UserDAO.connectionString);
                AccountID = Convert.ToString(dataTable.Rows[0]["max"]);*/

            }
            else
            {
                MessageBox.Show("Customer Not Fount, Please Create Customer First");
            }
        }
Exemplo n.º 17
0
        //constructor
        public void AddNewCutomer(string firstNameP, string middleNameP, string lastNameP,DateTime dateOfBirthP)
        {
            firstName = firstNameP;
            middleName = middleNameP;
            lastName = lastNameP;
            dateOfBirth = dateOfBirthP.Date;
            dateOfJoining = DateTime.Now.Date;

            UserDAO dbAccess = new UserDAO();
            string myQuery = @"use ApteanEdgeBank insert into Customer (FirstName,MiddleName,LastName,DateOfJoining,DateOfBirth) values('" + firstNameP + "'" + "," + "'" + middleName + "'" + "," + "'" + lastNameP + "'" + "," + "cast(getdate() as date)" + "," + "'" + dateOfBirth.Date.ToShortDateString() + "')" ;
               // System.Windows.Forms.MessageBox.Show(myQuery);
            dbAccess.InsertData(myQuery, UserDAO.connectionString);
               //System.Windows.Forms.MessageBox.Show(myQuery);
            System.Windows.Forms.MessageBox.Show("Customer Added successfully");
        }
Exemplo n.º 18
0
 public void AddContactNumber2(string ContactNumber2)
 {
     UserDAO dataAccess = new UserDAO();
     if (ContactID != null)
     {
         // System.Windows.Forms.MessageBox.Show(ContactID);
         dataAccess.InsertData("use ApteanEdgeBank insert into CustomerContactDetails (CustomerContactID,CustomerContactNumber) values(" + ContactID + "," + ContactNumber2 + ")", UserDAO.connectionString);
     }
     else
         System.Windows.Forms.MessageBox.Show("Fatal Error: Contact ID not generated");
 }
Exemplo n.º 19
0
        public override int Create(string accType,DateTime open,double balance)
        {
            /* accountID=ID;
            dateOpened=open;
            Balance=balance;
            Console.WriteLine("Chequing Acoount:");
            Console.WriteLine("Account ID:{0}\nDate Opened:{1}\nBalance:{2}", accountID, dateOpened, Balance);*/

            string myQuery = "insert into Account values("+accType+","+balance+","+"'"+open+"'"+","+"null"+")";
            string connectionstring = "Data Source=WS003LT1553PRD;Initial Catalog=ApteanEdgeBank;User=sa;Password=abc-123";
            BankGeneralAccount bg = new BankGeneralAccount();
            UserDAO dao = new UserDAO();
            dao.InsertData(myQuery, connectionstring);
            bg.BgaDeposit(balance);
            DataTable dataTable = dao.GetData("use ApteanEdgeBank select max(AccountID) as max from Account", UserDAO.connectionString);
            int AccountID = Convert.ToInt32(dataTable.Rows[0]["max"]);
            return AccountID;
            //dao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
        }
Exemplo n.º 20
0
        public override int Create(string accType,DateTime open,double balance)
        {
            if (balance <= Limit)
              {

                dateOpened = open;
                Balance = balance;
                string myQuery = "insert into Account values(" + accType + "," + balance + "," + "'" + open + "'" + "," + "null" + ")";
                string connectionstring = "Data Source=WS003LT1553PRD;Initial Catalog=ApteanEdgeBank;User=sa;Password=abc-123";
                BankGeneralAccount bg = new BankGeneralAccount();
                UserDAO dao = new UserDAO();
                dao.InsertData(myQuery, connectionstring);
                bg.BgaDeposit(balance);
                DataTable dataTable = dao.GetData("use ApteanEdgeBank select max(AccountID) as max from Account", UserDAO.connectionString);
                int AccountID = Convert.ToInt32(dataTable.Rows[0]["max"]);
                return AccountID;
             }

             else
            {
                MessageBox.Show("Balance is greater than limit!");
                return 0;
            }
        }