Output_ATM_System
Output_ATM_System
= 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 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 4.0 The Database that all the information are being stored at
Photo 4.1 The information stored in table client
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();
}
conn.ConnectionString = connString;
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.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();
}
}
register.Show();
}
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();
}
conn.ConnectionString = connString;
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);
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();
this.Hide();
login.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}
txtFname.Focus();
}
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();
}
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();
}
}
deposit.identifier = identifier;
deposit.Show();
}
withdraw.identifier = identifier;
withdraw.Show();
}
transaction.identifier = identifier;
transaction.Show();
}
private void btnBalance_Click(object sender, EventArgs e)
{
conn.ConnectionString = connString;
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();
}
try
{
conn.Open();
while (rdr.Read())
{
int value = Convert.ToInt32(rdr["balance"]);
amount += value;
}
rdr.Close();
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();
txtDeposit.Clear();
txtDeposit.Focus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}
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)
{
try
{
conn.Open();
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();
txtWithdraw.Clear();
txtWithdraw.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}
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();
}
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Prepare();
cmd.Parameters.AddWithValue("@id", id);
main.identifier = identifier;
main.Show();
}
}
}
}