private async void Window_Loaded(object sender, RoutedEventArgs e) { try { _patientData = await DPatient.GetData(); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message); Close(); return; } _patientSearchData = _patientData; if (string.IsNullOrEmpty(TxtSearch.Text.Trim())) { DgdPatient.ItemsSource = _patientSearchData; TxtSearch.Text = string.Empty; } else { TxtSearch_TextChanged(null, null); } DgdPatient.ItemsSource = _patientSearchData; BtnNew_Click(null, null); }
private async void BtnAdd_Click(object sender, RoutedEventArgs e) { if (!CheckEmpty()) { return; } #region AddPatient try { var addPatient = new DPatient { DPatientId = TxtPatientId.Text, DName = TxtFirstName.Text, DFamily = TxtLastName.Text, DSex = CboGender.SelectedIndex == 0, DAddress = TxtAddress.Text.Trim() == string.Empty ? null : TxtAddress.Text, DPhoneNumber = TxtTell.Text.Trim() == string.Empty ? null : TxtTell.Text, DMobileNumber = TxtMobile.Text.Trim() == string.Empty ? null : TxtMobile.Text, DDescription = TxtDescription.Text.Trim() == string.Empty ? null : TxtDescription.Text }; await Task.Run(() => addPatient.Add()); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات بیمار\n" + exception.Message); } Window_Loaded(null, null); Utility.Message("پیام", "اطلاعات با موفقیت ثبت گردید", "Correct.png"); #endregion }
private async void BtnEdit_Click(object sender, RoutedEventArgs e) { if (!CheckSelectEdit() || !CheckEmpty()) { return; } var selectItem = _patientSearchData[DgdPatient.SelectedIndex]; try { var editPatient = new DPatient { DId = selectItem.Id, DPatientId = TxtPatientId.Text, DName = TxtFirstName.Text, DFamily = TxtLastName.Text, DSex = CboGender.SelectedIndex == 0, DAddress = TxtAddress.Text.Trim() == string.Empty ? null : TxtAddress.Text, DPhoneNumber = TxtTell.Text.Trim() == string.Empty ? null : TxtTell.Text, DMobileNumber = TxtMobile.Text.Trim() == string.Empty ? null : TxtMobile.Text, DDescription = TxtDescription.Text.Trim() == string.Empty ? null : TxtDescription.Text }; await Task.Run(() => editPatient.Edit()); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ویرایش اطلاعات بیمار\n" + exception.Message); return; } Window_Loaded(null, null); Utility.Message("پیام", "اطلاعات با موفقیت ویرایش گردید", "Correct.png"); }
private async void BtnDelete_Click(object sender, RoutedEventArgs e) { if (!CheckSelectDelete()) { return; } var selectItem = _patientSearchData[DgdPatient.SelectedIndex]; Utility.MyMessageBox("هشدار", "آیا از حذف اطمینان دارید؟ ", "Warning.png", false); if (!Utility.YesNo) { return; } try { var deletePatient = new DPatient { DId = selectItem.Id }; await Task.Run(() => deletePatient.Delete()); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message); return; } Window_Loaded(null, null); Utility.Message("پیام", "اطلاعات با موفقیت حذف گردید", "Correct.png"); }
public async Task <ActionResult <DPatient> > PostDPatient(DPatient dPatient) { _context.DPatient.Add(dPatient); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDPatient", new { id = dPatient.id }, dPatient)); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { try { _doctorData = await DDoctor.GetViewData(); _patientData = await DPatient.GetData(); _doctorPatientData = await DDoctorPatient.GetViewData(); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message); Close(); return; } _doctorSearchData = _doctorData; _patientSearchData = _patientData; _doctorPatientSearchData = _doctorPatientData; DgdDoctor.ItemsSource = _doctorSearchData; DgdPatient.ItemsSource = _patientSearchData; DgdPatientVisit.ItemsSource = _doctorPatientSearchData; BtnNew_Click(null, null); }
private async void BtnAutoId_Click(object sender, RoutedEventArgs e) { try { TxtPatientId.Text = await DPatient.GetPatientId(); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message); } }
private async void BtnAddPatient_Click(object sender, RoutedEventArgs e) { var winPatient = new WinPatient(); winPatient.ShowDialog(); try { _patientData = await DPatient.GetData(); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message); Close(); return; } _patientSearchData = _patientData; DgdPatient.ItemsSource = _patientSearchData; }
public async Task <IActionResult> PutDPatient(int id, DPatient dPatient) { dPatient.id = id; _context.Entry(dPatient).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DPatientExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }