0% found this document useful (0 votes)
2 views

Output_ATM_System

The document outlines a bank system application developed using C# Windows Forms and MS SQL Server, featuring account registration, login, balance viewing, deposits, withdrawals, and transaction history. It includes a database structure with three tables: client, bank, and transcript, and provides various functionalities for users to manage their accounts. The application allows users to store personal information securely and perform banking transactions through a user-friendly interface.

Uploaded by

deltavintage0926
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Output_ATM_System

The document outlines a bank system application developed using C# Windows Forms and MS SQL Server, featuring account registration, login, balance viewing, deposits, withdrawals, and transaction history. It includes a database structure with three tables: client, bank, and transcript, and provides various functionalities for users to manage their accounts. The application allows users to store personal information securely and perform banking transactions through a user-friendly interface.

Uploaded by

deltavintage0926
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

FORONDA, JOHN DAVE D.

= LEADER BSCS 2A
BAÑEZ, BILLY JOENE C.
TANGONAN, JUNE ASSHLEY C.

Bank System
Storing personal information, and transactions then modifying the
stored balance in an account using a windows-based program that will
store those entered information to a database. Whereas the database
has three tables namely: client (client_id, fname, lname, pin), bank
(bank_id, client_id, balance), and transcript (transcript_id, client_id,
trans_type, amount, date). We have used C# Windows Form (.NET
FRAMEWORK) and used the MsSQL Server for our Database.

Features:
o Can register accounts personal information which are the name
of the person and pin of his / her account.
o Can login the registered account using the entered client_id and
pin.
o Can view the balance of his account on the main page.
o Can deposit and withdraw the entered amount from the user.
o Can view the transcript / transaction that he had in the past
showing the type of transcation whether deposit or withdraw
and the amount he deposited or withdrawed.
o Can logout the account and login a different account whenever
the user wants it or not.
o Stores and Reads everything out of the Database.
Photo 1.0 Logging in to an already created account

Photo 1.1 Creating a new account


Photo 1.2 Main page of the system

Photo 2.0 Depositing entered amount of money to the currently logged in account
Photo 2.1 Withdrawing entered amount of money to the currently logged in account

Photo 2.2 Viewing balance to the currently logged in account


Photo 3.0 Viewing the transactions that the user did. (Only Shows the users transactions)

Photo 4.0 The Database that all the information are being stored at
Photo 4.1 The information stored in table client

Photo 4.2 The information stored in table bank

Photo 4.3 The information stored in table transcript


using System;
using System.Windows.Forms;

namespace DATABASE_01_CS2A
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Login());
}
}
}

using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace DATABASE_01_CS2A
{
public partial class Login : Form
{
string connString = @"Data Source=DESKTOP-HVCU5JO\SQLEXPRESS;Initial
Catalog=atm_system;Integrated Security=True";
SqlConnection conn = new SqlConnection();

public Login()
{
InitializeComponent();
}

private void btnLogin_Click(object sender, EventArgs e)


{
string client_id = txtClientNum.Text.Trim();
string pin = txtPinNum.Text.Trim();

conn.ConnectionString = connString;

string query = @"SELECT


*
FROM client
WHERE client_id = @client_id AND pin = @pin";

try
{
conn.Open();
SqlCommand cmd = new SqlCommand(query, conn);

cmd.Prepare();
cmd.Parameters.AddWithValue("@client_id", client_id);
cmd.Parameters.AddWithValue("@pin", pin);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);

if(dt.Rows.Count > 0)
{
MessageBox.Show("Login Succesful", "", MessageBoxButtons.OK);

this.Hide();

Main main = new Main();


Deposit deposit = new Deposit();
Withdraw withdraw = new Withdraw();
Transaction transaction = new Transaction();

main.identifier = client_id;
main.Show();
}
else
{
MessageBox.Show("Incorrect User ID or Pin", "Login Unsuccesful",
MessageBoxButtons.OK);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}

private void btnRegister_Click(object sender, EventArgs e)


{
this.Hide();

Register register = new Register();

register.Show();
}

private void Login_Load(object sender, EventArgs e)


{
txtClientNum.Focus();
txtPinNum.UseSystemPasswordChar = true;
}

private void txtPinNum_TextChanged(object sender, EventArgs e)


{
txtPinNum.UseSystemPasswordChar = true;
}

private void chkPin_CheckedChanged(object sender, EventArgs e)


{
if (chkPin.Checked)
{
txtPinNum.UseSystemPasswordChar = false;
}
else
{
txtPinNum.UseSystemPasswordChar = true;
}
}
}
}

using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace DATABASE_01_CS2A
{
public partial class Register : Form
{
string connString = @"Data Source=DESKTOP-HVCU5JO\SQLEXPRESS;Initial
Catalog=atm_system;Integrated Security=True";
SqlConnection conn = new SqlConnection();

public Register()
{
InitializeComponent();
}

private void btnLogin_Click(object sender, EventArgs e)


{
string fname = txtFname.Text.Trim();
string lname = txtLname.Text.Trim();
int client_id = int.Parse(txtNewClientNum.Text.Trim());
int pin = int.Parse(txtNewPinNum.Text.Trim());
int balance = 0;

conn.ConnectionString = connString;

string query = @"INSERT INTO client


VALUES (
@client_id,
@fname,
@lname,
@pin
);";

string queryTwo = @"INSERT INTO bank


VALUES (
@client_id,
@balance
);";

SqlCommand cmd = new SqlCommand(query, conn);


cmd.Prepare();

cmd.Parameters.Add("@client_id", SqlDbType.Int);
cmd.Parameters.Add("@fname", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@lname", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@pin", SqlDbType.Int);

SqlCommand cmdTwo = new SqlCommand(queryTwo, conn);


cmdTwo.Prepare();

cmdTwo.Parameters.Add("@client_id", SqlDbType.Int);
cmdTwo.Parameters.Add("@balance", SqlDbType.Int);

try
{
conn.Open();

cmd.Parameters["@client_id"].Value = client_id;
cmd.Parameters["@fname"].Value = fname;
cmd.Parameters["@lname"].Value = lname;
cmd.Parameters["@pin"].Value = pin;

cmd.ExecuteNonQuery();

cmdTwo.Parameters["@client_id"].Value = client_id;
cmdTwo.Parameters["@balance"].Value = balance;

cmdTwo.ExecuteNonQuery();

MessageBox.Show("Succesfully Registered", "", MessageBoxButtons.OK);

this.Hide();

Login login = new Login();

login.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}

private void btnRegister_Click(object sender, EventArgs e)


{
txtFname.Clear();
txtLname.Clear();
txtNewClientNum.Clear();
txtNewPinNum.Clear();

txtFname.Focus();
}

private void Register_Load(object sender, EventArgs e)


{
txtFname.Focus();
}
private void txtNewPinNum_TextChanged(object sender, EventArgs e)
{

private void BackButton_Click(object sender, EventArgs e)


{
this.Hide();

Login login = new Login();

login.Show();
}
}
}

using System;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace DATABASE_01_CS2A
{
public partial class Main : Form
{
string connString = @"Data Source=DESKTOP-HVCU5JO\SQLEXPRESS;Initial
Catalog=atm_system;Integrated Security=True";
SqlConnection conn = new SqlConnection();

public Main()
{
InitializeComponent();
}

public string identifier { get; set; }

private void Main_Load(object sender, EventArgs e)


{
conn.ConnectionString = connString;

string query = @"SELECT


client_id
FROM client
WHERE client_id LIKE
@identifier";

string queryTwo = @"SELECT


fname
FROM client
WHERE client_id LIKE
@identifier";

string queryThree = @"SELECT


lname
FROM client
WHERE client_id LIKE
@identifier";
try
{
conn.Open();

SqlCommand cmd = new SqlCommand(query, conn);


cmd.Parameters.AddWithValue("@identifier", identifier);
SqlCommand cmdTwo = new SqlCommand(queryTwo, conn);
cmdTwo.Parameters.AddWithValue("@identifier", identifier);
SqlCommand cmdThree = new SqlCommand(queryThree, conn);
cmdThree.Parameters.AddWithValue("@identifier", identifier);

string id = Convert.ToString(cmd.ExecuteScalar());
string fname = Convert.ToString(cmdTwo.ExecuteScalar());
string client = fname + " " + Convert.ToString(cmdThree.ExecuteScalar());

lblClient.Text = client;
lblID.Text = id;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}

private void btnDeposit_Click(object sender, EventArgs e)


{
this.Hide();

Deposit deposit = new Deposit();

deposit.identifier = identifier;

deposit.Show();
}

private void btnWithdraw_Click(object sender, EventArgs e)


{
this.Hide();

Withdraw withdraw = new Withdraw();

withdraw.identifier = identifier;

withdraw.Show();
}

private void btnTrans_Click(object sender, EventArgs e)


{
this.Hide();

Transaction transaction = new Transaction();

transaction.identifier = identifier;

transaction.Show();
}
private void btnBalance_Click(object sender, EventArgs e)
{
conn.ConnectionString = connString;

string query = @"SELECT


balance
FROM bank
WHERE client_id LIKE
@identifier";
try
{
conn.Open();

SqlCommand cmd = new SqlCommand(query, conn);


cmd.Parameters.AddWithValue("@identifier", identifier);

string balance = Convert.ToString(cmd.ExecuteScalar());

MessageBox.Show("Balance is: " + balance, "Central Bank", MessageBoxButtons.OK);


}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}

private void btnLogout_Click(object sender, EventArgs e)


{
this.Hide();

Login login = new Login();

login.Show();
}
}
}

using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace DATABASE_01_CS2A
{
public partial class Deposit : Form
{
string connString = @"Data Source=DESKTOP-HVCU5JO\SQLEXPRESS;Initial
Catalog=atm_system;Integrated Security=True";
SqlConnection conn = new SqlConnection();

public Deposit()
{
InitializeComponent();
}

public string identifier { get; set; }

private void btnDeposit_Click(object sender, EventArgs e)


{
conn.ConnectionString = connString;

string query = @"SELECT


balance
FROM bank
WHERE client_id LIKE
@id";

string queryTwo = @"UPDATE


bank
SET balance = @amount
WHERE client_id LIKE
@id";

string queryThree = @"INSERT INTO transcript


VALUES (
@client_id,
@trans_type,
@amount,
@date
);";

SqlCommand cmdThree = new SqlCommand(queryThree, conn);


cmdThree.Prepare();
cmdThree.Parameters.Add("@client_id", SqlDbType.Int);
cmdThree.Parameters.Add("@trans_type", SqlDbType.VarChar, 50);
cmdThree.Parameters.Add("@amount", SqlDbType.Int);
cmdThree.Parameters.Add("@date", SqlDbType.Date);

string trans_type = "Deposit";


DateTime currentDate = DateTime.Now;

try
{
conn.Open();

SqlCommand cmd = new SqlCommand(query, conn);


cmd.Parameters.AddWithValue("@id", identifier);
SqlDataReader rdr = cmd.ExecuteReader();

int amount = int.Parse(txtDeposit.Text.Trim());


int deposit = amount;

while (rdr.Read())
{
int value = Convert.ToInt32(rdr["balance"]);
amount += value;
}

rdr.Close();

SqlCommand cmdTwo = new SqlCommand(queryTwo, conn);


cmdTwo.Parameters.AddWithValue("@amount", amount);
cmdTwo.Parameters.AddWithValue("@id", identifier);

cmdTwo.ExecuteNonQuery();

cmdThree.Parameters["@client_id"].Value = identifier;
cmdThree.Parameters["@trans_type"].Value = trans_type;
cmdThree.Parameters["@amount"].Value = amount;
cmdThree.Parameters["@date"].Value = currentDate;

cmdThree.ExecuteNonQuery();

MessageBox.Show("Succesfully Deposited: " + deposit, "", MessageBoxButtons.OK);

txtDeposit.Clear();
txtDeposit.Focus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}

private void btnBack_Click(object sender, EventArgs e)


{
this.Hide();

Main main = new Main();

main.identifier = identifier;

main.Show();
}
}
}

using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace DATABASE_01_CS2A
{
public partial class Withdraw : Form
{
string connString = @"Data Source=DESKTOP-HVCU5JO\SQLEXPRESS;Initial
Catalog=atm_system;Integrated Security=True";
SqlConnection conn = new SqlConnection();

public Withdraw()
{
InitializeComponent();
}
private void Withdraw_Load(object sender, EventArgs e)
{

public string identifier { get; set; }

private void btnWithdraw_Click(object sender, EventArgs e)


{
conn.ConnectionString = connString;

string query = @"SELECT


balance
FROM bank
WHERE client_id LIKE
@id";

string queryTwo = @"UPDATE


bank
SET balance = @amount
WHERE client_id LIKE
@id";

string queryThree = @"INSERT INTO transcript


VALUES (
@client_id,
@trans_type,
@amount,
@date
);";

SqlCommand cmdThree = new SqlCommand(queryThree, conn);


cmdThree.Prepare();
cmdThree.Parameters.Add("@client_id", SqlDbType.Int);
cmdThree.Parameters.Add("@trans_type", SqlDbType.VarChar, 50);
cmdThree.Parameters.Add("@amount", SqlDbType.Int);
cmdThree.Parameters.Add("@date", SqlDbType.Date);

string trans_type = "Withdraw";


DateTime currentDate = DateTime.Now;

try
{
conn.Open();

SqlCommand cmd = new SqlCommand(query, conn);


cmd.Parameters.AddWithValue("@id", identifier);
SqlDataReader rdr = cmd.ExecuteReader();

int amount = int.Parse(txtWithdraw.Text.Trim());


int withdraw = amount;

while(rdr.Read())
{
int value = Convert.ToInt32(rdr["balance"]);
amount = value - amount;
}
rdr.Close();

if (amount < 0)
{
MessageBox.Show("Not Enough Balance", "", MessageBoxButtons.OK);
}
else
{
SqlCommand cmdTwo = new SqlCommand(queryTwo, conn);
cmdTwo.Parameters.AddWithValue("@amount", amount);
cmdTwo.Parameters.AddWithValue("@id", identifier);

cmdTwo.ExecuteNonQuery();

cmdThree.Parameters["@client_id"].Value = identifier;
cmdThree.Parameters["@trans_type"].Value = trans_type;
cmdThree.Parameters["@amount"].Value = withdraw;
cmdThree.Parameters["@date"].Value = currentDate;

cmdThree.ExecuteNonQuery();

MessageBox.Show("Succesfully Withdrawed: " + withdraw, "",


MessageBoxButtons.OK);

txtWithdraw.Clear();
txtWithdraw.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}

private void btnBack_Click(object sender, EventArgs e)


{
this.Hide();

Main main = new Main();

main.identifier = identifier;

main.Show();
}
}
}

using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace DATABASE_01_CS2A
{
public partial class Transaction : Form
{
string connString = @"Data Source=DESKTOP-HVCU5JO\SQLEXPRESS;Initial
Catalog=atm_system;Integrated Security=True";
SqlConnection conn = new SqlConnection();

public Transaction()
{
InitializeComponent();
}

public string identifier { get; set; }

private void Transaction_Load(object sender, EventArgs e)


{
string id = "%" + identifier + "%";
get(id);
}

public void get(string id)


{
conn.ConnectionString = connString;

string query = @"SELECT


transcript_id AS [Transaction ID],
client_id AS [Client ID],
trans_type AS [Transaction Type],
amount AS [Amount],
date AS [Date]
FROM transcript
WHERE client_id LIKE
@id";

try
{
conn.Open();
SqlCommand cmd = new SqlCommand(query, conn);

cmd.Prepare();
cmd.Parameters.AddWithValue("@id", id);

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
dgwTransaction.AutoGenerateColumns = true;
dgwTransaction.DataSource = dt;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}

private void btnBack_Click(object sender, EventArgs e)


{
this.Hide();

Main main = new Main();

main.identifier = identifier;

main.Show();
}

private void dgwTransaction_CellContentClick(object sender, DataGridViewCellEventArgs e)


{

}
}
}

You might also like