public async Task CreateDatabaseAsync() { CreateDatatableStrings str = new CreateDatatableStrings(); sqlexec.SQLCommandKey(Properties.Settings.Default.DBName, str.FOREIGN_KEY(0)); //await SQLCommand(Properties.Settings.Default.DBName, str.FOREIGN_KEY(0)); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.PersonType()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.Person()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.Taxi()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.Expense()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.Income()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.TypeExpense()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.TypeIncome()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.TaxiPayment()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.PrimaryDriver()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.Kilometer()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.Shift()); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, str.Depth()); //await SQLCommand(Properties.Settings.Default.DBName, str.FOREIGN_KEY(1)); sqlexec.SQLCommandKey(Properties.Settings.Default.DBName, str.FOREIGN_KEY(1)); }
private async void CreateDatabase2(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Sure", "Title", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.No) { return; } int index = 20; CreateDatatableStrings str = new CreateDatatableStrings(); //System.Threading.Thread.Sleep(1000); sqlexec.SQLCommandKey(Properties.Settings.Default.DBName, str.FOREIGN_KEY(0)); for (int i = 1; i <= index; i++) { this.elementHost1.Child = new WPFControll("Repetition number : " + i.ToString(), $"Go to {index}"); await FillFakeDatabase(i); } sqlexec.SQLCommandKey(Properties.Settings.Default.DBName, str.FOREIGN_KEY(1)); }
private async void CreateDatabaseBTN(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Sure", "Title", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.No) { return; } var watch = System.Diagnostics.Stopwatch.StartNew(); CreateDatatableStrings str = new CreateDatatableStrings(); //await CreateDatabaseAsync(); sqlexec.SQLCommandKey(Properties.Settings.Default.DBName, str.FOREIGN_KEY(0)); await CreateDatabaseAsync(); //sqlexec.SQLCommandKey(Properties.Settings.Default.DBName, str.FOREIGN_KEY(0)); //await FillFakeDatabase(0); //sqlexec.SQLCommandKey(Properties.Settings.Default.DBName, str.FOREIGN_KEY(1)); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; MessageBox.Show(elapsedMs.ToString()); }
private async void ButtonSave_Click(object sender, RoutedEventArgs e) { //Create Shift Object Shift newshift = new Shift(); try { newshift.PersonID = Int32.Parse(cmbDriver.SelectedValue.ToString()); } catch { MessageBox.Show("You Must select a Driver"); return; } try { newshift.TaxiID = Int32.Parse(cmbTaxi.SelectedValue.ToString()); } catch { MessageBox.Show("You Must select a Taxi"); return; } if (!DatePicker1.Value.HasValue) { newshift.ShiftDate = DateTime.Today; } else { newshift.ShiftDate = DatePicker1.Value.Value; } if (TxtXZ.Text != "") { newshift.XZ = Convert.ToDecimal(TxtXZ.Text); } if (TxtOil.Text != "") { newshift.Oil = Convert.ToDecimal(TxtOil.Text); } if (TxtXZFpa.Text != "") { newshift.XZFPA = Convert.ToDecimal(TxtXZFpa.Text); } if (TxtOilFpa.Text != "") { newshift.OilFPA = Convert.ToDecimal(TxtOilFpa.Text); } if (TxtShift.Text != "") { newshift.ShiftPayment = Convert.ToDecimal(TxtShift.Text); } if (TxtIka.Text != "") { newshift.Insurance = Convert.ToDecimal(TxtIka.Text); } if (TxtFpa.Text != "") { newshift.FPA = Convert.ToDecimal(TxtFpa.Text); } if (TxtComment.Text != "") { newshift.Comment = TxtComment.Text; } shifts.Add(newshift); //Create kilometer object Kilometer newkilometer = new Kilometer(); if (TxtKmlFrom.Text != "") { newkilometer.KlmStart = Int32.Parse(TxtKmlFrom.Text); } if (TxtKmlTo.Text != "") { newkilometer.KlmFinish = Int32.Parse(TxtKmlTo.Text); } if (TxtKmlDifference.Text != "") { newkilometer.KlmShift = Int32.Parse(TxtKmlDifference.Text); } if (!DatePicker1.Value.HasValue) { newkilometer.ShiftDate = DateTime.Today; } else { newkilometer.ShiftDate = DatePicker1.Value.Value; } try { newkilometer.PersonID = Int32.Parse(cmbDriver.SelectedValue.ToString()); } catch { MessageBox.Show("You Must select a Driver"); return; } try { newkilometer.TaxiID = Int32.Parse(cmbTaxi.SelectedValue.ToString()); } catch { MessageBox.Show("You Must select a Taxi"); return; } kilometers.Add(newkilometer); //Create Depth object Depth newdepth = new Depth(); try { newdepth.Amount = Convert.ToDecimal(TxtAmount.Text); } catch { MessageBox.Show("The Total must be a decimal xxxx.xx "); return; } if (TxtComment.Text != "") { newdepth.Comment = TxtComment.Text; } newdepth.RepaidAmount = 0; newdepth.Paid = null; if (!DatePicker1.Value.HasValue) { newdepth.DepthDate = DateTime.Today; } else { newdepth.DepthDate = DatePicker1.Value.Value; } try { newdepth.PersonID = Int32.Parse(cmbDriver.SelectedValue.ToString()); } catch { MessageBox.Show("You Must select a Driver"); return; } try { newdepth.TaxiID = Int32.Parse(cmbTaxi.SelectedValue.ToString()); } catch { MessageBox.Show("You Must select a Taxi"); return; } List <PrimaryDriver> primedr = new List <PrimaryDriver>(); primedr.Add(new PrimaryDriver { TaxiID = Int32.Parse(cmbTaxi.SelectedValue.ToString()), PersonID = Int32.Parse(cmbDriver.SelectedValue.ToString()) }); depths.Add(newdepth); CreateDatatableStrings strings = new CreateDatatableStrings(); SQLExecute sqlexec = new SQLExecute(); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, strings.FOREIGN_KEY(0)); await Task.Run(() => SaveKilometer()); await Task.Run(() => SaveShift()); await Task.Run(() => SaveDepth()); await Task.Run(() => SaveIfPrimaryDriver(primedr)); await sqlexec.SQLCommand(Properties.Settings.Default.DBName, strings.FOREIGN_KEY(1)); ClearAll(); }