public static Cpda Getpda(string path, Cpda type) { try { MySqlConnection sqlCon = new MySqlConnection(path); sqlCon.Open(); MySqlCommand sqlcmd = sqlCon.CreateCommand(); sqlcmd.CommandText = "SELECT `FUNCTION` FROM `bspda` WHERE `PDA`=@PDA"; sqlcmd.Parameters.AddWithValue("PDA", type.PDA); MySqlDataReader sdr = sqlcmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection); if (sdr.Read()) { type.FUNCTION = sdr.GetString(0); return(type); } else { return(null); } } catch (Exception) { //Do any logging operation here if necessary return(null); } }
public static bool Delete(string path, Cpda type) { try { MySqlConnection sqlCon = new MySqlConnection(path); sqlCon.Open(); MySqlCommand sqlcmd = sqlCon.CreateCommand(); sqlcmd.CommandText = "DELETE FROM `bspda` WHERE `PDA`=@PDA"; sqlcmd.Parameters.AddWithValue("PDA", type.PDA); int i = sqlcmd.ExecuteNonQuery(); return(i == 1); } catch (Exception) { //Do any logging operation here if necessary return(false); } }
public static bool Update(string path, Cpda type) { try { MySqlConnection sqlCon = new MySqlConnection(path); sqlCon.Open(); MySqlCommand sqlcmd = sqlCon.CreateCommand(); sqlcmd.CommandText = "UPDATE bspda SET FUNCTION=@FUNCTION where PDA=@PDA;"; sqlcmd.Parameters.Add(new MySqlParameter("PDA", type.PDA)); sqlcmd.Parameters.Add(new MySqlParameter("FUNCTION", type.FUNCTION)); int i = sqlcmd.ExecuteNonQuery(); return(i == 1); } catch (Exception) { //Do any logging operation here if necessary return(false); } }
public static bool Insert(string path, Cpda type) { try { MySqlConnection sqlCon = new MySqlConnection(path); sqlCon.Open(); MySqlCommand sqlcmd = sqlCon.CreateCommand(); sqlcmd.CommandText = "INSERT INTO bspda(ID, PDA, FUNCTION) VALUES(uuid(),@PDA, @FUNCTION);"; sqlcmd.Parameters.Add(new MySqlParameter("PDA", type.PDA)); sqlcmd.Parameters.Add(new MySqlParameter("FUNCTION", type.FUNCTION)); int i = sqlcmd.ExecuteNonQuery(); return(i == 1); } catch (Exception) { //Do any logging operation here if necessary return(false); } }