Exemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();
            dataTable = new DataTable();
            dataTable.Columns.Add("用户名");
            dataTable.Columns.Add("论坛");
            dataTable.Columns.Add("当前状态");
            dataTable.Columns.Add("上次连接时间");
            userDataGridView.DataSource              = dataTable;
            userDataGridView.AllowUserToAddRows      = false;
            userDataGridView.AllowUserToDeleteRows   = false;
            userDataGridView.AllowUserToOrderColumns = true;
            userDataGridView.ReadOnly            = true;
            userDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            userDataGridView.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;
            userDataGridView.RowHeadersVisible = false;
            userDataGridView.MultiSelect       = false;
            userDataGridView.SelectionMode     = DataGridViewSelectionMode.FullRowSelect;
            notifyIcon1.Visible = false;
            stopButton.Enabled  = false;

            refreshers = S1Manager.GetUsersFromDB().Select(p => new Refresher(p.UserName, p.Password, p.QuestionID, p.Answer, p.FromForum))
                         .ToList();
            RefreshUserDataGridView();
        }
Exemplo n.º 2
0
        public void AddUser(string userName, string password, int questionID, string answer, ForumType type)
        {
            var refe = new Refresher(userName, password, questionID, answer, type);

            refreshers.Add(refe);
            S1Manager.AddUserToDB(refe.User);

            RefreshDataGridView();
        }
Exemplo n.º 3
0
        private void delButton_Click(object sender, EventArgs e)
        {
            if (IsRefreshing)
            {
                MessageBox.Show("删除用户请先停止刷新");
                return;
            }

            if (!refreshers.Any())
            {
                return;
            }

            var selectedName = userDataGridView.SelectedRows[0].Cells[0].Value as string;

            if (!string.IsNullOrWhiteSpace(selectedName))
            {
                refreshers.RemoveAll(p => p.User.UserName == selectedName);
                S1Manager.DelUserFromDB(selectedName);

                RefreshDataGridView();
            }
        }