Ejemplo n.º 1
0
 private void tsbModify_Click(object sender, EventArgs e)
 {
     if (tvRYZ.SelectedNode == null)
     {
         Dlg.ShowErrorInfo("未选择要修改的角色!");
         return;
     }
     if (tvRYZ.SelectedNode.Text == "管理员")
     {
         Dlg.ShowErrorInfo("管理员角色不允许修改!");
         return;
     }
     using (FrmInput mForm = new FrmInput())
     {
         mForm.txtInput.Text = tvRYZ.SelectedNode.Text;
         int zbh = Convert.ToInt32(tvRYZ.SelectedNode.Tag);
         if (mForm.ShowDialog() == DialogResult.OK)
         {
             string sSql = string.Format("select count(*) from PTRole where zmc='{0}'", mForm.txtInput.Text.Trim());
             int    iRet = (int)SqlHelper.ExecuteScalar(sSql);
             if (iRet == -1)
             {
                 return;
             }
             if (iRet != 0)
             {
                 Dlg.ShowErrorInfoAndHelp(string.Format("输入的新角色名称“{0}”已存在,不能修改!", mForm.txtInput.Text.Trim()));
                 return;
             }
             sSql = string.Format("update PTRole set zmc='{0}' where zbh={1}", mForm.txtInput.Text.Trim(), zbh);
             int ret = SqlHelper.ExecuteNonQuery(sSql);
             InitRYZ();
         }
     }
 }
Ejemplo n.º 2
0
        private void tsbResetPass_Click(object sender, EventArgs e)
        {
            //Confirm
            if (Dlg.ShowConfirmInfo("确认要重置密码吗?") == DialogResult.No)
            {
                return;
            }
            if (dgvRY.SelectedRows.Count < 1)
            {
                Dlg.ShowErrorInfoAndHelp("请先选择要重置的用户");
                return;
            }
            long id = Convert.ToInt64(dgvRY.SelectedRows[0].Cells[ColID.Index].Value);

            using (FrmInput mForm = new FrmInput())
            {
                if (mForm.ShowDialog() == DialogResult.OK)
                {
                    string strPass = mForm.txtInput.Text.Trim();
                    strPass = MD5.Md5Encrypt(strPass);

                    string mSql = string.Format("update t_users set password='******' where id={1}", strPass, id);
                    int    ret  = SqlHelper.ExecuteNonQuery(mSql);
                    if (ret > 0)
                    {
                        Dlg.ShowOKInfo("重置成功!");
                    }
                    else
                    {
                        Dlg.ShowErrorInfo("重置失败!");
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void tsbAddRole_Click(object sender, EventArgs e)
 {
     using (FrmInput mForm = new FrmInput())
     {
         if (mForm.ShowDialog() == DialogResult.OK)
         {
             int iRet = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(*) from PTRole where ZMC='{0}'", mForm.txtInput.Text.Trim())));
             if (iRet > 0)
             {
                 Dlg.ShowErrorInfoAndHelp("该角色已存在,请重新创建!");
                 return;
             }
             iRet = SqlHelper.ExecuteNonQuery(string.Format("insert into PTRole(zmc)values('{0}')", mForm.txtInput.Text.Trim()));
             InitRYZ();
             if (iRet != 0)
             {
                 Dlg.ShowOKInfo("创建成功!");
             }
         }
     }
 }