Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            banking_dbEntities1 dbe = new banking_dbEntities1();

            if (usertxt.Text != string.Empty || passtxt.Text != string.Empty)
            {
                var user1 = dbe.Admin_Table.FirstOrDefault(a => a.Username.Equals(usertxt.Text));
                if (user1 != null)
                {
                    if (user1.Password.Equals(passtxt.Text))
                    {
                        Menu m1 = new Menu();
                        m1.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Password incorrect");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter Username and Password");
            }
        }
Exemple #2
0
 //function to accept account no intrest rate etc and start FD calculation
 private void SaveButton_Click(object sender, EventArgs e)
 {
     try
     {
         banking_dbEntities1 dbe   = new banking_dbEntities1();
         decimal             accno = Convert.ToDecimal(accnotxt.Text);
         var accounts = dbe.userAccounts.Where(x => x.Account_No == accno).SingleOrDefault();
         FD  fdform   = new FD();
         fdform.Accoun_no       = (accnotxt.Text);
         fdform.mode            = comboBox1.SelectedItem.ToString();
         fdform.rupees          = Convert.ToDecimal(rupeestxt.Text);
         fdform.period          = Convert.ToInt32(periodtxt.Text);
         fdform.intrest_rate    = Convert.ToDecimal(intresttxt.Text);
         fdform.start_date      = DateTime.UtcNow.ToString("MM/dd/yyy");
         fdform.Maturity_date   = (DateTime.UtcNow.AddDays(Convert.ToInt32(periodtxt.Text))).ToString("MM/dd/yyy");
         fdform.Maturity_amount = ((Convert.ToDecimal(rupeestxt.Text) * Convert.ToInt32(periodtxt.Text) * Convert.ToDecimal(intresttxt.Text)) /
                                   (100 * 12 * 30)) + (Convert.ToDecimal(rupeestxt.Text));
         dbe.FDs.Add(fdform);
         decimal amount      = Convert.ToDecimal(rupeestxt.Text);
         decimal totalamount = Convert.ToDecimal(accounts.balance);
         decimal fdamount    = totalamount - amount;
         accounts.balance          = fdamount;
         dbe.Entry(accounts).State = EntityState.Modified;
         //dbe.userAccounts.Add(accounts);
         dbe.SaveChanges();
         //MessageBox.Show("FD Started Now");
         MessageBox.Show("FD Started Now", "FD information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }
Exemple #3
0
        //To Update the deposit details and save into th db
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            try
            {
                banking_dbEntities1 context = new banking_dbEntities1();
                NewAccountForm      acc     = new NewAccountForm();
                Deposit             dp      = new Deposit();
                dp.Date       = datelbl.Text;
                dp.AccountNo  = Convert.ToDecimal(acctxt.Text);
                dp.Name       = nametxt.Text;
                dp.OldBalance = Convert.ToDecimal(oldbaltxt.Text);
                dp.Mode       = comboBox1.SelectedItem.ToString();
                dp.DipAmount  = Convert.ToDecimal(amounttxt.Text);
                context.Deposits.Add(dp);
                context.SaveChanges();
                decimal b    = Convert.ToDecimal(acctxt.Text);
                var     item = (from u in context.userAccounts
                                where u.Account_No == b
                                select u).FirstOrDefault();

                item.balance = item.balance + Convert.ToDecimal(amounttxt.Text);
                context.SaveChanges();
                //    MessageBox.Show("Deposited Money Sucessfully");
                MessageBox.Show("Deposited Money Sucessfully", "Deposit information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception occurred");
            }
        }
        private void LoadAccount()
        {
            BSE = new banking_dbEntities1();
            var item = BSE.userAccounts.ToArray();

            no             = item.LastOrDefault().Account_No + 1;
            accnotext.Text = Convert.ToString(no);
        }
Exemple #5
0
 //updates the account holder details
 private void UpdateButton_Click(object sender, EventArgs e)
 {
     try
     {
         dbe = new banking_dbEntities1();
         decimal     accountno   = Convert.ToDecimal(acctxt.Text);
         userAccount useraccount = dbe.userAccounts.First(s => s.Account_No.Equals(accountno));
         useraccount.Account_No = Convert.ToDecimal(acctxt.Text);
         useraccount.Name       = Nametxt.Text;
         useraccount.Date       = dateTimePicker1.Value.ToString();
         useraccount.MotherName = mothertxt.Text;
         useraccount.FatherName = fathertxt.Text;
         useraccount.Phoneno    = phonetxt.Text;
         if (maleradio.Checked == true)
         {
             useraccount.Gender = "male";
         }
         else
         {
             if (femaleradio.Checked == true)
             {
                 useraccount.Gender = "female";
             }
         }
         if (marriedradio.Checked == true)
         {
             useraccount.martial_status = "married";
         }
         else
         {
             if (unmarriedradio.Checked == true)
             {
                 useraccount.martial_status = "unmarried";
             }
         }
         Image img = pictureBox1.Image;
         if (img.RawFormat != null)
         {
             if (ms != null)
             {
                 img.Save(ms, img.RawFormat);
                 useraccount.Picture = ms.ToArray();
             }
         }
         useraccount.Address  = addresstxt.Text;
         useraccount.District = disttxt.Text;
         useraccount.State    = statetxt.Text;
         dbe.SaveChanges();
         MessageBox.Show("Record updated", "Record information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }
 private void BindGrid()
 {
     try
     {
         CustomerGridView.AutoGenerateColumns = false;
         banking_dbEntities1 bs = new banking_dbEntities1();
         var item = bs.userAccounts.ToList();
         CustomerGridView.DataSource = item;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }
 //save new account details of the user and store to db
 private void SaveButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (maleradio.Checked)
         {
             gender = "male";
         }
         else if (femaleradio.Checked)
         {
             gender = "female";
         }
         else if (otherradio.Checked)
         {
             gender = "other";
         }
         if (marriedradio.Checked)
         {
             m_status = "married";
         }
         else if (unmarriedradio.Checked)
         {
             m_status = "unmarried";
         }
         BSE = new banking_dbEntities1();
         userAccount acc = new userAccount();
         acc.Account_No     = Convert.ToDecimal(accnotext.Text);
         acc.Name           = nametext.Text;
         acc.DOB            = dateTimePicker1.Value.ToString();
         acc.Phoneno        = phonetext.Text;
         acc.Address        = addresstext.Text;
         acc.District       = districttext.Text;
         acc.State          = comboBox1.SelectedItem.ToString();
         acc.Gender         = gender;
         acc.martial_status = m_status;
         acc.MotherName     = mothertext.Text;
         acc.FatherName     = fathertext.Text;
         acc.balance        = Convert.ToDecimal(balancetext.Text);
         //acc.Date = datel
         acc.Picture = ms.ToArray();
         BSE.userAccounts.Add(acc);
         BSE.SaveChanges();
         //MessageBox.Show("file saved");
         MessageBox.Show("File Saved", "File information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }
Exemple #8
0
 //deletes the details of the account
 private void DeleteButton_Click(object sender, EventArgs e)
 {
     try
     {
         bi.RemoveAt(UpdateGridView.SelectedRows[0].Index);
         dbe = new banking_dbEntities1();
         decimal     a   = Convert.ToDecimal(acctxt.Text);
         userAccount acc = dbe.userAccounts.First(s => s.Account_No.Equals(a));
         dbe.userAccounts.Remove(acc);
         dbe.SaveChanges();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }
 //show the FD details of all the accounts
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         b1  = new BindingList <FD>();
         dbe = new banking_dbEntities1();
         string date = dateTimePicker1.Value.ToString("MM/dd/yyyy");
         //MessageBox.Show(date);
         var item = dbe.FDs.Where(a => a.start_date.Equals(date));
         FDGridView.DataSource = item.ToList();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }
Exemple #10
0
 //search customer with name and displaying details
 private void SearchButton_Click(object sender, EventArgs e)
 {
     try
     {
         bi  = new BindingList <userAccount>();
         dbe = new banking_dbEntities1();
         var item = dbe.userAccounts.Where(a => a.Name == Nametxt.Text);
         foreach (var item1 in item)
         {
             bi.Add(item1);
         }
         UpdateGridView.DataSource = bi;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Value entered is invalid or does not exist", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #11
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         dbe = new banking_dbEntities1();
         decimal accno = Convert.ToDecimal(UpdateGridView.Rows[e.RowIndex].Cells[0].Value);
         var     item  = dbe.userAccounts.Where(a => a.Account_No == accno).FirstOrDefault();
         acctxt.Text     = item.Account_No.ToString();
         Nametxt.Text    = item.Name;
         mothertxt.Text  = item.MotherName;
         fathertxt.Text  = item.FatherName;
         phonetxt.Text   = item.Phoneno;
         addresstxt.Text = item.Address;
         byte[]       img = item.Picture;
         MemoryStream ms  = new MemoryStream(img);
         disttxt.Text  = item.District;
         statetxt.Text = item.State;
         if (item.Gender == "male")
         {
             maleradio.Checked = true;
         }
         else if (item.Gender == "female")
         {
             femaleradio.Checked = true;
         }
         else if (item.Gender == "other")
         {
             otherradio.Checked = true;
         }
         if (item.martial_status == "married")
         {
             marriedradio.Checked = true;
         }
         else if (item.martial_status == "unmarried")
         {
             unmarriedradio.Checked = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }
 //fetches the account details
 private void DetailButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (String.IsNullOrEmpty(acctxt.Text))
         {
             MessageBox.Show("Enter Account Number", "Account information", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         banking_dbEntities1 dbe = new banking_dbEntities1();
         decimal             b   = Convert.ToDecimal(acctxt.Text);
         var item = (from u in dbe.userAccounts
                     where u.Account_No == b
                     select u).FirstOrDefault();
         nametxt.Text   = item.Name;
         oldbaltxt.Text = Convert.ToString(item.balance);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }
Exemple #13
0
 //to let the user change password
 private void SaveButton_Click(object sender, EventArgs e)
 {
     try
     {
         banking_dbEntities1 dbe = new banking_dbEntities1();
         if (oldpass.Text != string.Empty || newpass.Text != string.Empty || repass.Text != string.Empty)
         {
             Admin_Table user1 = dbe.Admin_Table.FirstOrDefault(a => a.Username.Equals(usrtxt.Text));
             if (user1 != null)
             {
                 if (user1.Password.Equals(oldpass.Text))
                 {
                     user1.Password = newpass.Text;
                     dbe.SaveChanges();
                     //MessageBox.Show("Password changed successfully");
                     MessageBox.Show("Password changed successfully", "Password information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     //MessageBox.Show("Password Incorrect");
                     MessageBox.Show("Password Incorrect", "Password information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 //MessageBox.Show("Password Incorrect");
                 MessageBox.Show("UserName is a required field", "Username Needed", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             //MessageBox.Show("Password Incorrect");
             MessageBox.Show("Mandatory Values can not be blank", "Mandatory Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }
Exemple #14
0
        //to commit the changes of transferring money from one account to the other
        private void TransferButton_Click(object sender, EventArgs e)
        {
            try
            {
                banking_dbEntities1 dbe = new banking_dbEntities1();
                decimal             b   = Convert.ToDecimal(fromacctxt.Text);
                var item = (from u in dbe.userAccounts
                            where u.Account_No == b
                            select u).FirstOrDefault();
                decimal b1          = Convert.ToDecimal(item.balance);
                decimal totalbal    = Convert.ToDecimal(transfertxt.Text);
                decimal transferacc = Convert.ToDecimal(desaccounttxt.Text);
                if (b1 > totalbal)
                {
                    userAccount item2 = (from u in dbe.userAccounts
                                         where u.Account_No == transferacc
                                         select u).FirstOrDefault();
                    item2.balance = item2.balance + totalbal;
                    item.balance  = item.balance - totalbal;
                    //dbe.SaveChanges();
                    Transfer transfer = new Transfer();
                    transfer.Account_no = Convert.ToDecimal(fromacctxt.Text);
                    transfer.ToTransfer = Convert.ToDecimal(desaccounttxt.Text);
                    transfer.Date       = DateTime.UtcNow.ToString();
                    transfer.Name       = nametxt.Text;
                    transfer.balance    = Convert.ToDecimal(transfertxt.Text);

                    dbe.Transfers.Add(transfer);
                    dbe.SaveChanges();
                    //MessageBox.Show("Transfer Money Successfull");
                    MessageBox.Show("Transfer Money Successfull", "Money Transfer information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception occurred");
            }
        }
Exemple #15
0
        //fetch the details of the account no entered
        private void DetailsButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(acctxt.Text))
                {
                    MessageBox.Show("Enter Account Number", "Account information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                bi  = new BindingList <userAccount>();
                dbe = new banking_dbEntities1();
                decimal accno = Convert.ToDecimal(acctxt.Text);
                var     item  = dbe.userAccounts.Where(a => a.Account_No == accno);
                foreach (var item1 in item)
                {
                    bi.Add(item1);
                }
                UpdateGridView.DataSource = bi;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Account does not exist or is invalid", "Does not exist", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 //fetches debit deposit and transfer details of the account number
 protected void ShowButton_Click(object sender, EventArgs e)
 {
     try
     {
         banking_dbEntities1 dbe = new banking_dbEntities1();
         decimal             b   = Convert.ToDecimal(textBox1.Text);
         var item = (from u in dbe.debits
                     where u.AccountNo == b
                     select u);
         DebitGridView.DataSource = item.ToList();
         var item1 = (from u in dbe.Deposits
                      where u.AccountNo == b
                      select u);
         DepositGridView.DataSource = item1.ToList();
         var item2 = (from u in dbe.Transfers
                      where u.Account_no == b
                      select u);
         TransferGridView.DataSource = item2.ToList();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception occurred");
     }
 }