public void Update1() { ConnectionMysql connection = Main.con as ConnectionMysql; string query = "update books set name=?name,author=?author,genre=?genre where id_book=?id_book;"; if (connection.Connection.State != ConnectionState.Open) { connection.Connection.Open(); } MySqlCommand cmd = new MySqlCommand(query, connection.Connection); cmd.Parameters.Add(new MySqlParameter("?name", Name)); cmd.Parameters.Add(new MySqlParameter("?author", Author)); cmd.Parameters.Add(new MySqlParameter("?genre", Genre)); cmd.Parameters.Add(new MySqlParameter("?opinion", Opinion)); cmd.Parameters.Add(new MySqlParameter("?description", Description)); cmd.Parameters.Add(new MySqlParameter("?read", Read)); cmd.Parameters.Add(new MySqlParameter("?private", Private)); cmd.Parameters.Add(new MySqlParameter("?id_book", Id)); cmd.Parameters.Add(new MySqlParameter("?id_user", Main.lUser.Id)); cmd.ExecuteNonQuery(); cmd.CommandText = "update users_books set opinion=?opinion,description=?description,`read`=?read,`private`=?private " + "where id_book=?id_book and id_user=?id_user;"; cmd.ExecuteNonQuery(); connection.Connection.Close(); }
public void Update1() { ConnectionMysql connection = Main.con as ConnectionMysql; string query = "update series set name=?name,creators=?creators,genre=?genre where id_series=?id_series;"; if (connection.Connection.State != ConnectionState.Open) { connection.Connection.Open(); } MySqlCommand cmd = new MySqlCommand(query, connection.Connection); cmd.Parameters.Add(new MySqlParameter("?name", Name)); cmd.Parameters.Add(new MySqlParameter("?creators", Creators)); cmd.Parameters.Add(new MySqlParameter("?seasonwatched", SeasonWatched)); cmd.Parameters.Add(new MySqlParameter("?genre", Genre)); cmd.Parameters.Add(new MySqlParameter("?opinion", Opinion)); cmd.Parameters.Add(new MySqlParameter("?description", Description)); cmd.Parameters.Add(new MySqlParameter("?watched", Watched)); cmd.Parameters.Add(new MySqlParameter("?private", Private)); cmd.Parameters.Add(new MySqlParameter("?id_series", Id)); cmd.Parameters.Add(new MySqlParameter("?id_user", Main.lUser.Id)); cmd.ExecuteNonQuery(); cmd.CommandText = "update users_series set opinion=?opinion,description=?description,`watched`=?read,`private`=?private," + "season_watched=seasonwatched where id_series=?id_series and id_user=?id_user;"; cmd.ExecuteNonQuery(); connection.Connection.Close(); }
public void Update1() { ConnectionMysql connection = Main.con as ConnectionMysql; string query = "update users set name=?name,username=?username,email=?email,password=?password, " + " picture=?picture,number=?number where id_user=?id;"; if (connection.Connection.State != ConnectionState.Open) { connection.Connection.Open(); } MySqlCommand cmd = new MySqlCommand(query, connection.Connection); cmd.Parameters.Add(new MySqlParameter("?id", Id)); cmd.Parameters.Add(new MySqlParameter("?name", Name)); cmd.Parameters.Add(new MySqlParameter("?username", Username)); cmd.Parameters.Add(new MySqlParameter("?email", Email)); cmd.Parameters.Add(new MySqlParameter("?password", Password)); cmd.Parameters.Add(new MySqlParameter("?number", Number)); cmd.Parameters.Add("?picture", MySqlDbType.LongBlob); cmd.Parameters["?picture"].Value = Picture; cmd.ExecuteNonQuery(); connection.Connection.Close(); }
public void Insert1() { ConnectionMysql connection = Main.con as ConnectionMysql; string query = "insert into users (`Id_user`, `Name`, `Username`, `Email`, `Password`, `Picture`, `Number`) " + " values (null,?name,?username,?email,?password,?picture,?number)"; MySqlCommand cmd = new MySqlCommand(query, connection.Connection); cmd.Parameters.Add(new MySqlParameter("?id", Id)); cmd.Parameters.Add(new MySqlParameter("?name", Name)); cmd.Parameters.Add(new MySqlParameter("?username", Username)); cmd.Parameters.Add(new MySqlParameter("?email", Email)); cmd.Parameters.Add(new MySqlParameter("?password", Password)); cmd.Parameters.Add(new MySqlParameter("?number", Number)); if (Picture != null) { cmd.Parameters.Add("?picture", MySqlDbType.LongBlob); cmd.Parameters["?picture"].Value = Picture; } else { ImageConverter conv = new ImageConverter(); byte[] bytes = (byte[])conv.ConvertTo(Properties.Resources.default_user, typeof(byte[])); cmd.Parameters.Add("?picture", MySqlDbType.LongBlob); cmd.Parameters["?picture"].Value = bytes; } if (connection.Connection.State != ConnectionState.Open) { connection.Connection.Open(); } cmd.ExecuteNonQuery(); connection.Connection.Close(); }
public void Delete1() { ConnectionMysql connection = Main.con as ConnectionMysql; string query = "delete from users where id_user=?id_user;"; if (connection.Connection.State != ConnectionState.Open) { connection.Connection.Open(); } MySqlCommand cmd = new MySqlCommand(query, connection.Connection); cmd.Parameters.Add(new MySqlParameter("?id_user", Id)); cmd.ExecuteNonQuery(); connection.Connection.Close(); }
public void Insert1() { ConnectionMysql connection = Main.con as ConnectionMysql; string query = "select id_series from series where name like ?name;"; MySqlCommand cmd = new MySqlCommand(query, connection.Connection); cmd.Parameters.Add(new MySqlParameter("?name", Name)); cmd.Parameters.Add(new MySqlParameter("?creators", Creators)); cmd.Parameters.Add(new MySqlParameter("?seasonwatched", SeasonWatched)); cmd.Parameters.Add(new MySqlParameter("?genre", Genre)); cmd.Parameters.Add(new MySqlParameter("?opinion", Opinion)); cmd.Parameters.Add(new MySqlParameter("?description", Description)); cmd.Parameters.Add(new MySqlParameter("?watched", Watched)); cmd.Parameters.Add(new MySqlParameter("?private", Private)); if (connection.Connection.State != ConnectionState.Open) { connection.Connection.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); if (!reader.HasRows) { cmd.CommandText = "insert into series values(null,?name,?creators,?genre);"; reader.Close(); Console.WriteLine(cmd.ExecuteNonQuery()); cmd.CommandText = "select id_series from series where name like ?name;"; reader = cmd.ExecuteReader(); } reader.Read(); Id = (int)reader["id_series"]; reader.Close(); cmd.Parameters.Add(new MySqlParameter("?id_series", Id)); cmd.Parameters.Add(new MySqlParameter("?id_user", Main.lUser.Id)); cmd.CommandText = "insert into users_series values(?id_user,?id_series,?opinion,?description,?watched,?seasonwatched,?private);"; cmd.ExecuteNonQuery(); connection.Connection.Close(); }
public void Insert1() { ConnectionMysql connection = Main.con as ConnectionMysql; string query = "select books.id_book from books where books.name like ?name;"; MySqlCommand cmd = new MySqlCommand(query, connection.Connection); cmd.Parameters.Add(new MySqlParameter("?name", Name)); cmd.Parameters.Add(new MySqlParameter("?author", Author)); cmd.Parameters.Add(new MySqlParameter("?genre", Genre)); cmd.Parameters.Add(new MySqlParameter("?opinion", Opinion)); cmd.Parameters.Add(new MySqlParameter("?description", Description)); cmd.Parameters.Add(new MySqlParameter("?read", Read)); cmd.Parameters.Add(new MySqlParameter("?private", Private)); if (connection.Connection.State != ConnectionState.Open) { connection.Connection.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); if (!reader.HasRows) { cmd.CommandText = "insert into books values(null,?name,?author,?genre);"; reader.Close(); cmd.ExecuteNonQuery(); cmd.CommandText = "select books.id_book from books where books.name like ?name;"; reader = cmd.ExecuteReader(); } reader.Read(); Id = (int)reader["id_book"]; reader.Close(); cmd.Parameters.Add(new MySqlParameter("?id_book", Id)); cmd.Parameters.Add(new MySqlParameter("?id_user", Main.lUser.Id)); cmd.CommandText = "insert into users_books values(?id_user,?id_book,?opinion,?description,?read,?private);"; cmd.ExecuteNonQuery(); connection.Connection.Close(); }
public void Insert1() { ConnectionMysql connection = Main.con as ConnectionMysql; string query = "select id_song from songs where name like ?name;"; MySqlCommand cmd = new MySqlCommand(query, connection.Connection); cmd.Parameters.Add(new MySqlParameter("?name", Name)); cmd.Parameters.Add(new MySqlParameter("?singer", Singer)); cmd.Parameters.Add(new MySqlParameter("?genre", Genre)); cmd.Parameters.Add(new MySqlParameter("?opinion", Opinion)); cmd.Parameters.Add(new MySqlParameter("?description", Description)); cmd.Parameters.Add(new MySqlParameter("?listened", Listened)); cmd.Parameters.Add(new MySqlParameter("?private", Private)); if (connection.Connection.State != ConnectionState.Open) { connection.Connection.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); if (!reader.HasRows) { cmd.CommandText = "insert into songs values(null,?name,?singer,?genre);"; reader.Close(); cmd.ExecuteNonQuery(); cmd.CommandText = "select id_song from songs where name like ?name;"; reader = cmd.ExecuteReader(); } reader.Read(); Id = (int)reader["id_song"]; reader.Close(); cmd.Parameters.Add(new MySqlParameter("?id_song", Id)); cmd.Parameters.Add(new MySqlParameter("?id_user", Main.lUser.Id)); cmd.CommandText = "insert into users_songs values(?id_user,?id_song,?opinion,?description,?listened,?private);"; cmd.ExecuteNonQuery(); connection.Connection.Close(); }