private void btn_Delete_Click_1(object sender, RoutedEventArgs e) { if (grd_SubCompany.SelectedItem != null) { subsidiaryCompany = (SubsidiaryCompany)grd_SubCompany.SelectedItem; MessageBoxResult result = MessageBox.Show("هل انت متأكد من حذف " + subsidiaryCompany.Name, "حذف الشركة", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { subsidiaryCompanyDomain.Delete(subsidiaryCompany); if (subsidiaryCompanyDomain.ActionState.Status == Common.Enums.ActionStatusEnum.NoError) { MessageBox.Show("تم الحذف بنجاح", "حذف الشركة", MessageBoxButton.OK, MessageBoxImage.Information); subsidiaryCompanyList.Remove(subsidiaryCompany); grd_SubCompany.ItemsSource = null; grd_SubCompany.ItemsSource = subsidiaryCompanyList; Clear(); } else { MessageBox.Show(subsidiaryCompanyDomain.ActionState.Result, "حذف الشركة", MessageBoxButton.OK, MessageBoxImage.Error); Clear(); } } } }
private void grd_SubCompany_MouseDoubleClick_1(object sender, MouseButtonEventArgs e) { if (grd_SubCompany.SelectedItem != null) { subsidiaryCompany = (SubsidiaryCompany)grd_SubCompany.SelectedItem; txt_Description.Text = subsidiaryCompany.Description; txt_DescriptionEnglish.Text = subsidiaryCompany.DescriptionEnglish; txt_Information.Text = subsidiaryCompany.Note; txt_InformationEnglish.Text = subsidiaryCompany.NoteEnglish; txt_Name.Text = subsidiaryCompany.Name; txt_NameEnglish.Text = subsidiaryCompany.NameEnglish; txt_OwnerPercentage.Text = subsidiaryCompany.OwnPercentage.ToString(); txt_Place.Text = subsidiaryCompany.Place; txt_PlaceEnglish.Text = subsidiaryCompany.PlaceEnglish; chk_IsOutKSA.IsChecked = subsidiaryCompany.IsOutKSA; if (subsidiaryCompany.EstablishDate != null) { dtpkr_EstablishGer.Text = Convert.ToDateTime(subsidiaryCompany.EstablishDate).Date.ToString("dd/MM/yyyy"); dtpkr_EstablishHij.Text = GerToHejri(dtpkr_EstablishGer.Text); } if (subsidiaryCompany.FollowDate != null) { dtpkr_FollowDateGer.Text = Convert.ToDateTime(subsidiaryCompany.FollowDate).Date.ToString("dd/MM/yyyy"); dtpkr_FollowDateHij.Text = GerToHejri(dtpkr_EstablishGer.Text); } chk_IsOutKSA.IsChecked = subsidiaryCompany.IsOutKSA; for (int i = 0; i < cmbo_Sector.Items.Count; i++) { if (subsidiaryCompany.Sector.ID == ((Sector)cmbo_Sector.Items[i]).ID) { cmbo_Sector.SelectedIndex = i; break; } } } }
private void Clear() { txt_OwnerPercentage.Text = string.Empty; txt_Description.Text = string.Empty; txt_DescriptionEnglish.Text = string.Empty; txt_Err_OwnerPercentage.Text = string.Empty; txt_Place.Text = string.Empty; txt_PlaceEnglish.Text = string.Empty; txt_Err_Place.Text = string.Empty; txt_Err_PlaceEnglish.Text = string.Empty; txt_Err_Description.Text = string.Empty; txt_Err_DescriptionEnglish.Text = string.Empty; txt_Err_Establish.Text = string.Empty; txt_Err_Information.Text = string.Empty; txt_Err_InformationEnglish.Text = string.Empty; txt_Err_Name.Text = string.Empty; txt_Err_NameEnglish.Text = string.Empty; txt_Information.Text = string.Empty; txt_InformationEnglish.Text = string.Empty; txt_Name.Text = string.Empty; txt_NameEnglish.Text = string.Empty; dtpkr_EstablishGer.Text = string.Empty; dtpkr_EstablishHij.Text = string.Empty; dtpkr_FollowDateGer.Text = string.Empty; dtpkr_FollowDateHij.Text = string.Empty; txt_Err_FollowDate.Text = string.Empty; subsidiaryCompany = new SubsidiaryCompany(); cmbo_Sector.SelectedIndex = 0; }