コード例 #1
0
        //function to set the room available status
        public bool SetRoomFreeStatus(int rmNum, string status)
        {
            MySqlCommand command   = new MySqlCommand();
            string       editQuery = "UPDATE `rooms` SET `Available`= @fr WHERE `RoomNo`= @rn";


            command.CommandText = editQuery;
            command.Connection  = conn.GetConnection();

            command.Parameters.Add("@rn", MySqlDbType.Int32).Value   = rmNum;
            command.Parameters.Add("@fr", MySqlDbType.VarChar).Value = status;

            conn.OpenConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.CloseConnection();
                return(true);
            }
            else
            {
                conn.CloseConnection();
                return(false);
            }
        }
コード例 #2
0
        //function to add new clients
        public bool addClient(string fName, string lName, string phoneNum, string country)
        {
            MySqlCommand command  = new MySqlCommand();
            string       addQuery = "INSERT INTO `clients`(`first_name`, `last_name`, `phone`, `country`) VALUES (@fname,@lname,@pNum,@cnt)";


            command.CommandText = addQuery;
            command.Connection  = conn.GetConnection();
            command.Parameters.Add("@fname", MySqlDbType.VarChar).Value = fName;
            command.Parameters.Add("@lname", MySqlDbType.VarChar).Value = lName;
            command.Parameters.Add("@pNum", MySqlDbType.VarChar).Value  = phoneNum;
            command.Parameters.Add("@cnt", MySqlDbType.VarChar).Value   = country;

            conn.OpenConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.CloseConnection();
                return(true);
            }
            else
            {
                conn.CloseConnection();
                return(false);
            }
        }
コード例 #3
0
        //function to add new reservation
        public bool addReserv(int roomNum, int clientId, DateTime dtIn, DateTime dtOut)
        {
            MySqlCommand command  = new MySqlCommand();
            string       addQuery = "INSERT INTO `reservation`(`RoomNo`, `ClientID`, `DateIN`, `DateOUT`) VALUES (@rn,@cid,@dtIN,@dtOUT)";

            //@rn,@cid,@dtIN,@dtOUT
            command.CommandText = addQuery;
            command.Connection  = conn.GetConnection();
            command.Parameters.Add("@rn", MySqlDbType.Int32).Value   = roomNum;
            command.Parameters.Add("@cid", MySqlDbType.Int32).Value  = clientId;
            command.Parameters.Add("@dtIN", MySqlDbType.Date).Value  = dtIn;
            command.Parameters.Add("@dtOUT", MySqlDbType.Date).Value = dtOut;

            conn.OpenConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.CloseConnection();
                return(true);
            }
            else
            {
                conn.CloseConnection();
                return(false);
            }
        }