private void dostorsList() { var db = new PrzychodniaEntities(); doctorsDataGrid.AutoGenerateColumns = false; doctorsDataGrid.ItemsSource = db.Doctors.ToList(); }
private void DeletePat_btn_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Czy jesteś pewny?", "VITAMEDICAL", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { var db = new PrzychodniaEntities(); var tmp = int.Parse(UpdateId.Text); var patient = db.Patients.First(a => a.idPat == tmp); db.Patients.Remove(patient); db.SaveChanges(); Clear(); patientsList(); MessageBox.Show("Pomyślnie"); } }
private void Aktualizuj(object o, EventArgs e) { int tmp = (int)((Button)o).CommandParameter; var db = new PrzychodniaEntities(); var doctor = db.Doctors.FirstOrDefault(a => a.idDoc == tmp); UpdateId.Text = tmp.ToString(); DocName_input.Text = doctor.FirstName; DocLastName_input.Text = doctor.LastName; DocPESEL_input.Text = doctor.PESEL; DocPhone_input.Text = doctor.phoneNb; DocEmail_input.Text = doctor.mail; IdSpec_input.Text = doctor.specializations.ToString(); }
void reservationsList() { var db = new PrzychodniaEntities(); bookingVisitDataGrid.AutoGenerateColumns = false; var reservationsTable = db.BookingVisit.ToList().Select(a => new { idBV = a.idBV, idDoc = a.idDoc, idPat = a.idPat, dateOfReserv = a.dateOfReserv.Value.ToString("dd-MM-yyyy"), timeOfVisit = a.timeOfVisit.ToString(), }).ToList(); bookingVisitDataGrid.ItemsSource = reservationsTable; }
private void Aktualizuj(object a, EventArgs e) { int tmp = (int)((Button)a).CommandParameter; var db = new PrzychodniaEntities(); var patient = db.Patients.FirstOrDefault(p => p.idPat == tmp); UpdateId.Text = tmp.ToString(); Name_input.Text = patient.FirstName; LastName_input.Text = patient.LastName; PESEL_input.Text = patient.PESEL; Phone_input.Text = patient.phoneNb; email_input.Text = patient.mail; Gender_input.Text = patient.gender; City_input.Text = patient.city; PostalCode_input.Text = patient.postalCode; Street_input.Text = patient.street_adress; PatBirthDate_picker.Text = patient.birthDate.ToString(); }
private void UpdateDoc_btn_Click(object sender, RoutedEventArgs e) { var db = new PrzychodniaEntities(); var tmp = int.Parse(UpdateId.Text); var doctor = db.Doctors.First(a => a.idDoc == tmp); db.Doctors.Attach(doctor); doctor.FirstName = DocName_input.Text; doctor.LastName = DocLastName_input.Text; doctor.PESEL = DocPESEL_input.Text; doctor.phoneNb = DocPhone_input.Text; doctor.mail = DocEmail_input.Text; doctor.specializations = int.Parse(IdSpec_input.Text); db.SaveChanges(); Clear(); dostorsList(); MessageBox.Show("Dane zaktualizowano"); }
void patientsList() { var db = new PrzychodniaEntities(); patientsDataGrid.AutoGenerateColumns = false; var tmp = db.Patients.ToList().Select(a => new { idPat = a.idPat, FirstName = a.FirstName, LastName = a.LastName, PESEL = a.PESEL, phoneNb = a.phoneNb, mail = a.mail, gender = a.gender, city = a.city, postalCode = a.postalCode, street_adress = a.street_adress, birthDate = a.birthDate.ToString("yyyy-MM-dd") }).ToList(); patientsDataGrid.ItemsSource = tmp; }
void visitsList() { var db = new PrzychodniaEntities(); visitsDataGrid.AutoGenerateColumns = false; var visitsTable = db.Visits.ToList().Select(a => new { idVis = a.idVis, idPat = a.idPat, idDoc = a.idDoc, DateOfVisit = a.DateOfVisit.Value.ToString("dd-MM-yyyy"), TimeOfVisit = a.TimeOfVisit.ToString(), Symptoms = a.Symptoms, Diagnosis = a.Diagnosis, idDis = a.idDis, idPrescr = a.idPrescr, sickLeave = a.sickLeave, recommendations = a.recommendations, }).ToList(); visitsDataGrid.ItemsSource = visitsTable; }
private void UpdatePanient_btn_Click(object sender, RoutedEventArgs e) { var db = new PrzychodniaEntities(); var tmp = int.Parse(UpdateId.Text); var patient = db.Patients.First(a => a.idPat == tmp); db.Patients.Attach(patient); patient.FirstName = Name_input.Text; patient.LastName = LastName_input.Text; patient.PESEL = PESEL_input.Text; patient.phoneNb = Phone_input.Text; patient.mail = email_input.Text; patient.gender = Gender_input.Text; patient.city = City_input.Text; patient.birthDate = PatBirthDate_picker.SelectedDate.Value; patient.postalCode = PostalCode_input.Text; patient.street_adress = Street_input.Text; db.SaveChanges(); Clear(); patientsList(); MessageBox.Show("Dane zaktualizowano"); }
private void AddPatient_btn_Click(object sender, RoutedEventArgs e) { var db = new PrzychodniaEntities(); PatInvalidData_box.Text = ""; var patientsTable = db.Patients; string name = Name_input.Text; if (name == "") { PatInvalidData_box.Text = "Proszę podać imię!"; return; } string lastName = LastName_input.Text; if (lastName == "") { PatInvalidData_box.Text = "Proszę podać nazwisko!"; return; } if (PatBirthDate_picker.SelectedDate == null) { PatInvalidData_box.Text = "Proszę podać datę urodzenia"; return; } string pesel = PESEL_input.Text; if (pesel == "" || pesel.Length != 11) { PatInvalidData_box.Text = "Proszę podać prawidłowy PESEL"; return; } if (patientsTable.Where(p => p.PESEL == pesel).ToList().Count == 1) { PatInvalidData_box.Text = "Pacjent z takim numerem PESEL już jest w systemie"; return; } string gender = Gender_input.Text; if (gender == "" || gender.Length != 1) { PatInvalidData_box.Text = "Proszę prawidłowo wpisać płeć K lub M"; return; } string postalCode = PostalCode_input.Text; if (postalCode == "" || postalCode.Length != 5) { PatInvalidData_box.Text = "Proszę podać prawidłowy kod pocztowy"; return; } string city = City_input.Text; if (city == "") { PatInvalidData_box.Text = "Proszę podać miasto"; return; } string adress = Street_input.Text; if (adress == "") { PatInvalidData_box.Text = "Proszę podać adres"; return; } string phone = Phone_input.Text; if (phone == "" || phone.Length != 9) { PatInvalidData_box.Text = "Proszę podać prawidłowy numer telefonu"; return; } if (patientsTable.Where(d => d.phoneNb == phone).ToList().Count == 1) { PatInvalidData_box.Text = "Pacjent z takim numerem telefonu już jest w systemie"; return; } if (email_input.Text.Length == 0 || !Regex.IsMatch(email_input.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { PatInvalidData_box.Text = "Proszę podać prawidłowy adres mailowy"; return; } Patients patient = new Patients() { FirstName = Name_input.Text, LastName = LastName_input.Text, PESEL = PESEL_input.Text, phoneNb = Phone_input.Text, mail = email_input.Text, gender = Gender_input.Text, city = City_input.Text, birthDate = PatBirthDate_picker.SelectedDate.Value, postalCode = PostalCode_input.Text, street_adress = Street_input.Text, }; db.Patients.Add(patient); db.SaveChanges(); Clear(); patientsList(); MessageBox.Show("Dodano nowego pacjenta"); }
private void Reserv_btn_Click(object sender, RoutedEventArgs e) { var db = new PrzychodniaEntities(); ReservInvalidData_box.Text = ""; string idPat = IdPat_input.Text; int idValue = int.Parse(idPat); if (idPat == "") { ReservInvalidData_box.Text = "Proszę podać id pacjenta"; return; } if (db.Patients.Where(i => i.idPat == idValue).ToList().Count != 1) { ReservInvalidData_box.Text = "Pacjent z takim id nie jest zarejestrowany"; return; } string idDoc = IdDoc_input.Text; int idValue2 = int.Parse(idDoc); if (idDoc == "") { ReservInvalidData_box.Text = "Proszę podać id lekarza"; return; } var doctors = db.Doctors.Where(d => d.idDoc == idValue2).ToList(); var wszyscy = db.Doctors.ToList(); if (doctors.Count() != 1) { ReservInvalidData_box.Text = "Lekarz z takiem id nie pracuje w tej przychodni"; return; } if (dateOfVisit.SelectedDate == null) { ReservInvalidData_box.Text = "Proszę podać datę wizyty"; return; } string time = TimeOfVisit.Text; if (time == "") { ReservInvalidData_box.Text = "Proszę podać godzinę wizyty"; return; } DateTime dt = (dateOfVisit.SelectedDate is null) ? new DateTime(0, 0, 0) : (DateTime)dateOfVisit.SelectedDate; dt += TimeSpan.Parse(time); int doc = int.Parse(idDoc); var from = dt - new TimeSpan(0, 15, 0); var to = dt + new TimeSpan(0, 15, 0); var exist = db.BookingVisit .ToList() .Where(a => a.idDoc == doc && a.dateOfReserv + a.timeOfVisit > from && a.dateOfReserv + a.timeOfVisit < to ); if (exist.FirstOrDefault() != null) { ReservInvalidData_box.Text = "Lekarz z takim id już jest zajęty w tym terminie"; return; } BookingVisit reservation = new BookingVisit() { idPat = int.Parse(IdPat_input.Text), idDoc = int.Parse(IdDoc_input.Text), dateOfReserv = dateOfVisit.SelectedDate.Value, timeOfVisit = TimeSpan.Parse(TimeOfVisit.Text), }; db.BookingVisit.Add(reservation); db.SaveChanges(); Clear(); reservationsList(); MessageBox.Show("Zarezerwowano"); }
private void AddDoc_btn_Click(object sender, RoutedEventArgs e) { var db = new PrzychodniaEntities(); InvalidData_box.Text = ""; var doctorsTable = db.Doctors; var specTable = db.Specializations; string name = DocName_input.Text; if (name == "") { InvalidData_box.Text = "Proszę podać imię!"; return; } string lastName = DocLastName_input.Text; if (lastName == "") { InvalidData_box.Text = "Proszę podać nazwisko!"; return; } string pesel = DocPESEL_input.Text; if (pesel == "" || pesel.Length != 11) { InvalidData_box.Text = "Proszę podać prawidłowy PESEL"; return; } if (doctorsTable.Where(d => d.PESEL == pesel).ToList().Count == 1) { InvalidData_box.Text = "Lekarz z takim numerem PESEL już jest w systemie"; return; } string phone = DocPhone_input.Text; if (phone == "" || phone.Length != 9) { InvalidData_box.Text = "Proszę podać prawidłowy numer telefonu"; return; } if (doctorsTable.Where(d => d.phoneNb == phone).ToList().Count == 1) { InvalidData_box.Text = "Lekarz z takim numerem telefonu już jest w systemie"; return; } if (DocEmail_input.Text.Length == 0 || !Regex.IsMatch(DocEmail_input.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { InvalidData_box.Text = "Proszę podać prawidłowy adres mailowy"; return; } string idspec = IdSpec_input.Text; int idValue = int.Parse(idspec); if (specTable.Where(s => s.idSpec == idValue).ToList().Count != 1) { InvalidData_box.Text = "Nie ma takiej specjalizacji"; return; } Doctors doctor = new Doctors() { FirstName = DocName_input.Text, LastName = DocLastName_input.Text, PESEL = DocPESEL_input.Text, phoneNb = DocPhone_input.Text, mail = DocEmail_input.Text, specializations = idValue, }; db.Doctors.Add(doctor); db.SaveChanges(); Clear(); dostorsList(); MessageBox.Show("Dodano nowego lekarza"); }