//Get Product// public List <fitassitant> getProductAll() { List <fitassitant> prodList = new List <fitassitant>(); string topsize, bottomsize, footlength; decimal height, weight; string queryStr = "SELECT * FROM Fit Order By height"; SqlConnection conn = new SqlConnection(_connStr); SqlCommand cmd = new SqlCommand(queryStr, conn); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); //Continue to read the resultsets row by row if not the end while (dr.Read()) { height = decimal.Parse(dr["height"].ToString()); weight = decimal.Parse(dr["weight"].ToString()); topsize = dr["topsize"].ToString(); bottomsize = dr["bottomsize"].ToString(); footlength = (dr["footlength"].ToString()); fitassitant a = new fitassitant(height, weight, topsize, bottomsize, footlength); prodList.Add(a); } conn.Close(); dr.Close(); dr.Dispose(); return(prodList); }
// Get measurement// public fitassitant getmeasure(decimal height) { fitassitant detail = null; decimal Height, Weight; string topSize, bottomSize, footlength; string queryStr = "SELECT * FROM Fit WHERE height= @height"; SqlConnection conn = new SqlConnection(_connStr); SqlCommand cmd = new SqlCommand(queryStr, conn); cmd.Parameters.AddWithValue("@Height", this.height); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Height = decimal.Parse(dr["height"].ToString()); Weight = decimal.Parse(dr["weight"].ToString()); topSize = dr["topSize"].ToString(); bottomSize = dr["bottomSize"].ToString(); footlength = dr["footlength"].ToString(); detail = new fitassitant(); } else { detail = null; } conn.Close(); dr.Close(); dr.Dispose(); return(detail); }