// 刷新 private void button5_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag?.ToString() != "1") { dataGridView1.DataSource = UserCommons.GetUsers(treeView1.SelectedNode.Text); } }
private void button1_Click(object sender, EventArgs e) { if (UserCommons.ChangePassword(txtUser.Text, txtDescription.Text, txtPassWord.Text, _ip)) { MessageBox.Show("更改成功"); this.Close(); } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { dataGridView1.DataSource = null; if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag?.ToString() != "1") { this.Text = "用户管理:" + treeView1.SelectedNode.Text; dataGridView1.DataSource = UserCommons.GetUsers(treeView1.SelectedNode.Text); } }
//删除 private void button2_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag?.ToString() != "1") { if (dataGridView1.CurrentRow != null) { if (UserCommons.DeleteUser(dataGridView1.CurrentRow.Cells["Column1"]?.Value.ToString(), treeView1.SelectedNode.Text)) { MessageBox.Show("删除成功"); dataGridView1.DataSource = UserCommons.GetUsers(treeView1.SelectedNode.Text); } } } }
//更改 private void button3_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag?.ToString() != "1") { if (dataGridView1.CurrentRow != null) { new UserChangeForm(new UserModel() { Name = dataGridView1.CurrentRow.Cells["Column1"]?.Value.ToString(), DisplayName = dataGridView1.CurrentRow.Cells["Column2"]?.Value.ToString(), }, treeView1.SelectedNode.Text).ShowDialog(); dataGridView1.DataSource = UserCommons.GetUsers(treeView1.SelectedNode.Text); } } }
//添加 private void button1_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag?.ToString() != "1") { new UserForm(m => { var re = UserCommons.UpdateGroupUsers(m, "Users", treeView1.SelectedNode.Text); MessageBox.Show(re.Message); if (re.Status) { dataGridView1.DataSource = UserCommons.GetUsers(treeView1.SelectedNode.Text); } }).ShowDialog(); } }
//添加账户 private void button3_Click(object sender, EventArgs e) { new Action(() => { foreach (DataGridViewRow row in dataGridView1.Rows) { var model = new UserModel() { Name = row.Cells["Column1"].Value?.ToString(), DisplayName = row.Cells["Column1"].Value?.ToString(), }; var re = UserCommons.UpdateGroupUsers(model, "Users", _ip); SetRow(row, re.Message, re.Status); } }).BeginInvoke(null, null); }