Exemplo n.º 1
0
        /// <summary>
        /// 绑定用户。
        /// 作者:董帅 创建时间:2012-8-23 21:40:38
        /// </summary>
        public void bindUserInfos()
        {
            try
            {
                //获取配置文件路径。
                string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                //获取数据库操作对象
                OrgOperater orgOper = OrgOperater.createOrgOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);
                if (orgOper != null)
                {
                    List <UserInfo> users = orgOper.getUserByOrganizationId(Convert.ToInt32(this.hidParentId.Value));
                    if (users != null)
                    {
                        this.userList.DataSource = users;
                        this.userList.DataBind();
                    }
                    else
                    {
                        YMessageBox.show(this, "获取用户数据失败!错误信息[" + orgOper.errorMessage + "]");
                    }
                }
                else
                {
                    YMessageBox.show(this, "获取数据库操作对象失败!");
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "运行错误!错误信息[" + ex.Message + "]");
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!this.IsPostBack)
                {
                    //获取父id
                    string parentId = Request.QueryString["parentId"];
                    if (!string.IsNullOrEmpty(parentId))
                    {
                        this.hidParentId.Value = parentId;
                    }
                    else
                    {
                        YMessageBox.show(this, "未设置父菜单id失败!");
                    }

                    //获取id
                    string strId = Request.QueryString["id"];
                    if (!string.IsNullOrEmpty(strId))
                    {
                        this.hidOrgId.Value = strId;


                        //获取配置文件路径。
                        string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                        //创建操作对象
                        OrgOperater orgOper = OrgOperater.createOrgOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);
                        if (orgOper != null)
                        {
                            //获取机构信息
                            OrganizationInfo org = orgOper.getOrganization(Convert.ToInt32(strId));
                            if (org != null)
                            {
                                this.txtOrgName.Value  = org.name;
                                this.txtOrgOrder.Value = org.order.ToString();
                            }
                            else
                            {
                                YMessageBox.show(this, "获取机构信息失败!错误信息[" + orgOper.errorMessage + "]");
                                return;
                            }
                        }
                        else
                        {
                            YMessageBox.show(this, "创建数据库操作对象失败!");
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "程序运行出错!错误信息[" + ex.Message + "]");
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //获取父id
                string orgId = Request.QueryString["orgId"];
                if (!string.IsNullOrEmpty(orgId))
                {
                    this.hidOrgId.Value = orgId;
                }
                else
                {
                    YMessageBox.show(this, "未设置组织机构id!");
                }

                //获取id
                string strId = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(strId))
                {
                    this.hidUserId.Value = strId;

                    this.txtUserLogName.Disabled = true;
                    //获取配置文件路径。
                    string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                    //创建操作对象
                    OrgOperater orgOper = OrgOperater.createOrgOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);
                    if (orgOper != null)
                    {
                        ////获取用户信息
                        UserInfo user = orgOper.getUser(Convert.ToInt32(strId));
                        if (user != null)
                        {
                            this.txtUserLogName.Value = user.logName;
                            this.txtUserName.Value    = user.name;
                            this.txtUserOrder.Value   = user.order.ToString();
                        }
                        else
                        {
                            YMessageBox.show(this, "获取机构信息失败!错误信息[" + orgOper.errorMessage + "]");
                            return;
                        }
                    }
                    else
                    {
                        YMessageBox.show(this, "创建数据库操作对象失败!");
                        return;
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 绑定组织机构。
        /// 作者:董帅 创建时间:2012-8-22 13:45:41
        /// </summary>
        public void bindOrgInfos()
        {
            try
            {
                //获取配置文件路径。
                string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                //获取数据库操作对象
                OrgOperater orgOper = OrgOperater.createOrgOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);
                if (orgOper != null)
                {
                    //获取父机构信息
                    if (this.hidParentId.Value == "-1")
                    {
                        this.spanParentName.InnerText = "顶级机构";
                        this.returnButton.Disabled    = true;
                        this.hidReturnId.Value        = "";
                    }
                    else
                    {
                        OrganizationInfo org = orgOper.getOrganization(Convert.ToInt32(this.hidParentId.Value));
                        this.spanParentName.InnerText = org.name;
                        this.hidReturnId.Value        = org.parentId.ToString();
                    }

                    //获取组织机构列表
                    List <OrganizationInfo> orgs = orgOper.getOrganizationByParentId(Convert.ToInt32(this.hidParentId.Value));
                    if (orgs != null)
                    {
                        this.orgList.DataSource = orgs;
                        this.orgList.DataBind();
                    }
                    else
                    {
                        YMessageBox.show(this, "获取组织机构数据失败!错误信息[" + orgOper.errorMessage + "]");
                    }
                }
                else
                {
                    YMessageBox.show(this, "获取数据库操作对象失败!");
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "运行错误!错误信息[" + ex.Message + "]");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void butDeleteItems_Click(object sender, EventArgs e)
        {
            try
            {
                string   s       = Request["chkOrg"];
                string[] orgIds  = new string[0];
                string[] userIds = new string[0];
                if (!string.IsNullOrEmpty(s))
                {
                    orgIds = s.Split(','); //要删除的机构id
                }

                s = Request["chkUser"];
                if (!string.IsNullOrEmpty(s))
                {
                    userIds = s.Split(','); //要删除的用户id
                }

                if ((orgIds.Length + userIds.Length) > 0)
                {
                    //获取配置文件路径。
                    string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                    //创建数据库操作对象。
                    OrgOperater orgOper = OrgOperater.createOrgOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);
                    if (orgOper != null)
                    {
                        //删除机构和用户
                        int[] orgIntIds = new int[orgIds.Length];
                        for (int i = 0; i < orgIds.Length; i++)
                        {
                            orgIntIds[i] = Convert.ToInt32(orgIds[i]);
                        }

                        int[] userIntIds = new int[userIds.Length];
                        for (int i = 0; i < userIds.Length; i++)
                        {
                            userIntIds[i] = Convert.ToInt32(userIds[i]);
                        }

                        if (orgOper.deleteOrganizationAndUser(orgIntIds, userIntIds))
                        {
                            this.Response.Redirect("organization_list.aspx?parentId=" + this.hidParentId.Value);
                            //YMessageBox.showAndResponseScript(this, "删除数据成功!", "", "window.parent.menuButtonOnClick('组织机构管理','icon-organization','sys/organization/organization_list.aspx?parentId=" + this.hidParentId.Value + "')");
                        }
                        else
                        {
                            YMessageBox.show(this, "删除数据失败!错误信息[" + orgOper.errorMessage + "]");
                        }
                    }
                    else
                    {
                        YMessageBox.show(this, "获取数据库实例失败!");
                    }
                }
                else
                {
                    YMessageBox.show(this, "没有选择要删除的角色!");
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "系统运行异常!异常信息[" + ex.Message + "]");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 保存。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void butSave_Click(object sender, EventArgs e)
        {
            try
            {
                UserInfo user = new UserInfo();

                user.logName = this.txtUserLogName.Value;
                if (string.IsNullOrEmpty(user.logName) || user.logName.Length > 20)
                {
                    YMessageBox.show(this, "用户名不合法!");
                    return;
                }

                user.logPassword = this.txtUserLogPassword1.Value;
                if (string.IsNullOrEmpty(user.logPassword) || user.logPassword.Length > 40)
                {
                    //新增时报错
                    if (string.IsNullOrEmpty(this.hidUserId.Value))
                    {
                        YMessageBox.show(this, "用户登陆密码不合法!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(user.logPassword))
                {
                    //用户密码二次加密
                    MD5Encrypt md5Encrypt = new MD5Encrypt();
                    user.logPassword = md5Encrypt.GetMD5(user.logPassword);
                }

                user.name = this.txtUserName.Value;
                if (string.IsNullOrEmpty(user.name) || user.name.Length > 20)
                {
                    YMessageBox.show(this, "姓名不合法!");
                    return;
                }

                user.order = Convert.ToInt32(this.txtUserOrder.Value);

                user.organizationId = Convert.ToInt32(this.hidOrgId.Value);

                //获取配置文件路径。
                string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                //创建操作对象
                OrgOperater orgOper = OrgOperater.createOrgOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);
                if (orgOper != null)
                {
                    if (string.IsNullOrEmpty(this.hidUserId.Value))
                    {
                        //判断用户是否存在
                        if (orgOper.existUser(user.logName))
                        {
                            YMessageBox.show(this, "用户名已存在,请更换用户名后重试!");
                            return;
                        }

                        //新增
                        if (orgOper.createNewUser(user) > 0)
                        {
                            YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.parent.menuButtonOnClick('组织机构管理','icon-organization','sys/organization/organization_list.aspx?parentId=" + this.hidOrgId.Value + "');window.parent.closePopupsWindow('#popups');");
                        }
                        else
                        {
                            YMessageBox.show(this, "创建机构失败!错误信息:[" + orgOper.errorMessage + "]");
                            return;
                        }
                    }
                    else
                    {
                        //修改
                        user.id = Convert.ToInt32(this.hidUserId.Value);
                        if (orgOper.changeUser(user))
                        {
                            bool bRet = true;
                            if (!string.IsNullOrEmpty(user.logPassword))
                            {
                                //修改密码
                                bRet = orgOper.changePassword(user);
                            }
                            if (bRet)
                            {
                                YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.parent.menuButtonOnClick('组织机构管理','icon-organization','sys/organization/organization_list.aspx?parentId=" + this.hidOrgId.Value + "');window.parent.closePopupsWindow('#popups');");
                            }
                            else
                            {
                                YMessageBox.show(this, "修改密码失败!错误信息:[" + orgOper.errorMessage + "]");
                            }
                        }
                        else
                        {
                            YMessageBox.show(this, "修改用户失败!错误信息:[" + orgOper.errorMessage + "]");
                            return;
                        }
                    }
                }
                else
                {
                    YMessageBox.show(this, "创建数据库操作对象失败!");
                    return;
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "程序异常!错误信息[" + ex.Message + "]");
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 保存。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void butSave_Click(object sender, EventArgs e)
        {
            try
            {
                OrganizationInfo orgInfo = new OrganizationInfo();

                orgInfo.name = this.txtOrgName.Value;
                if (string.IsNullOrEmpty(orgInfo.name) || orgInfo.name.Length > 50)
                {
                    YMessageBox.show(this, "机构名称不合法!");
                    return;
                }

                orgInfo.order = Convert.ToInt32(this.txtOrgOrder.Value);

                orgInfo.parentId = Convert.ToInt32(this.hidParentId.Value);

                //获取配置文件路径。
                string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName;

                //创建操作对象
                OrgOperater orgOper = OrgOperater.createOrgOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey);
                if (orgOper != null)
                {
                    if (string.IsNullOrEmpty(this.hidOrgId.Value))
                    {
                        //新增
                        if (orgOper.createNewOrganization(orgInfo) > 0)
                        {
                            YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.parent.menuButtonOnClick('组织机构管理','icon-organization','sys/organization/organization_list.aspx?parentId=" + this.hidParentId.Value + "');window.parent.closePopupsWindow('#popups');");
                        }
                        else
                        {
                            YMessageBox.show(this, "创建机构失败!错误信息:[" + orgOper.errorMessage + "]");
                            return;
                        }
                    }
                    else
                    {
                        //修改
                        orgInfo.id = Convert.ToInt32(this.hidOrgId.Value);
                        if (orgOper.changeOrganization(orgInfo))
                        {
                            YMessageBox.showAndResponseScript(this, "保存成功!", "", "window.parent.menuButtonOnClick('组织机构管理','icon-organization','sys/organization/organization_list.aspx?parentId=" + this.hidParentId.Value + "');window.parent.closePopupsWindow('#popups');");
                        }
                        else
                        {
                            YMessageBox.show(this, "修改机构失败!错误信息:[" + orgOper.errorMessage + "]");
                            return;
                        }
                    }
                }
                else
                {
                    YMessageBox.show(this, "创建数据库操作对象失败!");
                    return;
                }
            }
            catch (Exception ex)
            {
                YMessageBox.show(this, "程序异常!错误信息[" + ex.Message + "]");
            }
        }