Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int nSel = listBox1.SelectedIndex;

            if (nSel < 0)
            {
                lbmsg.Text = "请选择需要初始化密码的用户...";
                return;
            }
            if (MessageBox.Show("确定初始化用户[" + listBox1.Text + "]密码吗?", "信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
            {
                lbmsg.Text = "正在初始化密码...";
                lbmsg.Refresh();

                LgUser lu     = (LgUser)m_arryUsers[nSel];
                string strSql = "UPDATE BT_USER_REGISTER SET UserPWS='1234' WHERE ID=" + lu.sIndex;
                if (!m_pDbMSSql.ExecuteSql(strSql))
                {
                    lbmsg.Text = @"初始化密码失败!";
                }
                else
                {
                    lbmsg.Text = "用户密码[" + listBox1.Text + "]初始为1234";
                }
            }
        }
Ejemplo n.º 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            int nSel = listBox1.SelectedIndex;

            if (nSel < 0)
            {
                lbmsg.Text = "请选择要删除的用户...";
                return;
            }
            if (MessageBox.Show("确定删除用户[" + listBox1.Text + "]?删除不可恢复", "信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
            {
                lbmsg.Text = "正在删除用户信息...";
                lbmsg.Refresh();

                LgUser lu     = (LgUser)m_arryUsers[nSel];
                string strSql = "DELETE FROM BT_USER_REGISTER WHERE ID=" + lu.sIndex;
                if (m_pDbMSSql.ExecuteSql(strSql))
                {
                    listBox1.Items.RemoveAt(nSel);
                    m_arryUsers.RemoveAt(nSel);
                    m_arryUsers.TrimToSize();

                    textBox1.Text = "";
                    textBox2.Text = "";

                    lbmsg.Text = "完成删除用户信息";
                }
                else
                {
                    lbmsg.Text = "删除成败";
                }
            }
        }
Ejemplo n.º 3
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int nSel = listBox1.SelectedIndex;

            if (nSel < 0)
            {
                return;
            }
            LgUser lu = (LgUser)m_arryUsers[nSel];

            textBox1.Text = lu.sId;
            textBox2.Text = lu.sName;
            int m = Convert.ToInt32(lu.sRole);

            if (m >= 0 && m < 3)
            {
                UserRole.SelectedIndex = m;
            }
            nCurId     = nSel;
            lbmsg.Text = "";
        }
Ejemplo n.º 4
0
        private void InitList()
        {
            if (m_pDbMSSql == null)
            {
                return;
            }
            string  sSql = "SELECT * FROM BT_USER_REGISTER";
            DataSet ds   = m_pDbMSSql.GetDataSet(sSql);

            if (ds == null)
            {
                return;
            }
            if (ds.Tables.Count == 0)
            {
                return;
            }
            if (ds.Tables[0].Rows.Count == 0)
            {
                return;
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow DR = ds.Tables[0].Rows[i];

                LgUser lu = new LgUser();
                lu.sIndex = DR[0].ToString();
                lu.sId    = DR[1].ToString();
                lu.sPass  = DR[2].ToString();
                lu.sName  = DR[3].ToString();
                lu.sRole  = DR[4].ToString();

                m_arryUsers.Add(lu);

                listBox1.Items.Add(DR[3].ToString() + "(" + DR[1].ToString() + ")");
            }
        }
Ejemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                lbmsg.Text = "用户登录账号不能为空!";
                return;
            }
            if (textBox2.Text == "")
            {
                lbmsg.Text = "请输入用户真实姓名!";
                return;
            }
            if (UserRole.Text == "")
            {
                lbmsg.Text = "请选择用户角色!";
                return;
            }

            lbmsg.Text = "正在保存用户信息...";
            lbmsg.Refresh();

            if (nCurId == -1)
            {
                string strSql = "INSERT INTO BT_USER_REGISTER(UserID,UserPWS,UserName,UserRole) VALUES('" + textBox1.Text + "','1234','" + textBox2.Text + "','" + UserRole.SelectedIndex.ToString() + "')";
                if (m_pDbMSSql.ExecuteSql(strSql))
                {
                    LgUser lu = new LgUser();

                    lu.sId   = textBox1.Text;
                    lu.sName = textBox2.Text;
                    lu.sRole = UserRole.SelectedIndex.ToString();

                    m_arryUsers.Add(lu);
                    listBox1.Items.Add(lu.sName + "(" + lu.sId + ")");

                    lbmsg.Text = "完成创建新用户";
                }
                else
                {
                    lbmsg.Text = "创建新用户失败";
                }
            }
            else
            {
                int    nSel = listBox1.SelectedIndex;
                LgUser lu   = (LgUser)m_arryUsers[nSel];

                string strSql = "UPDATE BT_USER_REGISTER SET UserName='******',UserRole='" + UserRole.SelectedIndex.ToString() + "' WHERE ID=" + lu.sIndex;
                if (m_pDbMSSql.ExecuteSql(strSql))
                {
                    lu.sId               = textBox1.Text;
                    lu.sName             = textBox2.Text;
                    lu.sRole             = UserRole.SelectedIndex.ToString();
                    listBox1.Items[nSel] = lu.sName + "(" + lu.sId + ")";

                    lbmsg.Text = "完成保存用户信息";
                }
                else
                {
                    lbmsg.Text = "保存用户信息失败!";
                }
            }
        }