Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 11, 2012 05:21 AM by Amy Peng - MSFT
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
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);
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("@service_id", roominfo.Service_type));
com.Parameters.Add(new SqlParameter("@RoomTypeID", roominfo.Room_type));
add button coding
private void Add_Click(object sender, EventArgs e)
Room_manager manageroom = new Room_manager(room);
room.Room_type = Convert.ToString(room_type.SelectedValue);
room.Room_no = Convert.ToInt32(room_no.Text);
//dataGridView1.DataSource = room.displaydata();
MessageBox.Show("Room Added Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
dt = room.displaydata();
dataGridView1.DataSource = dt;
how i dont this?
anybody tell me plz
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
Dec 09, 2012 04:40 AM|LINK
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.
if NOT EXISTS (select roomno from room where roomno=@room_no)
Dec 09, 2012 05:33 AM|LINK
Dec 09, 2012 06:05 AM|LINK
If you delete room record after customer quite then this solution will work.
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
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
Dec 09, 2012 03:52 PM|LINK
IN reservation how i create search funtion
like as how i search through id...
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
Dec 11, 2012 05:21 AM|LINK
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.