private void btn_Delete_Click(object sender, RoutedEventArgs e)
 {
     if (grd_Users.SelectedItem != null)
     {
         userEntity = (User)grd_Users.SelectedItem;
         MessageBoxResult result = MessageBox.Show("هل انت متأكد من حذف " + userEntity.FullName, "حذف المستخدم", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             userDomain.Delete(userEntity);
             if (userDomain.ActionState.Status == Common.Enums.ActionStatusEnum.NoError)
             {
                 MessageBox.Show("تم الحذف بنجاح", "حذف المستخدم", MessageBoxButton.OK, MessageBoxImage.Information);
                 userList.Remove(userEntity);
                 grd_Users.ItemsSource = null;
                 grd_Users.ItemsSource = userList;
                 Clear();
             }
             else
             {
                 MessageBox.Show(userDomain.ActionState.Result, "حذف المستخدم", MessageBoxButton.OK, MessageBoxImage.Error);
                 Clear();
             }
         }
     }
 }
Пример #2
0
        private void LoginOperation()
        {
            UserDomain userDomain = new UserDomain(1, Common.Enums.LanguagesEnum.Arabic);
            User userEntity = new User();
            userEntity = userDomain.CheckUserLogin(txt_Username.Text, txt_Password.Password);
            if (userDomain.ActionState.Status != Common.Enums.ActionStatusEnum.NoError)
            {
                SetError(0, userDomain.ActionState.Result);
            }
            else
            {
                UISecurity.UserEntity = userEntity;
                AppWindow appWindow = new AppWindow();

                appWindow.Show();
                ((Window)((Grid)this.Parent).Parent).Close();

            }
        }
        private void grd_Users_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (grd_Users.SelectedItem != null)
            {
                userEntity = (User)grd_Users.SelectedItem;
                userEntity = userDomain.FindByID(userEntity.ID);
                if (userDomain.ActionState.Status != Common.Enums.ActionStatusEnum.NoError)
                {
                    MessageBox.Show(userDomain.ActionState.Result, "جلب معلومات المستخدم", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                txt_Email.Text = userEntity.Email;
                txt_FullName.Text = userEntity.FullName;
                txt_Password.Password = userEntity.Password;
                txt_Phone.Text = userEntity.Phone;
                txt_RePassword.Password = txt_Password.Password;
                txt_Username.Text = userEntity.Username;

                for (int i = 0; i < cmbo_Group.Items.Count; i++)
                {
                    if (((Group)cmbo_Group.Items[i]).ID == userEntity.Group.ID)
                    {
                        cmbo_Group.SelectedIndex = i;
                        break;
                    }
                }
            }
            else
            {
            }
        }
        private void Clear()
        {
            txt_Email.Text = string.Empty;
            txt_FullName.Text = string.Empty;
            txt_Password.Password = string.Empty;
            txt_Phone.Text = string.Empty;
            cmbo_Group.SelectedIndex = 0;
            txt_RePassword.Password = string.Empty;
            txt_Username.Text = string.Empty;

            txt_Err_Email.Text = string.Empty;
            txt_Err_FullName.Text = string.Empty;
            txt_Err_Password.Text = string.Empty;
            txt_Err_Phone.Text = string.Empty;
            txt_Err_RePassword.Text = string.Empty;
            txt_Err_Username.Text = string.Empty;
            userEntity = new User();
        }