Ejemplo n.º 1
0
        private void BindToDataSet()
        {
            this.radGridView1.MasterTemplate.AutoGenerateColumns = true;

            if (set == null)
            {
                set     = new NorthwindDataSet();
                adapter = new Telerik.Examples.WinControls.DataSources.NorthwindDataSetTableAdapters.EmployeesTableAdapter();
                adapter.Fill(set.Employees);
            }
            radGridView1.DataSource = set.Employees;

            radGridView1.Columns["EmployeeID"].IsVisible      = false;
            radGridView1.Columns["TitleOfCourtesy"].IsVisible = false;
            radGridView1.Columns["BirthDate"].IsVisible       = false;
            radGridView1.Columns["HireDate"].IsVisible        = false;
            radGridView1.Columns["Address"].IsVisible         = false;
            radGridView1.Columns["Region"].IsVisible          = false;
            radGridView1.Columns["HomePhone"].IsVisible       = false;
            radGridView1.Columns["Extension"].IsVisible       = false;
            radGridView1.Columns["Photo"].IsVisible           = false;
            radGridView1.Columns["Notes"].IsVisible           = false;
            radGridView1.Columns["ReportsTo"].IsVisible       = false;

            radGridView1.Columns["LastName"].HeaderText   = "Last Name";
            radGridView1.Columns["FirstName"].HeaderText  = "First Name";
            radGridView1.Columns["PostalCode"].HeaderText = "Postal Code";
        }
Ejemplo n.º 2
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);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void LoadDataReport()
        {
            //Create the local report
            LocalReport report = new LocalReport();
            report.ReportEmbeddedResource = "RDLCDemo.ReportTest.rdlc";

            //Create the dataset
            _northWindDataSet = new NorthwindDataSet();
            _dataAdapter = new NorthwindDataSetTableAdapters.ProductsByCategoriesTableAdapter();

            _northWindDataSet.DataSetName = "NorthwindDataSet";
            _northWindDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
            _dataAdapter.ClearBeforeFill = true;

            //Created datasource and binding source
            ReportDataSource dataSource = new ReportDataSource();
            System.Windows.Forms.BindingSource source = new System.Windows.Forms.BindingSource();

            dataSource.Name = "ProductsDataSources";  //the datasource name in the RDLC report
            dataSource.Value = source;
            source.DataMember = "ProductsByCategories";
            source.DataSource = _northWindDataSet;
            report.DataSources.Add(dataSource);

            //Fill Data in the dataset
            _dataAdapter.Fill(_northWindDataSet.ProductsByCategories);

            //Create the printer/export rdlc printer
            RDLCPrinter rdlcPrinter = new RDLCPrinter(report);

            rdlcPrinter.BeforeRefresh += rdlcPrinter_BeforeRefresh;

            //Load in report viewer
            ReportViewer.Report = rdlcPrinter;
        }
Ejemplo n.º 4
0
        //---------------------------------------------------------------------
        void Test()
        {
            NorthwindDataSet northwindDataSet1 = new NorthwindDataSet();

            //<Snippet3>
            NorthwindDataSetTableAdapters.CustomersTableAdapter customersTableAdapter1;
            customersTableAdapter1 = new NorthwindDataSetTableAdapters.CustomersTableAdapter();
            //</Snippet3>

            //<Snippet4>
            customersTableAdapter1.Fill(northwindDataSet1.Customers);
            //</Snippet4>

            //<Snippet5>
            NorthwindDataSet.CustomersDataTable newCustomersTable;
            newCustomersTable = customersTableAdapter1.GetData();
            //</Snippet5>

            //<Snippet6>
            NorthwindDataSetTableAdapters.QueriesTableAdapter scalarQueriesTableAdapter;
            scalarQueriesTableAdapter = new NorthwindDataSetTableAdapters.QueriesTableAdapter();

            int returnValue;

            returnValue = (int)scalarQueriesTableAdapter.CustomerCount();
            //</Snippet6>
        }
Ejemplo n.º 5
0
        private void GenerateNorthwindNDb()
        {
            const string ndbFile = "northwind.ndb";

            OdbFactory.Delete(ndbFile);

            var dataSet = new NorthwindDataSet();
            var odb = OdbFactory.Open(ndbFile);
            var progress = 0.0;

            try
            {
                LogMessage("Start processing...", true);

                CopyCustomers(odb);
                StepFinished(progress += 2.75);

                CopyCategories(odb);
                StepFinished(progress += 0.24);

                CopySuppliers(odb);
                StepFinished(progress += 0.88);

                CopyShippers(odb);
                StepFinished(progress += 0.09);

                CopyRegions(odb, dataSet);
                StepFinished(progress += 0.12);

                CopyEmployees(odb);
                StepFinished(progress += 0.27);

                CopyCustomerDemographics(odb);
                CopyCustomerCustomerDemo(odb);
                
                CopyTerritories(odb);
                StepFinished(progress += 1.6);

                CopyEmployeeTerritories(odb);
                StepFinished(progress += 1.48);

                CopyProducts(odb);
                StepFinished(progress += 2.33);

                CopyOrders(odb, ref progress);
                
                CopyOrderDetails(odb, ref progress);

                LogMessage("Northwind database is ready: " + ndbFile + ".", true);
                LogMessage("Work is done, good job :)", true);
            }
            catch (Exception e)
            {
                LogMessage(e.ToString(), true);
            }
            finally
            {
                Terminate(odb, dataSet);
            }
        }
        private void GenerateNorthwindNDb()
        {
            const string ndbFile = "northwind.ndb";

            OdbFactory.Delete(ndbFile);

            var dataSet  = new NorthwindDataSet();
            var odb      = OdbFactory.Open(ndbFile);
            var progress = 0.0;

            try
            {
                LogMessage("Start processing...", true);

                CopyCustomers(odb);
                StepFinished(progress += 2.75);

                CopyCategories(odb);
                StepFinished(progress += 0.24);

                CopySuppliers(odb);
                StepFinished(progress += 0.88);

                CopyShippers(odb);
                StepFinished(progress += 0.09);

                CopyRegions(odb, dataSet);
                StepFinished(progress += 0.12);

                CopyEmployees(odb);
                StepFinished(progress += 0.27);

                CopyCustomerDemographics(odb);
                CopyCustomerCustomerDemo(odb);

                CopyTerritories(odb);
                StepFinished(progress += 1.6);

                CopyEmployeeTerritories(odb);
                StepFinished(progress += 1.48);

                CopyProducts(odb);
                StepFinished(progress += 2.33);

                CopyOrders(odb, ref progress);

                CopyOrderDetails(odb, ref progress);

                LogMessage("Northwind database is ready: " + ndbFile + ".", true);
                LogMessage("Work is done, good job :)", true);
            }
            catch (Exception e)
            {
                LogMessage(e.ToString(), true);
            }
            finally
            {
                Terminate(odb, dataSet);
            }
        }
Ejemplo n.º 7
0
        public Form3(NorthwindDataSet dataSet, bool dodavanjeForma, int id)
        {
            InitializeComponent();
            this.dataSet = dataSet;
            productsBindingSource.DataSource = this.dataSet;
            supplierBindingSource.DataSource = this.dataSet;
            categoryBindingSource.DataSource = this.dataSet;
            this.productID               = id;
            this.dodavanjeForma          = dodavanjeForma;
            productsBindingSource.Filter = "ProductID =" + this.productID;
            if (this.dodavanjeForma)
            {
                productIDTextBox.DataBindings.Clear();
                this.Text    = "Dodavanje";
                button1.Text = "Dodaj";
            }
            else
            {
                this.Text    = "Izmena";
                button1.Text = "Izmeni";

                productsBindingSource.MoveFirst();
                NorthwindDataSet.ProductsRow row = (NorthwindDataSet.ProductsRow)((DataRowView)productsBindingSource.Current).Row;
                int supplierID    = (int)row.SupplierID;
                int categoryID    = (int)row.CategoryID;
                int indexSupplier = supplierBindingSource.Find("SupplierID", supplierID);
                int indexCategory = categoryBindingSource.Find("CategoryID", categoryID);
                supplierIDComboBox.SelectedIndex = indexSupplier;
                categoryIDComboBox.SelectedIndex = indexCategory;
            }
        }
Ejemplo n.º 8
0
        public void CopyRegions(IOdb odb, NorthwindDataSet dataSet)
        {
            //Processing Regions
            LogMessage("Reading Regions...", false);
            var adapter1 = new RegionTableAdapter();
            var table1 = adapter1.GetData();
            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (var row in table1)
            {
                LogMessage("Regions: " + row.RegionID.ToString() + " ...", false);

                var r = new Region {RegionID = row.RegionID, RegionDescription = row.RegionDescription};

                odb.Store(r);
                LogMessage("saved", true);
            }
            odb.Commit();

            LogMessage("Commit done, starting create index ...", false);
            odb.IndexManagerFor<Region>().AddUniqueIndexOn("Region_RegionID_PK_index", Domain.Region.PK);
            odb.Commit();
            LogMessage(" index created.", true);

            long objectCount = NDbUtil.GetAllInstances<Region>(odb).Count;
            if (table1.Count == objectCount)
                LogMessage(table1.Count + " objects saved", true);
            else
                LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true);
            LogMessage("Done with Regions" + Environment.NewLine, true);
        }
Ejemplo n.º 9
0
 public Form4(NorthwindDataSet dataSet, int id)
 {
     InitializeComponent();
     this.dataSet = dataSet;
     this.id      = id;
     ordersBindingSource.Filter = "OrderID =" + this.id;
 }
Ejemplo n.º 10
0
        public override global::System.Data.DataSet Clone()
        {
            NorthwindDataSet cln = ((NorthwindDataSet)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Ejemplo n.º 11
0
        //---------------------------------------------------------------------
        void OtherSnips1()
        {
            //---------------------------------------------
            System.Data.SqlClient.SqlDataAdapter SqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
            System.Data.DataSet Dataset1 = new System.Data.DataSet();
            Dataset1.Tables.Add(new System.Data.DataTable("Table1"));

            //<Snippet26>
            try
            {
                SqlDataAdapter1.Update(Dataset1.Tables["Table1"]);
            }
            catch (Exception e)
            {
                // Error during Update, add code to locate error, reconcile
                // and try to update again.
            }
            //</Snippet26>


            //---------------------------------------------
            NorthwindDataSet northwindDataSet = new NorthwindDataSet();

            //<Snippet12>
            string xmlData = northwindDataSet.GetXml();
            //</Snippet12>

            //<Snippet13>
            string filePath = "ENTER A VALID FILEPATH";

            northwindDataSet.WriteXml(filePath);
            //</Snippet13>


            //---------------------------------------------
            //<Snippet15>
            NorthwindDataSetTableAdapters.RegionTableAdapter regionTableAdapter =
                new NorthwindDataSetTableAdapters.RegionTableAdapter();

            regionTableAdapter.Insert(5, "NorthWestern");
            //</Snippet15>


            //---------------------------------------------
            //<Snippet16>
            System.Data.SqlClient.SqlConnection sqlConnection1 =
                new System.Data.SqlClient.SqlConnection("YOUR CONNECTION STRING");

            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = "INSERT Region (RegionID, RegionDescription) VALUES (5, 'NorthWestern')";
            cmd.Connection  = sqlConnection1;

            sqlConnection1.Open();
            cmd.ExecuteNonQuery();
            sqlConnection1.Close();
            //</Snippet16>
        }
Ejemplo n.º 12
0
 public Form2(NorthwindDataSet dataSet, int categoryID, Form1 f1)
 {
     InitializeComponent();
     this.dataSet = dataSet;
     suppliersBindingSource.DataSource = this.dataSet;
     productsBindingSource.DataSource  = this.dataSet;
     this.f1         = f1;
     this.categoryID = categoryID;
 }
Ejemplo n.º 13
0
        public void Terminate(IOdb odb, NorthwindDataSet dataSet)
        {
            if (dataSet != null)
                dataSet.Dispose();

            if (odb == null)
                return;

            odb.Close();
        }
Ejemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var ds = new NorthwindDataSet();

            ds.ReadXml(Server.MapPath("~/App_data/veri.xml"));

            gv.DataSource = ds;
            gv.DataMember = "Customers";
            gv.DataBind();
        }
Ejemplo n.º 15
0
        //---------------------------------------------------------------------
        void Test2()
        {
            //<Snippet7>
            NorthwindDataSet northwindDataSet = new NorthwindDataSet();

            NorthwindDataSetTableAdapters.CustomersTableAdapter customersTableAdapter =
                new NorthwindDataSetTableAdapters.CustomersTableAdapter();

            customersTableAdapter.Fill(northwindDataSet.Customers);
            //</Snippet7>
        }
Ejemplo n.º 16
0
        private void ButtonGetCustomers_Click(object sender, EventArgs e)
        {
            NorthwindDataSet NorthwindDataset1 = new NorthwindDataSet();

            NorthwindDataSetTableAdapters.CustomersTableAdapter CustomersTableAdapter1 = new NorthwindDataSetTableAdapters.CustomersTableAdapter();
            CustomersTableAdapter1.Fill(NorthwindDataset1.Customers);
            foreach (NorthwindDataSet.CustomersRow NWCustomer in NorthwindDataset1.Customers.Rows)
            {
                ListBoxCustomers.Items.Add(NWCustomer.CompanyName);
            }
        }
Ejemplo n.º 17
0
        public MainWindow()
        {
            InitializeComponent();
            // Create a DataSet for the Customers data.
            this.nwDataSet = new NorthwindDataSet();
            this.nwDataSet.DataSetName = "nwDataSet";

            // Create a BindingSource for the Customers data.
            this.nwBindingSource = new System.Windows.Forms.BindingSource();
            this.nwBindingSource.DataMember = "Customers";
            this.nwBindingSource.DataSource = this.nwDataSet;
        }
Ejemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var ds = new NorthwindDataSet();

            using (var ta = new CustomersTableAdapter())
            {
                ta.Fill(ds.Customers);

                ds.WriteXml(Server.MapPath("~/App_data/veri.xml"),
                    System.Data.XmlWriteMode.WriteSchema);
            }
        }
Ejemplo n.º 19
0
        private void GetCustomersButton_Click(object sender, EventArgs e)
        {
            NorthwindDataSet northwindDataSet1 = new NorthwindDataSet();

            NorthwindDataSetTableAdapters.CustomersTableAdapter customersTableAdapter1 =
                new NorthwindDataSetTableAdapters.CustomersTableAdapter();
            customersTableAdapter1.Fill(northwindDataSet1.Customers);
            foreach (NorthwindDataSet.CustomersRow NWCustomer in northwindDataSet1.Customers.Rows)
            {
                CustomersListBox.Items.Add(NWCustomer.CompanyName);
            }
        }
Ejemplo n.º 20
0
        public MainWindow()
        {
            InitializeComponent();
            // Create a DataSet for the Customers data.
            this.nwDataSet             = new NorthwindDataSet();
            this.nwDataSet.DataSetName = "nwDataSet";

            // Create a BindingSource for the Customers data.
            this.nwBindingSource            = new System.Windows.Forms.BindingSource();
            this.nwBindingSource.DataMember = "Customers";
            this.nwBindingSource.DataSource = this.nwDataSet;
        }
Ejemplo n.º 21
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            NorthwindDataSet ds = new NorthwindDataSet();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
        public UserControlTabsGrid()
        {
            InitializeComponent();

            ds = new NorthwindDataSet();
            NorthwindDataSetTableAdapters.CustomersTableAdapter customerAdapter =
                new NorthwindDataSetTableAdapters.CustomersTableAdapter();

            //Populate adapter
            customerAdapter.Fill(ds.Customers);

            //Bind adapter to datagrid
            dataGrid1.ItemsSource = ds.Customers.DefaultView;
        }
Ejemplo n.º 23
0
        public MainWindow()
        {
            InitializeComponent();

            // Create a DataSet for the Customers data.
            _nwDataSet = new NorthwindDataSet {DataSetName = "nwDataSet"};

            // Create a BindingSource for the Customers data.
            _nwBindingSource = new BindingSource
            {
                DataMember = "Customers",
                DataSource = _nwDataSet
            };
        }
Ejemplo n.º 24
0
        public void Terminate(IOdb odb, NorthwindDataSet dataSet)
        {
            if (dataSet != null)
            {
                dataSet.Dispose();
            }

            if (odb == null)
            {
                return;
            }

            odb.Close();
        }
Ejemplo n.º 25
0
        public MainWindow()
        {
            InitializeComponent();

            // Create a DataSet for the Customers data.
            _nwDataSet = new NorthwindDataSet {
                DataSetName = "nwDataSet"
            };

            // Create a BindingSource for the Customers data.
            _nwBindingSource = new BindingSource
            {
                DataMember = "Customers",
                DataSource = _nwDataSet
            };
        }
Ejemplo n.º 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string connectionString = WebConfigurationManager.ConnectionStrings["NorthWind"].ConnectionString;
            SqlConnection con = new SqlConnection(connectionString);

            // Data
            string sqlProducts = "SELECT * FROM Products";
            string sqlCategories = "SELECT * FROM Categories";

            NorthwindDataSet ds = new NorthwindDataSet();

            // TO Fill the dataset

            SqlDataAdapter da = new SqlDataAdapter(sqlCategories, con);
            da.Fill(ds.Categories);

            da.SelectCommand.CommandText = sqlProducts;
            da.Fill(ds.Products);

            // to construct HTML string
            StringBuilder htmlStr = new StringBuilder("");
            foreach (NorthwindDataSet.CategoriesRow row in ds.Categories)
            {
                htmlStr.Append("<b>");
                htmlStr.Append(row.CategoryName);
                htmlStr.Append("</b><br /><i>");
                htmlStr.Append(row.Description);
                htmlStr.Append("</i><br />");

                // Get related product info
                // it uses the auxiliary methods GetChildRows()

                NorthwindDataSet.ProductsRow[] products = row.GetProductsRows();
                foreach (NorthwindDataSet.ProductsRow child in products)
                {
                    htmlStr.Append("<li>");
                    htmlStr.Append(child.ProductName);
                    htmlStr.Append("</li>");
                }

                htmlStr.Append("<br /><br />");
            }

            HtmlContent.Text = htmlStr.ToString();
        }
Ejemplo n.º 27
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            NorthwindDataSet      nwindDataSet          = new NorthwindDataSet();
            CustomersTableAdapter customersTableAdapter = new CustomersTableAdapter();

            customersTableAdapter.Fill(nwindDataSet.Customers);

            this.radMultiColumnComboBox1.DataSource = nwindDataSet.Customers;


            FilterDescriptor descriptor = new FilterDescriptor(this.radMultiColumnComboBox1.DisplayMember, FilterOperator.StartsWith, string.Empty);

            this.radMultiColumnComboBox1.EditorControl.FilterDescriptors.Add(descriptor);
            this.radMultiColumnComboBox1.DropDownStyle = RadDropDownStyle.DropDown;
            // Filtering END
        }
Ejemplo n.º 28
0
        private void LoadDataReport()
        {
            //Create the local report
            var report = new LocalReport
            {
                ReportEmbeddedResource = "RDLCDemo.ReportTest.rdlc"
            };

            //Create object
            var northWindDataSet = new NorthwindDataSet
            {
                DataSetName             = nameof(NorthwindDataSet),
                SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
            };

            var dataAdapter = new ProductsByCategoriesTableAdapter
            {
                ClearBeforeFill = true
            };

            var source = new BindingSource
            {
                DataMember = nameof(northWindDataSet.ProductsByCategories),
                DataSource = northWindDataSet
            };

            //Created datasource and binding source
            var dataSource = new ReportDataSource
            {
                Name  = "ProductsDataSources", //the datasource name in the RDLC report
                Value = source
            };

            //Add data source
            report.DataSources.Add(dataSource);

            //Fill Data in the dataset
            dataAdapter.Fill(northWindDataSet.ProductsByCategories);

            //Load in report viewer
            RDLCReportViewer.Report = new RDLCPrinter(report);
        }
Ejemplo n.º 29
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();
        }
Ejemplo n.º 30
0
        private void LoadDataReport()
        {
            //Create the local report
            LocalReport report = new LocalReport();

            report.ReportEmbeddedResource = "RDLCDemo.ReportTest.rdlc";


            //Create the dataset
            this._northWindDataSet = new NorthwindDataSet();
            this._dataAdapter      = new NorthwindDataSetTableAdapters.ProductsByCategoriesTableAdapter();

            this._northWindDataSet.DataSetName             = "NorthwindDataSet";
            this._northWindDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
            this._dataAdapter.ClearBeforeFill = true;

            //Created datasource and binding source
            ReportDataSource dataSource = new ReportDataSource();

            System.Windows.Forms.BindingSource source = new System.Windows.Forms.BindingSource();

            dataSource.Name   = "ProductsDataSources"; //the datasource name in the RDLC report
            dataSource.Value  = source;
            source.DataMember = "ProductsByCategories";
            source.DataSource = this._northWindDataSet;
            report.DataSources.Add(dataSource);


            //Fill Data in the dataset
            this._dataAdapter.Fill(this._northWindDataSet.ProductsByCategories);

            //Create the printer/export rdlc printer
            RDLCPrinter rdlcPrinter = new RDLCPrinter(report);

            rdlcPrinter.BeforeRefresh += rdlcPrinter_BeforeRefresh;

            //Load in report viewer
            ReportViewer.Report = rdlcPrinter;
        }
Ejemplo n.º 31
0
        public void CopyRegions(IOdb odb, NorthwindDataSet dataSet)
        {
            //Processing Regions
            LogMessage("Reading Regions...", false);
            var adapter1 = new RegionTableAdapter();
            var table1   = adapter1.GetData();

            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (var row in table1)
            {
                LogMessage("Regions: " + row.RegionID.ToString() + " ...", false);

                var r = new Region {
                    RegionID = row.RegionID, RegionDescription = row.RegionDescription
                };

                odb.Store(r);
                LogMessage("saved", true);
            }
            odb.Commit();

            LogMessage("Commit done, starting create index ...", false);
            odb.IndexManagerFor <Region>().AddUniqueIndexOn("Region_RegionID_PK_index", Domain.Region.PK);
            odb.Commit();
            LogMessage(" index created.", true);

            long objectCount = NDbUtil.GetAllInstances <Region>(odb).Count;

            if (table1.Count == objectCount)
            {
                LogMessage(table1.Count + " objects saved", true);
            }
            else
            {
                LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true);
            }
            LogMessage("Done with Regions" + Environment.NewLine, true);
        }
Ejemplo n.º 32
0
        public ViewModel()
        {
            // populate the data set
            var dataSet = new NorthwindDataSet();

            using (var customersAdp = new NorthwindDataSetTableAdapters.CustomersTableAdapter())
                using (var ordersAdp = new NorthwindDataSetTableAdapters.OrdersTableAdapter())
                {
                    customersAdp.Fill(dataSet.Customers);
                    ordersAdp.Fill(dataSet.Orders);
                }

            // populate your domain objects
            var customers = dataSet.Customers.ToArray().Select(cust => new Customer
            {
                Name   = cust.Company_Name,
                Orders = cust.GetOrdersRows().Select(order => new Order {
                    Id = order.Order_ID
                })
            });

            this.Customers = customers;

            // build the report
            StringBuilder report       = new StringBuilder();
            string        formatString = "{0,-30}|{1}";

            report.Append(string.Format(formatString, "Name", "Order Ids"));
            report.Append(Environment.NewLine);
            Customers.ToList().ForEach(cust => report.AppendLine(string.Format(
                                                                     formatString,
                                                                     cust.Name,
                                                                     string.Join(",", cust.Orders.Select(o => o.Id).ToArray()))
                                                                 ));

            // display the report
            Report = report.ToString();
        }
Ejemplo n.º 33
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            NorthwindDataSet      nwindDataSet          = new NorthwindDataSet();
            CustomersTableAdapter customersTableAdapter = new CustomersTableAdapter();

            customersTableAdapter.Fill(nwindDataSet.Customers);

            this.radMultiColumnComboBox1.DataSource = nwindDataSet.Customers;

            // Filtering START
            //FilterExpression filter = new FilterExpression(this.radMultiColumnComboBox1.DisplayMember, FilterExpression.BinaryOperation.AND,
            //    GridKnownFunction.StartsWith, GridFilterCellElement.ParameterName);

            //filter.Parameters.Add(GridFilterCellElement.ParameterName, string.Empty);

            //this.radMultiColumnComboBox1.EditorControl.MasterTemplate.FilterExpressions.Add(filter);

            this.radMultiColumnComboBox1.MultiColumnComboBoxElement.AutoCompleteMode = AutoCompleteMode.None;
            this.radMultiColumnComboBox1.DropDownStyle = RadDropDownStyle.DropDown;
            // Filtering END
        }
 public virtual int Update(NorthwindDataSet dataSet) {
     return this.Adapter.Update(dataSet, "Territories");
 }
 public virtual int Update(NorthwindDataSet dataSet) {
     return this.Adapter.Update(dataSet, "CustomerDemographics");
 }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     NorthwindDataSet ds = new NorthwindDataSet();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "EmployeesDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
 public virtual int Fill(NorthwindDataSet.Sales_by_YearDataTable dataTable, System.Nullable<System.DateTime> Beginning_Date, System.Nullable<System.DateTime> Ending_Date) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((Beginning_Date.HasValue == true)) {
         this.Adapter.SelectCommand.Parameters[1].Value = ((System.DateTime)(Beginning_Date.Value));
     }
     else {
         this.Adapter.SelectCommand.Parameters[1].Value = System.DBNull.Value;
     }
     if ((Ending_Date.HasValue == true)) {
         this.Adapter.SelectCommand.Parameters[2].Value = ((System.DateTime)(Ending_Date.Value));
     }
     else {
         this.Adapter.SelectCommand.Parameters[2].Value = System.DBNull.Value;
     }
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
 public virtual int Fill(NorthwindDataSet.SalesByCategoryDataTable dataTable, string CategoryName, string OrdYear) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((CategoryName == null)) {
         this.Adapter.SelectCommand.Parameters[1].Value = System.DBNull.Value;
     }
     else {
         this.Adapter.SelectCommand.Parameters[1].Value = ((string)(CategoryName));
     }
     if ((OrdYear == null)) {
         this.Adapter.SelectCommand.Parameters[2].Value = System.DBNull.Value;
     }
     else {
         this.Adapter.SelectCommand.Parameters[2].Value = ((string)(OrdYear));
     }
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
 public virtual int Update(NorthwindDataSet dataSet) {
     return this.Adapter.Update(dataSet, "Orders");
 }
 public virtual int Update(NorthwindDataSet.OrdersDataTable dataTable) {
     return this.Adapter.Update(dataTable);
 }
 public virtual int Fill(NorthwindDataSet.OrdersDataTable dataTable) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
 public virtual int Update(NorthwindDataSet.TerritoriesDataTable dataTable) {
     return this.Adapter.Update(dataTable);
 }
Ejemplo n.º 43
0
        public void Init()
        {
            if (File.Exists(DB4O_FILE))
                File.Delete(DB4O_FILE);
            ds = new NorthwindDataSet();
            container = Db4oFactory.OpenFile(Configuration(), DB4O_FILE);

            CopyCustomers();
            CopyCategories();
            CopySuppliers();
            CopyShippers();
            CopyRegions();
            CopyEmployees();
            CopyCustomerDemographics();
            CopyCustomerCustomerDemo();
            CopyTerritories();
            CopyEmployeeTerritories();
            CopyProducts();
            CopyOrders();
            CopyOrderDetails();
            Terminate();
        }
 public virtual int Fill(NorthwindDataSet.CustOrdersOrdersDataTable dataTable, string CustomerID) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((CustomerID == null)) {
         this.Adapter.SelectCommand.Parameters[1].Value = System.DBNull.Value;
     }
     else {
         this.Adapter.SelectCommand.Parameters[1].Value = ((string)(CustomerID));
     }
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
 private void DataRowFromBusinessObject(NorthwindDataSet.CustomersRow row, CustomerDataObject dataObject)
 {
     row.CustomerID = dataObject.ID;
     row.ContactName = dataObject.ContactName;
     row.CompanyName = dataObject.CompanyName;
 }
 public virtual int Fill(NorthwindDataSet.CustOrdersDetailDataTable dataTable, System.Nullable<int> OrderID) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((OrderID.HasValue == true)) {
         this.Adapter.SelectCommand.Parameters[1].Value = ((int)(OrderID.Value));
     }
     else {
         this.Adapter.SelectCommand.Parameters[1].Value = System.DBNull.Value;
     }
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
Ejemplo n.º 47
0
 void CustomersRowModified(object sender, NorthwindDataSet.CustomersRowChangeEvent e)
 {
     adapter.Update(NorthWindDataProvider.NorthwindDataSet.Customers);
 }
        string CreateMessage(NorthwindDataSet.ProductsRow cr)
        {

            return
                 "Database: " + GetRowData(GetCurrentRowInDB(cr), DataRowVersion.Default) + Environment.NewLine +
                 "Original: " + GetRowData(cr, DataRowVersion.Original) + Environment.NewLine +
                 "Proposed: " + GetRowData(cr, DataRowVersion.Current) + Environment.NewLine +
                 "Do you still want to update the database with the proposed value?";

        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     NorthwindDataSet ds = new NorthwindDataSet();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
        NorthwindDataSet.ProductsRow GetCurrentRowInDB(NorthwindDataSet.ProductsRow RowWithError)
        {

            TempProductsDataTable = new NorthwindDataSet.ProductsDataTable();
            this.productsTableAdapter1.Fill(TempProductsDataTable);

            NorthwindDataSet.ProductsRow currentRowInDb =
                 TempProductsDataTable.FindByProductID(RowWithError.ProductID);

            return currentRowInDb;

        }
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                NorthwindDataSet ds = new NorthwindDataSet();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "Report1TableDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
        //    //'--------------------------------------------------------------------------
        //    //' This method takes a productsRow and RowVersion 
        //    //' and returns a string of column values to display to the user.
        //    //'--------------------------------------------------------------------------
        string GetRowData(NorthwindDataSet.ProductsRow custRow, DataRowVersion RowVersion)
        {

            string rowData = "";

            for (int i = 0; i <= custRow.ItemArray.Length - 1; i++)
            {
                rowData += custRow[i, RowVersion].ToString() + " ";
            }


            return rowData;
        }
 public virtual int FillBy(NorthwindDataSet.CustomersDataTable dataTable, string customer) {
     this.Adapter.SelectCommand = this.CommandCollection[1];
     if ((customer == null)) {
         throw new System.ArgumentNullException("customer");
     }
     else {
         this.Adapter.SelectCommand.Parameters[0].Value = ((string)(customer));
     }
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
 public virtual int Fill(NorthwindDataSet.Products_Above_Average_PriceDataTable dataTable) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }