Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Ctrl_Sys_User dcUserInfo = new Ctrl_Sys_User();

            if (dcUserInfo.Exists(int.Parse(hdUserId.Value), txtUserName.Text))
            {
                MessageBox.Show(this, "用户名称,不允许重复!");
                return;
            }

            int iUserInfoId = int.Parse(hdUserId.Value.ToString());//取得区\县标识
            UserInfoEntity userInfo = new UserInfoEntity();
            userInfo.UserId = iUserInfoId;
            userInfo.UserName = txtUserName.Text;
            userInfo.UserNickName = txtUserNickName.Text;
            userInfo.UserLevel = int.Parse(drpUserLevel.SelectedValue);
            userInfo.StreetId = drpStreet.Enabled == true ? int.Parse(drpStreet.SelectedValue) : 0;
            userInfo.CommunityId = drpCommunity.Enabled == true ? int.Parse(drpCommunity.SelectedValue) : 0;

            if (iUserInfoId == 0)//代表添加
            {
                userInfo.UserPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtUserPwd.Text, "md5");
                iUserInfoId = dcUserInfo.Add(userInfo);
                if (iUserInfoId > 0)
                {
                    dcUserInfo.AddUserRole(iUserInfoId, int.Parse(drpUserRole.SelectedValue));
                    MessageBox.ShowAndRedirect(this, "成功添加一条信息!", "OperManage.aspx");
                }
                else
                {
                    MessageBox.Show(this, "添加信息失败,请与管理员联系!");
                }
            }
            else
            {
                if (chkIsModPwd.Checked)
                {
                    userInfo.UserPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtUserPwd.Text, "md5");
                }
                else
                {
                    userInfo.UserPwd = hdUserPwd.Value;
                }
                if (dcUserInfo.UpdateUserRole(iUserInfoId, int.Parse(drpUserRole.SelectedValue)) && dcUserInfo.Update(userInfo))
                {
                    MessageBox.ShowAndRedirect(this, "成功修改一条信息!", "OperManage.aspx");
                }
                else
                {
                    MessageBox.Show(this, "修改信息失败,请与管理员联系!");
                }
            }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            String sOldPwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtUserPwd.Text, "MD5");
            if (sOldPwd != Session["PassWord"].ToString())
            {
                MessageBox.Show(this, "请正确输入原密码!");
                return;
            }

            string sNewPwd=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPwd.Text, "MD5");
            Ctrl_Sys_User dacUserInfo = new Ctrl_Sys_User();
            if (dacUserInfo.UpdateUserPwd(Session["UserName"].ToString(), sNewPwd))
            {
                MessageBox.ShowAndRedirect(this, "更改密码成功,重新登录有效!", "/SystemManage/SystemManage.aspx");
            }
            else
            {
                MessageBox.Show(this, "更改密码失败,请与管理员联系!");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 绑定控件数据
        /// </summary>
        private void BindControlData()
        {
            Ctrl_Sys_User dcUserInfo = new Ctrl_Sys_User();
            int iUserInfoId = int.Parse(hdUserId.Value.ToString());//取得区\县标识
            UserInfoEntity userInfo = dcUserInfo.GetModel(iUserInfoId);
            drpUserRole.SelectedValue = userInfo.UserRole.ToString();
            if (userInfo.StreetId != 0)
            {
                drpStreet.Enabled = true;
                drpStreet.SelectedValue = userInfo.StreetId.ToString();

                drpCommunity.DataSource = Ctrl_Area.GetCommunityListByStreetId(int.Parse(drpStreet.SelectedValue)); ;
                drpCommunity.DataTextField = "Name";
                drpCommunity.DataValueField = "Id";
                drpCommunity.DataBind();
            }
            else
            {
                drpStreet.Enabled = false;
                drpCommunity.Enabled = false;
            }
            if (userInfo.CommunityId != 0)
            {
                drpCommunity.Enabled = true;
                drpCommunity.SelectedValue = userInfo.CommunityId.ToString();
            }
            else
                drpCommunity.Enabled = false;
            txtUserName.Text = userInfo.UserName;
            txtUserNickName.Text = userInfo.UserNickName;
            hdUserPwd.Value = userInfo.UserPwd;
            chkIsModPwd.Visible = true;
            BindDrpRoleInfo(userInfo.UserLevel);
            drpUserLevel.SelectedValue = userInfo.UserLevel.ToString();
        }