예제 #1
0
 public bool AddProduct(SizeMedium sizeMedium)
 {
     SqlParameter[] parameters = new SqlParameter[]
     {
         new SqlParameter("@SizeID", Convert.ToInt32(sizeMedium.Size)),
         new SqlParameter("@MediumID", Convert.ToInt32(sizeMedium.Medium)),
         new SqlParameter("@Price", sizeMedium.Price)
     };
     return(DBHelper.ExecuteNonQuery("sp_AddSizeMedium", CommandType.StoredProcedure, parameters));
 }
예제 #2
0
        //Get all products...
        public List <SizeMedium> GetAllProducts()
        {
            List <SizeMedium> list = new List <SizeMedium>();

            using (DataTable table = DBHelper.ExecuteSelectCommand("sp_GetAllSizeMedium", CommandType.StoredProcedure))
            {
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        SizeMedium product = new SizeMedium();
                        product.SizeMediumID = Convert.ToInt32(row["SizeMediumID"].ToString());
                        product.Product      = row["Product"].ToString() + " - " + (string.Format("{0:C}", Convert.ToDouble(row["Price"].ToString())));
                        list.Add(product);
                    }
                }
            }
            return(list);
        }
예제 #3
0
        public SizeMedium GetProdByName(string prodName)
        {
            SizeMedium SM = null;

            using (DataTable table = DBHelper.ExecuteSelectCommand("sp_GetAllSizeMedium", CommandType.StoredProcedure))
            {
                if (table.Rows.Count > 0)
                {
                    SM = new SizeMedium();

                    foreach (DataRow row in table.Rows)
                    {
                        if (row["Product"].ToString() == prodName)
                        {
                            SM.SizeMediumID = Convert.ToInt32(row["SizeMediumID"].ToString());
                        }
                    }
                }
            }

            return(SM);
        }