public Despesas(int pId, DateTime pData, decimal pValor, Gastos pgastos, string pLocal) { Id = pId; Data = pData.Date; Valor = pValor; gastos = pgastos; Local = pLocal; }
public void Create(Gastos pGastos) { MySqlCommand cmm = new MySqlCommand(); StringBuilder sql = new StringBuilder(); sql.Append("insert into tipogasto (Nome) "); sql.Append("values(@nome)"); cmm.CommandText = sql.ToString(); cmm.Parameters.AddWithValue("@nome", pGastos.Nome); conn.executarComando(cmm); }
public Gastos getOne(int pId) { MySqlCommand cmm = new MySqlCommand(); StringBuilder sql = new StringBuilder(); sql.Append("select * from tipogasto "); sql.Append("where IdTipo=@id"); cmm.CommandText = sql.ToString(); cmm.Parameters.AddWithValue("@id", pId); MySqlDataReader dr = conn.executarConsulta(cmm); dr.Read(); Gastos gastos = new Gastos { IdTipo = (int)dr["IdTipo"], Nome = (string)dr["Nome"] }; return gastos; }
public void Update(Gastos pgastos) { MySqlCommand cmm = new MySqlCommand(); StringBuilder sql = new StringBuilder(); sql.Append("update tipogasto "); sql.Append("set Nome=@nome "); sql.Append("where IdTipo=@tipo"); cmm.CommandText = sql.ToString(); cmm.Parameters.AddWithValue("@nome", pgastos.Nome); cmm.Parameters.AddWithValue("@tipo", pgastos.IdTipo); conn.executarComando(cmm); }