private void ButtonEditItem_Click(object sender, RoutedEventArgs e)
        {
            if (_SelIndex < 0)
            {
                return;
            }

            bool canEdit = false;

            try
            {
                UserAccount item = Global.userAccounts[_SelIndex];
                if (string.Empty.Equals(item.UserPassword))
                {
                    canEdit = true;
                }
                else
                {
                    InputDialog dialog = new InputDialog("请输入密码");
                    dialog.ShowDialog();
                    if (dialog.GetResult())
                    {
                        if (dialog.GetInput().Equals(item.UserPassword))
                        {
                            canEdit = true;
                        }
                        else
                        {
                            canEdit = false;
                            MessageBox.Show("密码错误");
                            return;
                        }
                    }
                }
                if (canEdit)
                {
                    LoginNameEdit window = new LoginNameEdit()
                    {
                        _item         = Global.userAccounts[_SelIndex],
                        ShowInTaskbar = false,
                        Owner         = this
                    };
                    window.ShowDialog();
                    ShowAllItems(Global.userAccounts);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常:\n" + ex.Message);
            }
        }
        private void ButtonEditItem_Click(object sender, RoutedEventArgs e)
        {
            if (_SelIndex < 0)
            {
                MessageBox.Show("请选择一个用户!", "系统提示");
                return;
            }
            UserAccount item    = Global.userAccounts[_SelIndex];
            bool        canEdit = false;

            if (string.Empty.Equals(item.UserPassword) || LoginWindow._userAccount.UserName.Equals("admin"))
            {
                canEdit = true;
            }
            else
            {
                for (int i = 0; i < 1; i++)
                {
                    InputDialog dialog = new InputDialog("请输入密码!");
                    dialog.ShowDialog();
                    if (dialog.GetResult())
                    {
                        if (dialog.GetInput().Equals(item.UserPassword))
                        {
                            canEdit = true;
                            break;
                        }
                        else
                        {
                            canEdit = false;
                            MessageBox.Show("密码错误!", "系统提示");
                            i--;
                        }
                    }
                }
            }
            if (canEdit)
            {
                LoginNameEdit window = new LoginNameEdit()
                {
                    _strDic       = this._strDic,
                    _item         = Global.userAccounts[_SelIndex],
                    ShowInTaskbar = false,
                    Owner         = this
                };
                window.ShowDialog();
                this._strDic = null;
                ShowAllItems(Global.userAccounts);
            }
        }
예제 #3
0
        private void ButtonEditItem_Click(object sender, RoutedEventArgs e)
        {
            if (_SelIndex < 0)
            {
                MessageBox.Show("未选择任何项目!", "操作提示");
                return;
            }

            Global.WaitingWindowIsClose = true;
            DYHMItemPara item    = Global.hmItems[_SelIndex];
            bool         canEdit = false;

            if (string.Empty.Equals(item.Password))
            {
                canEdit = true;
            }
            else
            {
                for (int i = 0; i < 1; i++)
                {
                    InputDialog dialog = new InputDialog("请输入密码");
                    dialog.ShowDialog();
                    if (dialog.GetResult())
                    {
                        if (dialog.GetInput().Equals(item.Password))
                        {
                            canEdit = true;
                            break;
                        }
                        else
                        {
                            canEdit = false;
                            MessageBox.Show("密码错误");
                        }
                        i--;
                    }
                }
            }
            if (canEdit)
            {
                HmEditItemWindow window = new HmEditItemWindow()
                {
                    _item         = Global.hmItems[_SelIndex],
                    ShowInTaskbar = false,
                    Owner         = this
                };
                window.ShowDialog();
                ShowAllItems(Global.hmItems, _SelIndex);
            }
        }
        private void ButtonDelItem_Click(object sender, RoutedEventArgs e)
        {
            if (_SelIndex < 0)
            {
                return;
            }

            bool canEdit = false;

            try
            {
                UserAccount item = Global.userAccounts[_SelIndex];
                if (string.Empty.Equals(item.UserPassword))
                {
                    canEdit = true;
                }
                else
                {
                    InputDialog dialog = new InputDialog("请输入密码");
                    dialog.ShowDialog();
                    if (dialog.GetResult())
                    {
                        if (dialog.GetInput().Equals(item.UserPassword))
                        {
                            canEdit = true;
                        }
                        else
                        {
                            canEdit = false;
                            MessageBox.Show("密码错误");
                            return;
                        }
                    }
                }
                if (canEdit)
                {
                    Global.userAccounts.RemoveAt(_SelIndex);
                    _SelIndex = -1;
                    Global.SerializeToFile(Global.userAccounts, Global.userAccountsFile);
                    ShowAllItems(Global.userAccounts);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常:\n" + ex.Message);
            }
        }
예제 #5
0
        private void ButtonDelItem_Click(object sender, RoutedEventArgs e)
        {
            if (_SelIndex < 0)
            {
                MessageBox.Show("未选择任何项目!", "操作提示");
                return;
            }
            DYHMItemPara item    = Global.hmItems[_SelIndex];
            bool         canEdit = false;

            if (string.Empty.Equals(item.Password))
            {
                canEdit = true;
            }
            else
            {
                for (int i = 0; i < 1; i++)
                {
                    InputDialog dialog = new InputDialog("请输入密码");
                    dialog.ShowDialog();
                    if (dialog.GetResult())
                    {
                        if (dialog.GetInput().Equals(item.Password))
                        {
                            canEdit = true;
                            break;
                        }
                        else
                        {
                            canEdit = false;
                            MessageBox.Show("密码错误");
                        }
                        i--;
                    }
                }
            }
            if (canEdit)
            {
                Global.hmItems.RemoveAt(_SelIndex);
                Global.SerializeToFile(Global.hmItems, Global.hmItemsFile);
                ShowAllItems(Global.hmItems);
                _SelIndex = -1;
            }
        }
        private void ButtonDelItem_Click(object sender, RoutedEventArgs e)
        {
            if (_SelIndex < 0)
            {
                MessageBox.Show("请选择一个用户!", "系统提示");
                return;
            }
            UserAccount item    = Global.userAccounts[_SelIndex];
            bool        canEdit = false;

            if (item.UserName.Equals("admin"))
            {
                MessageBox.Show("不能删除此管理员用户!", "操作提示"); return;
            }
            else
            {
                if (LoginWindow._userAccount.UserName.Equals("admin"))
                {
                    if (MessageBox.Show("确定要删除此用户吗?", "操作提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        canEdit = true;
                    }
                }
                else
                {
                    if (string.Empty.Equals(item.UserPassword))
                    {
                        canEdit = true;
                    }
                    else
                    {
                        for (int i = 0; i < 1; i++)
                        {
                            InputDialog dialog = new InputDialog("请输入密码!");
                            dialog.ShowDialog();
                            if (dialog.GetResult())
                            {
                                if (dialog.GetInput().Equals(item.UserPassword))
                                {
                                    canEdit = true;
                                    break;
                                }
                                else
                                {
                                    canEdit = false;
                                    MessageBox.Show("密码错误!", "系统提示");
                                    i--;
                                }
                            }
                        }
                    }
                }
                if (canEdit)
                {
                    _strDic = null;
                    Global.userAccounts.RemoveAt(_SelIndex);
                    Global.SerializeToFile(Global.userAccounts, Global.userAccountsFile);
                    ShowAllItems(Global.userAccounts);
                }
            }
        }