-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserControlCheckOut.cs
104 lines (83 loc) · 3.85 KB
/
UserControlCheckOut.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsHotelManagement.All_User_Control
{
public partial class UserControlCheckOut : UserControl
{
private DataAccess da = new DataAccess();
private string query;
private int c_id;
public UserControlCheckOut()
{
InitializeComponent();
}
private void UserControlCheckOut_Load(object sender, EventArgs e)
{
query = "select Customer.customerId,Customer.customerName,Customer.mobileNo,Customer.nationality,Customer.gender,Customer.dob,Customer.NID,Customer.customerAddress,Customer.checkinDate,Rooms.roomNo,Rooms.roomtype,Rooms.bed,Rooms.price from Customer inner join Rooms on Customer.roomid=Rooms.roomid where Checkedout='NO'";
dgvCustomer.DataSource = da.ExecuteQueryTable(query);
}
private void txtName_TextChanged(object sender, EventArgs e)
{
query = "select Customer.customerId,Customer.customerName,Customer.mobileNo,Customer.nationality,Customer.gender,Customer.dob,Customer.NID,Customer.customerAddress,Customer.checkinDate,Rooms.roomNo,Rooms.roomtype,Rooms.bed,Rooms.price from Customer inner join Rooms on Customer.roomid=Rooms.roomid where customerName like'" + txtNameSearch.Text + "%' and Checkedout='NO'";
dgvCustomer.DataSource = da.ExecuteQueryTable(query);
}
private void dgvCustomer_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (dgvCustomer.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
{
c_id = int.Parse(dgvCustomer.Rows[e.RowIndex].Cells[0].Value.ToString());// column remain same thats why Cell[0]
txtGetName.Text = dgvCustomer.Rows[e.RowIndex].Cells[1].Value.ToString();
txtGetRoomNo.Text = dgvCustomer.Rows[e.RowIndex].Cells[9].Value.ToString();
}
}
catch
{
MessageBox.Show("ERROR OCCUR", "Exception", MessageBoxButtons.RetryCancel);
}
}
private void txtRoomNo_TextChanged(object sender, EventArgs e)
{
}
private void txtGetName_TextChanged(object sender, EventArgs e)
{
}
private void btnCheckOut_uc_Click(object sender, EventArgs e)
{
if (txtGetName.Text != "")
{
if (MessageBox.Show("Confirm Check Out?", "CONFIRMATION", MessageBoxButtons.YesNo)==DialogResult.Yes)
{
query = "update Customer set Checkedout='YES',checkoutDate='" + dtpCheckOut.Text + "' where customerId=" + c_id + " update Rooms set reservation='NO' where roomNo='"+txtGetRoomNo.Text+"'; ";
da.ExecuteUpdateQuery(query);
MessageBox.Show("Check Out Successfull","Confirmed",MessageBoxButtons.OK);
UserControlCheckOut_Load(this, null);
this.ClearAll();
}
}
else
{
MessageBox.Show("Please select Customer", "Exception", MessageBoxButtons.RetryCancel);
}
}
public void ClearAll()
{
txtGetName.Clear();
txtNameSearch.Clear();
txtGetRoomNo.Clear();
dtpCheckOut.ResetText();
}
private void UserControlCheckOut_Leave(object sender, EventArgs e)
{
this.ClearAll();
}
}
}