Data Base Connectivity Code
Data Base Connectivity Code
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
namespace Repository
{
public class DatabaseConnectionClass
{
private SqlConnection myConnection;
private SqlCommand myCommand;
public DatabaseConnectionClass()
{
string connectionString = @"Integrated Security=SSPI;Persist Security Info=False;Initial
Catalog=BankingManagmentSystem;Data Source=RABIAKAINAT
";
myConnection = new SqlConnection(connectionString);
}
}
using Entity;
using Repository;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace App
{
public partial class LoginForm : Form
{
internal LoginRepo lr;
public LoginForm()
{
InitializeComponent();
lr = new LoginRepo();
}
if (l != null)
{
HomePage hp = new HomePage(l);
this.Visible = false;
hp.Visible = true;
HomePage.identity = id;
}
else
{
MessageBox.Show("Invalid Id or Password");
}
}
using Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace App
{
public partial class HomePage : Form
{
public static string identity;
Login l=new Login();
public HomePage(Login l)
{
InitializeComponent();
this.l = l;
WelcomeLabel.Text += l.Id;
}
if (l.Role == 1)
{
EmployeeActivities ca = new EmployeeActivities();
this.Visible = false;
ca.Visible = true;
}
else
{
MessageBox.Show("Access Denied");
}
}
}
public void test()
{
this.Visible = true;
}
}
using Entity;
using Repository;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace App
{
public partial class ManageCustomerForm : Form
{
Login l;
CustomerRepo cr;
LoginRepo lr;
public ManageCustomerForm(Login l)
{
InitializeComponent();
this.l = l;
cr = new CustomerRepo();
lr = new LoginRepo();
}
private void OnFormClose(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
if (cust == null)
{
MessageBox.Show("Invalid Id");
this.RefreshBtnn_Click_1(sender, e);
}
else
{
this.CustNameTB.Text = cust.Name;
this.CustPhnNumberTB2.Text = cust.PhnNumber.Substring(4);
this.RefreshBtnn.Enabled = true;
this.LoadBtnn.Enabled = false;
this.InsertBtnn.Enabled = false;
this.UpdateBtnn.Enabled = true;
this.DeleteBtnn.Enabled = true;
this.CustIdTF.Enabled = false;
}
if (lr.InsertUser(l))
{
if (cr.InsertCustomer(cust))
{
MessageBox.Show("Customer Added. Id : " + cust.CustId);
this.RefreshBtnn_Click_1(sender, e);
this.ViewAllBtnn_Click_1(sender, e);
}
}
else
{
MessageBox.Show("Can Not Add" + l.Id);
}
}
catch (Exception ex)
{
MessageBox.Show("Invalid Data");
}
if (cr.UpdateCustomer(cust))
{
MessageBox.Show("Update Done");
this.RefreshBtnn_Click_1(sender, e);
this.ViewAllBtnn_Click_1(sender, e);
}
else
{
MessageBox.Show("Update NOT Done");
}
if (lr.DeleteUser(l))
{
if (cr.DeleteCustomer(cust))
{
MessageBox.Show("Deleted");
this.RefreshBtnn_Click_1(sender, e);
this.ViewAllBtnn_Click_1(sender, e);
}
}
else
{
MessageBox.Show("Can Not Delete");
}
}
this.RefreshBtnn.Enabled = false;
this.LoadBtnn.Enabled = true;
this.InsertBtnn.Enabled = true;
this.UpdateBtnn.Enabled = false;
this.DeleteBtnn.Enabled = false;
this.CustIdTF.Enabled = true;
}
CustTable.DataSource = searchedList;
}
this.RefreshBtnn.Enabled = true;
this.LoadBtnn.Enabled = false;
this.InsertBtnn.Enabled = false;
this.UpdateBtnn.Enabled = true;
this.DeleteBtnn.Enabled = true;
this.CustIdTF.Enabled = true;
}
}
}
using Entity;
using Repository;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace App
{
public partial class ManageEmployeeForm : Form
{
Login l;
EmployeeRepo er;
LoginRepo lr;
public ManageEmployeeForm(Login l)
{
InitializeComponent();
this.l = l;
er = new EmployeeRepo();
lr = new LoginRepo();
}
if (emp == null)
{
MessageBox.Show("Invalid Id");
this.RefreshBtn_Click(sender, e);
}
else
{
this.EmpNameTB.Text = emp.Name;
this.EmpPhnNumberTB2.Text = emp.PhnNumber.Substring(4);
this.EmpSalaryTB.Text = emp.Salary + "";
this.EmpDesignationTB.Text = emp.Designation;
this.RefreshBtn.Enabled = true;
this.LoadBtn.Enabled = false;
this.InsertBtn.Enabled = false;
this.UpdateBtn.Enabled = true;
this.DeleteBtn.Enabled = true;
this.EmpIdTF.Enabled = false;
}
emp.EmpId = this.EmpIdTF.Text;
emp.Name = this.EmpNameTB.Text;
int phn = Convert.ToInt32(this.EmpPhnNumberTB2.Text);
emp.PhnNumber = this.EmpPhnNumberTB1.Text + this.EmpPhnNumberTB2.Text;
double sal = Convert.ToDouble(this.EmpSalaryTB.Text);
emp.Salary = sal;
emp.Designation = this.EmpDesignationTB.Text;
if((emp.Designation.ToLower()).Equals("manager"))
{
l.Role = 0;
}
else
{
l.Role = 1;
}
if (lr.InsertUser(l))
{
if (er.InsertEmployee(emp))
{
MessageBox.Show("Employee Added. Id : " + emp.EmpId + " & Password : " + l.Password);
this.RefreshBtn_Click(sender, e);
this.ViewAllBtn_Click(sender, e);
}
}
else
{
MessageBox.Show("Can Not Add" + l.Id);
}
}
catch (Exception exp)
{
MessageBox.Show("Invalid Data");
}
}
this.RefreshBtn.Enabled = false;
this.LoadBtn.Enabled = true;
this.InsertBtn.Enabled = true;
this.UpdateBtn.Enabled = false;
this.DeleteBtn.Enabled = false;
this.EmpIdTF.Enabled = true;
}
if (lr.DeleteUser(l))
{
if (er.DeleteEmployee(emp))
{
MessageBox.Show("Deleted");
this.RefreshBtn_Click(sender, e);
this.ViewAllBtn_Click(sender, e);
}
}
else
{
MessageBox.Show("Can Not Delete");
}
}
if (er.UpdateEmployee(emp))
{
MessageBox.Show("Update Done");
this.RefreshBtn_Click(sender, e);
this.ViewAllBtn_Click(sender, e);
}
else
{
MessageBox.Show("Update NOT Done");
}
}
this.RefreshBtn.Enabled = true;
this.LoadBtn.Enabled = false;
this.InsertBtn.Enabled = false;
this.UpdateBtn.Enabled = true;
this.DeleteBtn.Enabled = true;
this.EmpIdTF.Enabled = false;
EmpTable.DataSource = searchedList;
}
}
}