public void AddCurrency(RegistryCurrency registryCurrency) { try { using (MySqlCommand dbComm = new MySqlCommand()) { dbComm.CommandType = CommandType.Text; dbComm.CommandText = SQL.RegistryScripts.AddCurrency; dbComm.Parameters.AddWithValue("desc", registryCurrency.DescCurrency); dbComm.Parameters.AddWithValue("code", registryCurrency.CodeCurrency); dbComm.Connection = new MySqlConnection(DAFconnection.GetConnectionType()); dbComm.Connection.Open(); dbComm.ExecuteNonQuery(); dbComm.Connection.Close(); } } catch (MySqlException err) { throw new Exception(err.Message); } catch (Exception err) { throw new Exception(err.Message); } }
public RegistryCurrencyList GetRegistryCurrencyList() { try { using (MySqlDataAdapter dbAdaptar = new MySqlDataAdapter()) { dbAdaptar.SelectCommand = new MySqlCommand(); dbAdaptar.SelectCommand.Connection = new MySqlConnection(DAFconnection.GetConnectionType()); dbAdaptar.SelectCommand.CommandType = CommandType.Text; dbAdaptar.SelectCommand.CommandText = SQL.RegistryScripts.GetRegistryCurrencyList; DataTable dt = new DataTable(); dbAdaptar.Fill(dt); RegistryCurrencyList RcL = new RegistryCurrencyList(); foreach (DataRow dr in dt.Rows) { RegistryCurrency Rc = new RegistryCurrency(); Rc.IdCurrency = (int)dr.Field <uint>("id_valuta"); Rc.DescCurrency = dr.Field <string>("desc_valuta"); Rc.CodeCurrency = dr.Field <string>("cod_valuta"); RcL.Add(Rc); } return(RcL); } } catch (MySqlException err) { throw new Exception(err.Message); } catch (Exception err) { throw new Exception(err.Message); } }