Exemplo n.º 1
0
        private void ChangePasswordButton_Click(object sender, EventArgs e)
        {
            if (ChangePasswordTextbox.Text == "")
            {
                MessageBox.Show("密码只能由字母、数字、点、下划线组成,且不能为空!");
            }
            ShowPasswordTextbox.Enabled = true;
            DataTable dt = new DataTable();
            CTMySql   cm = new CTMySql();

            dt = cm.GetTableValue("Account");
            int    pkvalue = -1;
            string pkname  = dt.Columns[0].ColumnName;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (UserNameTextbox.Text == dt.Rows[i]["Account"].ToString())
                {
                    pkvalue = Convert.ToInt32(dt.Rows[i][0]);
                    break;
                }
            }
            cm.UpdataDatabass("account", ChangePasswordTextbox.Text, "Password", pkname, pkvalue);
            MessageBox.Show("密码修改成功!");
            ShowPasswordTextbox.Text = ChangePasswordTextbox.Text;
        }
Exemplo n.º 2
0
        private void ChangeAdminYesRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            CTMySql   cm = new CTMySql();

            dt = cm.GetTableValue("Account");
            int    pkvalue = -1;
            string pkname  = dt.Columns[0].ColumnName;

            if (dt.Rows[0]["Account"].ToString() == UserNameTextbox.Text)
            {
                MessageBox.Show("此默认账户不能被修改!");
                return;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (UserNameTextbox.Text == dt.Rows[i]["Account"].ToString())
                {
                    pkvalue = Convert.ToInt32(dt.Rows[i][0]);
                    break;
                }
            }
            if (ChangeAdminYesRadioButton.Checked)
            {
                cm.UpdataDatabass("Account", "1", "Level", pkname, pkvalue);
            }
            else
            {
                cm.UpdataDatabass("Account", "0", "Level", pkname, pkvalue);
            }
            cm.IsUserAdmin();
            this.Refresh();
            #region 获取所有用户信息
            //获取所有用户信息
            UserListView.BeginUpdate();

            UserListView.View = View.Details;
            UserListView.Clear();
            UserListView.Columns.Add("用户名(双击选择用户)", 200, HorizontalAlignment.Right);
            UserListView.Columns.Add("管理员", 50, HorizontalAlignment.Center);
            UserListView.FullRowSelect = true;

            dt = cm.GetTableValue("Account");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string name;
                ulong  admin;
                name  = (string)dt.Rows[i]["Account"];
                admin = (ulong)dt.Rows[i]["Level"];

                ListViewItem lvi = new ListViewItem();
                lvi.Text = name;
                if (admin == 1)
                {
                    lvi.SubItems.Add("是");
                }
                else
                {
                    lvi.SubItems.Add("否");
                }
                UserListView.Items.Add(lvi);
            }
            UserListView.EndUpdate();
            #endregion
        }