Пример #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            AdminInfo entity = new AdminInfo();
            int id = GetInt("id");
            if (id > 0) entity = Admins.Instance.GetAdmin(id);
            FillData(entity);

            if (id > 0) Admins.Instance.UpdateAdmin(entity);
            else Admins.Instance.AddAdmin(entity);

            Response.Redirect(string.IsNullOrEmpty(FromUrl) ? "adminmg.aspx" : FromUrl);
        }
Пример #2
0
 private void FillData(AdminInfo entity)
 {
     entity.UserName = txtUserName.Value;
     entity.UserRole = UserRoleType.系统管理员;
     entity.Password = EncryptString.MD5(txtPassword.Value);
     entity.PasswordText = txtPassword.Value;
     entity.Realname = txtRealname.Value;
     entity.Mobile = txtMobile.Value;
     entity.QQ = txtQQ.Value;
     entity.Sex = DataConvert.SafeInt(rblSex.SelectedValue);
     entity.LastLoginIP = string.Empty;
     if (!entity.Administrator)
     {
         entity.CorporationID = DataConvert.SafeInt(ddlCorp.SelectedValue);
         entity.Corporation = ddlCorp.SelectedItem.Text;
     }
     entity.State = rblState.SelectedValue;
 }
Пример #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            AdminInfo entity = new AdminInfo()
            {
                UserRole = UserRoleType.普通用户
            };
            int id = GetInt("id");
            if (id > 0) entity = Admins.Instance.GetAdmin(id);
            FillData(entity);

            if (id > 0) Admins.Instance.UpdateAdmin(entity);
            else
            {
                Admins.Instance.AddAdmin(entity);
                PowerGroups.Instance.ReloadPowerGroupListCache();
            }

            Response.Redirect(string.IsNullOrEmpty(FromUrl) ? "adminmg.aspx" : FromUrl);
        }
Пример #4
0
 /// <summary>
 /// 添加管理员
 /// </summary>
 /// <param name="model">后台用户实体类</param>
 /// <returns>添加成功返回ID</returns>
 public override int AddAdmin(AdminInfo model)
 {
     SerializerData data = model.GetSerializerData();
     string sql = @"
     INSERT INTO ComOpp_AdminUser(UserName,Password,Administrator,LastLoginIP,LastLoginTime,[PropertyNames],[PropertyValues],[UserRole],[PowerGroupID])
     VALUES (@UserName,@Password,@Administrator,@LastLoginIP,@LastLoginTime,@PropertyNames,@PropertyValues,@UserRole,@PowerGroupID)
     ;SELECT @@IDENTITY";
     SqlParameter[] p =
     {
         new SqlParameter("@UserName",model.UserName),
         new SqlParameter("@Password",model.Password),
         new SqlParameter("@Administrator",model.Administrator),
         new SqlParameter("@LastLoginIP",model.LastLoginIP),
         new SqlParameter("@LastLoginTime",model.LastLoginTime),
         new SqlParameter("@UserRole",model.UserRole),
         new SqlParameter("@PowerGroupID",model.PowerGroupID),
         new SqlParameter("@PropertyNames",data.Keys),
         new SqlParameter("@PropertyValues",data.Values)
     };
     model.ID = DataConvert.SafeInt(SqlHelper.ExecuteScalar(_con, CommandType.Text, sql, p));
     return model.ID;
 }
Пример #5
0
 /// <summary>
 /// 添加管理员
 /// </summary>
 /// <param name="model">后台用户实体类</param>
 /// <returns>添加成功返回ID</returns>
 public int AddAdmin(AdminInfo model)
 {
     return CommonDataProvider.Instance().AddAdmin(model);
 }
Пример #6
0
 /// <summary>
 /// 更新管理员
 /// </summary>
 /// <param name="model">后台用户实体类</param>
 /// <returns>修改是否成功</returns>
 public bool UpdateAdmin(AdminInfo model)
 {
     return CommonDataProvider.Instance().UpdateAdmin(model);
 }
Пример #7
0
        private void FillData(AdminInfo entity)
        {
            entity.UserName = txtUserName.Value;
            entity.Password = EncryptString.MD5(txtPassword.Value);
            entity.PasswordText = txtPassword.Value;
            entity.Realname = txtRealname.Value;
            entity.Mobile = txtMobile.Value;
            entity.QQ = txtQQ.Value;
            entity.Sex = DataConvert.SafeInt(rblSex.SelectedValue);
            entity.LastLoginIP = string.Empty;
            entity.State = rblState.SelectedValue;
            if (entity.UserRole == UserRoleType.普通用户)
                entity.PowerGroupID = DataConvert.SafeInt(hdnPowerGroup.Value);

            if (Admin.Administrator)
            {
                entity.CorporationID = DataConvert.SafeInt(ddlCorporation.SelectedValue);
                entity.Corporation = ddlCorporation.SelectedItem.Text;
            }
            else
            {
                entity.CorporationID = Admin.CorporationID;
                entity.Corporation = Admin.Corporation;
            }
        }
Пример #8
0
        private void LoadData()
        {
            int id = GetInt("id");
            if (id > 0)
            {
                CurrentAdmin = Admins.Instance.GetAdmin(id);
                if (CurrentAdmin == null)
                    WriteMessage("/message.aspx", "系统提示", "无效账户!", "", "/index.aspx");
                else
                {
                    if (!Admin.Administrator && Admin.CorporationID != CurrentAdmin.CorporationID)
                        WriteMessage("/message.aspx", "系统提示", "没有权限!", "", "/index.aspx");

                    txtUserName.Value = CurrentAdmin.UserName;
                    txtUserName.Attributes["readonly"] = "true";
                    txtPassword.Value = CurrentAdmin.PasswordText;
                    txtRealname.Value = CurrentAdmin.Realname;
                    txtMobile.Value = CurrentAdmin.Mobile;
                    txtQQ.Value = CurrentAdmin.QQ;
                    SetSelectedByValue(rblSex, CurrentAdmin.Sex.ToString());
                    SetSelectedByValue(rblState, CurrentAdmin.State);
                    if (Admin.Administrator)
                    {
                        SetSelectedByValue(ddlCorporation, CurrentAdmin.CorporationID.ToString());
                        CorporationChanged(DataConvert.SafeInt(ddlCorporation.SelectedValue));
                    }
                    else
                    {
                        CorporationChanged(DataConvert.SafeInt(Admin.CorporationID));
                    }
                    SetSelectedByValue(ddlPowerGroupEdit, CurrentAdmin.PowerGroupID.ToString());
                    hdnPowerGroup.Value = CurrentAdmin.PowerGroupID.ToString();
                }
            }
            else
            {
                if (!Admin.Administrator)
                    CorporationChanged(DataConvert.SafeInt(Admin.CorporationID));
                else
                    CorporationChanged(DataConvert.SafeInt(ddlCorporation.SelectedValue));
                hdnPowerGroup.Value = ddlPowerGroupEdit.SelectedValue;
            }
        }
Пример #9
0
 /// <summary>
 /// 更新管理员
 /// </summary>
 /// <param name="model">后台用户实体类</param>
 /// <returns>修改是否成功</returns>
 public override bool UpdateAdmin(AdminInfo model)
 {
     SerializerData data = model.GetSerializerData();
     string sql = @"UPDATE ComOpp_AdminUser SET
     UserName = @UserName
     ,Password = @Password
     ,Administrator = @Administrator
     ,LastLoginIP = @LastLoginIP
     ,LastLoginTime = @LastLoginTime
     ,UserRole = @UserRole
     ,PowerGroupID = @PowerGroupID
     ,[PropertyNames] = @PropertyNames
     ,[PropertyValues] = @PropertyValues
     WHERE ID = @ID
     ";
     SqlParameter[] p =
     {
         new SqlParameter("@UserName",model.UserName),
         new SqlParameter("@Password",model.Password),
         new SqlParameter("@Administrator",model.Administrator),
         new SqlParameter("@LastLoginIP",model.LastLoginIP),
         new SqlParameter("@LastLoginTime",model.LastLoginTime),
         new SqlParameter("@UserRole",(int)model.UserRole),
         new SqlParameter("@PowerGroupID",model.PowerGroupID),
         new SqlParameter("@PropertyNames",data.Keys),
         new SqlParameter("@PropertyValues",data.Values),
         new SqlParameter("@ID",model.ID)
     };
     int result = SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, p);
     if (result > 0)
     {
         return true;
     }
     return false;
 }
Пример #10
0
        private void LoadData()
        {
            int id = GetInt("id");
            if (id > 0)
            {
                CurrentAdmin = Admins.Instance.GetAdmin(id);

                txtUserName.Value = CurrentAdmin.UserName;
                txtUserName.Attributes["readonly"] = "true";
                txtPassword.Value = CurrentAdmin.PasswordText;
                txtRealname.Value = CurrentAdmin.Realname;
                txtMobile.Value = CurrentAdmin.Mobile;
                txtQQ.Value = CurrentAdmin.QQ;
                SetSelectedByValue(rblSex,CurrentAdmin.Sex.ToString());
                SetSelectedByValue(rblState, CurrentAdmin.State);
                SetSelectedByValue(ddlCorp, CurrentAdmin.CorporationID.ToString());
            }
        }
Пример #11
0
        /// <summary>
        /// 填充后台用户实体类
        /// </summary>
        /// <param name="reader">记录集</param>
        /// <returns>实体类</returns>
        protected AdminInfo PopulateAdmin(IDataReader reader)
        {
            AdminInfo admin = new AdminInfo();
            admin.ID = (int)reader["ID"];
            admin.Administrator = DataConvert.SafeBool(reader["Administrator"]);
            admin.LastLoginIP = reader["LastLoginIP"] as string;
            admin.LastLoginTime = reader["LastLoginTime"] as DateTime?;
            admin.Password = reader["Password"] as string;
            admin.UserName = reader["UserName"] as string;
            admin.UserRole = (UserRoleType)(Int16)reader["UserRole"];
            admin.PowerGroupID = DataConvert.SafeInt(reader["PowerGroupID"]);
            admin.PowerGroupName = reader["PowerGroupName"] as string;
            admin.GroupPower = reader["GroupPower"] as string;

            SerializerData data = new SerializerData();
            data.Keys = reader["PropertyNames"] as string;
            data.Values = reader["PropertyValues"] as string;
            admin.SetSerializerData(data);

            return admin;
        }
Пример #12
0
 /// <summary>
 /// 更新管理员
 /// </summary>
 /// <param name="model">后台用户实体类</param>
 /// <returns>修改是否成功</returns>
 public abstract bool UpdateAdmin(AdminInfo model);
Пример #13
0
 /// <summary>
 /// 添加管理员
 /// </summary>
 /// <param name="model">后台用户实体类</param>
 /// <returns>添加成功返回ID</returns>
 public abstract int AddAdmin(AdminInfo model);