BeatSamurai 0 Newbie Poster

yo,
I've been struggling with this problem for a few weeks now, so I'm hoping you guys can help a dude out...

I'm using a monthcalender control and a listbox;which displays roomnames, if it's available or not(roomstatus), it's price and it's capacity.

problem 1: so depending on which date you click on the monthcalender, if there is a booking on that clicked date, then the status should change to "booked" for the room that is booked on that date...it works fine for one room, but the problem comes in, if there is more than one room booked on that date, it doesn't display both as being booked, only the last one of however many is booked on that date, which is a problem

any help? please...

problem 2: a booking has a fromdate and a todate
(eg. fromdate = 01/01/2010 and todate = 02/01/2010, which is one night)
now the problem is, when you select a date range on the monthcalender from say, 01/01/2010 until 03/01/2010, but there is a booking on 02/01/2010, then it should display "booked" for that room, but is doesn't...
please help...

below is the method is use for doing all the above mentioned...

public void getStatus()
//displays Rooms and their booking status,Interacts with Calender Form
        {

            
            String datermsql = "SELECT * FROM Booking";
// check which rooms are booked on that specific date

            MySqlConnection roomcon = new MySqlConnection(oleDbConString);
            MySqlCommand roomdateCom = new MySqlCommand(datermsql, roomcon);
            roomdateCom.CommandType = CommandType.Text;

            MySqlDataAdapter rmAdapt = new MySqlDataAdapter();
            MySqlCommandBuilder rmCB = new MySqlCommandBuilder(rmAdapt);
            DataSet rmDS = new DataSet();

            try
            {
                roomcon.Open();
               

                rmAdapt.SelectCommand = roomdateCom;

                int rmrecs = rmAdapt.Fill(rmDS, "Booking");
                
                if(rmrecs>0)
                {
                for(int v =0; v< rmDS.Tables["Booking"].Rows.Count;v++) 
                {
                    if (rmDS.Tables["Booking"].Rows[v]["BookingStatus"].ToString() != "Checked Out")
                    {
                        rseldates[v] = roombookdate;
                        
                        
                        rindates[v] = Convert.ToDateTime(rmDS.Tables["Booking"].Rows[v]["BookingDateIn"]).ToShortDateString().ToString();
                        routdates[v] = Convert.ToDateTime(rmDS.Tables["Booking"].Rows[v]["BookingDateOut"]).ToShortDateString().ToString();
                        
                        if (DateTime.Parse(rindates[v]) <= DateTime.Parse(rseldates[v]))
                           
                            {
                            statroom = rmDS.Tables["Booking"].Rows[v]["RoomName"].ToString();
                             }

                    }// end of checked out if statement
                }// end of for loop
                }// end of rmrecs if statement
                //////////////////////////////////////////////////////////
            

            }
            catch (Exception rs)
            {
                MessageBox.Show("error" + rs.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                roomcon.Close();
            }
             
             String statsql = "SELECT * FROM Room";


                MySqlConnection dbcone = new MySqlConnection(oleDbConString);
                MySqlCommand statCom = new MySqlCommand(statsql, dbcone);
                MySqlDataAdapter statAdapt = new MySqlDataAdapter();
                MySqlCommandBuilder statCB = new MySqlCommandBuilder(statAdapt);
                DataSet statDS = new DataSet();
                statCom.CommandType = CommandType.Text;

                try
                {
                    dbcone.Open();
                    statAdapt.SelectCommand = statCom;
                    int nrows = statAdapt.Fill(statDS,"Room");

                     
                   

                    if (nrows > 0)
                    { //Getting the Column names
                        row1 = statDS.Tables["Room"].Columns["RoomName"].ToString().PadRight(20);


                      
                        row1 += "Status".PadRight(20);
                        row1 += "Capacity".PadRight(15);
                        row1 += "Room Price";
                           

                        

                        for (int j = 0; j < statDS.Tables["Room"].Rows.Count; j++)//Filling the listbox with the roomnumbers and booking status
                        {
                            
                             
                           
                              
                            srooms[j] = statDS.Tables["Room"].Rows[j]["RoomName"].ToString().PadRight(25);
                            
                            
                            if(srooms[j].Substring(0,11).Trim() == statroom)
                            {
                              
                                
                                    srooms[j] += "Booked".PadRight(20);
                                

                            }
                                else if (srooms[j] != statroom)
                                {
                                    srooms[j] += "Available".PadRight(20);
                                }

                             

                            srooms[j] += statDS.Tables["Room"].Rows[j]["RoomCapacity"].ToString().PadRight(20);// getting the corresponding room's capacity
                            
                            if (Convert.ToDateTime(fdate).Month >= 10)// get inseason price
                            {
                                


                                srooms[j] += "R "+statDS.Tables["Room"].Rows[j]["RoomInSeasonPrice"].ToString();
                            }
                            else if (Convert.ToDateTime(fdate).Month < 10)// get outseason price
                            {
                                

                                srooms[j] += "R "+statDS.Tables["Room"].Rows[j]["RoomOutSeasonPrice"].ToString(); 
                            }

                          
                              
                             
                        }
                        strooms.AddRange(srooms);
                        
                    }

                   

                }
                
                catch (Exception br)
                {
                    MessageBox.Show("Error: " + br.Message,"Exception");

                }
                dbcone.Close();

                
                
                }

thanks in advance guys

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.