Пример #1
0
        public List <OrderBLL> GetAllOrders()
        {
            adpOrder.Fill(tblOrders);
            listOrders = null;
            if (tblOrders.Count > 0)

            {
                //this list will be used to fill data in the grid view of cart
                listOrders = new List <OrderBLL>();

                foreach (var row in tblOrders)
                {
                    OrderBLL order = new OrderBLL();
                    order.OrderId = row.OrderID;
                    order.ItemId  = row.ItemID;
                    //order.CustomerId = row.CustID;
                    order.shippedAddr = row.ShippingAddress;
                    order.Price       = row.Price;
                    order.Shipped     = row.Shipped;
                    listOrders.Add(order);
                }
            }

            return(listOrders);
        }
        private void Report_Load(object sender, EventArgs e)
        {
            productsTableAdapter.Fill(NorthwindDataSet.Products);
            employeesTableAdapter.Fill(NorthwindDataSet.Employees);
            customersTableAdapter.Fill(NorthwindDataSet.Customers);
            OrdersTableAdapter.Fill(NorthwindDataSet.Orders);

            var q = from em in NorthwindDataSet.Employees
                    where em.EmployeeID == Convert.ToInt32(id)
                    select new
            {
                firstName = em.FirstName,
                lastName  = em.LastName
            };

            foreach (var i in q)
            {
                employee.Add(i.firstName);
                employee.Add(i.lastName);
            }

            ReportParameterCollection reportParameters = new ReportParameterCollection();

            reportParameters.Add(new ReportParameter("parameterFirstName", employee[0]));
            reportParameters.Add(new ReportParameter("parameterLastName", employee[1]));
            reportViewer1.LocalReport.SetParameters(reportParameters);

            da.Fill(ds.Tables["Orders"]);
            cb_OrderDetails.DataSource    = bs;
            cb_OrderDetails.DisplayMember = "OrderID";

            Order_DetailsTableAdapter.Fill(NorthwindDataSet.Order_Details);
            Order_Details_fill_name();
        }
Пример #3
0
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            // Fill the Customers table adapter with data.
            _customersTableAdapter.ClearBeforeFill = true;
            _customersTableAdapter.Fill(_nwDataSet.Customers);

            // Fill the Orders table adapter with data.
            _ordersTableAdapter.Fill(_nwDataSet.Orders);

            // Assign the BindingSource to
            // the data context of the main grid.
            mainGrid.DataContext = _nwBindingSource;

            // Assign the BindingSource to
            // the data source of the list box.
            listBox1.ItemsSource = _nwBindingSource;

            // Because this is a master/details form, the DataGridView
            // requires the foreign key relating the tables.
            dataGridView1.DataSource = _nwBindingSource;
            dataGridView1.DataMember = "FK_Orders_Customers";

            // Handle the currency management aspect of the data models.
            // Attach an event handler to detect when the current item
            // changes via the WPF ListBox. This event handler synchronizes
            // the list collection with the BindingSource.
            //

            var cv = CollectionViewSource.GetDefaultView(
                _nwBindingSource) as BindingListCollectionView;

            cv.CurrentChanged += WPF_CurrentChanged;
        }
        public DatabaseOps()
        {
            InitializeComponent();

            custAdap.Fill(aset.Customers);
            ordAdap.Fill(aset.Orders);
            ord_det_extAdap.Fill(aset.Order_Details_Extended);
            Grid1.DataContext = aset.Customers;
        }
Пример #5
0
        public StronglyTypedDataSetWindowsFormsDesignerMainForm()
        {
            InitializeComponent();

            // fill the datatables from the database

            inventoryTableAdapter.Fill(inventoryTable);
            customersTableAdapter.Fill(customersTable);
            ordersTableAdapter.Fill(ordersTable);

            // initialize the controls

            InitializeDataGridView(dataGridViewInventory, inventoryTable);
            InitializeDataGridView(dataGridViewCustomers, customersTable);
            InitializeDataGridView(dataGridViewOrders, ordersTable);

            // set the button event handler

            buttonUpdate.Click += ButtonUpdate_Click;
        }
Пример #6
0
        void InitializeDataSources()
        {
            var dataSource = new DataSet1();
            var connection = new OleDbConnection();

            connection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\nwind.mdb";

            EmployeesTableAdapter employees = new EmployeesTableAdapter();

            employees.Connection = connection;
            employees.Fill(dataSource.Employees);

            CustomersTableAdapter customers = new CustomersTableAdapter();

            customers.Connection = connection;
            customers.Fill(dataSource.Customers);

            EmployeeCustomersTableAdapter employeeCustomers = new EmployeeCustomersTableAdapter();

            employeeCustomers.Connection = connection;
            employeeCustomers.Fill(dataSource.EmployeeCustomers);

            OrdersTableAdapter orders = new OrdersTableAdapter();

            orders.Connection = connection;
            orders.Fill(dataSource.Orders);

            Order_DetailsTableAdapter orderDetails = new Order_DetailsTableAdapter();

            orderDetails.Connection = connection;
            orderDetails.Fill(dataSource.Order_Details);

            SnapDocument document = snapControl1.Document;

            document.BeginUpdateDataSource();

            var employeesBinding = new BindingSource()
            {
                DataSource = dataSource, DataMember = employeeDataSourceName
            };

            document.DataSources.Add(new DataSourceInfo(employeeDataSourceName, employeesBinding));

            var customersBinding = new BindingSource()
            {
                DataSource = dataSource, DataMember = customerDataSourceName
            };

            document.DataSources.Add(new DataSourceInfo(customerDataSourceName, customersBinding));

            document.EndUpdateDataSource();
        }
Пример #7
0
        private void downloadData(string customerID)
        {
            DataSet1 myData = new DataSet1();
            CustomersTableAdapter customersTableAdapter = new CustomersTableAdapter();
            OrdersTableAdapter ordersTableAdapter = new OrdersTableAdapter();

            customersTableAdapter.Fill(myData.Customers, customerID);
            ordersTableAdapter.Fill(myData.Orders, customerID);

            dataGridView1.DataSource = myData.Tables["Customers"];
            dataGridView2.DataSource = myData.Tables["Orders"];

        }
        public DatabaseOps()
        {
            InitializeComponent();
            custAdap.Fill(aset.Customers);
            ordAdap.Fill(aset.Orders);
            ord_det_extAdap.Fill(aset.Order_Details_Extended);
            Grid1.DataContext = aset.Customers;

            ICollectionView aView;

            aView = CollectionViewSource.GetDefaultView(aset.Customers);
            aView.GroupDescriptions.Add(new PropertyGroupDescription("Country", new CountryGrouper()));

            aView.SortDescriptions.Add(new SortDescription("Country", ListSortDirection.Ascending));
        }
Пример #9
0
    protected void PobierzDaneZamowienia(string idKlienta)
    {
        DataSet mojZbiorDanych             = new DataSet();
        CustomersTableAdapter klientDA     = new CustomersTableAdapter();
        OrdersTableAdapter    zamowieniaDA = new OrdersTableAdapter();

        klientDA.Fill(mojZbiorDanych.Customers, idKlienta);
        zamowieniaDA.Fill(mojZbiorDanych.Orders, idKlienta);

        GridView1.DataSource = mojZbiorDanych.Tables["Customers"];
        GridView1.DataBind();

        GridView2.DataSource = mojZbiorDanych.Tables["Orders"];
        GridView2.DataBind();
    }
Пример #10
0
        public MainForm()
        {
            InitializeComponent();

            // Get Adapters.
            invTableAdapter    = new InventoryTableAdapter();
            custTableAdapter   = new CustomersTableAdapter();
            ordersTableAdapter = new OrdersTableAdapter();

            // Add tables to DS.
            invTableAdapter.Fill(autoLotDS.Inventory);
            custTableAdapter.Fill(autoLotDS.Customers);
            ordersTableAdapter.Fill(autoLotDS.Orders);

            // Bind to grids
            dataGridViewInventory.DataSource = autoLotDS.Inventory;
            dataGridViewCustomers.DataSource = autoLotDS.Customers;
            dataGridViewOrders.DataSource    = autoLotDS.Orders;
        }
Пример #11
0
        //</Snippet5>

        //<Snippet6>
        private void PopulateSalesOrderInfo()
        {
            String[] tempArray = comboBox1.Text.Split(new Char[] { '|' });
            menu1.Items.Clear();

            orderTable        = nwDataSet.Orders;
            orderDetailsTable = nwDataSet.Order_Details;
            productsTable     = nwDataSet.Products;

            ordersTableAdapter.Fill(orderTable);
            detailsTableAdapter.Fill(orderDetailsTable);
            productsTableAdapter.Fill(productsTable);

            var orderQuery = from orders in orderTable.AsEnumerable()
                             where orders.Field <string>("Customer ID") == tempArray[1]
                             select new { OrderID = orders.Field <int>("Order ID") };

            foreach (var orderItem in orderQuery)
            {
                menu1.Items.Add(CreateRibbonMenu());

                RibbonMenu orderMenu = (RibbonMenu)menu1.Items.Last();
                orderMenu.Dynamic = true;
                orderMenu.Label   = orderItem.OrderID.ToString();
                orderMenu.Tag     = orderItem.OrderID;

                var productQuery = from orderDetail in orderDetailsTable.AsEnumerable()
                                   join product in productsTable.AsEnumerable() on
                                   orderDetail.Field <int>("Product ID")
                                   equals product.Field <int>("Product ID")
                                       where orderDetail.Field <int>("Order ID") ==
                                   orderItem.OrderID
                                   select new { ProductName = product.Field <string>("Product Name") };

                foreach (var productItem in productQuery)
                {
                    RibbonButton button = CreateRibbonButton();
                    button.Label = productItem.ProductName;
                    orderMenu.Items.Add(button);
                }
            }
        }
 protected void SubmitOrder()
 {
     if (IsNotNull(txtBoxStreetName.Text) == true &&
         IsNotNull(TxtBoxUnit.Text) == true &&
         IsNotNull(TxtBoxPostal.Text) == true)
     {
         string spiceOption = "";
         foreach (ListItem o in CheckBoxSpice.Items)
         {
             if (o.Selected)
             {
                 spiceOption += " " + o.Value.ToString();
             }
         }
         OrdersTableAdapter orderta = new OrdersTableAdapter();
         orderta.Fill(ds.Orders);
         try
         {
             DataRow dr = ds.Orders.NewRow();
             dr["orderUser"]        = userName;
             dr["orderDate"]        = DateTime.Now;
             dr["orderDish"]        = DdlFoodChoice.SelectedItem.ToString();
             dr["orderSize"]        = DddlSizeOption.SelectedItem.ToString();
             dr["orderSpices"]      = spiceOption;
             dr["deliveryLocation"] = txtBoxStreetName.Text + " " + TxtBoxUnit.Text + " Postal Code " + TxtBoxPostal.Text;
             dr["orderStatus"]      = "Pending";
             ds.Tables["Orders"].Rows.Add(dr);
             orderta.Update(ds.Orders);
             LabelStatus.Text = "Order Submitted Successfully";
             ClearForm();
         }
         catch (Exception ex)
         {
             LabelStatus.Text = ex.ToString();
         }
     }
     else
     {
         LabelStatus.Text = "Error! Please enter the information for all fields.";
     }
 }
Пример #13
0
        /*
         * Function get_data()
         * Fills database tables using DataSet.
         */
        private void get_data()
        {
            ds   = new DataSet1();
            mt   = new MenuTableAdapter();
            it   = new InventoryTableAdapter();
            et   = new EmployeesTableAdapter();
            ot   = new OrdersTableAdapter();
            olt  = new OrderlineTableAdapter();
            st   = new SuppliersTableAdapter();
            pot  = new PurchaseOrdersTableAdapter();
            polt = new PurchaseOrderlineTableAdapter();

            mt.Fill(ds.Menu);
            it.Fill(ds.Inventory);
            et.Fill(ds.Employees);
            ot.Fill(ds.Orders);
            olt.Fill(ds.Orderline);
            st.Fill(ds.Suppliers);
            pot.Fill(ds.PurchaseOrders);
            polt.Fill(ds.PurchaseOrderline);
        }
        private static object CreateDataSource()
        {
            var dataSource = new nwindDataSet();
            var connection = new OleDbConnection();

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

            CustomersTableAdapter customers = new CustomersTableAdapter();

            customers.Connection = connection;
            customers.Fill(dataSource.Customers);

            OrdersTableAdapter orders = new OrdersTableAdapter();

            orders.Connection = connection;
            orders.Fill(dataSource.Orders);

            var bindingSource = new BindingSource();

            bindingSource.DataSource = dataSource;
            bindingSource.DataMember = "Customers";
            return(bindingSource);
        }
Пример #15
0
        public Example()

        {
            InitializeComponent();

            NWindDataSet dataSet = new
                                   NWindDataSet();

            OrdersTableAdapter ordersAdapter =
                new OrdersTableAdapter();

            ordersAdapter.Fill(dataSet.Orders);

            Order_DetailsTableAdapter detailAdapter
                = new Order_DetailsTableAdapter();

            detailAdapter.Fill(dataSet.Order_Details);

            radGridView1.AutoGenerateHierarchyFromDataSet = true;

            radGridView1.DataMember = dataSet.Tables["Orders"].TableName;

            radGridView1.ItemsSource = dataSet;
        }
        public OrdersDataProvider()
        {
            NorthwindDataSet dataset = NorthWindDataProvider.NorthwindDataSet;

            adapter = new OrdersTableAdapter();
            adapter.Fill(dataset.Orders);

            AddRowChangeHandlers();
        }
        /// <summary>
        /// Display inventory, customers, and orders report.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OutputForm_Load(object sender, EventArgs e)
        {
            // Create new strongly typed datatables, and associated table adapters.

            var inventoryTable = new AutoLotDataSet.InventoryDataTable();
            var ordersTable    = new AutoLotDataSet.OrdersDataTable();
            var customersTable = new AutoLotDataSet.CustomersDataTable();

            InventoryTableAdapter inventoryAdapter = new InventoryTableAdapter();
            CustomersTableAdapter customersAdapter = new CustomersTableAdapter();
            OrdersTableAdapter    ordersAdapter    = new OrdersTableAdapter();

            // now fill the tables with data

            inventoryAdapter.Fill(inventoryTable);
            customersAdapter.Fill(customersTable);
            ordersAdapter.Fill(ordersTable);

            // display all of the cars from inventory

            textBoxOutput.AppendText($"Inventory Count = {inventoryTable.Count()}{Environment.NewLine}");

            foreach (var car in inventoryTable)
            {
                textBoxOutput.AppendText($"{car.CarId} {car.Make} {car.Color} {car.Name}{Environment.NewLine}");
            }


            // display  only cars with Id < 5

            var carsQuery =
                from car in inventoryTable
                where car.CarId < 5
                select car;

            textBoxOutput.AppendText($"{Environment.NewLine}LINQ result CarId < 5{Environment.NewLine}");

            foreach (var car in carsQuery)
            {
                textBoxOutput.AppendText($"{car.CarId} {car.Make} {car.Color} {car.Name}{Environment.NewLine}");
            }

            // display all orders, and show customer first and last name

            var ordersQuery =
                from order in ordersTable
                from car in inventoryTable
                from customer in customersTable
                where order.CustId == customer.CustId
                where order.CarId == car.CarId
                select new
            {
                order.OrderId,
                car.CarId,      // note use of implicit names for new anon object
                car.Name,
                car.Make,
                CustomerId   = customer.CustId,
                CustomerName = customer.FirstName + " " + customer.LastName,
            };

            textBoxOutput.AppendText($"{Environment.NewLine}Orders Count = {ordersQuery.Count()}{Environment.NewLine}");
            foreach (var order in ordersQuery)
            {
                textBoxOutput.AppendText($"#{order.OrderId} {order.CarId} {order.Make} {order.Name} by {order.CustomerId} {order.CustomerName}{Environment.NewLine}");
            }
        }