Example #1
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);
        }
        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);
            }
        }
Example #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;
        }
Example #4
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 #5
0
        public void Terminate(IOdb odb, NorthwindDataSet dataSet)
        {
            if (dataSet != null)
                dataSet.Dispose();

            if (odb == null)
                return;

            odb.Close();
        }
        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();
        }
        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);
            }
        }
        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;
        }
Example #9
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
            };
        }
        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();
        }
Example #11
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();
        }
        NorthwindDataSet.ProductsRow GetCurrentRowInDB(NorthwindDataSet.ProductsRow RowWithError)
        {

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

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

            return currentRowInDb;

        }
        //    //'--------------------------------------------------------------------------
        //    //' 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 Update(NorthwindDataSet dataSet) {
     return this.Adapter.Update(dataSet, "CustomerDemographics");
 }
        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;
 }
 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 Update(NorthwindDataSet.OrdersDataTable dataTable) {
     return this.Adapter.Update(dataTable);
 }
 public virtual int Update(NorthwindDataSet dataSet) {
     return this.Adapter.Update(dataSet, "Orders");
 }
 public virtual int Update(NorthwindDataSet dataSet) {
     return this.Adapter.Update(dataSet, "Territories");
 }
 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 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;
 }
 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;
 }
 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 Update(NorthwindDataSet.TerritoriesDataTable dataTable) {
     return this.Adapter.Update(dataTable);
 }
 void CustomersRowModified(object sender, NorthwindDataSet.CustomersRowChangeEvent e)
 {
     adapter.Update(NorthWindDataProvider.NorthwindDataSet.Customers);
 }
 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 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.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;
 }