private void btnDeltaSync_Click(object sender, RoutedEventArgs e) { AccessQueries accquer = new AccessQueries(); //txtDBSyncStatus.Text = ""; DateTime end = DateTime.Now; DateTime start = new DateTime(); string gac = "", writedate = end.ToString("MM/dd/yyyy"), storenum = ""; string query = "SELECT TOP 1 * FROM app_config WHERE ukey = 'previous_sync'"; if (ss.IfExists(query)) { // if previuos_sync exists in database gac = ss.GetAppConfig("previous_sync"); } else { si.InsertAppConfig("previous_sync", writedate); gac = "02/01/2016"; } // converts string gac to DateTime start start = conv.ConvertToDate(gac, -7); if (cbStores.IsChecked.Value == true) { } if (cbEmployees.IsChecked.Value == true) { } if (cbCustomers.IsChecked.Value == true) { DataTable customers = new DataTable(); DataTable chargecustomers = new DataTable(); // TODO: Get Acct Balances to show up // Access Query => Field<decimal>("ACCTBAL") // Iterate throught he list and do the following: for (var dte = start; dte <= end; dte = dte.AddDays(1)) { // Check to see if customer exists in the table // Import Customers and ChargeCustomers by joindate from previous_import -> now. customers = accquer.ImportCustomers(dte.ToString()); foreach (DataRow row in customers.Rows) { } customers.Clear(); } } if (cbVendors.IsChecked.Value == true) { } if (cbCategories.IsChecked.Value == true) { } if (cbItems.IsChecked.Value == true) { DataTable items = new DataTable(); // Import items for (var dt = start; dt <= end; dt = dt.AddDays(1)) { items = accquer.GetItems(storenum, dt); foreach (DataRow row in items.Rows) { // look for new items where date received is today // input the information into the database } items.Clear(); } } if (cbTickets.IsChecked.Value == true) // Import tickets from date { DataTable tickets = new DataTable(); for (var dt = start; dt <= end; dt = dt.AddDays(1)) { tickets = accquer.GetTicketsByDate(dt.ToString("MM/dd/yyyy")); SyncTickets(tickets, dt.Date); tickets.Clear(); } } su.UpdateAppConfig("previous_sync", writedate); }
private void btnFullSync_Click(object sender, RoutedEventArgs e) { AccessQueries accquer = new AccessQueries(); //txtDBSyncStatus.Text = ""; if (cbStores.IsChecked.Value == true) { DataTable dt = new DataTable(); accquer.ImportDepartments(); //txtDBSyncStatus.Text += "Stores Imported...\n"; string addressid = "", departmentid = ""; foreach (DataRow row in dt.Rows) { // Insert into Address get ID addressid = si.InsertAddress("", "", "", "", "", "", "USA", "Imported from Access"); // Insert into Person get ID departmentid = si.InsertDepartment(row[0].ToString(), row[1].ToString(), addressid, "Imported from Access", "Active"); } try { dt.Clear(); } catch (Exception) { logging.writeToLog("Error: Clearing the results in Department of dataTable. "); } } if (cbEmployees.IsChecked.Value == true) { accquer.ImportEmployees(); // Import Employees //txtDBSyncStatus.Text += "Employees Imported...\n"; } if (cbCustomers.IsChecked.Value == true) { DataTable dt = new DataTable(); dt = accquer.ImportCustomers(); Customers(dt); //txtDBSyncStatus.Text += "Customers Imported...\n"; } if (cbVendors.IsChecked.Value == true) { DataTable dt = new DataTable(); eargs = eargs + "vendors "; //txtDBSyncStatus.Text += "Vendors Imported...\n"; // Import Vendors dt = accquer.ImportVendors(); VendorImport(dt); } if (cbCategories.IsChecked.Value == true) { //txtDBSyncStatus.Text += "Seasons Imported...\n"; //txtDBSyncStatus.Text += "Sizes Imported...\n"; //txtDBSyncStatus.Text += "Divisions Imported...\n"; // Import Divisions //txtDBSyncStatus.Text += "Classes Imported...\n"; // Import Classes // TODO: import categories } if (cbItems.IsChecked.Value == true) // Import Items { eargs = eargs + "items "; Items(); } if (cbTickets.IsChecked.Value == true) { DataTable tickets = new DataTable(); // Tickets => Date | TicketNumber | Total | Payment | Customer | Employee string date = dpTickets.SelectedDate.ToString(); DateTime start = DateTime.Now; DateTime end = DateTime.Now; start = conv.ConvertToDate(date); if (start.ToString("MM/dd/yyyy") == DateTime.Now.ToString("MM/dd/yyyy")) { start = start.AddMonths(-4); } for (var dte = start; dte <= end; dte = dte.AddDays(1)) { // Insert into tickets, ticket_items and ticket_payments tickets = accquer.GetTicketsByDate(dte.ToString("MM/dd/yyyy")); Tickets(tickets); tickets.Clear(); } PopUp pop = new PopUp("Tickets Imported.", "Tickets have finished importing."); pop.Show(); } //txtDBSyncStatus.Text += "Approvals Imported...\n"; //// Import Approvals //txtDBSyncStatus.Text += "Charge Customers Imported...\n"; //// Import Charge Customers. //txtDBSyncStatus.Text += "Cost Codes Imported...\n"; //// Import CostCode //txtDBSyncStatus.Text += "Credits Imported...\n"; //// Import Credits //txtDBSyncStatus.Text += "Orders Imported...\n"; //// Import Orders //txtDBSyncStatus.Text += "Sales Imported...\n"; //// Import Sales //txtDBSyncStatus.Text += "Tickets Imported...\n"; //// Import Tickets }