コード例 #1
0
ファイル: BikePage1.aspx.cs プロジェクト: Swiftrow/Project
        protected void Button1_Click2(object sender, EventArgs e)
        {
            var s = new Service1();
            var b = new Bike();

            int ID = Int32.Parse(IDBike.Text);

            b = s.FindBikeById(ID);

            Name.Text = b.Name;
            Category.Text = b.Category;
        }
コード例 #2
0
ファイル: BikeCtr.cs プロジェクト: Swiftrow/Project
        public List<Bike> SortByPrice(List<Bike> bikes)
        {
            List<Bike> sortedBikes = new List<Bike>();
            Bike aux = new Bike();

            for(int i = 0; i < bikes.Count - 1; i++)
            {
                for(int j = i + 1; j < bikes.Count; j++)
                {
                    if(bikes[i].Price > bikes[j].Price)
                    {
                        aux = bikes[j];
                        bikes[j] = bikes[i];
                        bikes[i] = aux;
                    }
                }
            }
            sortedBikes = bikes;

            return sortedBikes;
        }
コード例 #3
0
ファイル: DBBike.cs プロジェクト: Swiftrow/Project
 public Bike FindBikeById(int IDBike)
 {
     Bike b = new Bike();
     using (SqlConnection myConnection = new SqlConnection(cnStr))
     {
         string q = " Select * From Bike where IDBike=@IDBike";
         SqlCommand myCommand = new SqlCommand(q, myConnection);
         myCommand.Parameters.AddWithValue("@IDBike", IDBike);
         myConnection.Open();
         using (SqlDataReader myDataReader = myCommand.ExecuteReader())
         {
             if (myDataReader != null)
             {
                 while (myDataReader.Read())
                 {
                     string strId = myDataReader["IDBike"].ToString();
                     b.IDBike = Int32.Parse(strId);
                     b.Name = myDataReader["Name"].ToString();
                     b.Category = myDataReader["Category"].ToString();
                     b.Brand = myDataReader["Brand"].ToString();
                     string strPrice = myDataReader["Price"].ToString();
                     b.Price = Int32.Parse(strPrice);
                     string bWeight = myDataReader["BWeight"].ToString();
                     b.BWeight = float.Parse(bWeight);
                     string strSize = myDataReader["Size"].ToString();
                     b.Size = Int32.Parse(strSize);
                     b.Gender = myDataReader["Gender"].ToString();
                     b.Material = myDataReader["Material"].ToString();
                     b.Colour = myDataReader["Colour"].ToString();
                     string strWsize = myDataReader["WheelSize"].ToString();
                     b.WheelSize = Int32.Parse(strSize);
                     b.Features = myDataReader["Features"].ToString();
                 }
             }
             myConnection.Close();
         }
     }
     return b;
 }
コード例 #4
0
ファイル: OrderLineBike.cs プロジェクト: Swiftrow/Project
 public OrderLineBike(Bike Bike, int Amount)
 {
     this.Bike = Bike;
     this.Amount = Amount;
 }
コード例 #5
0
ファイル: Service1.svc.cs プロジェクト: Swiftrow/Project
 public void InsertBike(Bike b)
 {
     bikeCtr.InsertBike(b.IDBike, b.Name, b.Category, b.Brand, b.Price, b.BWeight, b.Size, b.Gender, b.Material, b.Colour, b.WheelSize, b.Features);
 }
コード例 #6
0
ファイル: DBBike.cs プロジェクト: Swiftrow/Project
        public List<Bike> GetBikes()
        {
            List<Bike> bikes  = new List<Bike>();
            using (SqlConnection myConnection = new SqlConnection(cnStr))
            {
                string q = " Select * From Bike ";
                SqlCommand myCommand = new SqlCommand(q, myConnection);
                myConnection.Open();
                using (SqlDataReader myDataReader = myCommand.ExecuteReader())
                {
                    if (myDataReader != null)
                    {
                        while (myDataReader.Read())
                        {
                            Bike b = new Bike();
                            string strId = myDataReader["IDBike"].ToString();
                            b.IDBike = Int32.Parse(strId);
                            b.Name = myDataReader["Name"].ToString();
                            b.Category = myDataReader["Category"].ToString();
                            b.Brand = myDataReader["Brand"].ToString();
                            string strPrice = myDataReader["Price"].ToString();
                            b.Price = Int32.Parse(strPrice);
                            string bWeight = myDataReader["BWeight"].ToString();
                            b.BWeight = float.Parse(bWeight);
                            string strSize = myDataReader["Size"].ToString();
                            b.Size = Int32.Parse(strSize);
                            b.Gender = myDataReader["Gender"].ToString();
                            b.Material = myDataReader["Material"].ToString();
                            b.Colour = myDataReader["Colour"].ToString();
                            string strWsize = myDataReader["WheelSize"].ToString();
                            b.WheelSize = Int32.Parse(strSize);
                            b.Features = myDataReader["Features"].ToString();

                            bikes.Add(b);
                        }
                    }
                    myConnection.Close();
                }
            }
            return bikes;
        }