public bool InsertPiwo(PiwoDetailDTO piwo) { if (DBHelper.addBeer(piwo)) { return(true); } return(false); }
public bool UpdatePiwo(PiwoDetailDTO piwo) { if (DBHelper.updateBeer(piwo)) { return(true); } return(false); }
public bool updateBeer(PiwoDetailDTO beer) { if (this.deleteBeer(beer.Id)) { if (this.updateBeer(beer)) { return(true); } } return(false); }
public bool addBeer(PiwoDetailDTO beer) { this.query = string.Format("INSERT INTO dbo.Browar (id, nazwa) VALUES ({0}, {1})", beer.Id, beer.Name); using (SqlCommand command = new SqlCommand(this.query, this.conn)) { conn.Open(); if (command.ExecuteNonQuery() > 0) { return(true); } else { return(false); } } }
public PiwoDetailDTO getBeerWithId(int id) { PiwoDetailDTO beer = new PiwoDetailDTO(); this.query = string.Format("SELECT id, nazwa FROM dbo.Browar WHERE id = {0}", id); using (SqlCommand command = new SqlCommand(this.query, this.conn)) { conn.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { reader.Read(); beer.Id = int.Parse(reader.GetValue(0).ToString()); beer.Name = reader.GetValue(1).ToString(); } return(beer); } }
public PiwoDetailDTO GetBeer(int id) { PiwoDetailDTO beer = DBHelper.getBeerWithId(id); return(beer); }