private async void BtnAdd_Click(object sender, RoutedEventArgs e) { if (!CheckEmpty()) { return; } #region AddDoctor try { var addDoctor = new DDoctor { DSpecialtyId = ((tblSpecialty)CboSpecialty.SelectedItem)?.Id ?? 0, DCountyId = (short?)(CboCounty.SelectedIndex == -1 ? 0 : ((tblCounty)CboCounty.SelectedItem).Id), DDoctorId = TxtDocterId.Text, DDoctorName = TxtFirstName.Text, DDoctorFamily = 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(() => addDoctor.Add()); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات پزشک\n" + exception.Message); } Window_Loaded(null, null); Utility.Message("پیام", "اطلاعات با موفقیت ثبت گردید", "Correct.png"); #endregion }
private async void BtnDelete_Click(object sender, RoutedEventArgs e) { if (!CheckSelectDelete()) { return; } var selectItem = _doctorSearchData[DgdDoctor.SelectedIndex]; Utility.MyMessageBox("هشدار", "آیا از حذف اطمینان دارید؟ ", "Warning.png", false); if (!Utility.YesNo) { return; } try { var deleteDoctor = new DDoctor { DId = selectItem.Id }; await Task.Run(() => deleteDoctor.Delete()); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message); return; } Window_Loaded(null, null); Utility.Message("پیام", "اطلاعات با موفقیت حذف گردید", "Correct.png"); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { try { _doctorData = await DDoctor.GetViewData(); _specialtyData = await DDoctor.GetSpecialty(); CboProvince.ItemsSource = await DDoctor.GetProvince(); _countiyData = await DDoctor.GetCounty(); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message); Close(); return; } _doctorSearchData = _doctorData; if (string.IsNullOrEmpty(TxtSearch.Text.Trim()) || _add) { DgdDoctor.ItemsSource = _doctorSearchData; CboSpecialty.ItemsSource = _specialtyData; TxtSearch.Text = string.Empty; CboSpecialty.Text = string.Empty; } else { TxtSearch_TextChanged(null, null); } CboSpecialty.ItemsSource = _specialtyData; DgdDoctor.ItemsSource = _doctorSearchData; BtnNew_Click(null, null); }
private async void BtnEdit_Click(object sender, RoutedEventArgs e) { if (!CheckSelectEdit() || !CheckEmpty()) { return; } var selectItem = _doctorSearchData[DgdDoctor.SelectedIndex]; try { var editDoctor = new DDoctor { DId = selectItem.Id, DSpecialtyId = ((tblSpecialty)CboSpecialty.SelectedItem).Id, DCountyId = (short?)(CboCounty.SelectedIndex == -1 ? 0 : ((tblCounty)CboCounty.SelectedItem).Id), DDoctorId = TxtDocterId.Text, DDoctorName = TxtFirstName.Text, DDoctorFamily = 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(() => editDoctor.Edit()); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ویرایش اطلاعات پزشک\n" + exception.Message); return; } Window_Loaded(null, null); Utility.Message("پیام", "اطلاعات با موفقیت ویرایش گردید", "Correct.png"); }
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 { TxtDocterId.Text = await DDoctor.GetDoctorId(); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message); } }
private async void BtnAddDoctor_Click(object sender, RoutedEventArgs e) { var winDoctor = new WinDoctor(); winDoctor.ShowDialog(); try { _doctorData = await DDoctor.GetViewData(); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message); Close(); return; } _doctorSearchData = _doctorData; DgdDoctor.ItemsSource = _doctorSearchData; }
async void Button_Clicked(System.Object sender, System.EventArgs e) { var db = new SQLiteConnection(_dbPath); db.CreateTable <DDoctor>(); var maxPk = db.Table <DDoctor>().OrderByDescending(c => c.III).FirstOrDefault(); DDoctor ddoctor = new DDoctor() { III = (maxPk == null ? 1 : maxPk.III + 1), Doc = D.Text, Num = DD.Text }; db.Insert(ddoctor); await DisplayAlert(null, "Saved", "Ok"); await Navigation.PopAsync(); }
//baraye shomare gozari datagrid #endregion private async void Window_Loaded(object sender, RoutedEventArgs e) { try { _doctorData = await DDoctor.GetViewData(); _specialtyData = await DDoctor.GetSpecialty(); CboProvince.ItemsSource = await DDoctor.GetProvince(); _countiyData = await DDoctor.GetCounty(); } catch (Exception exception) { Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message); Close(); return; } _doctorSearchData = _doctorData; CboSpecialty.ItemsSource = _specialtyData; DgdDoctor.ItemsSource = _doctorSearchData; BtnNew_Click(null, null); }