Food Court Project is developed based on Windows Forms Application in 3 Tier Architecture by Using Visual Studio 2010 and Database SQL Server 2008. Food Court Project is main intension to develop for user friendly desktop application for maintenance of the FoodCourt i.e Bakers, SuperMarkets, Food Junction..... etc. This application is used to maintain the Food and Bevarages along with Sales Details.
This Food Court Project can be handle by two User's
- Administrator User
- Employees (Salesman) User
Administrator User | Modules
Administrator User can handle sub modules like
Add Food Item Type
In Add Food Item Type Forms Administrator can add new Food Item Type which are not available in Food Court.
For Example's : Cake | Fruits | Puff | Pizza | Cool Drinks | Burger | Snacks | Biscuts . . . . etc
Add Food Item Name
In this Forms Administrator add food item name based on Food Item Types
For Example : Cake : Pine Apple Cake | Butter Scotch Cake | Chocolate Cake . . .etc Fruits : Orange | Apple | Banana . . . etc Puff : Veg Puff | Chicken Puff . . . etc
Creating New Employee Account (or) Create New SalesMan Account
Admin can generate empID for new Joining Salesman with New Employee Form in Food Court with this empID Employee can acceess entire Employee Module. Employee can access ViewStock Details
, Sales
, Generating Bill's
, Print Bill's
...
Update Stock Details
Update Stock Detials is used to perform one Update Operation and one Insert Operation on database table's. i.e
- 1.) FoodItems Database Table
- 2.) Stock Data Database Table
- in StockData table Update Stock Details Form Perform Inserting Operation to store new updated stockdata in database table along with ID's (i.e StockID, FoodItemTypeID, FoodItemNameID, Qty, TotalPrice)
Employee
Admin can view Employee Details and Reset Password for Employee's through this form.
To download project with source code, please Click Here
DATABASE : Food Item Type Master
for FoodItemTypeMaster
table i written 2 stored procedure's one is Insert_FoodItemTypeMaster
and another is proc_getFoodItemType
StoredProcedure : Insert Food Item Type Master
this below Stored procedure is used to insert Food Item Type
Table
USE [FoodCourtDB] GO create procedure [dbo].[Insert_FoodItemTypeMaster]( @fitemno varchar(20), @fitemname varchar(30)) as begin Insert into fooditemtypemaster values(@fitemno, @fitemname) end
StoredProcedure : retrieve Food Item Type Master
USE [FoodCourtDB] GO create procedure [dbo].[proc_getFoodItemType] as begin Select * from fooditemtypemaster end
DATABASE : Food Items
StoredProcedure : Insert Food Item Names
USE [FoodCourtDB] GO create procedure [dbo].[proc_InsertFoodItem]( @itemno varchar(10), @itemname varchar(30), @itemqty int, @itemprice money, @fitemtypeno varchar(20)) as begin Insert Into fooditems values(@itemno,@itemname,@itemqty, @itemprice,@fitemtypeno) end
StoredProcedure : Retrieve Food Item Names
In this Stored Procedure we are retrieving FoodItemNames based on "Where Condition" by passing values of FoodItemTypeNo
USE [FoodCourtDB] GO Create procedure [dbo].[proc_getFoodItemNames](@FoodItemType varchar(20)) as begin Select * from fooditems where fitemtypeno=@FoodItemType end
StoredProcedure : Retrieve Qty and Price from FoodItemNames
In this Stored Procedure we are retrieving 2 values Quantity and Price based on "Where Condition" by passing values of FoodItemNo
USE [FoodCourtDB] GO Create procedure [dbo].[proc_getFoodItem_Qty_Price](@itemno varchar(30)) as begin Select fquantity, fprice from fooditems where fitemno=@itemno end
DATABASE : Employee
StoredProcedure : Insert Employee Details
USE [FoodCourtDB] GO Create procedure [dbo].[proc_InsertEmployee]( @eid varchar(10), @ename varchar(50), @password varchar(50), @address varchar(50), @phone varchar(15)) as begin Insert into employee values(@eid, @ename,@password, @address,@phone) end
StoredProcedure : Retrieving Employee Details
USE [FoodCourtDB] GO Create procedure [dbo].[proc_getEmployee] as begin Select empid, empname, empaddress, empphone from employee end
StoredProcedure : Verifying Employee Details
In this Stored Procedure we see how to verify employee at the time of login by passing parameters to VerifyEmployee Stored procedure query.
USE [FoodCourtDB] GO Create procedure [dbo].[proc_VerifyEmployee]( @empid varchar(10), @pwd varchar(50)) as begin Select * from employee where empid=@empid and emppassword=@pwd end
StoredProcedure : Update Employee Details
USE [FoodCourtDB] GO Create procedure [dbo].[proc_UpdateEmployee]( @empid nvarchar(50), @empname nvarchar(50), @empaddress nvarchar(200), @empphone nvarchar(50)) as begin Update employee set empname=@empname, empaddress=@empaddress, empphone=@empphone where empid=@empid end
StoredProcedure : Respet Employee Password
USE [FoodCourtDB] GO Create procedure [dbo].[proc_RestPassword](@empid nvarchar(50)) as begin Update employee set emppwd=@empid where empid=@empid end
DATABASE : StockData and FoodItems
StoredProcedure : Insert Stock Data and Update Fooditem
In this Stored Procedure we have 2 queries one is Inserting Stock Data Table with new values and also at the same time Update query also perform to update "Quantity" in FoodItems Table based on Where Condition by passing through FoodItemNo
USE [FoodCourtDB] GO Create procedure [dbo].[proc_updateStock_and_FoodItems]( @sID varchar(10), @fitemTypeNo varchar(20), @fitemNo varchar(10), @qty int, @price money) as begin Insert into StockData values(@sID,@fitemTypeNo, @fitemNo, @qty, @price) update fooditems set fquantity=@qty where fitemno=@fitemNo end
DATABASE : BillTransaction
StoredProcedure : Insert Bill Transaction and BillMaster
In this stored procedure we are performing 2 Insert operation i.e Inserting Bill Transaction Table and also at the same time another Inserting Operation perform to insert single values to Bill Master i.e BMID.
USE [FoodCourtDB] GO Create procedure [dbo].[proc_BillTransaction]( @bid varchar(10), @bmid varchar(10), @fitemno varchar(10), @qty int, @amount money, @trnno int) as begin if(@trnno=1) Insert into BillMaster(BMID) values(@bmid) Insert into BillTransaction values(@bid,@bmid,@fitemno,@qty,@amount) end
DATABASE : BillMaster
StoredProcedure : Update Bill Master Table
In this Stored Procedure we see how to update Bill Master based on BillMasterID, this stored procedure will call salesman at the time of generating bill to print.
USE [FoodCourtDB] GO Create procedure [dbo].[proc_GenerateBillMaster](@bmid varchar(10), @totalSales int, @totalamount money, @date date, @empid nvarchar(50)) as begin update BillMaster set totalSales=@totalSales, totalamt=@totalamount, date=@date, empid=@empid where BMID=@bmid end
Business Object
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace FoodCourtBusinessObject { public class BusinessObject { // Common Object for Food Court Project public int Quantity { get; set; } public double Price { get; set; } public string Password { get; set; } public int NoOfTransaction { get; set; } public string Date { get; set; } // Food Item Type Object public string FoodItemTypeNo { get; set; } public string FoodItemTypeName { get; set; } // Food Item Object public string FoodItemNo { get; set; } public string FoodItemName { get; set; } // Employee Object public string EmployeeID { get; set; } public string EmployeeName { get; set; } public string EmployeeAddress { get; set; } public string EmployeePhone { get; set; } // Stock Object public string StockID { get; set; } // Bill Transaction and Bill Master Object public string BillMasterID { get; set; } public string BillID { get; set; } public int TotalSales { get; set; } } }
Business Logic
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using FoodCourtBusinessObject; using FoodCourtDatabaseLogic; namespace FoodCourtBusinessLogic { public class BusinessLogic { DataBaseLogic dbLogic = new DataBaseLogic(); #region This Block related to Food_Item_Type_No and Food_Item_Type_Name #region Insert Food Item Type public int AddFoodItemTypeData(BusinessObject ITObject) { return dbLogic.InsertFoodItemType(ITObject); } #endregion #region Display Food Item Type to ComboBox public DataSet GetFoodItemType() { DataSet dstype = new DataSet(); dstype = dbLogic.GetIFoodtemType(); return dstype; } #endregion #endregion #region This Block related to Food Items #region Insert Food Items public int InsertFoodItems(BusinessObject itemsObject) { return dbLogic.InsertFoodItems(itemsObject); } #endregion #region Get Food Items Price public double GetFoodItemPrice(BusinessObject FIPObj) { return dbLogic.GetFooditemPrice(FIPObj); } #endregion #region Display Quantity & Price public DataSet GetQtyPrice(BusinessObject QtyObject) { return dbLogic.DisplayQtyPriceFoodItem(QtyObject); } #endregion #region Display Bill Data to GridView public DataSet BindBillData(BusinessObject BObj) { return dbLogic.DisplayBillDataGridView(BObj); } #endregion #region Bind Food Item Name to ComboBox public DataSet BindFoodItemNames(BusinessObject FINObject) { return dbLogic.GetFoodItemsName(FINObject); } #endregion #endregion #region Create Employee Record public int InsertEmployeeRecord(BusinessObject empObject) { return dbLogic.CreateEmployeeAccount(empObject); } #endregion #region Update Food Item Quantity and Stock Data public int UpdateFoodItem_and_StockData(BusinessObject updateObj) { return dbLogic.UpdateStockData(updateObj); } #endregion #region Verify Employee Login Credentials public DataSet Login(BusinessObject loginObj) { return dbLogic.VerifyLoginCredientials(loginObj); } #endregion #region Get Employee's Data public DataSet getEmployees() { return dbLogic.GetEmployees(); } #endregion #region Update Employee public int UpdateEmployee(BusinessObject empUObj) { return dbLogic.UpdateEmployee(empUObj); } #endregion #region Delete Employee's public int DeleteEmployee(BusinessObject eObject) { return dbLogic.DeleteEmployee(eObject); } #endregion #region Reset Password public int PasswordReset(BusinessObject prObj) { return dbLogic.ResetPassword(prObj); } #endregion #region Inserting Bill Transaction and Master Details public int InsertBillTransaction(BusinessObject BTObject) { return dbLogic.InsertBillTransaction(BTObject); } #endregion #region Update Bill Master public int UpdateBillMaster(BusinessObject BMObj) { return dbLogic.InsertBillMaster(BMObj); } #endregion } }
Database Logic
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Configuration; using System.Data; using System.Data.SqlClient; using FoodCourtBusinessObject; namespace FoodCourtDatabaseLogic { public class DataBaseLogic { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCon"].ToString()); #region This Block Related to All Food_Item_Type_NO and Food_Item_Type_Name #region ADD Food Item Type to Database public int InsertFoodItemType(BusinessObject boObj) { try { con.Open(); SqlCommand cmd = new SqlCommand("Insert_FoodItemTypeMaster", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@fitemno", boObj.FoodItemTypeNo); cmd.Parameters.AddWithValue("@fitemname", boObj.FoodItemTypeName); ; int i = cmd.ExecuteNonQuery(); con.Close(); return i; } catch { throw; } finally { con.Close(); } } #endregion #region Bind Food Item Type to Form public DataSet GetIFoodtemType() { SqlCommand cmd = new SqlCommand("proc_getFoodItemType", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; DataSet ds = new DataSet(); da.Fill(ds); return ds; } #endregion #endregion #region This Block Related to All Food_Item #region ADD Food Items to Database public int InsertFoodItems(BusinessObject boObject) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_InsertFoodItem", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@itemno", boObject.FoodItemNo); cmd.Parameters.AddWithValue("@itemname", boObject.FoodItemName); cmd.Parameters.AddWithValue("@itemqty", boObject.Quantity); cmd.Parameters.AddWithValue("@itemprice", boObject.Price); cmd.Parameters.AddWithValue("@fitemtypeno", boObject.FoodItemTypeNo); int i = cmd.ExecuteNonQuery(); con.Close(); return i; } catch { throw; } finally { con.Close(); } } #endregion #region Bind Food Item Based on Food Item Types public DataSet GetFoodItemsName(BusinessObject Obj) { SqlCommand cmd = new SqlCommand("proc_getFoodItemNames", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@FoodItemType", Obj.FoodItemTypeNo); DataSet ds = new DataSet(); da.Fill(ds); return ds; } #endregion #region Get Price of Food Item public double GetFooditemPrice(BusinessObject boObj) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_getItemPrice", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@itemno", boObj.FoodItemNo); cmd.Parameters.AddWithValue("@itemtypeno", boObj.FoodItemTypeNo); double price = Convert.ToDouble(cmd.ExecuteScalar()); cmd.Clone(); return price; } catch { throw; } finally { con.Close(); } } #endregion #region Display Quantity and Price In Food Item public DataSet DisplayQtyPriceFoodItem(BusinessObject QtyPricObject) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_getFoodItem_Qty_Price", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@itemno", QtyPricObject.FoodItemNo); DataSet ds = new DataSet(); da.Fill(ds); return ds; } catch { throw; } finally { con.Close(); } } #endregion #endregion #region Create Employee Account public int CreateEmployeeAccount(BusinessObject empObj) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_InsertEmployee", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@eid", empObj.EmployeeID); cmd.Parameters.AddWithValue("@ename", empObj.EmployeeName); cmd.Parameters.AddWithValue("@password", empObj.Password); cmd.Parameters.AddWithValue("@address", empObj.EmployeeAddress); cmd.Parameters.AddWithValue("@phone", empObj.EmployeePhone); int i = cmd.ExecuteNonQuery(); return i; } catch { throw; } finally { con.Close(); } } #endregion #region Update Stock and Food Items Quantity public int UpdateStockData(BusinessObject usObject) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_updateStock_and_FoodItems", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@sID", usObject.StockID); cmd.Parameters.AddWithValue("@fitemTypeNo", usObject.FoodItemTypeNo); cmd.Parameters.AddWithValue("@fitemNo", usObject.FoodItemNo); cmd.Parameters.AddWithValue("@qty", usObject.Quantity); cmd.Parameters.AddWithValue("@price", usObject.Price); int i = cmd.ExecuteNonQuery(); return i; } catch { throw; } finally { con.Close(); } } #endregion #region Verify Employee Login public DataSet VerifyLoginCredientials(BusinessObject empObj) { SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCon"].ToString()); try { con1.Open(); string query = "Select * from employee Where empid='" + empObj.EmployeeID + "' and emppwd='" + empObj.Password + "'"; SqlCommand cmd1 = new SqlCommand(query, con1); SqlDataAdapter da = new SqlDataAdapter(cmd1); DataSet ds = new DataSet(); da.Fill(ds); if(ds.Tables[0].Rows.Count>0) { con1.Close(); } return ds; } catch { throw; } finally { con1.Close(); } } #endregion #region Get Employee's Details public DataSet GetEmployees() { SqlCommand cmd = new SqlCommand("proc_getEmployee", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; DataSet ds = new DataSet(); da.Fill(ds); return ds; } #endregion #region Update Employee Details public int UpdateEmployee(BusinessObject updObj) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_UpdateEmployee", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@empid", updObj.EmployeeID); cmd.Parameters.AddWithValue("@empname", updObj.EmployeeName); cmd.Parameters.AddWithValue("@empaddress", updObj.EmployeeAddress); cmd.Parameters.AddWithValue("@empphone", updObj.EmployeePhone); int i = cmd.ExecuteNonQuery(); if (i > 0) { con.Close(); } return i; } catch { throw; } finally { con.Close(); } } #endregion #region Reset Password public int ResetPassword(BusinessObject rpObj) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_RestPassword", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@empid", rpObj.EmployeeID); int i = cmd.ExecuteNonQuery(); return i; } catch { throw; } finally { con.Close(); } } #endregion public int DeleteEmployee(BusinessObject empObj) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_DeleteEmployee", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@empid", empObj.EmployeeID); int i = cmd.ExecuteNonQuery(); if (i > 0) { con.Close(); } return i; } catch { throw; } finally { con.Close(); } } #region Display Bill to DataGridView public DataSet DisplayBillDataGridView(BusinessObject BGridObject) { SqlCommand cmd = new SqlCommand("proc_DisplayBill_DataGrid", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.Parameters.AddWithValue("@bilmasterid", BGridObject.BillMasterID); DataSet ds1 = new DataSet(); da.Fill(ds1); if (ds1.Tables[0].Rows.Count > 0) { con.Close(); } return ds1; } #endregion #region Insert Bill Transaction Data public int InsertBillTransaction(BusinessObject BTnxObject) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_BillTransaction", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@bid", BTnxObject.BillID); cmd.Parameters.AddWithValue("@bmid", BTnxObject.BillMasterID); cmd.Parameters.AddWithValue("@fitemno", BTnxObject.FoodItemNo); cmd.Parameters.AddWithValue("@qty", BTnxObject.Quantity); cmd.Parameters.AddWithValue("@amount", BTnxObject.Price); cmd.Parameters.AddWithValue("@trnno", BTnxObject.NoOfTransaction); int i = cmd.ExecuteNonQuery(); return i; } catch { throw; } finally { con.Close(); } } #endregion #region Generate Bill Master Data public int InsertBillMaster(BusinessObject BMObject) { try { con.Open(); SqlCommand cmd = new SqlCommand("proc_GenerateBillMaster", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@bmid", BMObject.BillMasterID); cmd.Parameters.AddWithValue("@totalSales", BMObject.TotalSales); cmd.Parameters.AddWithValue("@totalamount", BMObject.Price); cmd.Parameters.AddWithValue("@date", BMObject.Date); cmd.Parameters.AddWithValue("@empid", BMObject.EmployeeID); int i = cmd.ExecuteNonQuery(); if (i > 0) { con.Close(); } return i; } catch (Exception ex) { throw ex; } finally { con.Close(); } } #endregion } }
0 Comments