Example #1
0
        public bool insertClient(String fname, String lname, String phone, String country)
        {
            MySqlCommand command     = new MySqlCommand();
            String       insertQuery = "INSERT INTO `clients`(`first_name`, `last_name`, `phone`, `country`) VALUES (@fnm,@lnm,@phn,@cnt)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            //@fnm,@lnm,@phn,@cnt
            command.Parameters.Add("@fnm", MySqlDbType.VarChar).Value = fname;
            command.Parameters.Add("@lnm", MySqlDbType.VarChar).Value = lname;
            command.Parameters.Add("@phn", MySqlDbType.VarChar).Value = phone;
            command.Parameters.Add("@cnt", MySqlDbType.VarChar).Value = country;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
Example #2
0
        //add new reservation
        public bool addReservation(int number, int clientId, DateTime dateIn, DateTime dateOut)
        {
            MySqlCommand command     = new MySqlCommand();
            String       insertQuery = "INSERT INTO `reservations`( `roomNumber`, `clientId`, `DateIn`, `DateOut`) VALUES (@rnm,@cid,@din,@dout) ";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            //@rnm,@cid,@din,@dout
            command.Parameters.Add("@rnm", MySqlDbType.Int32).Value = number;
            command.Parameters.Add("@cid", MySqlDbType.Int32).Value = clientId;
            command.Parameters.Add("@din", MySqlDbType.Date).Value  = dateIn;
            command.Parameters.Add("@dout", MySqlDbType.Date).Value = dateOut;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
Example #3
0
        //fun to insert a new room
        public bool addRoom(int number, int type, String phone, String free)
        {
            MySqlCommand command     = new MySqlCommand();
            String       insertQuery = "INSERT INTO `rooms`(`number`, `type`, `phone`, `free`) VALUES (@num,@tp,@phn,@fr)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            //@num,@tp,@phn,@fr
            command.Parameters.Add("@num", MySqlDbType.Int32).Value   = number;
            command.Parameters.Add("@tp", MySqlDbType.Int32).Value    = type;
            command.Parameters.Add("@phn", MySqlDbType.VarChar).Value = phone;
            command.Parameters.Add("@fr", MySqlDbType.VarChar).Value  = free;

            conn.openConnection();

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