public CustomersCls insert(ArrayList ObjBaseModels) { bool _flag = true; CustomersCls ObjCustomers = (CustomersCls)ObjBaseModels[0]; try { CustomersDataSetTableAdapters.CustomersTableAdapter taCustomers = new CustomersTableAdapter(); // if not custoemr loaded if (ObjCustomers.CustomerID == 0) { } else { taCustomers.UpdateCustomerByID(ObjCustomers.CustomerID); } return(ObjCustomers); } catch (Exception exp) { string a = exp.Message; _flag = false; } if (_flag) { ObjCustomers = null; // perhaps not? } return(ObjCustomers); }
public CustomerDataAccessLayer() { NorthwindDataSet dataset = NorthWindDataProvider.NorthwindDataSet; // populate the typed data set adapter = new CustomersTableAdapter(); adapter.Fill(NorthWindDataProvider.NorthwindDataSet.Customers); }
private void Form1_Load(object sender, EventArgs e) { var ds = new Data.InvoicesDataSet(); var ta = new CustomersTableAdapter(); ta.Fill(ds.Customers); dgCustomers.DataSource = ds.Customers; }
public CustomerDataProvider() { NorthwindDataSet dataset = NorthWindDataProvider.NorthwindDataSet; adapter = new CustomersTableAdapter(); adapter.Fill(NorthWindDataProvider.NorthwindDataSet.Customers); dataset.Customers.CustomersRowChanged += new NorthwindDataSet.CustomersRowChangeEventHandler(CustomersRowModified); dataset.Customers.CustomersRowDeleted += new NorthwindDataSet.CustomersRowChangeEventHandler(CustomersRowModified); }
public bool GetCustomers(out DataTable table) { table = null; if (_paymentClient.isPayed(_serviceId, _company)) { var adapter = new CustomersTableAdapter(); table = adapter.GetCustomers(); return(true); } return(false); }
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); } }
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(); }
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"]; }
private void CopyCustomers(IOdb odb) { //Processing Customers LogMessage("Reading Customers...", false); var adapter1 = new CustomersTableAdapter(); var table1 = adapter1.GetData(); LogMessage("processing " + table1.Count.ToString() + " rows", true); foreach (var row in table1) { LogMessage("Customer: " + row.CustomerID + " ...", false); var c = new Customer { CustomerID = row.CustomerID, CompanyName = row.CompanyName, ContactName = row.IsContactNameNull() ? null : row.ContactName, ContactTitle = row.IsContactTitleNull() ? null : row.ContactTitle, Address = row.IsAddressNull() ? null : row.Address, City = row.IsCityNull() ? null : row.City, Region = row.IsRegionNull() ? null : row.Region, PostalCode = row.IsPostalCodeNull() ? null : row.PostalCode, Country = row.IsCountryNull() ? null : row.Country, Phone = row.IsPhoneNull() ? null : row.Phone, Fax = row.IsFaxNull() ? null : row.Fax }; odb.Store(c); LogMessage("saved", true); } odb.Commit(); LogMessage("Commit done, starting create index ...", false); odb.IndexManagerFor <Customer>().AddUniqueIndexOn("Customer_CustomerID_PK_index", Customer.PK); odb.Commit(); LogMessage(" index created.", true); long objectCount = NDbUtil.GetAllInstances <Customer>(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 Customers" + Environment.NewLine, true); }
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(); }
static void Main(string[] args) { var customersTableAdapter = new CustomersTableAdapter(); var customers = customersTableAdapter.GetData(); //creates a customersdatatable foreach (DataRow row in customers.Rows) { foreach (DataColumn column in customers.Columns) { Console.WriteLine($"{column.ColumnName}: {row[column]}"); } Console.WriteLine(); } Console.ReadKey(); }
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); } }
static void Main(string[] args) { var shopDB = new ShopDb(); var customersTableAdapter = new CustomersTableAdapter(); customersTableAdapter.Fill(shopDB.Customers); //this will fill shopdb.customers table with data, so easy! foreach (DataRow row in shopDB.Customers.Rows) { foreach (DataColumn column in shopDB.Customers.Columns) { Console.WriteLine($"{column.ColumnName}: {row[column]}"); } Console.WriteLine(); } Console.ReadKey(); }
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 }
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; }
static void Main(string[] args) { var customers = new ShopDB.CustomersDataTable(); var customersTableAdapter = new CustomersTableAdapter(); customersTableAdapter.ClearBeforeFill = true; customersTableAdapter.Insert("test", "test", "test", "test", "test", "test", "test", new DateTime(9999 / 12 / 31)); //var insertedRowNumber = customersTableAdapter.Insert("test", "test", "test", "test", "test", "test", "test", new DateTime(9999 / 12 / 31)); customers = customersTableAdapter.GetData(); DataRow[] testRows = customers.Select("Phone='test'"); foreach (DataRow testRow in testRows) { foreach (DataColumn column in customers.Columns) { Console.WriteLine($"{column.ColumnName}: {testRow[column]}"); } Console.WriteLine(); } //now we're going to delete rows with test phone numbers Console.WriteLine(new string('*', 30)); Console.WriteLine($"Total test row(s) deleted: {DeleteTestRows()}"); //customersTableAdapter.Delete(insertedRowNumber); //doesn't work with sole int customers = customersTableAdapter.GetData(); testRows = customers.Select("Phone = 'test'"); foreach (DataRow testRow in testRows) { foreach (DataColumn column in customers.Columns) { Console.WriteLine($"{column.ColumnName}: {testRow[column]}"); } } Console.ReadKey(); }
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 }
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); }
private void CopyCustomers(IOdb odb) { //Processing Customers LogMessage("Reading Customers...", false); var adapter1 = new CustomersTableAdapter(); var table1 = adapter1.GetData(); LogMessage("processing " + table1.Count.ToString() + " rows", true); foreach (var row in table1) { LogMessage("Customer: " + row.CustomerID + " ...", false); var c = new Customer { CustomerID = row.CustomerID, CompanyName = row.CompanyName, ContactName = row.IsContactNameNull() ? null : row.ContactName, ContactTitle = row.IsContactTitleNull() ? null : row.ContactTitle, Address = row.IsAddressNull() ? null : row.Address, City = row.IsCityNull() ? null : row.City, Region = row.IsRegionNull() ? null : row.Region, PostalCode = row.IsPostalCodeNull() ? null : row.PostalCode, Country = row.IsCountryNull() ? null : row.Country, Phone = row.IsPhoneNull() ? null : row.Phone, Fax = row.IsFaxNull() ? null : row.Fax }; odb.Store(c); LogMessage("saved", true); } odb.Commit(); LogMessage("Commit done, starting create index ...", false); odb.IndexManagerFor<Customer>().AddUniqueIndexOn("Customer_CustomerID_PK_index", Customer.PK); odb.Commit(); LogMessage(" index created.", true); long objectCount = NDbUtil.GetAllInstances<Customer>(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 Customers" + Environment.NewLine, true); }
private void btnCheckIn_Click(object sender, EventArgs e) { if (!this.customerDetailPanel.ValidateChildren()) { tabControl1.SelectedIndex = 0; return; } if (this.roomDetailPanel.cbxRoomNO.SelectedItem == null) { MessageBox.Show("คุณยังไม่ได้เลือกห้องพัก", "คุณยังไม่ได้เลือกห้องพัก", MessageBoxButtons.OK, MessageBoxIcon.Information); tabControl1.SelectedIndex = 1; return; } double amountRoom = 0; double roomPrices = Convert.ToDouble(((DataRowView)this.roomDetailPanel.fKRoomTypesCustomerTypesBindingSource.Current).Row["Prices"]); if (Convert.ToInt32(this.roomDetailPanel.cbxCustomerType.SelectedValue) == 1) { int days = this.roomDetailPanel.dtpEndStay.Value.Subtract(this.roomDetailPanel.dtpStarStay.Value).Days; if (days < 30) { amountRoom = (roomPrices / 30) * days; Console.WriteLine("รายเดือน " + amountRoom + " " + days); } } else if (Convert.ToInt32(this.roomDetailPanel.cbxCustomerType.SelectedValue) == 2) { int days = this.roomDetailPanel.dtpEndStay.Value.Subtract(this.roomDetailPanel.dtpStarStay.Value).Days; amountRoom = roomPrices * days; Console.WriteLine("รายวัน " + amountRoom + " " + days); } try { CustomersTableAdapter customerTableAdapter = new CustomersTableAdapter(); customerTableAdapter.Insert( this.customerDetailPanel.tbxPeopleID.Text, this.customerDetailPanel.tbxFirstname.Text, this.customerDetailPanel.tbxLastname.Text, Convert.ToByte(this.customerDetailPanel.cbxSex.SelectedIndex), this.customerDetailPanel.dtpBirthDay.Value, this.customerDetailPanel.tbxAddress.Text, this.customerDetailPanel.tbxSubDistrict.Text, this.customerDetailPanel.tbxDistrict.Text, this.customerDetailPanel.cbxProvince.SelectedItem.ToString(), this.customerDetailPanel.cbxCountry.SelectedItem.ToString(), this.customerDetailPanel.tbxTelephone.Text, this.customerDetailPanel.tbxMobile.Text, this.customerDetailPanel.tbxEmail.Text); CustomerTypesTableAdapter customerTypesTableAdapter = new CustomerTypesTableAdapter(); RoomTypesTableAdapter roomTypesTableAdapter = new RoomTypesTableAdapter(); CheckInsTableAdapter checkInsTableAdapter = new CheckInsTableAdapter(); RoomsTableAdapter roomsTableAdapter = new RoomsTableAdapter(); int customerID = Convert.ToInt32(customerTableAdapter.GetMaxID()); if (BookingID == 0) { checkInsTableAdapter.Insert( customerID, Convert.ToInt32(roomDetailPanel.cbxCustomerType.SelectedValue), customerTypesTableAdapter.GetCustomerTypeName(Convert.ToInt32(roomDetailPanel.cbxCustomerType.SelectedValue)), Convert.ToInt32(roomDetailPanel.cbxRoomType.SelectedValue), roomTypesTableAdapter.GetRoomTypeName(Convert.ToInt32(roomDetailPanel.cbxRoomType.SelectedValue)), Convert.ToInt32(this.roomDetailPanel.roomsTableAdapter.GetRoomID(((DataRowView)roomDetailPanel.fKRoomsRoomTypesBindingSource.Current).Row["NO"].ToString())), ((DataRowView)roomDetailPanel.fKRoomsRoomTypesBindingSource.Current).Row["NO"].ToString(), roomPrices, roomDetailPanel.dtpStarStay.Value, roomDetailPanel.dtpEndStay.Value, roomDetailPanel.tbxDescription.Text, MainUI.StaffID, null, DateTime.Now, null, 0); } else { checkInsTableAdapter.Insert( customerID, Convert.ToInt32(roomDetailPanel.cbxCustomerType.SelectedValue), customerTypesTableAdapter.GetCustomerTypeName(Convert.ToInt32(roomDetailPanel.cbxCustomerType.SelectedValue)), Convert.ToInt32(roomDetailPanel.cbxRoomType.SelectedValue), roomTypesTableAdapter.GetRoomTypeName(Convert.ToInt32(roomDetailPanel.cbxRoomType.SelectedValue)), Convert.ToInt32(this.roomDetailPanel.roomsTableAdapter.GetRoomID(((DataRowView)roomDetailPanel.fKRoomsRoomTypesBindingSource.Current).Row["NO"].ToString())), ((DataRowView)roomDetailPanel.fKRoomsRoomTypesBindingSource.Current).Row["NO"].ToString(), roomPrices, roomDetailPanel.dtpStarStay.Value, roomDetailPanel.dtpEndStay.Value, roomDetailPanel.tbxDescription.Text, MainUI.StaffID, BookingID, DateTime.Now, null, 0); } PaymentsTableAdapter paymentsTableAdapter = new PaymentsTableAdapter(); int checKInID = Convert.ToInt32(checkInsTableAdapter.GetMaxID()); paymentsTableAdapter.Insert( checKInID, this.roomDetailPanel.dtpStarStay.Value, this.roomDetailPanel.dtpEndStay.Value, (int)amountRoom, 0, (int)amountRoom, null, 0, null, null); MessageBox.Show("เช็คอินเสร็จสมบูรณ์", "เสร็จสมบูรณ์", MessageBoxButtons.OK, MessageBoxIcon.Information); //เปิดหน้าชำระเงิน PaymentDetailUI payment = new PaymentDetailUI(); payment.PaymentID = Convert.ToInt32(paymentsTableAdapter.GetMaxID()); payment.ShowDialog(); this.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); MessageBox.Show("ไม่สามารถเช็คอินได้, กรุณาลองใหม่อีกครั้ง ", "ข้อผิดผลาด", MessageBoxButtons.OK, MessageBoxIcon.Warning); DialogResult = System.Windows.Forms.DialogResult.No; } }
/// <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}"); } }
public void CopyCustomers() { //Processing Customers LogMessage("Reading Customers...", false); CustomersTableAdapter adapter1 = new CustomersTableAdapter(); NorthwindDb4o.NorthwindDataSet.CustomersDataTable table1 = adapter1.GetData(); LogMessage("processing " + table1.Count.ToString() + " rows", true); foreach (NorthwindDb4o.NorthwindDataSet.CustomersRow row in table1) { LogMessage("Customer: " + row.CustomerID.ToString() + " ...", false); Customer c = new Customer(); c.CustomerID = row.CustomerID; c.CompanyName = row.CompanyName; c.ContactName = row.IsContactNameNull() ? null : row.ContactName; c.ContactTitle = row.IsContactTitleNull() ? null : row.ContactTitle; c.Address = row.IsAddressNull() ? null : row.Address; c.City = row.IsCityNull() ? null : row.City; c.Region = row.IsRegionNull() ? null : row.Region; c.PostalCode = row.IsPostalCodeNull() ? null : row.PostalCode; c.Country = row.IsCountryNull() ? null : row.Country; c.Phone = row.IsPhoneNull() ? null : row.Phone; c.Fax = row.IsFaxNull() ? null : row.Fax; container.Store(c); LogMessage("saved", true); } container.Commit(); long objectCount = Db4oUtil.GetAllInstances(container, typeof(Customer)).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 Customers" + Environment.NewLine, true); }