public ProductList GetAll()
        {
            Database database = new Database("Customer");

            database.Command.Parameters.Clear();
            database.Command.CommandType = CommandType.StoredProcedure;
            database.Command.CommandText = "tblProductGetAll";

            DataTable dt = database.ExecuteQuery();
            Product blank = new Product();
            blank.Name = "- Please Select -";
            _List.Add(blank);

            foreach (DataRow dr in dt.Rows)
            {
                Product pr = new Product();
                pr.Initialize(dr);
                pr.InitializeBusinessData(dr);
                pr.IsNew = false;
                pr.IsDirty = false;
                pr.Savable += Product_Savable;
                _List.Add(pr);
            }

            return this;
        }
Пример #2
0
        public ProductList GetByCategoryId(Guid categoryId)
        {
            Database database = new Database("Customer");

            database.Command.Parameters.Clear();
            database.Command.CommandType = System.Data.CommandType.StoredProcedure;
            database.Command.CommandText = "tblProductGetByCategoryId";
            database.Command.Parameters.Add("@CategoryId", SqlDbType.UniqueIdentifier).Value = categoryId;
            DataTable dt = database.ExecuteQuery();

            foreach (DataRow dr in dt.Rows)
            {
                Product product = new Product();
                product.FilePath = _path;
                product.Initialize(dr);
                product.InitializeBusinessData(dr);
                product.IsNew    = false;
                product.IsDirty  = false;
                product.Savable += ProductType_Savable;
                _List.Add(product);
            }

            return(this);
        }