Example #1
0
            /// <summary>
            /// Returns a VariablesDataSet, as defined by VariablesDataSet.xsd
            ///
            /// In SDSC code, this variable is loaded once, and is stored in an
            /// Application, or AppServer variable, and queries are run against the stored dataset.
            /// Other methods in this class are used to query the dataset.
            /// </summary>
            /// <param name="networkID"></param>
            /// <returns></returns>
            public static VariablesDataset GetVariableDataSet(int networkID)
            {
                VariablesDataset ds = new VariablesDataset();

                UnitsTableAdapter      unitTableAdapter       = new UnitsTableAdapter();
                VariablesTableAdapter  varsTableAdapter       = new VariablesTableAdapter();
                CategoriesTableAdapter categoriesTableAdapter = new CategoriesTableAdapter();

                unitTableAdapter.Connection.ConnectionString       = Config.ODDB();
                varsTableAdapter.Connection.ConnectionString       = Config.ODDB();
                categoriesTableAdapter.Connection.ConnectionString = Config.ODDB();

                try
                {
                    unitTableAdapter.Fill(ds.Units);
                    varsTableAdapter.Fill(ds.Variables);
                    categoriesTableAdapter.Fill(ds.Categories);
                }
                catch (Exception e)
                {
                    log.Fatal("Cannot retrieve units or variables from database" + e.Message);
                    //+ unitTableAdapter.Connection.DataSource
                    throw new WaterOneFlowServerException("Cannot retrieve units or variables from database", e);
                }

                return(ds);
            }
        public override List <Identity> GetAll(NorthwindConfig config, string whereExpression, OleDbParameter[] oleDbParameters)
        {
            #region Declarations
            List <Identity> result      = new List <Identity>();
            int             recordCount = 0;
            Category        dataset     = new Category();
            #endregion

            // get the first 11 rows of the changelog
            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                CategoriesTableAdapter tableAdapter;

                tableAdapter = new CategoriesTableAdapter();

                tableAdapter.Connection = connection;

                if (string.IsNullOrEmpty(whereExpression))
                {
                    recordCount = tableAdapter.Fill(dataset.Categories);
                }
                else
                {
                    recordCount = tableAdapter.FillByWhereClause(dataset.Categories, whereExpression, oleDbParameters);
                }
            }

            foreach (Category.CategoriesRow row in dataset.Categories.Rows)
            {
                // use where expression !!
                result.Add(new Identity(this.EntityName, row.CategoryID.ToString()));
            }

            return(result);
        }
Example #3
0
        static void Main(string[] args)
        {
            using (NorthwindDataSet ds =
                new NorthwindDataSet())
            using (CategoriesTableAdapter tac =
                new CategoriesTableAdapter())
            using (ProductsTableAdapter tap =
                new ProductsTableAdapter())
            {
                tac.Fill(ds.Categories);
                tap.Fill(ds.Products);

                foreach (var item in ds.Categories)
                {
                    Console.WriteLine("{0} {1} {2}",
                        item.ItemArray);

                    NorthwindDataSet.ProductsRow[] childs =
                        item.GetProductsRows();
                    foreach (var item2 in childs)
                    {
                        Console.WriteLine("\t{0} {1} {2} {3} ",
                            item2.CategoryID,
                            item2.ProductID,
                            item2.ProductName,
                            item2.UnitPrice);
                    }
                }
            }
        }
Example #4
0
        // Populate your datasources for an editing session using the following method.
        protected override void FillDataSources(XtraReport report, string reportName, bool isDesignActive)
        {
            DataSet1 dataSet = (DataSet1)report.GetDataSourceByName("XtraReport1Data");

            using (var categoriesTableAdapter = new CategoriesTableAdapter())
                using (var productsTableAdapter = new ProductsTableAdapter()) {
                    categoriesTableAdapter.Fill(dataSet.Categories);
                    productsTableAdapter.Fill(dataSet.Products);
                }
        }
        public static Northwind CreateNorthwindData()
        {
            var northwind = new Northwind();

            using (var categoriesAdapter = new CategoriesTableAdapter())
                using (var productsAdapter = new ProductsTableAdapter()) {
                    categoriesAdapter.Fill(northwind.Categories);
                    productsAdapter.Fill(northwind.Products);
                }
            return(northwind);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DrillDownDataSet       ddds = new DrillDownDataSet();
            CategoriesTableAdapter cta  = new CategoriesTableAdapter();

            cta.Fill(ddds.Categories);
            Session["DrillDownDataSet"] = ddds;
            Session["detailsLevel"]     = 0;
            ShowCategories();
        }
    }
Example #7
0
    protected nwndDataSet GetData()
    {
        if ((nwndDataSet)Session["dataset"] == null)
        {
            nwndDataSet            ds  = new nwndDataSet();
            CategoriesTableAdapter cta = new CategoriesTableAdapter();
            ProductsTableAdapter   pta = new ProductsTableAdapter();

            cta.Fill(ds.Categories);
            pta.Fill(ds.Products);

            Session["dataset"] = ds;
        }

        return((nwndDataSet)Session["dataset"]);
    }
        protected void Application_Start(object sender, EventArgs e)
        {
            var dataSet1 = new DataSet1();

            using (var categoriesAdapter = new CategoriesTableAdapter()) {
                categoriesAdapter.Fill(dataSet1.Categories);
                var categoriesProvider = new ObjectDataProvider(dataSet1);
                DataProviderRepository.Current.Register("Categories", "Categories", categoriesProvider);
            }

            var dataSet2 = new DataSet2();

            using (var customersAdapter = new CustomersTableAdapter()) {
                customersAdapter.Fill(dataSet2.Customers);
                var customersProvider = new ObjectDataProvider(dataSet2);
                DataProviderRepository.Current.Register("Customers", "Customers", customersProvider);
            }
        }
Example #9
0
        static object CreateDataSource()
        {
            var dataSource = new nwindDataSet();
            var connection = new OleDbConnection();

            connection.ConnectionString = Properties.Settings.Default.nwindConnectionString;

            CategoriesTableAdapter categories = new CategoriesTableAdapter();

            categories.Connection = connection;
            categories.Fill(dataSource.Categories);

            ProductsTableAdapter products = new ProductsTableAdapter();

            products.Connection = connection;
            products.Fill(dataSource.Products);

            return(dataSource);
        }
Example #10
0
        private static void Main()
        {
            var dataSet    = new NorthwindDataSet();
            var tblAdapter = new ProductsTableAdapter();

            tblAdapter.Fill(dataSet.Products);

            var tblAdapterCategories = new CategoriesTableAdapter();

            tblAdapterCategories.Fill(dataSet.Categories);

            foreach (var row in dataSet.Products)
            {
                Console.WriteLine($"{row.ProductName}");
            }
            var peterProduct   = dataSet.Products.FirstOrDefault(x => x.ProductName == "Peter");
            var gabrielProduct = dataSet.Products.FirstOrDefault(x => x.ProductName == "Gabriel");

            if (gabrielProduct == default(NorthwindDataSet.ProductsRow) && peterProduct == default(NorthwindDataSet.ProductsRow))
            {
                var newRow = dataSet.Products.NewProductsRow();
                newRow.ProductName   = "Gabriel";
                newRow.Discontinued  = false;
                newRow.CategoriesRow = dataSet.Categories.First();
                dataSet.Products.AddProductsRow(newRow);
            }
            else if (peterProduct == default(NorthwindDataSet.ProductsRow))
            {
                gabrielProduct.BeginEdit();
                gabrielProduct.ProductName = "Peter";
                gabrielProduct.EndEdit();
            }
            else if (gabrielProduct == default(NorthwindDataSet.ProductsRow))
            {
                peterProduct.Delete();
            }
            tblAdapter.Update(dataSet);
            Console.ReadLine();
        }
Example #11
0
 public DataControlCls()
 {
     CategoriesAdapter.Fill(nwdataset.Categories);
 }
Example #12
0
 public ClsCategories()
 {
     adapter2.Fill(northwindDataSet1.Categories);
 }
Example #13
0
            /// <summary>
            /// Returns a VariablesDataSet, as defined by VariablesDataSet.xsd
            /// 
            /// In SDSC code, this variable is loaded once, and is stored in an 
            /// Application, or AppServer variable, and queries are run against the stored dataset.
            /// Other methods in this class are used to query the dataset.
            /// </summary>
            /// <param name="networkID"></param>
            /// <returns></returns>
            public static VariablesDataset GetVariableDataSet(int networkID)
            {
                VariablesDataset ds = new VariablesDataset();

                UnitsTableAdapter unitTableAdapter = new UnitsTableAdapter();
                VariablesTableAdapter varsTableAdapter = new VariablesTableAdapter();
                CategoriesTableAdapter categoriesTableAdapter = new CategoriesTableAdapter();

                unitTableAdapter.Connection.ConnectionString = Config.ODDB();
                varsTableAdapter.Connection.ConnectionString = Config.ODDB();
                categoriesTableAdapter.Connection.ConnectionString = Config.ODDB();

                try
                {
                    unitTableAdapter.Fill(ds.Units);
                    varsTableAdapter.Fill(ds.Variables);
                    categoriesTableAdapter.Fill(ds.Categories);
                }
                catch (Exception e)
                {
                    log.Fatal("Cannot retrieve units or variables from database" + e.Message);
                        //+ unitTableAdapter.Connection.DataSource
                    throw new WaterOneFlowServerException("Cannot retrieve units or variables from database", e);
                }

                return ds;
            }
        public void ProcessRequest(HttpContext context)
        {
            _context = context;
            _req = context.Request;
            _res = context.Response;

            if (!string.IsNullOrEmpty(_req.QueryString["t"]))
            {
                switch (_req.QueryString["t"].ToLower())
                {
                    case "categories":
                        if (!string.IsNullOrEmpty(_req.QueryString["id"]))
                        {
                            cata = new CategoriesTableAdapter();
                            var ds = new NorthwindDataSet();
                            cata.FillByCategoryID(ds.Categories, int.Parse(_req.QueryString["id"]));
                            foreach (var item in ds.Categories)
                            {
                                item.Picture = null;
                            }
                            _res.ContentType = "text/xml";
                            _res.ContentEncoding = Encoding.UTF8;
                            _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                            ds.WriteXml(_res.OutputStream);

                        }
                        else
                        {
                            cata = new CategoriesTableAdapter();
                            var ds = new NorthwindDataSet();
                            cata.Fill(ds.Categories);
                            foreach (var item in ds.Categories)
                            {
                                item.Picture = null;
                            }
                            _res.ContentType = "text/xml";
                            _res.ContentEncoding = Encoding.UTF8;
                            _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                            ds.WriteXml(_res.OutputStream);

                        }
                        return;

                    case "products":
                        if (!string.IsNullOrEmpty(_req.QueryString["id"]))
                        {
                            prta = new ProductsTableAdapter();
                            var ds = new NorthwindDataSet();
                            prta.FillByProductID(ds.Products, int.Parse(_req.QueryString["id"]));
                            _res.ContentType = "text/xml";
                            _res.ContentEncoding = Encoding.UTF8;
                            _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                            ds.WriteXml(_res.OutputStream);

                        }
                        else if (!string.IsNullOrEmpty(_req.QueryString["cid"]))
                        {
                            prta = new ProductsTableAdapter();
                            var ds = new NorthwindDataSet();
                            prta.FillByCategoryID(ds.Products, int.Parse(_req.QueryString["cid"]));
                            _res.ContentType = "text/xml";
                            _res.ContentEncoding = Encoding.UTF8;
                            _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                            ds.WriteXml(_res.OutputStream);

                        }
                        else
                        {
                            prta = new ProductsTableAdapter();
                            var ds = new NorthwindDataSet();
                            prta.Fill(ds.Products);
                            _res.ContentType = "text/xml";
                            _res.ContentEncoding = Encoding.UTF8;
                            _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                            ds.WriteXml(_res.OutputStream);

                        }
                        return;
                    default:
                        break;
                }
            }
        }
Example #15
0
 public ClsNorthWind()
 {
     adapter.Fill(nwd.Products);
     categories.Fill(nwd.Categories);
 }