Grocery Assignment
Grocery Assignment
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();
}
P.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}
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 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);
}
}
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);
}
}
}
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;
}
}
}
Product Class:
namespace ProjectGMS
{
class Product
{
int Pid;
String Pname;
int Pprice;
int Pqty;
int Catid;
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 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 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);
}
}
}
}
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 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();
}
}
}
}
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();
}
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;
}
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;
}
}
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();
}
S.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
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;
}
}
}
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;
}
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);
}
}
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);
}
}
Inventory Class:
namespace ProjectGMS
{
class Inventorys
{
// Propertipublic class Inventorys
// P
}
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}";
}
}
Inventory Form:
namespace ProjectGMS
{
public partial class Inventory : Form
{
public Inventory()
{
InitializeComponent();
}
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);
}
}
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 dataGridView3_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
}
}
}
Inventory Update:
namespace ProjectGMS
{
public partial class InventoryUpdate : Form
{
public InventoryUpdate()
{
InitializeComponent();
}
}
}
}
Employee Class:
namespace ProjectGMS
{
class Employee
{
int Eid;
string name;
string type;
string email;
string password;
int contact;
string address;
}
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();
}
e1.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
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();
}
E.Create();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
E.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
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();
}
c.Create();
MessageBox.Show("customer inserted successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
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);
}
}
}
string connectionstring = "Data Source=DESKTOP-VKORAQ4\\
MSSQLSERVERR;Initial Catalog=FMS;Integrated Security=True";
SqlConnection con = new SqlConnection(connectionString);
private static string connectionString;
}
}
}
Category Class:
namespace ProjectGMS
{
class Category
{
int Catid;
string Name;
string Description;
public int CateId
{
set
{
Catid = value;
}
get
{
return Catid;
}
}
}
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();
}
C.Create();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
C.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}
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 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();
}
t.Create();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
t.Update();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
}
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;
}
}
}
namespace ProjectGMS
{
public partial class TransactionDetails : Form
{
public TransactionDetails()
{
InitializeComponent();
}
private void button6_Click(object sender, EventArgs e)
{
}
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);
}
}
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);
}
}
}
}
}
DBConnection:
namespace ProjectGMS
{
class DbConnection
{
}
}
}
User Authentication:
namespace ProjectGMS
{
class User_Authentication
{
private bool _isLoggedIn;
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();
Main Home:
namespace ProjectGMS
{
public partial class MainHome : Form
{
public MainHome()
{
InitializeComponent();
}
if (checkBox1.Checked)
{
textBox2.UseSystemPasswordChar = false;
}
else
{
textBox2.UseSystemPasswordChar = true;
}
}
namespace ProjectGMS
{
public partial class Home : Form
{
public Home()
{
InitializeComponent();
}
Admin Home:
namespace ProjectGMS
{
public partial class AdminHome : Form
{
public AdminHome()
{
InitializeComponent();
}
this.Hide();
}
}
private void button1_Click(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();
}
p1.Create();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}