Professional Documents
Culture Documents
Project Report
Project Report
Sincerely thanks!
P a g e 1 | 46
University of Technology and Education
For the completion of this project, I would like to express my sincere thanks to:
The Board of Directors of Ho Chi Minh City University of Technology and
Education for creating favorable conditions in terms of facilities with a modern
library system with a variety of books and documents that are convenient for
searching and researching. information.
We would like to thank Assoc. Prof. Hoang Van Dung, who has been dedicated to
guiding and teaching during the project implementation. We have completed on
time and accumulated valuable knowledge base for ourselves. Despite trying to
complete the best project, due to the limited time and knowledge, we could not
avoid certain shortcomings. We are looking forward to receiving your sympathy
and dedicated contribution.
Index
FOREWORD ......................................................................................4
Part 1: Introduction (project description) .......................................4
P a g e 2 | 46
University of Technology and Education
FOREWORD
P a g e 3 | 46
University of Technology and Education
Today, with the strong development of science and technology, especially the
rapid development of information technology, information technology is
increasingly coming into life and being exploited by people in a very effective
way, making it a useful labor tool and playing a very important role in social life,
labor tools and information system design analysis is an important part of the field
of information technology, it helps people to manage databases more simply, easily
and quickly, saving a lot of time and manpower. We implemented the topic "cafe
management" to improve our knowledge and understanding of this field. The field
of information technology in general and the subject of system design and
management in particular.
PART 1: INTRODUCTION
1. Problem and the purpose
Coffee shops have a special reputation with increasing number of visitors, to serve customers
better, more accurately and quickly, the owner is gradually computerizing the management
stages. Especially in accounting and management of goods and beverages. Because with the
previous work, the store has revealed many limitations as follows :
P a g e 4 | 46
University of Technology and Education
Look up information about goods, customers take a long time and sometimes inaccurate
Store information on goods import and export, revenue and expenditure needs many
types of documents so it is cumbersome and inefficient
Daily updates take time and difficulty in reporting and statistics, especially when there
are unexpected tasks.
In the face of that situation, the problem is to build a new information system that makes
it easier to manage the coffee shop.
2. Research objectives
Reduce the volume of information recorded to store information
Update data quickly, accurately and in a timely manner
Statistics on the quantity of goods exported, income and expenditure
and the revenue situation of the store
Automatically print necessary invoices such as …………..
Capable of long-term information storage, ensuring fast queries when
needed
Applied Technique
ADO.NET Entity Framework
Entity Data Model
Abstraction over a relational database
Consists of conceptual & logical models
Provides mapping layer between conceptual model and logical model
Entity Client
Provides classes similar to ADO.NET providers
Can return results as DbDataReaders
Object Services
Enables you to work with object instances
Provides persistence and change tracking
P a g e 5 | 46
University of Technology and Education
No. Table code
3. Research methodology
P a g e 6 | 46
University of Technology and Education
d) Desk area management: store information of all desk areas, manage tables
by area
2. Architecture
- ADO.NET
- LINQ
- ENITY
P a g e 7 | 46
University of Technology and Education
- MICROSOFT REPORT
PART 3: DESIGNS
1. Diagram
2. Login form
P a g e 8 | 46
University of Technology and Education
int count = 0;
private void btLogin_Click(object sender, EventArgs e)
{
if (txtMName.Text == "ThuyDiem" && txtPass.Text == "20TM11014")
{
MessageBox.Show("Login successfully!");
this.Hide();
Manager manager = new Manager();
manager.Show();
}
else
{
count++;
txtMName.ResetText();
txtPass.ResetText();
MessageBox.Show("Failed login!");
this.txtMName.Focus();
if (count == 3)
{
this.Close();
}
}
}
3. Store form
P a g e 9 | 46
University of Technology and Education
a. Form
dtGridView.DataSource = dt;
}
private void ResetAllTextBox()
{
txtSID.ResetText();
txtSName.ResetText();
txtPhone.ResetText();
txtEmail.ResetText();
txtStreet.ResetText();
txtDID.ResetText();
txtFind.ResetText();
}
private void LoadData()
{
MySetProvince();
MySetDistrict();
ResetAllTextBox();
}
txtEmail.Text =
dtGridView.Rows[r].Cells[3].Value.ToString();
txtStreet.Text =
dtGridView.Rows[r].Cells[4].Value.ToString();
txtDID.Text =
dtGridView.Rows[r].Cells[5].Value.ToString();
}
string tempSID =
dtGridView.Rows[r].Cells[0].Value.ToString();
store SQuery = db.stores.Single(x => x.store_id ==
tempSID);
if (SQuery != null)
{
district DTQuery = db.districts.Single(x =>
x.district_id == txtDID.Text);
db.SaveChanges();
store S = new store();
S.store_id = txtSID.Text;
S.store_name = txtSName.Text;
P a g e 14 | 46
University of Technology and Education
S.phone = txtPhone.Text;
S.email = txtEmail.Text;
S.street = txtStreet.Text;
S.district_id = txtDID.Text;
db.stores.Add(S);
db.SaveChanges();
}
catch
{
MessageBox.Show("Store ID has already
existed!", "Error!");
}
}
}
MySetStore();
}
P a g e 15 | 46
University of Technology and Education
4. Staff form
a. Form
}
CoffeeManagementEntities db = null;
private void MySetStore()
{
db = new CoffeeManagementEntities();
var StoreQ = from StoreL in db.stores select
StoreL.store_name;
foreach (string SName in StoreQ)
{
cbSName.Items.Add(SName);
}
cbSName.SelectedIndex = 0;
}
private void MySetStaff()
{
var Staff = from StaffList in db.staffs
join StoreL in db.stores on StaffList.store_id
equals StoreL.store_id
where (StoreL.store_name == cbSName.Text)
select StaffList;
DataTable dt = new DataTable();
dt.Columns.Add("staff_id");
dt.Columns.Add("first_name");
dt.Columns.Add("last_name");
dt.Columns.Add("phone");
dt.Columns.Add("email");
dt.Columns.Add("active");
dt.Columns.Add("store_id");
dt.Columns.Add("manager_id");
foreach (var p in Staff)
{
dt.Rows.Add(p.staff_id, p.first_name, p.last_name,
p.phone, p.email, p.active, p.store_id, p.manager_id);
}
dtGridView.DataSource = dt;
}
private void FindStaffByName()
{
var Find = from StaffList in db.staffs
where
StaffList.first_name.Contains(txtFind.Text)
|| StaffList.last_name.Contains(txtFind.Text)
select StaffList;
dt.Columns.Add("first_name");
dt.Columns.Add("last_name");
dt.Columns.Add("phone");
dt.Columns.Add("email");
dt.Columns.Add("active");
dt.Columns.Add("store_id");
dt.Columns.Add("manager_id");
foreach (var p in Find)
{
dt.Rows.Add(p.staff_id, p.first_name, p.last_name,
p.phone, p.email, p.active, p.store_id, p.manager_id);
}
dtGridView.DataSource = dt;
}
private void ResetAllTextBox()
{
txtSfID.ResetText();
txtFName.ResetText();
txtLName.ResetText();
txtPhone.ResetText();
txtEmail.ResetText();
txtActive.ResetText();
txtSID.ResetText();
txtMID.ResetText();
txtFind.ResetText();
}
private void LoadData()
{
MySetStore();
ResetAllTextBox();
}
int r = dtGridView.CurrentCell.RowIndex;
txtSfID.Text =
dtGridView.Rows[r].Cells[0].Value.ToString();
txtFName.Text =
dtGridView.Rows[r].Cells[1].Value.ToString();
txtLName.Text =
dtGridView.Rows[r].Cells[2].Value.ToString();
txtPhone.Text =
dtGridView.Rows[r].Cells[3].Value.ToString();
txtEmail.Text =
dtGridView.Rows[r].Cells[4].Value.ToString();
txtActive.Text =
dtGridView.Rows[r].Cells[5].Value.ToString();
txtSID.Text =
dtGridView.Rows[r].Cells[6].Value.ToString();
txtMID.Text =
dtGridView.Rows[r].Cells[7].Value.ToString();
}
{
MessageBox.Show("Store id " +
"doest not exist in Store table!" + " Please
update store id first",
"Error!");
}
MySetStaff();
}
}
{
MessageBox.Show("Store id " +
"doest not exist in Store table!",
"Error!");
return;
}
try
{
db.staffs.Remove(SQuery);
db.SaveChanges();
staff S = new staff();
S.staff_id = txtSfID.Text;
S.first_name = txtFName.Text;
S.last_name = txtLName.Text;
S.phone = txtPhone.Text;
S.email = txtEmail.Text;
S.active = txtActive.Text;
S.store_id = txtSID.Text;
S.manager_id = txtMID.Text;
db.staffs.Add(S);
db.SaveChanges();
}
catch
{
MessageBox.Show("Staff ID has already
existed!", "Error!");
}
}
}
MySetStaff();
}
{
LoadData();
}
5. Category form
P a g e 22 | 46
University of Technology and Education
try
{
conn = new SqlConnection(connstr);
adCategory = new SqlDataAdapter("SELECT * FROM
categories", conn);
dtCategory = new DataTable();
adCategory.Fill(dtCategory);
dtGridView.DataSource = dtCategory;
}
catch (SqlException)
{
P a g e 23 | 46
University of Technology and Education
}
}
void FindByNameCategory()
{
try
{
conn = new SqlConnection(connstr);
adCategory = new SqlDataAdapter("SELECT * FROM
categories WHERE category_name LIKE '%" + txtFind.Text + "%'", conn);
dtCategory = new DataTable();
adCategory.Fill(dtCategory);
dtGridView.DataSource = dtCategory;
}
catch (SqlException)
{
MessageBox.Show("Cannot connect to Categories table",
"Error!");
}
}
void CheckCategoryIDExit()
{
// Mở kết nối
if (conn.State == ConnectionState.Open)
conn.Close();
conn.Open();
SqlCommand cmd = new SqlCommand();
try
{
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
txtCID.Text.Trim() + "'";
int nCount;
nCount = Int32.Parse(cmd.ExecuteScalar().ToString());
if (nCount > 0)
{
P a g e 24 | 46
University of Technology and Education
MessageBox.Show("CategoryID (" +
txtCID.Text.Trim() + ") have already existed. " +
"Please enter again!");
txtCID.ResetText();
txtCID.Focus();
}
else
{
txtCName.Focus();
}
}
catch (SqlException)
{
MessageBox.Show("Error!");
}
finally
{
conn.Close();
}
}
cmd.CommandType = CommandType.Text;
P a g e 25 | 46
University of Technology and Education
cmd.ExecuteNonQuery();
LoadData();
MessageBox.Show("Add successully!");
}
catch (SqlException)
MessageBox.Show(cmd.CommandText);
}
conn.Close();
}
cmd.CommandType = CommandType.Text;
int r = dtGridView.CurrentCell.RowIndex;
string strCID =
dtGridView.Rows[r].Cells[0].Value.ToString();
cmd.ExecuteNonQuery();
LoadData();
// Thông báo
MessageBox.Show("Edit successfully!");
}
catch (SqlException)
P a g e 26 | 46
University of Technology and Education
if (CheckYN == DialogResult.Yes)
{
if (conn.State == ConnectionState.Open)
conn.Close();
conn.Open();
try
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
int r = dtGridView.CurrentCell.RowIndex;
string CID =
dtGridView.Rows[r].Cells[0].Value.ToString();
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
LoadData();
}
catch (SqlException)
{
MessageBox.Show("Cannot delete Category ID.",
"Error!");
}
P a g e 27 | 46
University of Technology and Education
finally
{
conn.Close();
}
}
}
txtCID.Text =
dtGridView.Rows[r].Cells[0].Value.ToString();
txtCName.Text =
dtGridView.Rows[r].Cells[1].Value.ToString();
}
P a g e 28 | 46
University of Technology and Education
6. Food form
a. Form
CoffeeManagementEntities db = null;
private void MySetCategory()
{
db = new CoffeeManagementEntities();
var CQ = from CL in db.categories select CL.category_name;
foreach (string CName in CQ)
{
cbCName.Items.Add(CName);
}
cbCName.SelectedIndex = 0;
}
private void MySetFood()
{
var Food = from FoodList in db.foods
join CL in db.categories on
FoodList.category_id equals CL.category_id
where (CL.category_name == cbCName.Text)
select FoodList;
DataTable dt = new DataTable();
dt.Columns.Add("food_id");
dt.Columns.Add("food_name");
P a g e 29 | 46
University of Technology and Education
dt.Columns.Add("food_price");
dt.Columns.Add("category_id");
foreach (var p in Food)
{
dt.Rows.Add(p.food_id, p.food_name, p.food_price,
p.category_id);
}
dtGridView.DataSource = dt;
}
private void FindFoodByName()
{
var Find = from FoodList in db.foods
where FoodList.food_name.Contains(txtFind.Text)
select FoodList;
int r = dtGridView.CurrentCell.RowIndex;
string tempFID =
dtGridView.Rows[r].Cells[0].Value.ToString();
food Food = db.foods.Single(x => x.food_id == tempFID);
db.foods.Remove(Food);
db.SaveChanges();
MySetFood();
}
try
{
db.foods.Remove(FQuery);
db.SaveChanges();
food F = new food();
F.food_id = txtFID.Text;
F.food_name = txtFName.Text;
F.food_price = decimal.Parse(txtPrice.Text);
F.category_id = txtCID.Text;
db.foods.Add(F);
db.SaveChanges();
}
catch
{
MessageBox.Show("Food ID has already
existed!", "Error!");
}
}
}
MySetFood();
}
{
MessageBox.Show("Category id " +
"doest not exist in Category table!" + "
Please update category id first",
"Error!");
}
MySetFood();
}
}
P a g e 33 | 46
University of Technology and Education
b. Report
7. Manager form
P a g e 34 | 46
University of Technology and Education
P a g e 35 | 46
University of Technology and Education
AddForm(food);
}
8. Order form
P a g e 36 | 46
University of Technology and Education
CoffeeManagementEntities db = null;
private void MySetCategory()
{
db = new CoffeeManagementEntities();
var CQ = from CL in db.categories select CL.category_name;
foreach (string CName in CQ)
{
cbCName.Items.Add(CName);
}
cbCName.SelectedIndex = 0;
}
private void MySetFood()
{
P a g e 37 | 46
University of Technology and Education
{
var OrderFood = from OFList in db.order_foods
join OL in db.orders on OFList.order_id equals
OL.order_id
where (OL.order_id == txtOID.Text)
select OFList;
DataTable dt = new DataTable();
dt.Columns.Add("order_id");
dt.Columns.Add("food_id");
dt.Columns.Add("food_quantity");
dt.Columns.Add("total_price");
foreach (var p in OrderFood)
{
dt.Rows.Add(p.order_id, p.food_id, p.food_quantity,
p.total_price);
}
dtGridView.DataSource = dt;
}
private void MySetStore()
{
db = new CoffeeManagementEntities();
var StoreQ = from StoreL in db.stores select StoreL.store_name;
foreach (string StoreName in StoreQ)
{
cbStoreName.Items.Add(StoreName);
}
cbStoreName.SelectedIndex = 0;
}
private void MySetStaff()
{
}
cbStaffName.SelectedIndex = 0;
}
private void Reset()
{
numQuan.ResetText();
txtTotal.Text = "0";
txtOID.ResetText();
txtTableID.ResetText();
}
private void SetButtonOff()
{
groupBox1.Enabled = false;
btDelete.Enabled = false;
btSave.Enabled = false;
}
private void SetButtonOn()
{
groupBox1.Enabled = true;
btDelete.Enabled = true;
btSave.Enabled = true;
}
private void linkLabel1_LinkClicked(object sender,
LinkLabelLinkClickedEventArgs e)
{
FormLogin lg = new FormLogin();
lg.Show();
this.Hide();
}
P a g e 39 | 46
University of Technology and Education
MySetStaff();
}
{
SetButtonOn();
pay = 1;
}
}
if (pay == 1)
{
if (bt.BackColor == Color.Red)
{
foreach (var id in Order)
{
txtOID.Text = id.order_id.ToString();
txtSID.Text = id.store_id.ToString();
txtSfID.Text = id.staff_id.ToString();
txtTotal.Text = id.total_price.ToString();
}
MySetOrderFood();
MySetOrderFood();
SetButtonOff();
}
else
{
Reset();
MySetOrderFood();
SetButtonOff();
}
}
else
{
MessageBox.Show("This table has no customer!", "Payment");
pay = 0;
txtTableID.ResetText();
MySetOrderFood();
SetButtonOff();
}
}
if (bt.BackColor == Color.Red)
{
MessageBox.Show("This table has already had customer!",
"Table");
}
}
PART 4: CONCLUDES
This is a relatively complex and broad topic, although our group has tried to build
a program system capable of managing a coffee shop. During the implementation
of the project, it has brought us a lot of useful knowledge, fixed the lost holes, as
well as found many good resources. Knowing how to design and run an interface
that we have never tried and thought we can do before is quite an interesting
experience and a stepping stone for us to continue to develop deeper and broader
research if we have the opportunity.
P a g e 46 | 46