Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

OOP PROJECT

APPLICATION: CHEETAHMART

S.NO NAME ROLL NO: E-MAIL


1 MOHIB UDDIN 107 CS20F-107@SSUET.EDU.PK

2 M. SHAYAN ALI 102 CS20F-102@SSUET.EDU.PK

3 AZIZ UR REHMAN 103 CS20F-103@SSUET.EDU.PK

4 MOHAMMAD SAAD 148 CS20F-148@SSUET.EDU.PK

5 HAMMAD ARAIN 259 CS20F-259@SSUET.EDU.PK


INTRODUCTION:
This project is about an online grocery store. Which could help the vendors who wants
to take their business online. The app works quite like some of the most popular mart
apps like Panda Mart & Hum Mart. The name of the store is CheetahMart which is
purely made on C# Windows Form.

FEATURES:
• Login Form in Which User Has to Login Before Accessing the Main Menu.
Some Preset Accounts Are Added to The Backend in An Array.
• Registration Form Is Also Added in Which Temporary Account Is Created to
Login.
• Tab Control Having Items of Different Categories Beverages, Meats,
Vegetables, Fruits Each Product Has a Add to Cart Feature After Clicking on
It at the Backend the Count of The Product Will Increase.
• Each Products Has Specific Stocks Which Will Decrease the Product
Quantity of the Product at Backend.
• Each Product Has a Specific Price Which Will Increase by Clicking at Add to
Cart. Each time the button is clicked the price will increase.
• Form Has a My Cart Button Which Will Show All the Added Product with
Specific Total Prices of each product and the total bill.
• By Adding a Promo Code “Bachat15” 15% Discount Will Be Provided.
• 5% GST Will Be added to the total bill.
• DataGrid View Is Used for To Show the Items at The Cart After Each
Product’s Add to Cart Click.
• After Clicking on The Order Now Button A Form Prompting “Rider Has Been
Dispatched To Your Location” Will Appear.
App Logo:
METHODOLOGY:
Registration Class:
public class Registration
{
public string username { get; set; }
public string password { get; set; }
}

REGISTRATION-FORM:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2nd_Sem_Project
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
public Registration user;
private void Form3_Load(object sender, EventArgs e)
{

private void Register_Click(object sender, EventArgs e)


{
// If A Field Is Left Empty In The Text Box
if (textBox1.Text == "" || textBox3.Text == "" || textBox3.Text == "" || textBox3.Text == "" ||
textBox4.Text == "")
{
label7.Text = "Error! All Fields Must Be Filled";
}
else
{
user = new Registration();
user.username = textBox1.Text;
user.password = textBox2.Text;
MessageBox.Show(" Your Account Registered Successfully.");
this.Hide();

Form1 Login = new Form1(user);

Login.ShowDialog();
}
}

}
}

IN-APP DEMONSTRATION:
LOGIN-FORM:
User Has To Login To The System Before Buying And Accessing The Products
CODE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2nd_Sem_Project
{
public partial class Form1 : Form
{
string NewUser, NewPassword;
public Form1()
{
InitializeComponent();

}
public Form1(Registration user)
{
InitializeComponent();
NewUser = user.username;
NewPassword = user.password;
}
//Register Now Form

private void Form1_Load(object sender, EventArgs e)


{

}
private void Register_Click(object sender, EventArgs e)
{
this.Hide();
Form3 RegisterNow = new Form3();
RegisterNow.ShowDialog();
}
private void button1_Click_1(object sender, EventArgs e)
{
//Following are the index sensitive password and username password entered should be of same index
as username
// The NewUser And NewPassword Variable Will Have The Registration Form’s Username & Password

string[] username = { "Mohib", "Shayan", "Aziz", "M.Saad", "Arain",NewUser };


string[] Password = { "ILYProgramming", "a", "Kawwal", "NK", "Rabri", NewPassword};

for (int i = 0; i < username.Length; i++)


{
if (textBox1.Text == username[i])
{
if (textBox2.Text == Password[i])
{
//If Username And Password Is Correct Main Menu Will Open
this.Hide();
Form2 MainMenu = new Form2();
MainMenu.ShowDialog();
}
else
{
MessageBox.Show("Incorrect Username Or Password!");
}
}

}
}

}
LOGIN DEMONSTRATION:
PRODUCT CLASS:
CODE:
//A Template Class for All the Products in The System
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2nd_Sem_Project
{
public class Product
{
public string Description { get; set; }
public double BasePrice { get; set; }

public double TotalProductPrice { get; set; }


public int ProductCount { get; set; }
public int ProductStock { get; set; }
public Product(string description,double price,int ProductStock)
{
Description = description;
BasePrice = price;
this.ProductStock = ProductStock;
}
}
}
MAIN MENU:
This Is The Main Form Where All The Categories And The Cart Is Displayed:
CODE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2nd_Sem_Project
{
public partial class Form2 : Form
{
//Array Of Objects For Class Product
public Product[] MyProducts = new Product[30];
public double TotalCartPrice;
public Form2()
{
InitializeComponent();
//Fruit Products
MyProducts[0] = new Product("1 Box Of Cherry", 100,10);
MyProducts[1] = new Product("1 Dozen Bananna", 80,10);
MyProducts[2] = new Product("1Kg Cheeku", 250,10);

//Vegetable Products
MyProducts[3] = new Product("Cucumber", 25,10);
MyProducts[4] = new Product("Tomato", 80,10);
MyProducts[5] = new Product("Brocolli", 40,10);
MyProducts[6] = new Product("Capsicum", 30,10);
MyProducts[7] = new Product("Egg Plant", 35,10);
MyProducts[8] = new Product("Chillis", 20,10);
//Beverages Products
MyProducts[9] = new Product("Pepsi 500ml", 60,10);
MyProducts[10] = new Product("Coca Cola 500ml", 60,10);
MyProducts[11] = new Product("Mirinda 500ml", 60,10);
MyProducts[12] = new Product("7-Up 500ml", 60,10);
MyProducts[13] = new Product("AquaFina 500ml", 35,10);
//Meat Products
MyProducts[14] = new Product("Mutton 1kg", 750,10);
MyProducts[15] = new Product("Beef 1kg", 550,10);
MyProducts[16] = new Product("Chicken 1kg",350,10);
//More Fruit Products
MyProducts[17] = new Product("1Kg Falsa", 250, 10);
MyProducts[18] = new Product("1Kg Mango", 250, 10);
//
MyProducts[19] = new Product("Juice", 30, 20);
MyProducts[20] = new Product("RoohAfza", 70, 20);
MyProducts[21] = new Product("Sting", 60, 20);
MyProducts[22] = new Product("Strawberry", 270, 20);
MyProducts[23] = new Product("1Kg Tuna Fish", 350, 20);
MyProducts[24] = new Product("1Kg Rohu Fish", 550, 20);
MyProducts[25] = new Product("1Kg Trout Fish", 450, 20);
}

private void btnCherries_Click(object sender, EventArgs e)


{
MyProducts[0].ProductCount += 1;
MyProducts[0].TotalProductPrice = MyProducts[0].ProductCount * MyProducts[0].BasePrice;
MyProducts[0].ProductStock -= 1;
if (MyProducts[0].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void Banana_Click(object sender, EventArgs e)
{
MyProducts[1].ProductCount += 1;
MyProducts[1].TotalProductPrice = MyProducts[1].ProductCount * MyProducts[1].BasePrice;
MyProducts[1].ProductStock -= 1;
if (MyProducts[1].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void btnCheeku_Click(object sender, EventArgs e)
{
MyProducts[2].ProductCount += 1;
MyProducts[2].TotalProductPrice = MyProducts[2].ProductCount * MyProducts[2].BasePrice;
MyProducts[2].ProductStock -= 1;
if (MyProducts[2].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void Form2_Load(object sender, EventArgs e)
{
}

//By Entering The Promo Code Sara15 Customer Will Get A 15% Discount In Final Order

private void CucumberBtn_Click(object sender, EventArgs e)


{
MyProducts[3].ProductCount += 1;
MyProducts[3].TotalProductPrice = MyProducts[3].ProductCount * MyProducts[3].BasePrice;
MyProducts[3].ProductStock -= 1;
if (MyProducts[3].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void TomatoBtn_Click(object sender, EventArgs e)
{
MyProducts[4].ProductCount += 1;
MyProducts[4].TotalProductPrice = MyProducts[4].ProductCount * MyProducts[4].BasePrice;
MyProducts[4].ProductStock -= 1;
if (MyProducts[4].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void BroccoliBtn_Click(object sender, EventArgs e)
{
MyProducts[5].ProductCount += 1;
MyProducts[5].TotalProductPrice = MyProducts[5].ProductCount * MyProducts[5].BasePrice;
MyProducts[5].ProductStock -= 1;
if (MyProducts[5].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void CapsicumBtn_Click(object sender, EventArgs e)

{
MyProducts[6].ProductCount += 1;
MyProducts[6].TotalProductPrice = MyProducts[6].ProductCount * MyProducts[6].BasePrice;
MyProducts[6].ProductStock -= 1;
if (MyProducts[6].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void EggPlantBtn_Click(object sender, EventArgs e)
{
MyProducts[7].ProductCount += 1;
MyProducts[7].TotalProductPrice = MyProducts[7].ProductCount * MyProducts[7].BasePrice;
MyProducts[7].ProductStock -= 1;
if (MyProducts[7].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void ChilliBtn_Click(object sender, EventArgs e)
{
MyProducts[8].ProductCount += 1;
MyProducts[8].TotalProductPrice = MyProducts[8].ProductCount * MyProducts[8].BasePrice;
MyProducts[8].ProductStock -= 1;
if (MyProducts[8].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void Pepsibtn_Click(object sender, EventArgs e)
{
MyProducts[9].ProductCount += 1;
MyProducts[9].TotalProductPrice = MyProducts[9].ProductCount * MyProducts[9].BasePrice;
MyProducts[9].ProductStock -= 1;
if (MyProducts[9].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}

}
private void CokeBtn_Click(object sender, EventArgs e)
{
MyProducts[10].ProductCount += 1;
MyProducts[10].TotalProductPrice = MyProducts[10].ProductCount * MyProducts[10].BasePrice;
MyProducts[10].ProductStock -= 1;
if (MyProducts[10].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}

private void MirindaBtn_Click(object sender, EventArgs e)


{
MyProducts[11].ProductCount += 1;
MyProducts[11].TotalProductPrice = MyProducts[11].ProductCount * MyProducts[11].BasePrice;
MyProducts[11].ProductStock -= 1;
if (MyProducts[11].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
//7-UP Product
private void button3_Click(object sender, EventArgs e)
{
MyProducts[12].ProductCount += 1;
MyProducts[12].TotalProductPrice = MyProducts[12].ProductCount * MyProducts[12].BasePrice;
MyProducts[12].ProductStock -= 1;
if (MyProducts[12].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}

}
private void WaterBtn_Click(object sender, EventArgs e)
{
MyProducts[13].ProductCount += 1;
MyProducts[13].TotalProductPrice = MyProducts[13].ProductCount * MyProducts[13].BasePrice;
MyProducts[13].ProductStock -= 1;
if (MyProducts[13].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}

}
private void MuttonBtn_Click(object sender, EventArgs e)
{
MyProducts[14].ProductCount += 1;
MyProducts[14].TotalProductPrice = MyProducts[14].ProductCount * MyProducts[14].BasePrice;
MyProducts[14].ProductStock -= 1;
if (MyProducts[14].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}

}
private void BeefBtn_Click(object sender, EventArgs e)
{
MyProducts[15].ProductCount += 1;
MyProducts[15].TotalProductPrice = MyProducts[15].ProductCount * MyProducts[15].BasePrice;
MyProducts[15].ProductStock -= 1;
if (MyProducts[15].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}

}
private void ChickenBtn_Click(object sender, EventArgs e)
{
MyProducts[16].ProductCount += 1;
MyProducts[16].TotalProductPrice = MyProducts[16].ProductCount * MyProducts[16].BasePrice;
MyProducts[16].ProductStock -= 1;
if (MyProducts[16].ProductStock==0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}

//After Clicking Place Order The Order And Items Will Reset Without Reseting The Stocks
private void buttonfalsa_Click(object sender, EventArgs e)
{

MyProducts[17].ProductCount += 1;
MyProducts[17].TotalProductPrice = MyProducts[17].ProductCount *
MyProducts[17].BasePrice;
MyProducts[17].ProductStock -= 1;
if (MyProducts[17].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}

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

MyProducts[18].ProductCount += 1;
MyProducts[18].TotalProductPrice = MyProducts[18].ProductCount *
MyProducts[18].BasePrice;
MyProducts[18].ProductStock -= 1;
if (MyProducts[18].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
private void Juicebtn_Click(object sender, EventArgs e)
{
MyProducts[19].ProductCount += 1;
MyProducts[19].TotalProductPrice = MyProducts[19].ProductCount * MyProducts[19].BasePrice;
MyProducts[19].ProductStock -= 1;
if (MyProducts[19].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}

private void RoohAfzabtn_Click(object sender, EventArgs e)


{
MyProducts[20].ProductCount += 1;
MyProducts[20].TotalProductPrice = MyProducts[20].ProductCount * MyProducts[20].BasePrice;
MyProducts[20].ProductStock -= 1;
if (MyProducts[20].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}

private void Stingbtn_Click(object sender, EventArgs e)


{
MyProducts[21].ProductCount += 1;
MyProducts[21].TotalProductPrice = MyProducts[21].ProductCount * MyProducts[21].BasePrice;
MyProducts[21].ProductStock -= 1;
if (MyProducts[21].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}

private void Strawberry_Click(object sender, EventArgs e)


{
MyProducts[22].ProductCount += 1;
MyProducts[22].TotalProductPrice = MyProducts[22].ProductCount * MyProducts[22].BasePrice;
MyProducts[22].ProductStock -= 1;
if (MyProducts[22].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}

private void Fish1_Click(object sender, EventArgs e)


{
MyProducts[23].ProductCount += 1;
MyProducts[23].TotalProductPrice = MyProducts[23].ProductCount * MyProducts[23].BasePrice;
MyProducts[23].ProductStock -= 1;
if (MyProducts[23].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}

private void Fish2_Click(object sender, EventArgs e)


{
MyProducts[24].ProductCount += 1;
MyProducts[24].TotalProductPrice = MyProducts[24].ProductCount * MyProducts[24].BasePrice;
MyProducts[24].ProductStock -= 1;
if (MyProducts[24].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}

private void Fish3_Click(object sender, EventArgs e)


{
MyProducts[25].ProductCount += 1;
MyProducts[25].TotalProductPrice = MyProducts[25].ProductCount * MyProducts[25].BasePrice;
MyProducts[25].ProductStock -= 1;
if (MyProducts[25].ProductStock == 0)
{
MessageBox.Show("Sorry! The Product Is Out Of Stock Now:");
}
}
// If You Click View Your Order The My Cart Tab Will Open
private void OrderCart_Click(object sender, EventArgs e)
{
tabControl1.SelectTab(tabPage3);
}
//If Customer Enters A Promo Of Sara15 He Will Get 15 Percent Off
private void btnPromoCode_Click(object sender, EventArgs e)
{
double discount = 0;
string promo = "Bachat15";
if (discount==0&&PromoBox.Text == promo)
{
discount = (TotalCartPrice * 0.15);
}
else
{
discount = 0;
}
TotalCartPrice -= discount;
PromoLabel.Text = ("Discount: " + discount.ToString());
label24.Text = (TotalCartPrice.ToString()+" Rs. ");
}
// After Placing The Order The System Will Reset (Not The Stock)
private void placeorder_Click(object sender, EventArgs e)
{
if (Addressbox.Text == "" || ContactBox.Text == "")
{
checkouterror.Text = "Address Box & Contact Box Must Be Filled!";
}
else
{
//After Clicking On The Button A New Delivery Form Will Be Created
this.Hide();
Form4 Delivery = new Form4();
Delivery.ShowDialog();

dataGridView1.Rows.Clear();
for (int i = 0; i < 26; i++)
{
MyProducts[i].ProductCount = 0;
}
label24.Text = " ";
label22.Text = "GST (5%): ";
//tabControl1.SelectTab(tabPage1);
//this.Hide();
PromoLabel.Text = "Discount: ";
}

}
//When We Will Click On My Cart Tab Following Workings Takes Place
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabPage3)
{
//DataGrid Will Reset Each Time The Tab Is Selected
dataGridView1.Rows.Clear();
TotalCartPrice = 0;
for (int i = 0; i < 26; i++)
{
if (MyProducts[i].ProductCount > 0)
{
//Loop If The Quantity Ordered Is More Than Available Stock
while (MyProducts[i].ProductStock < 0)
{
MyProducts[i].ProductCount--;
MyProducts[i].ProductStock++;
MyProducts[i].TotalProductPrice -= MyProducts[i].BasePrice;
}
if (MyProducts[i].ProductStock >= 0)
{
//New Rows Are Created For Data Grid View Coloumns For Each Added To Cart Product
string[] row = new string[] { MyProducts[i].ProductCount.ToString(),
MyProducts[i].Description, MyProducts[i].TotalProductPrice.ToString() };
dataGridView1.Rows.Add(row);
TotalCartPrice += MyProducts[i].TotalProductPrice;
}
}

}
//5 Percent GST On The Total Bill
double GST = TotalCartPrice * 0.05;
label22.Text = "GST (5%): " + GST.ToString()+" Rs. ";
TotalCartPrice += GST;
label24.Text = (TotalCartPrice.ToString()+" Rs. ");
//Add Random Order No For Every Order
Random InvoiceNo = new Random();
int orderno = InvoiceNo.Next(1,1000);
label23.Text = "Order #: " + orderno;

}
}

}
}

MAIN MENU DEMONSTRATION:


If The Product Stock Is Finished:
MY CART:
Applying The Promo Bachat15:
After The Order Is Completed:

You might also like