0% found this document useful (0 votes)
24 views14 pages

Nhóm 10 Quách Văn Hùng

The document describes a hotel management software system with forms for login, dashboard, adding rooms, customer reservation, check out, and employees. It includes code for connecting interfaces, loading and clearing fields, and inserting/updating database records.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views14 pages

Nhóm 10 Quách Văn Hùng

The document describes a hotel management software system with forms for login, dashboard, adding rooms, customer reservation, check out, and employees. It includes code for connecting interfaces, loading and clearing fields, and inserting/updating database records.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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 ChuongTrinhQuanLyKhachSan
{
public partial class Form1 : Form
{
function fn = new function();
String query;
public Form1()
{
InitializeComponent();
}

private void btnExit_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void btnLogin_Click(object sender, EventArgs e)


{
query = "select username, pass from employee where username = '" +
txtUsername.Text + "' and pass = '" + txtPassword.Text + "' ";
DataSet ds = fn.GetData(query);

if (ds.Tables[0].Rows.Count != 0)
{
labelError.Visible = false;
Dashbroad dash = new Dashbroad();
this.Hide();
dash.Show();
}
else
{
labelError.Visible = true;
txtPassword.Clear();
}
}
}
}

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 ChuongTrinhQuanLyKhachSan
{
public partial class Dashbroad : Form
{
public Dashbroad()
{
InitializeComponent();
}

private void btnExit_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void Dashbroad_Load(object sender, EventArgs e)


{
uC_AddRoom1.Visible = false;
uC_CustomerRes1.Visible = false;
uC_CheckOut1.Visible = false;
uC_CustomerDetails1.Visible = false;
uC_Employee1.Visible = false;
btnAddRoom.PerformClick();
}
private void btnAddRoom_Click(object sender, EventArgs e)
{
PanelMoving.Left = btnAddRoom.Left + 50;
uC_AddRoom1.Visible = true;
uC_AddRoom1.BringToFront();
}

private void btnCustomerRes_Click(object sender, EventArgs e)


{
PanelMoving.Left = btnCustomerRes.Left + 60;
uC_CustomerRes1.Visible = true;
uC_CustomerRes1.BringToFront();
}

private void btnCheckOut_Click(object sender, EventArgs e)


{
PanelMoving.Left = btnCheckOut.Left + 60;
uC_CheckOut1.Visible = true;
uC_CheckOut1.BringToFront();
}

private void btnCustomesDetail_Click(object sender, EventArgs e)


{
PanelMoving.Left = btnCustomesDetail.Left + 60;
uC_CustomerDetails1.Visible = true;
uC_CustomerDetails1.BringToFront();
}

private void btnEmployee_Click(object sender, EventArgs e)


{
PanelMoving.Left = btnEmployee.Left + 60;
uC_Employee1.Visible = true;
uC_Employee1.BringToFront();
}
}
}
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 ChuongTrinhQuanLyKhachSan.All_User_Control
{
public partial class UC_AddRoom : UserControl
{
function fn = new function();
String query;
public UC_AddRoom()
{
InitializeComponent();
}

private void UC_AddRoom_Load(object sender, EventArgs e)


{
query = "select * from rooms";
DataSet ds = fn.GetData(query);
DataGridView1.DataSource = ds.Tables[0];
}

private void btnAddRoom_Click(object sender, EventArgs e)


{
if (txtRoomNo.Text != "" && txtRoomNo.Text != "" && txtBed.Text != "" &&
txtPrice.Text != "")
{
String roomno = txtRoomNo.Text;
String type = txtRoomType.Text;
String bed = txtBed.Text;
Int64 price = Int64.Parse(txtPrice.Text);

query = "insert into rooms (roomNo, roomType, bed, price) values


('"+ roomno +"', '"+ type +"', '"+ bed +"', '"+ price +"')";
fn.setData(query, " Đã Thêm Phòng");

UC_AddRoom_Load(this, null);
clearAll();
}
else
{
MessageBox.Show("Xin vui lòng điền đầy đủ thông tin", "warning !",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}

public void clearAll()


{
txtRoomNo.Clear();
txtRoomType.SelectedIndex = -1;
txtBed.SelectedIndex = -1;
txtPrice.Clear();
}

private void UC_AddRoom_Leave(object sender, EventArgs e)


{
clearAll();
}

private void UC_AddRoom_Enter(object sender, EventArgs e)


{
UC_AddRoom_Load(this, null);
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ChuongTrinhQuanLyKhachSan.All_User_Control
{
public partial class UC_CustomerRes : UserControl
{
function fn = new function();
String query;
public UC_CustomerRes()
{
InitializeComponent();
}

public void setComboBox(String query, ComboBox combo)


{
SqlDataReader sdr = fn.getForCombo(query);
while (sdr.Read())
{
for (int i = 0; i < sdr.FieldCount; i++)
{
combo.Items.Add(sdr.GetString(i));
}
}
sdr.Close();
}

private void guna2TextBox1_TextChanged(object sender, EventArgs e)


{

private void UC_CustomerRes_Load(object sender, EventArgs e)


{

private void txtBed_SelectedIndexChanged(object sender, EventArgs e)


{
txtRoom.SelectedIndex = -1;
txtRoomNo.Items.Clear();
txtPrice.Clear();
}

private void txtRoom_SelectedIndexChanged(object sender, EventArgs e)


{
txtRoomNo.Items.Clear();
query = "select roomNo from rooms where bed = '" + txtBed.Text + "' and
roomType = '" + txtRoom.Text + "' and booked = 'NO'";
setComboBox(query, txtRoomNo);
}

int rid;
private void txtRoomNo_SelectedIndexChanged(object sender, EventArgs e)
{
query = "select price, roomid from rooms where roomNo = '" +
txtRoomNo.Text + "'";
DataSet ds = fn.GetData(query);
txtPrice.Text = ds.Tables[0].Rows[0][0].ToString();
rid = int.Parse(ds.Tables[0].Rows[0][1].ToString());
}

private void btnAllotCustomer_Click(object sender, EventArgs e)


{
if (txtName.Text != "" && txtContact.Text != "" && txtNationnality.Text
!= "" && txtGender.Text != "" && txtDob.Text != "" && txtIDProof.Text != "" &&
txtAddress.Text != "" && txtCheckin.Text != "" && txtPrice.Text != "")
{
String name = txtName.Text;
Int64 mobile = Int64.Parse(txtContact.Text);
String national = txtNationnality.Text;
String gender = txtGender.Text;
String dob = txtDob.Text;
String idproof = txtIDProof.Text;
String address = txtAddress.Text;
String checkin = txtCheckin.Text;

query = "insert into customer (cname, mobile, nationality, gender,


dob, idproof, address, checkin, roomid) values ('" + name + "', '" + mobile + "', '"
+ national + "', '" + gender + "','"+ dob +"', '" + idproof + "', '" + address + "',
'" + checkin + "', '" + rid + "') update rooms set booked = 'YES' where roomNo = '"
+ txtRoomNo.Text + "'";
fn.setData(query, "Số Phòng " + txtRoomNo.Text + "Đăng ký khách hàng
thành công.");
ClearAll();
}
else
{
MessageBox.Show("Xin vui lòng nhập đầy đủ thông tin.", "Thông Tin",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
public void ClearAll()
{
txtName.Clear();
txtContact.Clear();
txtNationnality.Clear();
txtGender.SelectedIndex = -1;
txtDob.ResetText();
txtIDProof.Clear();
txtAddress.Clear();
txtCheckin.ResetText();
txtBed.SelectedIndex = -1;
txtRoom.SelectedIndex = -1;
txtRoomNo.Items.Clear();
txtPrice.Clear();
}

private void UC_CustomerRes_Leave(object sender, EventArgs e)


{
ClearAll();
}
}
}

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 ChuongTrinhQuanLyKhachSan.All_User_Control
{
public partial class UC_CheckOut : UserControl
{
function fn = new function();
String query;
public UC_CheckOut()
{
InitializeComponent();
}

private void label2_Click(object sender, EventArgs e)


{

private void UC_CheckOut_Load(object sender, EventArgs e)


{
query = "select customer.cid, customer.cname, customer.mobile,
customer.nationality, customer.gender, customer.dob, customer.idproof,
customer.address, customer.checkin, rooms.roomNo, rooms.roomType, rooms.bed,
rooms.price from customer inner join rooms on customer.roomid = rooms.roomid where
chekout = 'NO'";
DataSet ds = fn.GetData(query);
guna2DataGridView1.DataSource = ds.Tables[0];
}

private void txtName_TextChanged(object sender, EventArgs e)


{
query = "select customer.cid, customer.cname, customer.mobile,
customer.nationality, customer.gender, customer.dob, customer.idproof,
customer.address, customer.checkin, rooms.roomNo, rooms.roomType, rooms.bed,
rooms.price from customer inner join rooms on customer.roomid = rooms.roomid where
cname like '"+ txtName.Text +"%' and chekout = 'NO'";
DataSet ds = fn.GetData(query);
guna2DataGridView1.DataSource = ds.Tables[0];

int id;
private void guna2DataGridView1_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
if (guna2DataGridView1.Rows[e.RowIndex].Cells[e.RowIndex].Value != null)
{
id =
int.Parse(guna2DataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
txtCName.Text =
guna2DataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
txtRoom.Text =
guna2DataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
}
}

private void btnCheckOut_Click(object sender, EventArgs e)


{
if(txtCName.Text != "")
{
if(MessageBox.Show("Bạn có chắc chắn không?", "Xác Nhận",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
String cdate = txtCheckOutDate.Text;
query = "update customer set chekout = 'YES', checkout = '" +
cdate + "' where cid = "+ id +" update rooms set booked = 'NO' where roomNO = '"+
txtRoom.Text +"'";
fn.setData(query, "Thanh Toán Thành Công.");
UC_CheckOut_Load(this, null);
clearAll();
}
}
else
{
MessageBox.Show("Không có khách hàng để lựa chọn.", "Thông Tin",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

public void clearAll()


{
txtCName.Clear();
txtName.Clear();
txtRoom.Clear();
txtCheckOutDate.ResetText();
}

private void UC_CheckOut_Leave(object sender, EventArgs e)


{
clearAll();
}
}
}
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 ChuongTrinhQuanLyKhachSan.All_User_Control
{
public partial class UC_CustomerDetails : UserControl
{
function fn = new function();
String query;
public UC_CustomerDetails()
{
InitializeComponent();
}

private void label2_Click(object sender, EventArgs e)


{

private void txtSearchBy_SelectedIndexChanged(object sender, EventArgs e)


{
if(txtSearchBy.SelectedIndex == 0)
{
query = "select customer.cid, customer.cname, customer.mobile,
customer.nationality, customer.gender, customer.dob, customer.idproof,
customer.address, customer.checkin, rooms.roomNo, rooms.roomType, rooms.bed,
rooms.price from customer inner join rooms on customer.roomid = rooms.roomid";
getRecord(query);
}
else if (txtSearchBy.SelectedIndex == 1)
{
query = "select customer.cid, customer.cname, customer.mobile,
customer.nationality, customer.gender, customer.dob, customer.idproof,
customer.address, customer.checkin, rooms.roomNo, rooms.roomType, rooms.bed,
rooms.price from customer inner join rooms on customer.roomid = rooms.roomid where
checkout is null";
getRecord(query);
}
else if (txtSearchBy.SelectedIndex == 2)
{
query = "select customer.cid, customer.cname, customer.mobile,
customer.nationality, customer.gender, customer.dob, customer.idproof,
customer.address, customer.checkin, rooms.roomNo, rooms.roomType, rooms.bed,
rooms.price from customer inner join rooms on customer.roomid = rooms.roomid where
checkout is not null";
getRecord(query);
}
}

private void getRecord(String query)


{
DataSet ds = fn.GetData(query);
guna2DataGridView1.DataSource = ds.Tables[0];
}
}
}

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 ChuongTrinhQuanLyKhachSan.All_User_Control
{
public partial class UC_Employee : UserControl
{
function fn = new function();
String query;
public UC_Employee()
{
InitializeComponent();
}

private void UC_Employee_Load(object sender, EventArgs e)


{
getMaxID();
}

//=================
public void getMaxID()
{
query = "select max(eid) from employee";
DataSet ds = fn.GetData(query);

if (ds.Tables[0].Rows[0][0].ToString() != "")
{
Int64 num = Int64.Parse(ds.Tables[0].Rows[0][0].ToString());
labelToSET.Text = (num +1).ToString();
}
}

private void btnRegistaion_Click(object sender, EventArgs e)


{
if (txtName.Text != "" && txtMobile.Text != "" && txtGender.Text != ""
&& txtEmail.Text != "" && txtUsername.Text != "" && txtPassword.Text != "")
{
String name = txtName.Text;
Int64 mobile = Int64.Parse(txtMobile.Text);
String gender = txtGender.Text;
String email = txtEmail.Text;
String username = txtUsername.Text;
String pass = txtPassword.Text;

query = "insert into employee (ename, mobile, gender, emailid,


username, pass) values ('" + name + "', '" + mobile + "', '" + gender + "', '" +
email + "', '" + username + "', '" + pass + "')";
fn.setData(query, "Đăng Ký Nhân Viên Thành Công.");

clearAll();
getMaxID();
}
}

public void clearAll()


{
txtName.Clear();
txtMobile.Clear();
txtGender.SelectedIndex = -1;
txtEmail.Clear();
txtUsername.Clear();
txtPassword.Clear();
}

private void tabEmployee_SelectedIndexChanged(object sender, EventArgs e)


{
if(tabEmployee.SelectedIndex == 1)
{
setEmployee(guna2DataGridView1);
}
else if (tabEmployee.SelectedIndex == 2)
{
setEmployee(guna2DataGridView2);
}
}

public void setEmployee(DataGridView dgv)


{
query = "select * from employee";
DataSet ds = fn.GetData(query);
dgv.DataSource = ds.Tables[0];
}

private void btnDelete_Click(object sender, EventArgs e)


{
if(txtID.Text != "")
{
if (MessageBox.Show("Bạn có chắc chắn muốn xóa không?", "Xác Nhận",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
query = "delete from employee where eid = "+ txtID.Text +" ";
fn.setData(query, "Thông Tin Nhân Viên Đã Được Xóa!!");
tabEmployee_SelectedIndexChanged(this, null);
}
}
}

private void UC_Employee_Leave(object sender, EventArgs e)


{
clearAll();
}
}
}

You might also like