private async void AddDB(DataDB data, int companies, int customers, int flights, int tickets, int countries, int total) { await Task.Run(() => { data.AddCountriesToDB(countries); data.AddCompaniesToDB(companies); data.AddCustomersToDB(customers); data.AddFlightsToDB(flights); data.AddTicketsToDB(tickets); doWork = false; IsEnable = true; }); }
private void ExecuteReplaceCommand() { doWork = false; IsEnable = false; DataDB data = new DataDB(); data.DeleteDB(); IsEnable = true; BarValue = 0; Countriesmessage = "Data has been deleted!"; Customersmessage = ""; Companiesmessage = ""; Ticketsmessage = ""; Flightsmessage = ""; }
private void ExecuteAddCommand() { doWork = true; IsEnable = false; int total = 0; int _Companies = 0; int _Customers = 0; int _Flights = 0; int _Tickets = 0; int _Countries = 0; try { _Companies = Convert.ToInt32(Companies); _Customers = Convert.ToInt32(Customers); _Flights = Convert.ToInt32(Flights); _Tickets = Convert.ToInt32(Tickets); _Countries = Convert.ToInt32(Countries); total = _Companies + _Customers + _Flights * _Companies + _Tickets + _Countries; } catch (Exception) { } DataDB data = new DataDB(); Task t = Task.Run(() => { do { BarValue = data.GetCounter() * 100 / total; Countriesmessage = data.getMessegeCountries(_Countries); Companiesmessage = data.getMessegeCompanies(_Companies); Customersmessage = data.getMessegeCustomers(_Customers); Flightsmessage = data.getMessegeFlights(_Flights * _Companies); Ticketsmessage = data.getMessegeTickets(_Tickets); Thread.Sleep(1); } while (data.GetCounter() <= total && doWork); }); AddDB(data, _Companies, _Customers, _Flights, _Tickets, _Countries, total); }