예제 #1
0
 public bool InsertPiwo(PiwoDetailDTO piwo)
 {
     if (DBHelper.addBeer(piwo))
     {
         return(true);
     }
     return(false);
 }
예제 #2
0
 public bool UpdatePiwo(PiwoDetailDTO piwo)
 {
     if (DBHelper.updateBeer(piwo))
     {
         return(true);
     }
     return(false);
 }
예제 #3
0
 public bool updateBeer(PiwoDetailDTO beer)
 {
     if (this.deleteBeer(beer.Id))
     {
         if (this.updateBeer(beer))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #4
0
 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);
         }
     }
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
        public PiwoDetailDTO GetBeer(int id)
        {
            PiwoDetailDTO beer = DBHelper.getBeerWithId(id);

            return(beer);
        }