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();
}
and here is add button coding
private 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();
}
anybody help plz