private void ProgrameazaButton_Click(object sender, RoutedEventArgs e) { using (var data = new SpalatorieEntities()) { Programari programare = new Programari() { ClientID = data.Clienti.First(c => c.Nume == Client.Nume).ClientID, Data = DateTime.Parse(DataTextBox.Text), NumarInmatriculare = NrMasinaTextBox.Text, Ora = TimeSpan.Parse(OraTextBox.Text), TipulSpalarii = TipSpalareTextBox.Text }; try { if (data.Programari.Find(programare.Ora) != null) { throw (new Exception()); } else { data.Programari.Add(programare); MessageBox.Show("Programarea a fost realizata cu succes!", "Succes", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception exception) { MessageBox.Show("Exista deja o programare la aceasta ora", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void CreateAppointments() { int i = 0; using (var data = new SpalatorieEntities()) { foreach (var programare in data.Programari) { if (programare.ClientID == data.Clienti.First(c => c.Nume == Client.Nume).ClientID) { appointments[i] = new Appointment() { ClientName = Client.Nume, ClientFirstName = Client.Prenume, CarNumber = programare.NumarInmatriculare, Date = programare.Data, Hour = programare.Ora, WashType = programare.TipulSpalarii }; if (data.Clienti.First(c => c.Nume == Client.Nume).TipClient == "Permanent") { appointments[i].Cost = data.ServiciiSpalatorie.First(c => c.TipSpalare == programare.TipulSpalarii).PretRedus; } else { appointments[i].Cost = data.ServiciiSpalatorie.First(c => c.TipSpalare == programare.TipulSpalarii).Pret; } i++; } } } }
private void AddUser() { Clienti client = new Clienti() { Nume = NumeTextBox.Text, Prenume = PrenumeTextBox.Text, AdresaEMAIL = EmailTextBox.Text, Parola = ParolaTextBox.SecurePassword.ToString() }; if (ParolaTextBox.SecurePassword.ToString() != ConfPassTextBox.SecurePassword.ToString()) { MessageBox.Show("Confirmation password do not match!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } if (ClientPermanentRadioButton.IsChecked == true) { client.TipClient = "permanent"; client.NumarInmatriculare = NumarInmatriculareTextBox.Text; client.NumarTelefon = NumarTelefonTextBox.Text; } else { client.TipClient = "simplu"; } using (var data = new SpalatorieEntities()) { data.Clienti.Add(client); } }
static public string GetFirstName(string email) { using (var data = new SpalatorieEntities()) { string prenume = data.Clienti.First(c => c.AdresaEMAIL == email).Prenume; return(prenume); } }
private void DoneButton_Click(object sender, RoutedEventArgs e) { string nume = acceptedAppointments[ProgramariAcceptateDataGrid.SelectedIndex].ClientName; using (var data = new SpalatorieEntities()) { IstoricProgramari programare; programare = SetProgramare(data, nume); data.IstoricProgramari.Add(programare); acceptedAppointments.Remove(acceptedAppointments[ProgramariAcceptateDataGrid.SelectedIndex]); } }
private void AcceptButton_Click(object sender, RoutedEventArgs e) { acceptedAppointments.Add(allAppointments[ProgramariDataGrid.SelectedIndex]); string nume = allAppointments[ProgramariDataGrid.SelectedIndex].ClientName; allAppointments.Remove(allAppointments[ProgramariDataGrid.SelectedIndex]); using (var data = new SpalatorieEntities()) { data.Programari.Remove(data.Programari.First(c => c.Clienti.Nume == nume)); } ProgramariAcceptateDataGrid.DataContext = acceptedAppointments; }
private IstoricProgramari SetProgramare(SpalatorieEntities data, string nume) { IstoricProgramari programare = new IstoricProgramari() { Data = acceptedAppointments.First(c => c.ClientName == nume).Date, MuncitorID = data.Muncitori.First(c => c.Nume == angajat.Nume).MuncitorID, NumarInmatriculare = data.Clienti.First(c => c.Nume == nume).NumarInmatriculare, ClientID = data.Clienti.First(c => c.Nume == nume).ClientID, NumarTelefon = data.Clienti.First(c => c.Nume == nume).NumarTelefon, Ora = acceptedAppointments.First(c => c.ClientName == nume).Hour, TipulSpalarii = acceptedAppointments.First(c => c.ClientName == nume).WashType }; return(programare); }