private void btn_Delete_Click_1(object sender, RoutedEventArgs e) { if (grd_Groups.SelectedItem != null) { groupEntity = (Group)grd_Groups.SelectedItem; MessageBoxResult result = MessageBox.Show("هل انت متأكد من حذف " + groupEntity.Name, "حذف المجموعة", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { groupDomain.Delete(groupEntity); if (groupDomain.ActionState.Status == Common.Enums.ActionStatusEnum.NoError) { MessageBox.Show("تم الحذف بنجاح", "حذف المجموعة", MessageBoxButton.OK, MessageBoxImage.Information); groupList.Remove(groupEntity); grd_Groups.ItemsSource = null; grd_Groups.ItemsSource = groupList; Clear(); } else { MessageBox.Show(groupDomain.ActionState.Result, "حذف المجموعة", MessageBoxButton.OK, MessageBoxImage.Error); Clear(); } } } }
private void grd_Behaviour_MouseDoubleClick_1(object sender, MouseButtonEventArgs e) { if (grd_Groups.SelectedItem != null) { groupEntity = (Group)grd_Groups.SelectedItem; groupEntity = groupDomain.FindByID(groupEntity.ID); if (groupDomain.ActionState.Status != Common.Enums.ActionStatusEnum.NoError) { MessageBox.Show(groupDomain.ActionState.Result, "جلب سجل المجموعة", MessageBoxButton.OK, MessageBoxImage.Error); } else { txt_Description.Text = groupEntity.Description; txt_Name.Text = groupEntity.Name; for (int i = 0; i < groupEntity.AccessList.Count; i++) { for (int j = 0; j < cmbo_AccessList.Items.Count; j++) { if (((AccessList)((CheckBox)cmbo_AccessList.Items[j]).DataContext).ID == groupEntity.AccessList[i].ID) { ((CheckBox)cmbo_AccessList.Items[j]).IsChecked = true; } } } for (int k = 0; k < groupEntity.Permissions.Count; k++) { for (int m = 0; m < cmbo_Permissions.Items.Count; m++) { if (((Permission)((CheckBox)cmbo_Permissions.Items[m]).DataContext).ID == groupEntity.Permissions[k].ID) { ((CheckBox)cmbo_Permissions.Items[m]).IsChecked = true; } } } } } }
private void Clear() { txt_Description.Text = string.Empty; txt_Err_Description.Text = string.Empty; txt_Err_Name.Text = string.Empty; txt_Name.Text = string.Empty; for (int i = 0; i < cmbo_AccessList.Items.Count; i++) { ((CheckBox)cmbo_AccessList.Items[i]).IsChecked = false; } for (int j = 0; j < cmbo_Permissions.Items.Count; j++) { ((CheckBox)cmbo_Permissions.Items[j]).IsChecked = false; } groupEntity = new Group(); }