0% found this document useful (0 votes)
23 views163 pages

Grocery Assignment

Uploaded by

faizanaseem873
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views163 pages

Grocery Assignment

Uploaded by

faizanaseem873
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 163

Grocery_Management

Class Payment:

namespace ProjectGMS
{
class Payments
{
int id;
string method;
public int Payid
{
set
{
id = value;
}
get
{
return id;
}
}
public string PayMethod
{
set
{
method = value;
}
get
{
return method;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Payment_Methods
(Payment_ID,Method)
values({Payid},'{PayMethod}')";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Payment_Methods";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int Payid)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Payment_Methods where
Payment_ID={Payid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Payment_Methods set
Method='{PayMethod}' where Payment_ID={Payid}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Payment_Methods where
Payment_ID={Payid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}

Form Payment:

namespace ProjectGMS
{
public partial class Payment : Form
{
public Payment()
{
InitializeComponent();
}

private void Payment_Load(object sender, EventArgs e)


{
Payments P= new Payments();
DataTable dt = P.Read();
dataGridView1.DataSource = dt;
}

private void button1_Click(object sender, EventArgs e)


{
Payments P = new Payments();
try
{
P.Payid = Convert.ToInt32(textBox1.Text);
P.PayMethod = textBox2.Text;

P.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button3_Click(object sender, EventArgs e)


{
Payments P = new Payments();
try
{
P.Payid = Convert.ToInt32(textBox1.Text);
P.PayMethod = textBox2.Text;
P.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button4_Click(object sender, EventArgs e)


{
Payments P = new Payments();
DataTable dt = P.Delete();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Payments P = new Payments();
DataTable dt =P.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}
private void button2_Click(object sender, EventArgs e)
{
Payments P = new Payments();
DataTable dt = P.Read();
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
this.Hide();
Home h1 = new Home();
h1.Show();

}
}
}

Order class:

namespace ProjectGMS
{
class Orders
{
int Oid;
int cid;
string date;
int amount;
public int Orderid
{
set
{
Oid = value;
}
get
{
return Oid;
}
}
public int Cusid
{
set
{
cid = value;
}
get
{
return cid;
}
}
public string OrderDate
{
set
{
date = value;
}
get
{
return date;
}
}
public int TotalAmount
{
set
{
amount = value;
}
get
{
return amount;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Orders
(Order_ID,Customer_ID,Total_Amount,Order_Date)
values({Orderid},{Cusid},{TotalAmount},'{OrderDate}')";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = $@"select
o.Order_ID,o.Order_Date,o.Total_Amount as Order_Total,
C.Customer_ID,C.CussName as Customer_Name, C.Contact as
Customer_Contact, C.Address as Customer_Address from Orders o join
Customers C on o.Customer_ID = C.Customer_ID;";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}
public DataTable Read(int Payid)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Orders where
Order_ID={Orderid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Orders set

Order_Date='{OrderDate}',Customer_ID={Cusid},Total_Amount={TotalA
mount} where Order_ID={Orderid}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Orders where Order_ID={Orderid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}
Order Form:
namespace ProjectGMS
{
public partial class Order : Form
{
public Order()
{
InitializeComponent();
}

private void button6_Click(object sender, EventArgs e)


{

}
private void button1_Click(object sender, EventArgs e)
{
Orders o=new Orders();

try
{

o.Orderid = Convert.ToInt32(textBox1.Text);
o.Cusid= Convert.ToInt32(textBox2.Text);
o.OrderDate = dateTimePicker1.Text;
o.TotalAmount= Convert.ToInt32(textBox4.Text);

o.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button3_Click(object sender, EventArgs e)


{
Orders o = new Orders();
try
{

o.Orderid = Convert.ToInt32(textBox1.Text);
o.Cusid = Convert.ToInt32(textBox2.Text);
o.OrderDate = dateTimePicker1.Text;
o.TotalAmount = Convert.ToInt32(textBox4.Text);

o.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Orders o = new Orders();
DataTable dt = o.Read();
dataGridView1.DataSource = dt;
}
private void button4_Click(object sender, EventArgs e)
{
Orders o = new Orders();
DataTable dt = o.Delete();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Orders o = new Orders();
DataTable dt = o.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
Home h1 = new Home();
h1.Show();
this.Hide();
}

private void button6_Click_1(object sender, EventArgs e)


{
transForm t = new transForm();
t.Show();
this.Hide();
}

private void Order_Load(object sender, EventArgs e)


{

private void label7_Click(object sender, EventArgs e)


{
MainHome m = new MainHome();
m.Show();
this.Hide();
}
}
}

Order Detail Class:


namespace ProjectGMS
{
class OrderDetail
{
int detailID;
int orderID;
int productID;
int quantity;
double subtotal;
public int DetailID
{
get
{
return detailID;
}
set
{
detailID = value;
}
}
public int OrderID
{
get
{
return orderID;
}
set
{
orderID = value;
}
}
public int ProductID
{
get
{
return productID;
}
set
{
productID = value;
}
}
public int Quantity
{
get
{
return quantity;
}
set
{
quantity = value;
}
}
public double Subtotal
{
get
{
return subtotal;
}
set
{
subtotal = value;
}
}
public void Create()
{
//insert
DbConnection d = new DbConnection();
string query = $@"insert into Order_Details
(Detail_ID,Order_ID,Product_ID,Quantity,Subtotal)
values({DetailID},{OrderID},{ProductID},{Quantity},{Subtotal})";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select* from Order_Details";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}
public DataTable Read(int Detail_ID)
{
DbConnection d = new DbConnection();
string query = $"select* from Order_Details where Detail_ID={DetailID}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Order_Details set
Product_ID={ProductID},Order_ID={OrderID},Quantity={Quantity} where
Detail_ID={DetailID} ";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Order_Details where Detail_ID={DetailID}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}

Order Detail form:

Product Class:
namespace ProjectGMS
{
class Product
{

int Pid;
String Pname;
int Pprice;
int Pqty;
int Catid;

public int Proid


{
set
{
Pid = value;
}
get
{
return Pid;
}
}

public string ProName


{
set
{
Pname = value;
}
get
{
return Pname;
}
}
public int ProPrice
{
set
{
Pprice = value;
}
get
{
return Pprice;
}
}
public int ProQTY
{
set
{

Pqty = value;
}
get
{
return Pqty;
}
}
public int CateId
{
set
{
Catid = value;
}
get
{
return Catid;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Products
(Product_ID,Name,Price,Quantity,Category_ID)
values({Proid},'{ProName}',{ProPrice},{ProQTY},{CateId})";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Products";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

public DataTable Read(int Proid)


{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Products where Product_ID={Proid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Products set
Category_ID= {CateId}, Name='{ProName}',Price={ProPrice},
Quantity={ProQTY} where Product_ID={Proid}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Products where Category_ID={CateId}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}
}
}
Product Form:
namespace ProjectGMS
{
public partial class Products : Form
{
public Products()
{
InitializeComponent();
}

private void filterByProduct()


{

}
private void label6_Click(object sender, EventArgs e)
{
this.Hide();
Home h1 = new Home();
h1.Show();
}
private void button1_Click(object sender, EventArgs e)
{
Product P = new Product();
try
{
P.Proid = Convert.ToInt32(textBox1.Text);
P.ProName = listBox1.Text;
P.ProPrice = Convert.ToInt32(textBox3.Text);
P.ProQTY = Convert.ToInt32(textBox4.Text);
P.CateId = Convert.ToInt32(comboBox1.Text);
P.Create();
MessageBox.Show("Product Entered Successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void Products_Load(object sender, EventArgs e)


{
Product P = new Product();
DataTable dt = P.Read();
dataGridView1.DataSource = dt;
}

private void button3_Click(object sender, EventArgs e)


{
Product P = new Product();
try
{
P.Proid = Convert.ToInt32(textBox1.Text);
P.ProName = listBox1.Text;
P.ProPrice = Convert.ToInt32(textBox3.Text);
P.ProQTY = Convert.ToInt32(textBox3.Text);
P.CateId = Convert.ToInt32(comboBox1.Text);
P.Update();
MessageBox.Show("Product Updated Successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Product P = new Product();
DataTable dt = P.Read();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Product P = new Product();
DataTable dt = P.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void button4_Click(object sender, EventArgs e)


{
Product P = new Product();
DataTable dt = P.Delete();
dataGridView1.DataSource = dt;
MessageBox.Show("Product Deleted Successfully");
}

private void button6_Click(object sender, EventArgs e)


{
Category C = new Category();
DataTable dt = C.Read();
dataGridView2.DataSource = dt;
}

private void dataGridView2_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{

private void button7_Click(object sender, EventArgs e)


{
textBox1.Text = "";
textBox3.Text = "";
textBox4.Text = "";
comboBox1.Text = "";

private void dataGridView1_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{
if (dataGridView1.CurrentRow != null)
{
textBox1.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
}
}

}
}
Image Product:
namespace ProjectGMS
{
class ImageProduct
{
public string ImagePath { get; set; }
public string ProductName { get; set; }
public string ProductValue { get; set; }

}
}

Salary Class:
namespace ProjectGMS
{
class Salary
{

int Eid;
int allowance;
int deduction;
public int Empid
{
set
{
Eid = value;
}
get
{
return Eid;
}
}

public int Allowance


{
set
{
allowance = value;
}
get
{
return allowance;
}
}
public int Deductions
{
set
{
deduction= value;
}
get
{
return deduction;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Salary
(allowance,deductions,Employee_ID)
values({Allowance},{Deductions},{Empid})";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Salary";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int Payid)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Salary where Employee_ID={Empid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Salary set
allowance={Allowance},deductions={Deductions} where
Employee_ID={Empid}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Salary where Employee_ID={Empid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}
Salary Form:

namespace ProjectGMS
{
public partial class Salarys : Form
{
public Salarys()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
Salary S = new Salary();
try
{
S.Empid = Convert.ToInt32(textBox1.Text);
S.Allowance = Convert.ToInt32(textBox2.Text);
S.Deductions = Convert.ToInt32(textBox3.Text);
S.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void Salarys_Load(object sender, EventArgs e)


{
Salary S= new Salary();
DataTable dt = S.Read();
dataGridView1.DataSource = dt;

private void button3_Click(object sender, EventArgs e)


{
Salary S = new Salary();
try
{
S.Empid = Convert.ToInt32(textBox1.Text);
S.Allowance = Convert.ToInt32(textBox2.Text);
S.Deductions = Convert.ToInt32(textBox3.Text);
S.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button4_Click(object sender, EventArgs e)


{
Salary S = new Salary();
DataTable dt = S.Delete();
dataGridView1.DataSource = dt;
}

private void button2_Click(object sender, EventArgs e)


{
Salary S = new Salary();
DataTable dt = S.Read();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Salary S = new Salary();
DataTable dt = S.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
this.Hide();
Home h1 = new Home();
h1.Show();
}

private void dataGridView2_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{
textBox1.Text = dataGridView2.CurrentCell.Value.ToString();
}

private void button6_Click(object sender, EventArgs e)


{
Employee e1 = new Employee();
DataTable dt = e1.Read();
dataGridView2.DataSource = dt;
}

private void dataGridView1_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{

}
}
}
Supplier Class:
namespace ProjectGMS
{
class Supplier
{
int id;
string name;
int contact;
string address;
public int Supid
{
set
{
id = value;
}
get
{
return id;
}
}
public string Supname
{
set
{
name = value;
}
get
{
return name;
}
}
public int Supcontact
{
set
{
contact = value;

}
get
{
return contact;
}

}
public string Supaddress
{
set
{
address = value;
}
get
{
return address;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Suppliers
(Supplier_ID,Name,Contact,Address)
values({Supid},'{Supname}',{Supcontact},'{Supaddress}')";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Suppliers";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int Supid)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Suppliers where Supplier_ID={Supid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Suppliers set
Name='{Supname}',Contact={Supcontact},Address='{Supaddress}' where
Supplier_ID={Supid}";
d.ExecuteQuery(query, true);
}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Suppliers where Supplier_ID={Supid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}
Supplier Form:
namespace ProjectGMS
{
public partial class Suppliers : Form
{
public Suppliers()
{
InitializeComponent();
}

private void Suppliers_Load(object sender, EventArgs e)


{
Supplier S = new Supplier();
DataTable dt = S.Read();
dataGridView1.DataSource = dt;
}

private void button1_Click(object sender, EventArgs e)


{
Supplier S= new Supplier();
try
{
S.Supid = Convert.ToInt32(textBox1.Text);
S.Supname = textBox2.Text;
S.Supcontact = Convert.ToInt32(textBox3.Text);
S.Supaddress = textBox4.Text;

S.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
Supplier S = new Supplier();
DataTable dt = S.Read();
dataGridView1.DataSource = dt;
}

private void button3_Click(object sender, EventArgs e)


{
Supplier S = new Supplier();
try
{

S.Supid = Convert.ToInt32(textBox1.Text);
S.Supname = textBox2.Text;
S.Supcontact = Convert.ToInt32(textBox3.Text);
S.Supaddress = textBox4.Text;
S.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button4_Click(object sender, EventArgs e)
{
Supplier S = new Supplier();
DataTable dt = S.Delete();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Supplier S = new Supplier();
DataTable dt = S.Read();
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
this.Hide();
Home h1 = new Home();
h1.Show();
}
}
}
Store Class:
namespace ProjectGMS
{
class Stores
{
int id;
string name;
int contact;
string location;
public int Sid
{
set
{
id = value;
}
get
{
return id;
}
}
public string Sname
{
set
{
name = value;
}
get
{
return name;
}
}
public int Scontact
{
set
{
contact = value;

}
get
{
return contact;
}

}
public string Slocation
{
set
{
location = value;
}
get
{
return location;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Store_Information
(Store_ID,Name,Location,Contact)
values({Sid},'{Sname}','{Slocation}',{Scontact})";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Store_Information";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int id)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Store_Information where Store_ID={Sid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Store_Information set
Name='{Sname}',Contact={Scontact},Location='{Slocation}' where
Store_ID={Sid}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Store_Information where Store_ID={Sid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}
Store Form:
namespace ProjectGMS
{
public partial class Store : Form
{
public Store()
{
InitializeComponent();
}

private void Store_Load(object sender, EventArgs e)


{

Stores S = new Stores();


DataTable dt = S.Read();
dataGridView1.DataSource = dt;
}

private void button1_Click(object sender, EventArgs e)


{
Stores S = new Stores();
try
{
S.Sid = Convert.ToInt32(textBox1.Text);
S.Sname = textBox2.Text;
S.Slocation = textBox3.Text;
S.Scontact = Convert.ToInt32(textBox4.Text);

S.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Stores S = new Stores();
DataTable dt = S.Read();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Stores S = new Stores();
DataTable dt = S.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void button3_Click(object sender, EventArgs e)


{
Stores S = new Stores();
try
{
S.Sid = Convert.ToInt32(textBox1.Text);
S.Sname = textBox2.Text;
S.Slocation = textBox3.Text;
S.Scontact = Convert.ToInt32(textBox4.Text);
S.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button4_Click(object sender, EventArgs e)


{
Stores S = new Stores();
DataTable dt = S.Delete();
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
this.Hide();
Home h1 = new Home();
h1.Show();
}
}
}
Promotion Class:

namespace ProjectGMS
{
class Promotion
{
int id;
int Pid;
int discount;
string Sdate;
string Edate;
public int PrId
{
set
{
id = value;
}
get
{
return id;
}
}
public int Prdiscount
{
set
{
discount = value;
}
get
{
return discount;
}
}
public int Proid
{
set
{
Pid = value;
}
get
{
return Pid;
}
}

public String PrEdate


{
set
{
Edate = value;

}
get
{
return Edate;
}

}
public string PrSdate
{
set
{
Sdate = value;
}
get
{
return Sdate;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Promotions
(Product_ID,Promo_ID,Discount,Start_Date,End_Date)
values({Proid},{PrId},{Prdiscount},'{PrSdate}','{PrEdate}')";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = $@"SELECT P.Product_ID,P.Name as ProductName,
P.Price as ProductPrice,
P.Category_ID,
P.Quantity AS ProductQuantity,
pr.Promo_ID,
pr.Discount as PromotionDiscount,
pr.Start_Date as PromotionStartDate,
pr.End_Date as PromotionEndDate,
pr.Product_ID
FROM
Products P
JOIN
Promotions pr ON P.Product_ID = pr.Product_ID; ";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int PrId)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Category where Promo_ID={PrId}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Promotions set
Product_ID={Proid},Discount={Prdiscount},Start_Date='{PrSdate}',End_Date='{PrE
date}' where Promo_ID={PrId}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Promotions where Product_Id={Proid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}
}
}
Promotion Form:

namespace ProjectGMS
{
public partial class Promotions : Form
{
public Promotions()
{
InitializeComponent();
}
private void Promotions_Load(object sender, EventArgs e)
{
Promotion p1 = new Promotion();
DataTable dt = p1.Read();
dataGridView1.DataSource = dt;
}

private void button1_Click(object sender, EventArgs e)


{
Promotion p1 = new Promotion();

try
{

p1.Proid= Convert.ToInt32(textBox5.Text);
p1.PrId = Convert.ToInt32(textBox1.Text);
p1.Prdiscount = Convert.ToInt32(textBox2.Text);
p1.PrSdate =dateTimePicker1.Text;
p1.PrEdate = dateTimePicker2.Text;

p1.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button3_Click(object sender, EventArgs e)


{
Promotion p1 = new Promotion();
try
{

p1.Proid = Convert.ToInt32(textBox5.Text);
p1.PrId = Convert.ToInt32(textBox1.Text);
p1.Prdiscount = Convert.ToInt32(textBox2.Text);
p1.PrSdate = dateTimePicker1.Text;
p1.PrEdate = dateTimePicker2.Text;

p1.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Promotion p1 = new Promotion();
DataTable dt = p1.Read();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Promotion p1 = new Promotion();
DataTable dt = p1.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void button4_Click(object sender, EventArgs e)


{
Promotion p1 = new Promotion();
DataTable dt = p1.Delete();
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
this.Hide();
Home h1 = new Home();
h1.Show();
}

private void button6_Click(object sender, EventArgs e)


{
}

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)


{

private void dataGridView2_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{
///* textBox5.Text = dataGridView2.CurrentCell.Value.ToString*/();
}
}
}

Inventory Class:
namespace ProjectGMS
{
class Inventorys
{
// Propertipublic class Inventorys

// P

public string name;


public int price;
int Quantity;
int Pid;
int exqty;
string expdate;
int Catid;
int Batchid;
int id;
public int CateId
{
set
{
Catid = value;
}
get
{
return Catid;
}
}
public int Supid
{
set
{
id = value;
}
get
{
return id;
}
}
public int ExQTY
{
set
{
exqty = value;
}
get
{
return exqty;
}
}
public int Proid
{
set
{
Pid = value;
}
get
{
return Pid;
}
}
public int QTY
{
set
{
Quantity= value;
}
get
{
return Quantity;
}
}
public int BatchId
{
set
{
Batchid = value;
}
get
{
return Batchid;
}
}
public string ExpiryDate
{
set
{
expdate = value;
}
get
{
return expdate;
}
}

public void Create()


{
DbConnection d = new DbConnection();
string query = $@"insert into Inventory
(Product_ID,Supplier_ID,ExistingQuantity,Batchid,Category_ID,Quantity)
values({Proid},{Supid},{ExQTY},{BatchId},{CateId},{QTY})";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = $@"SELECT
P.Product_ID,
P.Name AS ProductName,
P.Price AS ProductPrice,
P.Category_ID,
P.Quantity AS ProductQuantity,
S.Supplier_ID,
S.Name AS SupplierName,
S.Contact AS SupplierContact,
S.Address AS SupplierAddress,
I.ExistingQuantity,
I.Quantity,
I.BatchID as StockBatchId,
I.Quantity as StockTotalQty
FROM
Products P
JOIN
Inventory I ON P.Product_ID = I.Product_ID
JOIN
Suppliers S ON I.Supplier_ID = S.Supplier_ID
-- If there is a Categories table and you want to include Category details, you can
join it as well
JOIN
Category C ON P.Category_ID = C.Category_ID;
";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}
public DataTable Read(int Proid)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Inventory where Product_ID={Proid} ";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Inventory set
Supplier_ID={Supid},ExistingQuantity={ExQTY},Quantity={QTY},Batchid={BatchId},
Category_ID={CateId} where Product_ID={Proid}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Inventory where Product_ID={Proid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}
public void UpdateQuantity(string connectionString, int Proid, int ExQTY, int
QTY,int BatchId)
{
string updateQuery = $@"UPDATE Inventory
SET Quantity = {QTY}+{ExQTY},Batchid={BatchId},ExistingQuantity={ExQTY} where
Product_ID={Proid}";

using (SqlConnection connection = new SqlConnection(connectionString))


{
connection.Open();
SqlCommand updateCommand = new SqlCommand(updateQuery,
connection);
updateCommand.Parameters.AddWithValue("@ExQTY", ExQTY);
updateCommand.Parameters.AddWithValue("@Quantity", QTY);
updateCommand.Parameters.AddWithValue("@ProductID", Proid);

int rowsAffected = updateCommand.ExecuteNonQuery();


if (rowsAffected > 0)
{
Console.WriteLine("Quantity updated successfully.");
}
else
{
Console.WriteLine("No rows affected. Product ID may not exist.");
}
}
}

}
}
Inventory Form:
namespace ProjectGMS
{
public partial class Inventory : Form
{

public int Proid { get; internal set; }

public Inventory()
{
InitializeComponent();
}

private void Inventory_Load(object sender, EventArgs e)


{
Inventorys i = new Inventorys();
DataTable dt = i.Read();
dataGridView1.DataSource = dt;
}

private void button1_Click(object sender, EventArgs e)


{
Inventorys i = new Inventorys();

try
{

i.Proid = Convert.ToInt32(textBox1.Text);
i.Supid = Convert.ToInt32(textBox2.Text);
i.ExQTY = Convert.ToInt32(textBox3.Text);
i.QTY = Convert.ToInt32(textBox4.Text);
i.BatchId = Convert.ToInt32(textBox6.Text);

i.CateId = Convert.ToInt32(textBox8.Text);

i.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button3_Click(object sender, EventArgs e)


{
Inventorys i = new Inventorys();

try
{
i.Proid = Convert.ToInt32(textBox1.Text);
i.Supid = Convert.ToInt32(textBox2.Text);
i.ExQTY = Convert.ToInt32(textBox3.Text);
i.QTY = Convert.ToInt32(textBox4.Text);

i.BatchId = Convert.ToInt32(textBox6.Text);

i.CateId = Convert.ToInt32(textBox8.Text);
i.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Inventorys i = new Inventorys();
DataTable dt = i.Read();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Inventorys i = new Inventorys();
DataTable dt = i.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void button4_Click(object sender, EventArgs e)


{
Inventorys i = new Inventorys();
DataTable dt = i.Delete();
dataGridView1.DataSource = dt;

private void label6_Click(object sender, EventArgs e)


{
AdminHome h = new AdminHome();
h.Show();
this.Hide();
}

private void dataGridView2_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{

}
private void dataGridView3_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{

private void dataGridView1_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{
textBox1.Text = dataGridView1.CurrentCell.Value.ToString();
textBox2.Text = dataGridView1.CurrentCell.Value.ToString();
}

private void button6_Click_1(object sender, EventArgs e)


{
InventoryUpdate i = new InventoryUpdate();
i.Show();
this.Hide();

}
}
}

Inventory Update:
namespace ProjectGMS
{
public partial class InventoryUpdate : Form
{
public InventoryUpdate()
{
InitializeComponent();
}

private void button6_Click(object sender, EventArgs e)


{
string connectionString = "Data Source=DESKTOP-VKORAQ4\\
MSSQLSERVERR;Initial Catalog=FMS;Integrated Security=True";
Inventorys i = new Inventorys();
int Proid = int.Parse(textBox1.Text);
int ExQTY = int.Parse(textBox3.Text);
int QTY = int.Parse(textBox4.Text);
int BatchId = int.Parse(textBox5.Text);
i.UpdateQuantity(connectionString, Proid, ExQTY, QTY,BatchId);
}

private void button2_Click(object sender, EventArgs e)


{
Inventorys i = new Inventorys();
DataTable dt = i.Read();
dataGridView1.DataSource = dt;
}

private void dataGridView1_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{

private void label6_Click(object sender, EventArgs e)


{
Inventory i=new Inventory();
i.Show();
this.Hide();
}

private void InventoryUpdate_Load(object sender, EventArgs e)


{

}
}
}

Employee Class:
namespace ProjectGMS
{
class Employee
{

int Eid;
string name;
string type;
string email;
string password;
int contact;
string address;

public int Empid


{
set
{
Eid = value;
}
get
{
return Eid;
}
}
public string EmpType
{
set
{
type = value;
}
get
{
return type;
}
}
public string Empname
{
set
{
name = value;
}
get
{
return name;
}
}
public int Empcontact
{
set
{
contact = value;

}
get
{
return contact;
}

}
public string Empaddress
{
set
{
address = value;
}
get
{
return address;
}
}
public string EmpEmail
{
set
{
email = value;
}
get
{
return email;
}

}
public string EmpPassword
{
set
{
password= value;
}
get
{
return password;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Employees
(Employee_ID,Name,Type,Contact,Address,Email,Password)
values({Empid},'{Empname}','{EmpType}',
{Empcontact},'{Empaddress}','{EmpEmail}','{EmpPassword}')";
d.ExecuteQuery(query, true);
}
public void Insert()
{
DbConnection d = new DbConnection();
string query = $@"insert into Employees
(Type,Email,Password)
values('{EmpType}','{EmpEmail}','{EmpPassword}')";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Employees";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int id)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Employees where Employee_ID={Empid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Employees set

Name='{Empname}',Position='{EmpType}',Contact={Empcontact},Address='{Empa
ddress}','{EmpEmail}','{EmpPassword} where Employee_ID={Empid}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Employee where Employee_Id={Empid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}
Employee Form:
namespace ProjectGMS
{
public partial class Employees : Form
{
public Employees()
{
InitializeComponent();
}

private void Employees_Load(object sender, EventArgs e)


{

Employee e1 = new Employee();


DataTable dt = e1.Read();
dataGridView1.DataSource = dt;
}

private void button1_Click(object sender, EventArgs e)


{
Employee e1 = new Employee();
try
{
e1.Empid = Convert.ToInt32(textBox1.Text);
e1.Empname = textBox2.Text;
e1.EmpType = comboBox1.Text;
e1.Empcontact = Convert.ToInt32(textBox3.Text);
e1.Empaddress = textBox4.Text;
e1.EmpEmail = textBox5.Text;
e1.EmpPassword = textBox6.Text;

e1.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Employee e1 = new Employee();
DataTable dt = e1.Read();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Employee e1 = new Employee();
DataTable dt = e1.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void button3_Click(object sender, EventArgs e)


{
Employee e1 = new Employee();
try
{
e1.Empid = Convert.ToInt32(textBox1.Text);
e1.Empname = textBox2.Text;
e1.EmpType = comboBox1.Text;
e1.Empcontact = Convert.ToInt32(textBox3.Text);
e1.Empaddress = textBox4.Text;
e1.EmpEmail = textBox5.Text;
e1.EmpPassword = textBox6.Text;
e1.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button4_Click(object sender, EventArgs e)
{

Employee e1 = new Employee();


DataTable dt = e1.Delete();
dataGridView1.DataSource = dt;
}

private void label9_Click(object sender, EventArgs e)


{
this.Hide();
Home h1 = new Home();
h1.Show();
}
}
}

Expenses Class:
namespace ProjectGMS
{
class Expense
{
int id;
string description;
int amount;
string date;
public int Exid
{
set
{
id = value;
}
get
{
return id;
}
}
public string Exdes
{
set
{
description = value;
}
get
{
return description;
}
}
public int Examount

{
set
{
amount = value;

}
get
{
return amount;
}

}
public string Exdate
{
set
{
date = value;
}
get
{
return date;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Expenses
(Expense_ID,Description,Amount,Date)
values({Exid},'{Exdes}',{Examount},'{Exdate}')";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Expenses";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int Exid)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Expenses where Expense_ID={Exid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Expenses set
Description='{Exdes}',Amount={Examount},Date={Exdate} where
Expense_ID={Exid}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Expenses where Expense_ID={Exid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

Expenses Form:
namespace ProjectGMS
{
public partial class Expenses : Form
{
public Expenses()
{
InitializeComponent();
}

private void Expenses_Load(object sender, EventArgs e)


{

Expense E = new Expense();


DataTable dt = E.Read();
dataGridView1.DataSource = dt;
}

private void button1_Click(object sender, EventArgs e)


{
Expense E = new Expense();
try
{
E.Exid = Convert.ToInt32(textBox1.Text);
E.Exdes= textBox2.Text;
E.Examount= Convert.ToInt32(textBox3.Text);
E.Exdate = dateTimePicker1.Text;

E.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Expense E = new Expense();
DataTable dt = E.Read();
dataGridView1.DataSource = dt;
}

private void button3_Click(object sender, EventArgs e)


{
Expense E = new Expense();
try
{
E.Exid = Convert.ToInt32(textBox1.Text);
E.Exdes = textBox2.Text;
E.Examount = Convert.ToInt32(textBox3.Text);
E.Exdate = dateTimePicker1.Text;

E.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button4_Click(object sender, EventArgs e)


{
Expense E = new Expense();
DataTable dt = E.Delete();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Expense E = new Expense();
DataTable dt = E.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
this.Hide();
Home h1 = new Home();
h1.Show();
}
}
}

Customer Class:
namespace ProjectGMS
{
class Customer
{
int id;
int cid;
string name;
int contact;
string address;
public int ProId
{
set
{
id = value;
}
get
{
return id;
}
}
public int Cusid
{
set
{
cid = value;
}
get
{
return cid;
}
}
public string Cusname
{
set
{
name = value;
}
get
{
return name;
}
}
public int Cuscontact
{
set
{
contact = value;

}
get
{
return contact;
}

}
public string Cusaddress
{
set
{
address = value;
}
get
{
return address;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Customers
(Customer_id,CussName,Contact,Address)
values({Cusid},'{Cusname}',{Cuscontact},'{Cusaddress}')";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Customers";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int Cusid)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Customers where Customer_id={Cusid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Customers set
Cussname='{Cusname}',Contact={Cuscontact},Address='{Cusaddress}'
where Customer_Id={Cusid}";
d.ExecuteQuery(query, true);

}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Customers where Customer_Id={Cusid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}
Customer Form:
namespace ProjectGMS
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

Customer c = new Customer();


DataTable dt = c.Read();
dataGridView1.DataSource = dt;
}

private void button1_Click(object sender, EventArgs e)


{
Customer c = new Customer();
try
{
c.Cusid = Convert.ToInt32(textBox1.Text);
c.Cusname = textBox2.Text;
c.Cuscontact = Convert.ToInt32(textBox3.Text);
c.Cusaddress = textBox4.Text;

c.Create();
MessageBox.Show("customer inserted successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Customer c = new Customer();
DataTable dt = c.Read();
dataGridView1.DataSource = dt;
}

private void button3_Click(object sender, EventArgs e)


{
Customer c = new Customer();
try
{

c.Cusid = Convert.ToInt32(textBox1.Text);
c.Cusname = textBox2.Text;
c.Cuscontact = Convert.ToInt32(textBox3.Text);
c.Cusaddress = textBox4.Text;
c.Update();
MessageBox.Show("customer updated successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button4_Click(object sender, EventArgs e)


{
Customer c = new Customer();
DataTable dt = c.Delete();
dataGridView1.DataSource = dt;
MessageBox.Show("customer deleted successfully");
}

private void button5_Click(object sender, EventArgs e)


{
Customer c = new Customer();
DataTable dt = c.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
MainHome m = new MainHome();
m.Show();
this.Hide();
}

private void label5_Click(object sender, EventArgs e)


{

}
string connectionstring = "Data Source=DESKTOP-VKORAQ4\\
MSSQLSERVERR;Initial Catalog=FMS;Integrated Security=True";
SqlConnection con = new SqlConnection(connectionString);
private static string connectionString;

private void button6_Click(object sender, EventArgs e)


{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";

}
}
}
Category Class:
namespace ProjectGMS
{
class Category
{

int Catid;
string Name;
string Description;
public int CateId
{
set
{
Catid = value;
}
get
{
return Catid;
}
}

public string CateName


{
set
{
Name= value;
}
get
{
return Name;
}
}

public void Create()


{
DbConnection d = new DbConnection();
string query = $@"insert into Category
(Category_ID,Name)
values({CateId},'{CateName}')";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Category";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int CateId)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Category where Category_ID={CateId}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Category set
Name='{CateName}' where Category_ID={CateId}";
d.ExecuteQuery(query, true);
}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Category where Category_ID={CateId}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}
Category Form:
namespace ProjectGMS
{
public partial class Categorys : Form
{
public Categorys()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
Category C=new Category();
try
{
C.CateId = Convert.ToInt32(comboBox1.Text);
C.CateName = comboBox2.Text;

C.Create();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}

private void button3_Click(object sender, EventArgs e)


{
Category C = new Category();
try
{
C.CateId = Convert.ToInt32(comboBox1.Text);
C.CateName = comboBox2.Text;

C.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Category C = new Category();
DataTable dt = C.Read();
dataGridView1.DataSource = dt;

private void button5_Click(object sender, EventArgs e)


{
Category C = new Category();
DataTable dt = C.Read(Convert.ToInt32(comboBox1.Text));
dataGridView1.DataSource = dt;
}

private void button4_Click(object sender, EventArgs e)


{
Category C = new Category();
DataTable dt = C.Delete();
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
this.Hide();
Home h1 = new Home();
h1.Show();
}

private void Categorys_Load(object sender, EventArgs e)


{

}
}
}

Transaction Class:
namespace ProjectGMS
{
class Transaction
{
public Customer Customer
{
get;
set;
}
public List<Product> Products
{
get;
set;
}
public decimal TotalAmount
{
get;
set;
}
int Tid;
int Eid;
int id;
string Date;
public int Transid
{
set
{
Tid = value;
}
get
{
return Tid;
}
}
public int Empid
{
set
{
Eid = value;
}
get
{
return Eid;
}
}

public int Payid


{
set
{
id = value;
}
get
{
return id;
}
}
public string TransDate
{
set
{
Date= value;
}
get
{
return Date;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Transactions
(Transaction_ID,Employee_ID,Payment_ID,Transaction_Date)
values({Transid},{Empid},{Payid},'{TransDate}')";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = "select * from Transactions";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int Payid)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Transactions where
Transaction_ID={Transid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Transactions set

Transaction_Date='{TransDate}',Payment_ID={Payid},Transaction_ID={Transid}
where Employee_ID={Empid}";
d.ExecuteQuery(query, true);
}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Transactions where
Transaction_ID={Transid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}
Transaction Form:
namespace ProjectGMS
{
public partial class Transactions : Form
{
public Transactions()
{
InitializeComponent();
}

private void dataGridView3_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{
textBox2.Text = dataGridView3.CurrentCell.Value.ToString();
}

private void button1_Click(object sender, EventArgs e)


{
Transaction t=new Transaction();
try
{
t.Transid = Convert.ToInt32(textBox1.Text);
t.Empid = Convert.ToInt32(textBox2.Text);
t.Payid = Convert.ToInt32(textBox3.Text);
t.TransDate = dateTimePicker1.Text;

t.Create();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
Transaction t = new Transaction();
DataTable dt = t.Read();
dataGridView1.DataSource = dt;
}

private void button5_Click(object sender, EventArgs e)


{
Transaction t = new Transaction();
DataTable dt =t.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void button4_Click(object sender, EventArgs e)


{
Transaction t = new Transaction();
DataTable dt = t.Delete();
dataGridView1.DataSource = dt;
}

private void button3_Click(object sender, EventArgs e)


{
Transaction t = new Transaction();
try
{
t.Transid = Convert.ToInt32(textBox1.Text);
t.Empid = Convert.ToInt32(textBox2.Text);
t.Payid = Convert.ToInt32(textBox3.Text);
t.TransDate = dateTimePicker1.Text;

t.Update();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}

private void button6_Click(object sender, EventArgs e)


{
Payments P = new Payments();
DataTable dt = P.Read();
dataGridView2.DataSource = dt;
}

private void button7_Click(object sender, EventArgs e)


{
Employee e1 = new Employee();
DataTable dt = e1.Read();
dataGridView3.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
Home h1 = new Home();
h1.Show();
this.Hide();
}

private void dataGridView2_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{
textBox3.Text = dataGridView2.CurrentCell.Value.ToString();
}

private void button8_Click(object sender, EventArgs e)


{
transForm t = new transForm();
t.Show();
this.Hide();
}

}
}
Transaction Detail Class:
namespace ProjectGMS
{
class TransactionDetail
{
int id;
int Tid;
int Pid;
int QTY;
int Price;
public int Detailid
{
set
{
id = value;
}
get
{
return id;
}
}
public int Transid
{
set
{
Tid = value;
}
get
{
return Tid;
}
}
public int Proid
{
set
{
Pid = value;
}
get
{
return Pid;
}
}
public int TQTY
{
set
{
QTY= value;
}
get
{
return QTY;
}
}
public int TPrice
{
set
{
Price = value;
}
get
{
return Price;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into Transaction_Details
(Detail_ID,Transaction_ID,Product_ID,Quantity,Price)
values({Detailid},{Transid},{Proid},{TQTY},{TPrice})";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = $@"SELECT
o.Order_ID,
o.Customer_ID,
o.Order_Date,
o.Total_Amount AS OrderTotalAmount,
od.Detail_ID AS OrderDetailID,
od.Product_ID AS ProductID,
p.Name AS ProductName,
p.Price AS ProductPrice,
od.Quantity AS OrderQuantity,
od.Subtotal AS OrderSubTotal,
p.Quantity AS ProductQuantity,
p.Category_ID

FROM
Orders o
JOIN
Order_Details od ON o.Order_ID = od.Order_ID
JOIN
Products p ON od.Product_ID = p.Product_ID
JOIN
Category c ON p.Category_ID = c.Category_ID;
";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public DataTable Read(int Detailid)
{
//select where
DbConnection d = new DbConnection();
string query = $"select * from Transaction_Details where
Detail_ID={Detailid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
public void Update()
{
DbConnection d = new DbConnection();
string query = $@"update Transaction_Details set

Product_ID={Proid},Transaction_ID={Transid},Quantity={TQTY},Price={TPrice}
where Detail_ID={Detailid}";
d.ExecuteQuery(query, true);
}
public DataTable Delete()
{
DbConnection d = new DbConnection();
string query = $"delete from Transaction_Details where
Detail_ID={Detailid}";
DataTable dt = d.ExecuteQuery(query, false);
return dt;
}

}
}

Transaction Detail Form:

namespace ProjectGMS
{
public partial class TransactionDetails : Form
{
public TransactionDetails()
{
InitializeComponent();
}
private void button6_Click(object sender, EventArgs e)
{
}

private void button7_Click(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
TransactionDetail td=new TransactionDetail();

try
{

td.Detailid= Convert.ToInt32(textBox1.Text);
td.Transid = Convert.ToInt32(textBox2.Text);
td.Proid= Convert.ToInt32(textBox3.Text);
td.TQTY = Convert.ToInt32(textBox4.Text);
td.TPrice= Convert.ToInt32(textBox5.Text);

td.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
TransactionDetail td=new TransactionDetail();
DataTable dt = td.Read();
dataGridView1.DataSource = dt;
}

private void button4_Click(object sender, EventArgs e)


{
TransactionDetail td = new TransactionDetail();
DataTable dt = td.Delete();
dataGridView1.DataSource = dt;
}

private void button3_Click(object sender, EventArgs e)


{
TransactionDetail td = new TransactionDetail();

try
{

td.Detailid = Convert.ToInt32(textBox1.Text);
td.Transid = Convert.ToInt32(textBox2.Text);
td.Proid = Convert.ToInt32(textBox3.Text);
td.TQTY = Convert.ToInt32(textBox4.Text);
td.TPrice = Convert.ToInt32(textBox5.Text);

td.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button5_Click(object sender, EventArgs e)


{
TransactionDetail td = new TransactionDetail();
DataTable dt = td.Read(Convert.ToInt32(textBox1.Text));
dataGridView1.DataSource = dt;
}

private void label6_Click(object sender, EventArgs e)


{
Home h = new Home();
h.Show();
this.Hide();
}

private void dataGridView2_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{

private void dataGridView1_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{

private void dataGridView3_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{

private void TransactionDetails_Load(object sender, EventArgs e)


{

}
}
}
DBConnection:
namespace ProjectGMS
{
class DbConnection
{

string connectionstring = "Data Source=DESKTOP-VKORAQ4\\


MSSQLSERVERR;Initial Catalog=FMS;Integrated Security=True";
public DataTable procedureExecuteQuery(string query, bool flag, string
EmpEmail, string EmpPassword, string EmpType)
{
SqlConnection con = new SqlConnection(connectionstring);
SqlCommand cmd = new SqlCommand(query, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Email", EmpEmail);
cmd.Parameters.AddWithValue("@Password", EmpPassword);
cmd.Parameters.AddWithValue("@Type", EmpType);

DataTable dt = new DataTable();


SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
return dt;
}
public DataTable ExecuteQuery(string query, bool flag)
{
SqlConnection con = new SqlConnection(connectionstring);
SqlCommand cmd = new SqlCommand(query, con);
DataTable dt = new DataTable();
if (flag)
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
return null;
}
else
{
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
return dt;
}

}
}
}

User Authentication:
namespace ProjectGMS
{
class User_Authentication
{
private bool _isLoggedIn;

public DataTable Login(string email, string password, string type)


{
DbConnection d = new DbConnection();
string query = $@"auth";
DataTable dt = d.procedureExecuteQuery(query, false, email, password,
type);
return dt;
//T and T password='bilalhgf' OR 'a'='a'

public void Logout()


{
if (_isLoggedIn)
{
_isLoggedIn = false;
Console.WriteLine($"Employee logged out successfully.");
}
else
{
Console.WriteLine("Employee is not logged in.");
}
}
}
}

GMS:
namespace ProjectGMS
{
public partial class GMS : Form
{
public GMS()
{
InitializeComponent();
}
private void button1_Click_1(object sender, EventArgs e)
{
Login_Form l = new Login_Form();
l.Show();

private void GMS_Load(object sender, EventArgs e)


{

private void label6_Click(object sender, EventArgs e)


{
Application.Exit();
}
}
}

Main Home:
namespace ProjectGMS
{
public partial class MainHome : Form
{
public MainHome()
{
InitializeComponent();
}

private void pictureBox1_Click(object sender, EventArgs e)


{
Products p = new Products();
p.Show();
this.Hide();
}

private void label6_Click(object sender, EventArgs e)


{
GMS g = new GMS();
g.Show();
this.Hide();
}

private void pictureBox2_Click(object sender, EventArgs e)


{
Form1 f = new Form1();
f.Show();
this.Hide();
}

private void pictureBox3_Click(object sender, EventArgs e)


{
Order o = new Order();
o.Show();
this.Hide();
}

private void pictureBox4_Click(object sender, EventArgs e)


{
Categorys c = new Categorys();
c.Show();
this.Hide();
}
Login Form:
namespace ProjectGMS
{
public partial class Login_Form : Form
{
public Login_Form()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
User_Authentication a = new User_Authentication();
DataTable dt = a.Login(textBox1.Text, textBox2.Text, comboBox1.Text);
if (dt.Rows.Count > 0)
{
if (comboBox1.Text == "Management Worker")
{
MessageBox.Show("Successfully Login As Worker");
Worker w=new Worker();
w.Show();
this.Hide();
}
else if (comboBox1.Text == "Admin")
{
MessageBox.Show("Successfully Login As Admin");
AdminHome A=new AdminHome();
A.Show();
this.Hide();
}
else
{
MessageBox.Show("Successfully Login As Cashier");
Cashier c=new Cashier();
c.Show();
this.Hide();
}
}
else
{
MessageBox.Show("Login Failed");
}
}

private void label6_Click(object sender, EventArgs e)


{
Home h = new Home();
h.Show();
this.Hide();
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)


{

if (checkBox1.Checked)
{
textBox2.UseSystemPasswordChar = false;
}
else
{
textBox2.UseSystemPasswordChar = true;
}
}

private void Login_Form_Load(object sender, EventArgs e)


{
textBox2.UseSystemPasswordChar = true;
}

private void linkLabel1_LinkClicked(object sender,


LinkLabelLinkClickedEventArgs e)
{
Signup s = new Signup();
s.Show();
this.Hide();
}
}
}
Home:

namespace ProjectGMS
{
public partial class Home : Form
{
public Home()
{
InitializeComponent();
}

private void customerToolStripMenuItem_Click(object sender, EventArgs e)


{
}

private void customerInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Form1 f1 = new Form1();
f1.Show();

private void suppliersInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Suppliers s1 = new Suppliers();
s1.Show();
this.Hide();

private void expensesInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{

Expenses e2 = new Expenses();


e2.Show();

private void storeInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Store s2 = new Store();
s2.Show();
}

private void adminToolStripMenuItem_Click(object sender, EventArgs e)


{
Employees e1 = new Employees();
e1.Show();
}

private void managerToolStripMenuItem_Click(object sender, EventArgs e)


{
Employees e1 = new Employees();
e1.Show();
}

private void maintainanceWorkerToolStripMenuItem_Click(object sender,


EventArgs e)
{

private void adminToolStripMenuItem_Click_1(object sender, EventArgs e)


{

Login_Form l = new Login_Form();


l.Show();
this.Hide();
}
private void cashierToolStripMenuItem_Click_1(object sender, EventArgs e)
{
Login_Form l = new Login_Form();
l.Show();
this.Hide();
}

private void workerToolStripMenuItem_Click(object sender, EventArgs e)


{
Login_Form l = new Login_Form();
l.Show();
this.Hide();
}

private void label6_Click(object sender, EventArgs e)


{
AdminHome h = new AdminHome();
h.Show();
this.Hide();
}

private void paymentInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Payment P = new Payment();
P.Show();
this.Hide();
}

private void salaryInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Salarys s= new Salarys();
s.Show();
this.Hide();
}

private void productInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Products P= new Products();
P.Show();
this.Hide();
}

private void categoryInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{

Categorys C = new Categorys();


C.Show();
this.Hide();
}

private void promotionInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Promotions P = new Promotions();
P.Show();
this.Hide();
}

private void loginAsToolStripMenuItem_Click_1(object sender, EventArgs e)


{
Employees E = new Employees();
E.Show();
this.Hide();
}

private void transactionInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Transactions t = new Transactions();
t.Show();
this.Hide();
}

private void orderInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Order o = new Order();
o.Show();
this.Hide();

private void transactionDetailInformationToolStripMenuItem_Click(object


sender, EventArgs e)
{
TransactionDetails t = new TransactionDetails();
t.Show();
this.Hide();
}

private void inventoryInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
Inventory i = new Inventory();
i.Show();
this.Hide();
}

private void transacToolStripMenuItem_Click(object sender, EventArgs e)


{
transForm t = new transForm();
t.Show();
this.Hide();
}

private void toolStripMenuItem1_Click(object sender, EventArgs e)


{
transForm f = new transForm();
f.Show();
this.Hide();

private void transactionToolStripMenuItem_Click(object sender, EventArgs e)


{
transForm t = new transForm();
t.Show();
this.Hide();
}

private void detailInformationToolStripMenuItem_Click(object sender,


EventArgs e)
{
TransactionDetails t = new TransactionDetails();
t.Show();
this.Hide();
}
}
}

Admin Home:

namespace ProjectGMS
{
public partial class AdminHome : Form
{
public AdminHome()
{
InitializeComponent();
}

private void button6_Click(object sender, EventArgs e)


{
Payments p = new Payments();
DataTable dt4 = p.Read();
dataGridView1.DataSource = dt4;
}

private void button7_Click(object sender, EventArgs e)


{
Salary s=new Salary();
DataTable dt4 = s.Read();
dataGridView1.DataSource = dt4;
}

private void button9_Click(object sender, EventArgs e)


{
Product P = new Product();
DataTable dt4 = P.Read();
dataGridView1.DataSource = dt4;

private void button10_Click(object sender, EventArgs e)


{
Category P = new Category();
DataTable dt4 = P.Read();
dataGridView1.DataSource = dt4;
}

private void button11_Click(object sender, EventArgs e)


{
Promotion P = new Promotion();
DataTable dt4 = P.Read();
dataGridView1.DataSource = dt4;
}

private void button12_Click(object sender, EventArgs e)


{
Transaction t=new Transaction();
DataTable dt4 = t.Read();
dataGridView1.DataSource = dt4;
}

private void button13_Click(object sender, EventArgs e)


{
Orders o = new Orders();
DataTable dt4 = o.Read();
dataGridView1.DataSource = dt4;
}
private void button4_Click(object sender, EventArgs e)
{
Expense ex = new Expense();
DataTable dt4 = ex.Read();
dataGridView1.DataSource = dt4;
}

private void button5_Click(object sender, EventArgs e)


{
Supplier s = new Supplier();
DataTable dt4 = s.Read();
dataGridView1.DataSource = dt4;
}

private void button8_Click(object sender, EventArgs e)


{
Employees es = new Employees();
es.Show();
this.Hide();
}

private void button14_Click(object sender, EventArgs e)


{
TransactionDetail t = new TransactionDetail();
DataTable dt4 = t.Read();
dataGridView1.DataSource = dt4;
}

private void button3_Click(object sender, EventArgs e)


{
Employee es=new Employee();
DataTable dt4 = es.Read();
dataGridView1.DataSource = dt4;
}

private void button1_Click(object sender, EventArgs e)


{
Customer P=new Customer();
DataTable dt4 = P.Read();
dataGridView1.DataSource = dt4;
}

private void button2_Click(object sender, EventArgs e)


{
Stores s = new Stores();
DataTable dt4 = s.Read();
dataGridView1.DataSource = dt4;
}

private void AdminHome_Load(object sender, EventArgs e)


{

private void label6_Click(object sender, EventArgs e)


{

this.Hide();
}

private void button15_Click(object sender, EventArgs e)


{
MainHome m = new MainHome();
m.Show();
this.Hide();
}

private void button16_Click(object sender, EventArgs e)


{
Inventory i = new Inventory();
i.Show();
this.Hide();
}

private void button17_Click(object sender, EventArgs e)


{
Home h = new Home();
h.Show();
this.Hide();
}
}
}
Casheir:
namespace ProjectGMS
{
public partial class Cashier : Form
{
public Cashier()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)


{
string connectionString = "Data Source=DESKTOP-VKORAQ4\\
MSSQLSERVERR;Initial Catalog=FMS;Integrated Security=True";
string textboxValue = textBox1.Text; // Assuming TextBoxName is the ID of
your textbox

using (SqlConnection connection = new SqlConnection(connectionString))


{
connection.Open();

using (SqlCommand command = new SqlCommand("SELECT Name FROM


Products WHERE Name LIKE @textboxValue", connection))
{
command.Parameters.AddWithValue("@textboxValue", "%" +
textboxValue + "%");

using (SqlDataReader reader = command.ExecuteReader())


{
DataTable dataTable = new DataTable();
dataTable.Load(reader);
dataGridView1.DataSource = dataTable;
}
}
}

}
private void button1_Click(object sender, EventArgs e)
{

private void button6_Click(object sender, EventArgs e)


{
MessageBox.Show("Please pay through cash at the counter.", "Cash
Payment");
}

private void button5_Click(object sender, EventArgs e)


{
ATM a = new ATM();
a.Show();
this.Hide();
}

private void label6_Click(object sender, EventArgs e)


{
Login_Form f = new Login_Form();
f.Show();
this.Hide();
}
private void button1_Click_1(object sender, EventArgs e)
{
Home h = new Home();
h.Show();
this.Hide();
}

private void button3_Click(object sender, EventArgs e)


{
MainHome n = new MainHome();
n.Show();
this.Hide();
}

private void Cashier_Load(object sender, EventArgs e)


{

}
}

ATM Pay:
namespace ProjectGMS
{
class ATMPay
{
int num;
int code;
public int CardNum
{
set
{
num = value;
}
get
{
return num;
}
}
public int PIN
{
set
{
code = value;
}
get
{
return code;
}
}
public void Create()
{
DbConnection d = new DbConnection();
string query = $@"insert into ATM
(CardNum,PIN)
values({CardNum},{PIN})";
d.ExecuteQuery(query, true);
}
public DataTable Read()
{
DbConnection d = new DbConnection();
string query = $@"select * from ATM";
DataTable dt = d.ExecuteQuery(query, false);
return dt;

}
}

ATM Form:
namespace ProjectGMS
{
public partial class ATM : Form
{
public ATM()
{
InitializeComponent();
}

private void ATM_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
ATMPay p1=new ATMPay();
try
{
p1.CardNum = Convert.ToInt32(textBox1.Text);
p1.PIN= Convert.ToInt32(textBox2.Text);

p1.Create();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}

private void button3_Click(object sender, EventArgs e)


{
textBox1.Text = "";
textBox2.Text = "";
}

private void label6_Click(object sender, EventArgs e)


{
Cashier c = new Cashier();
c.Show();
this.Hide();
}
}
}

You might also like