private void getDays() { if (string.IsNullOrEmpty(pickerDate.Text.ToString())) { comboHour.ItemsSource = null; return; } var selectedDoc = comboDoctor.SelectedItem as SimpleModel; var date = DateTime.ParseExact(pickerDate.Text.ToString(), "d.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture).Date; if (selectedDoc == null || date == null) { comboHour.ItemsSource = null; return; } using (var db = new DentistDbEntities()) { var todaysAppo = db.Appointments.Where(x => x.DOCTORID == selectedDoc.ID && x.DATE == date).Select(x => x.HOUR).ToList(); var allHoures = Shared.houres; allHoures = allHoures.Where(x => !todaysAppo.Contains(x.ID)).ToList(); comboHour.ItemsSource = allHoures; } }
private void init() { using (var db = new DentistDbEntities()) { var doctors = db.Doctors.Where(x => !x.ISDELETE).Select(x => new SimpleModel { NAME = x.NAME + " " + x.SURNAME, ID = x.ID }).ToList <SimpleModel>(); comboDoctor.ItemsSource = doctors; var patients = db.Patients.Where(x => !x.ISDELETE).Select(x => new SimpleModel { NAME = x.NAME + " " + x.SURNAME, ID = x.ID }).ToList <SimpleModel>(); comboHasta.ItemsSource = patients; comboType.ItemsSource = Shared.types; if (updateAppointment.ID != 0) { save.Content = "GÜNCELLE"; pickerDate.SelectedDate = updateAppointment.DATE; var indexsDoc = doctors.Select((car, index) => new { car, index }).First(c => c.car.ID == updateAppointment.DOCTORID).index; comboDoctor.SelectedIndex = indexsDoc; var indexsPat = patients.Select((car, index) => new { car, index }).First(c => c.car.ID == updateAppointment.PATIENTID).index; comboHasta.SelectedIndex = indexsPat; var indexsType = Shared.types.Select((car, index) => new { car, index }).First(c => c.car.NAME == updateAppointment.TYPE).index; comboType.SelectedIndex = indexsType; var todaysAppo = db.Appointments.Where(x => x.DOCTORID == updateAppointment.DOCTORID && x.DATE == updateAppointment.DATE && x.HOUR != updateAppointment.HOUR).Select(x => x.HOUR).ToList(); var allHoures = Shared.houres; allHoures = allHoures.Where(x => !todaysAppo.Contains(x.ID)).ToList(); comboHour.ItemsSource = allHoures; var indexhour = allHoures.Select((car, index) => new { car, index }).First(c => c.car.ID == updateAppointment.HOUR).index; comboHour.SelectedIndex = indexhour; txPrice.Text = updateAppointment.PRICE + ""; txDescription.Text = updateAppointment.DESCRIPTION; chPaid.IsChecked = updateAppointment.ISPAID; chCame.IsChecked = updateAppointment.ISCAME; } } }
private void Delete_Click(object sender, RoutedEventArgs e) { ProgressOn(); Patient clickedDoctor = ((FrameworkElement)sender).DataContext as Patient; using (var db = new DentistDbEntities()) { var query = db.Patients.SingleOrDefault(x => x.ID == clickedDoctor.ID); query.ISDELETE = true; db.SaveChanges(); } ProgressOf(); getList(); }
private void save_Click(object sender, RoutedEventArgs e) { var name = txName.Text.Trim(); var surname = txSurname.Text.Trim(); var phone = txPhone.Text.Trim(); var adres = txAdress.Text.Trim(); var tc = txTc.Text.Trim(); if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(adres) || string.IsNullOrEmpty(tc) || string.IsNullOrEmpty(pickbirthDay.Text)) { MessageBox.Show("Lütfen Bütün Alanları Doldurunuz.", ""); return; } var birthday = DateTime.ParseExact(pickbirthDay.Text.ToString(), "d.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture); ProgressOn(); using (var db = new DentistDbEntities()) { //insert if (updateDoktor.ID == 0) { var model = db.Doctors.Add(db.Doctors.Create()); model.NAME = name; model.SURNAME = surname; model.BIRTHDAY = birthday; model.PHONE = phone; model.ADRESS = adres; model.PERSONELID = tc; db.SaveChanges(); } //update else { var model = db.Doctors.SingleOrDefault(row => row.ID == updateDoktor.ID); model.NAME = name; model.SURNAME = surname; model.BIRTHDAY = birthday; model.PHONE = phone; model.ADRESS = adres; model.PERSONELID = tc; db.SaveChanges(); } } ProgressOf(); DialogHost.CloseDialogCommand.Execute(false, null); }
private void init() { ProgressOn(); using (var db = new DentistDbEntities()) { user = Shared.OnlineUser = db.Users.FirstOrDefault(x => x.ID == user.ID); txEmail.Text = user.EMAIL; txName.Text = user.NAME; txSurname.Text = user.SURNAME; txUsername.Text = user.USERNAME; } ProgressOf(); }
private void Delete_Click(object sender, RoutedEventArgs e) { ProgressOn(); VW_Appointment clickedDoctor = ((FrameworkElement)sender).DataContext as VW_Appointment; using (var db = new DentistDbEntities()) { var query = db.Appointments.SingleOrDefault(x => x.ID == clickedDoctor.ID); db.Appointments.Attach(query); db.Appointments.Remove(query); db.SaveChanges(); } ProgressOf(); getList(); }
private void getList() { ProgressOn(); using (var db = new DentistDbEntities()) { patients = db.Patients.Where(x => !x.ISDELETE).ToList(); if (patients == null || !patients.Any()) { MessageBox.Show("Veri Buluamadı", ""); mDataGrid.ItemsSource = null; ProgressOf(); return; } mDataGrid.ItemsSource = patients; } ProgressOf(); }
private void Button_Click(object sender, RoutedEventArgs e) { var username = txUsername.Text; var password = txPassword.Password; if (username == null || username.Length == 0) { MessageBox.Show("Lütfen Kullanıcı Adı Giriniz", ""); return; } if (password == null || password.Length == 0) { MessageBox.Show("Lütfen Şifre Adı Giriniz", ""); return; } ProgressOn(); using (var db = new DentistDbEntities()) { var user = db.Users.FirstOrDefault(x => x.USERNAME == username); if (user == null) { MessageBox.Show("Kullanıcı Buluamadı", ""); ProgressOf(); return; } if (user.PASSWORD != password) { MessageBox.Show("Yanlış Şifre", ""); ProgressOf(); return; } Shared.OnlineUser = user; HomePageWindow main = new HomePageWindow(); App.Current.MainWindow = main; this.Close(); main.Show(); } }
private void getList() { ProgressOn(); using (var db = new DentistDbEntities()) { list = db.VW_Appointment.Where(x => x.ISPAID).ToList(); if (list == null || !list.Any()) { MessageBox.Show("Veri Buluamadı", ""); mDataGrid.ItemsSource = null; ProgressOf(); return; } mDataGrid.ItemsSource = list; } ProgressOf(); }
private void getList() { ProgressOn(); var dates = Calendar.Days.Select(x => x.Date).ToList(); using (var db = new DentistDbEntities()) { var first = dates[0]; var last = dates[dates.Count - 1]; var list = db.VW_Appointment.Where(x => x.DATE >= first && x.DATE <= last).ToList(); foreach (var item in list) { Calendar.Days.FirstOrDefault(x => x.Date == item.DATE).Notes = string.IsNullOrEmpty(Calendar.Days.FirstOrDefault(x => x.Date == item.DATE).Notes)? item.PATIENTFULLNAME : Calendar.Days.FirstOrDefault(x => x.Date == item.DATE).Notes + " - " + item.PATIENTFULLNAME; } } ProgressOf(); }
private void Button_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txEmail.Text) || string.IsNullOrEmpty(txName.Text) || string.IsNullOrEmpty(txSurname.Text) || string.IsNullOrEmpty(txUsername.Text)) { MessageBox.Show("Lütfen Bütün Alanları Doldurunuz.", ""); return; } ProgressOn(); using (var db = new DentistDbEntities()) { var model = db.Users.SingleOrDefault(row => row.ID == user.ID); model.NAME = txName.Text; model.SURNAME = txSurname.Text; model.USERNAME = txUsername.Text; model.EMAIL = txEmail.Text; db.SaveChanges(); user = Shared.OnlineUser = model; MessageBox.Show("Başarılı İşlem.", ""); } ProgressOf(); }
private void save_Click(object sender, RoutedEventArgs e) { if ((comboDoctor.SelectedItem) == null) { MessageBox.Show("Lütfen Bütün Alanları Doldurunuz.", ""); return; } if ((comboHasta.SelectedItem) == null) { MessageBox.Show("Lütfen Bütün Alanları Doldurunuz.", ""); return; } if ((comboType.SelectedItem) == null) { MessageBox.Show("Lütfen Bütün Alanları Doldurunuz.", ""); return; } if ((comboHour.SelectedItem) == null) { MessageBox.Show("Lütfen Bütün Alanları Doldurunuz.", ""); return; } var price = txPrice.Text.Trim(); var desc = txDescription.Text.Trim(); var doctor = ((SimpleModel)comboDoctor.SelectedItem).ID; var patient = ((SimpleModel)comboHasta.SelectedItem).ID; var type = ((SimpleModel)comboType.SelectedItem).NAME; var hour = ((SimpleModel)comboHour.SelectedItem).ID; var isPaid = chPaid.IsChecked; var isCame = chCame.IsChecked; if (string.IsNullOrEmpty(price) || string.IsNullOrEmpty(desc) || string.IsNullOrEmpty(pickerDate.Text)) { MessageBox.Show("Lütfen Bütün Alanları Doldurunuz.", ""); return; } var date = DateTime.ParseExact(pickerDate.Text.ToString(), "d.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture); ProgressOn(); using (var db = new DentistDbEntities()) { //insert if (updateAppointment.ID == 0) { var model = db.Appointments.Add(db.Appointments.Create()); model.DOCTORID = doctor; model.PATIENTID = patient; model.DATE = date; model.HOUR = hour; model.PRICE = decimal.Parse(price); model.ISCAME = (bool)isCame; model.ISPAID = (bool)isPaid; model.TYPE = type; model.DESCRIPTION = desc; db.SaveChanges(); } //update else { var model = db.Appointments.SingleOrDefault(row => row.ID == updateAppointment.ID); model.DOCTORID = doctor; model.PATIENTID = patient; model.DATE = date; model.HOUR = hour; model.PRICE = decimal.Parse(price); model.ISCAME = (bool)isCame; model.ISPAID = (bool)isPaid; model.TYPE = type; model.DESCRIPTION = desc; db.SaveChanges(); } } ProgressOf(); DialogHost.CloseDialogCommand.Execute(false, null); }