private void btn_Delete_Click_1(object sender, RoutedEventArgs e) { if (grd_Behaviour.SelectedItem != null) { behaviour = (Behaviour)grd_Behaviour.SelectedItem; MessageBoxResult result = MessageBox.Show("هل انت متأكد من حذف " + behaviour.Name, "حذف النشاط", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { behaviourDomain.Delete(behaviour); if (behaviourDomain.ActionState.Status == Common.Enums.ActionStatusEnum.NoError) { MessageBox.Show("تم الحذف بنجاح", "حذف النشاط", MessageBoxButton.OK, MessageBoxImage.Information); behaviourList.Remove(behaviour); grd_Behaviour.ItemsSource = null; grd_Behaviour.ItemsSource = behaviourList; Clear(); } else { MessageBox.Show(behaviourDomain.ActionState.Result, "حذف النشاط", MessageBoxButton.OK, MessageBoxImage.Error); Clear(); } } } }
private void grd_Behaviour_MouseDoubleClick_1(object sender, MouseButtonEventArgs e) { if (grd_Behaviour.SelectedItem != null) { behaviour = (Behaviour)grd_Behaviour.SelectedItem; txt_Description.Text = behaviour.Description; txt_DescriptionEnglish.Text = behaviour.DescriptionEnglish; txt_NameEnglish.Text = behaviour.NameEnglish; txt_Name.Text = behaviour.Name; for (int i = 0; i < cmbo_JudgmentBehavior.Items.Count; i++) { if (behaviour.Judgment.ID == ((BehaviorJudgment)cmbo_JudgmentBehavior.Items[i]).ID) { cmbo_JudgmentBehavior.SelectedIndex = i; break; } } } }
private void Clear() { txt_Description.Text = string.Empty; txt_DescriptionEnglish.Text = string.Empty; txt_NameEnglish.Text = string.Empty; txt_Err_Description.Text = string.Empty; txt_Err_DescriptionEnglish.Text = string.Empty; txt_Err_NameEnglish.Text = string.Empty; txt_Err_Name.Text = string.Empty; txt_Name.Text = string.Empty; behaviour = new Behaviour(); cmbo_JudgmentBehavior.SelectedIndex = 0; }