I agree with @SohailShaikh, you can add the extra column room_flag, if room_flag=0 means the room is booked(but not use the room), if the rom_flag=1 means the room is not be used and not be booked, and the room_flag=-1 means the room is using;
If the room is checkout, then change the room_flag to 1.
Thanks,
Amy Peng
Please mark the replies as answers if they help or unmark if not.
Feedback to us
AMBER ASHIQ
Member
1 Points
24 Posts
rooom number
Dec 09, 2012 01:47 AM|LINK
i have a form whcih is room and in this there is when i add a data on it that is
room id,room no and service type and room type
then when i add the data like as
room id=1
room no=2
room type=double
service type=luxury
then when i again add the data with ths same room number whcih is already booked then how to show it that this room no is already booked ...
here is room add fuction coding
public void add() { string ConString = @"Data Source=USER-PC\SQLEXPRESS;Initial Catalog=htm;Integrated Security=True"; SqlConnection con = new SqlConnection(ConString); con.Open(); DataTable dt = new DataTable(); SqlCommand com = new SqlCommand("insertroominfo", con); com.CommandType = CommandType.StoredProcedure; //com.Parameters.Add(new SqlParameter("@guest_ID", guest_id)); com.Parameters.Add(new SqlParameter("@room_no",roominfo.Room_no)); com.Parameters.Add(new SqlParameter("@service_id", roominfo.Service_type)); com.Parameters.Add(new SqlParameter("@RoomTypeID", roominfo.Room_type)); com.ExecuteNonQuery(); con.Close(); } add button codingprivate void Add_Click(object sender, EventArgs e) { Room_manager manageroom = new Room_manager(room); room.Service_type=Convert.ToString(service_type.SelectedValue); room.Room_type = Convert.ToString(room_type.SelectedValue); room.Room_no = Convert.ToInt32(room_no.Text); manageroom.add(); //dataGridView1.DataSource = room.displaydata(); MessageBox.Show("Room Added Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); dt.Clear(); dt = room.displaydata(); dataGridView1.DataSource = dt; clearfield1(); }how i dont this?
anybody tell me plz
SohailShaikh
Contributor
6119 Points
1167 Posts
Re: rooom number
Dec 09, 2012 03:58 AM|LINK
in this condition you have to add one extra column
and when your are gooing to insert then please run this query first
select * from your_tabel_Name where room no=2 and room_isbooked=true;
if its retirve row then show error in lable that room is alerdy booked else run your insertion query
and when customer going to checkout for the room the set false the room_isbooked=false
Sohail Shaikh
Milind986
Participant
766 Points
161 Posts
Re: rooom number
Dec 09, 2012 04:40 AM|LINK
Hello,
To solve this problem, At the time of adding record into the table, check whether this record already exists.
Add below condition in your SP.
My Blog
SohailShaikh
Contributor
6119 Points
1167 Posts
Re: rooom number
Dec 09, 2012 05:33 AM|LINK
Milind986 this will be wrong if i want to booked this room again when the customer quite because your given query always retive data except onece
Sohail Shaikh
Milind986
Participant
766 Points
161 Posts
Re: rooom number
Dec 09, 2012 06:05 AM|LINK
If you delete room record after customer quite then this solution will work.
My Blog
AMBER ASHIQ
Member
1 Points
24 Posts
Re: rooom number
Dec 09, 2012 06:24 AM|LINK
when i delete record from reservation through id then is this possible that from reservation
like id is 1 and guest name is amber and room no is 3 service type luxury
when i delete this record form reservation then automaticlly delete record from guest and from room ??????
becz in reservation the guest id and room id is involve
SohailShaikh
Contributor
6119 Points
1167 Posts
Re: rooom number
Dec 09, 2012 10:14 AM|LINK
hey any type of help feel free to ask any think any time just provide me your email address i will send you a sample program
Sohail Shaikh
AMBER ASHIQ
Member
1 Points
24 Posts
Re: rooom number
Dec 09, 2012 03:52 PM|LINK
yup
IN reservation how i create search funtion
like as how i search through id...
AMBER ASHIQ
Member
1 Points
24 Posts
Re: rooom number
Dec 09, 2012 03:53 PM|LINK
and when guest is check out then how i update id that this id number is check out
Amy Peng - M...
Star
10122 Points
958 Posts
Microsoft
Re: rooom number
Dec 11, 2012 05:21 AM|LINK
Hi AMBER,
I agree with @SohailShaikh, you can add the extra column room_flag, if room_flag=0 means the room is booked(but not use the room), if the rom_flag=1 means the room is not be used and not be booked, and the room_flag=-1 means the room is using;
If the room is checkout, then change the room_flag to 1.
Thanks,
Amy Peng
Feedback to us
Develop and promote your apps in Windows Store