protected void butRemoerMember_Click(object sender, EventArgs e)
        {
            string ReMoveId = this.lbOption2.SelectedValue;

            if (ReMoveId != string.Empty)
            {
                SOSOshop.BLL.Administrators   bll   = new SOSOshop.BLL.Administrators();
                SOSOshop.Model.Administrators model = bll.GetModel(int.Parse(ReMoveId));
                string AmentStr = string.Empty;
                if (model != null)
                {
                    char sep = ','; string[] RoleStrs = model.Role.Trim(',').Split(sep);
                    foreach (string RoleStr in RoleStrs)
                    {
                        if (!string.IsNullOrEmpty(RoleStr) && !ViewState["RoleId"].ToString().Equals(RoleStr))
                        {
                            AmentStr += RoleStr + sep;
                        }
                    }
                    bll.Amend(Convert.ToInt32(model.AdminId), "role", AmentStr.Trim(sep));
                    #region 后台用户操作日志记录
                    SOSOshop.Model.AdminInfo adminInfo = SOSOshop.BLL.AdministrorManager.Get();
                    SOSOshop.BLL.Logs.Log.LogAdminAdd("删除角色【" + this.lbRoleName.Text + "】成员【" + model.Name + "】", (adminInfo == null ? 0 : adminInfo.AdminId), (adminInfo == null ? "" : adminInfo.AdminName), 1);
                    #endregion
                }
                Response.Redirect("role_setmember.aspx?id=" + ViewState["RoleId"].ToString() + "");
            }
        }
        protected void butAddRoleMember_Click(object sender, EventArgs e)
        {
            string ReAddId = this.lbOption.SelectedValue;

            if (ReAddId != string.Empty)
            {
                SOSOshop.BLL.Administrators   bll   = new SOSOshop.BLL.Administrators();
                SOSOshop.Model.Administrators model = bll.GetModel(int.Parse(ReAddId));
                if (model != null)
                {
                    char sep = ','; string RoleStr = model.Role;
                    if (!string.IsNullOrEmpty(RoleStr))
                    {
                        bll.Amend(Convert.ToInt32(model.AdminId), "role", (RoleStr.Trim(sep) + "," + ViewState["RoleId"]).Trim(sep));
                    }
                    else
                    {
                        bll.Amend(Convert.ToInt32(model.AdminId), "role", ViewState["RoleId"].ToString());
                    }
                    #region 后台用户操作日志记录
                    SOSOshop.Model.AdminInfo adminInfo = SOSOshop.BLL.AdministrorManager.Get();
                    SOSOshop.BLL.Logs.Log.LogAdminAdd("添加角色【" + this.lbRoleName.Text + "】成员【" + model.Name + "】", (adminInfo == null ? 0 : adminInfo.AdminId), (adminInfo == null ? "" : adminInfo.AdminName), 1);
                    #endregion
                }
                Response.Redirect("role_setmember.aspx?id=" + ViewState["RoleId"].ToString() + "");
            }
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Administrators GetModel(int adminId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select adminid,name,password,state,managebegintime,manageendtime,power,allowmodifypassword,role,OfficePhone,HomePhone,MobilePhone,LoginAuthenticationOfficePhone,QQ from yxs_administrators ");
            strSql.Append(" where adminid=@adminid ");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "adminid", DbType.Int32, adminId);
            SOSOshop.Model.Administrators model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        private void GetModel()
        {
            SOSOshop.Model.AdminInfo aInfo = SOSOshop.BLL.AdministrorManager.Get();
            int adminid = ChangeHope.WebPage.PageRequest.GetInt("adminid");

            this.txtName.ReadOnly = false;
            if (Request["edit"] != null && Request["edit"] == "pwd")
            {
                adminid = aInfo.AdminId; enabled_edit_everyone = false;
                this.HyperLink1.Visible = false;
                this.Tr0.Attributes.Add("style", "display:none");
                this.Tr1.Attributes.Add("style", "display:none");
                this.Tr2.Attributes.Add("style", "display:none");
                this.Tr3.Attributes.Add("style", "display:none");
            }
            if (adminid > 0)
            {
                SOSOshop.BLL.Administrators   bll   = new SOSOshop.BLL.Administrators();
                SOSOshop.Model.Administrators model = bll.GetModel(adminid);
                if (model != null)
                {
                    this.txtName.ReadOnly               = true;
                    this.txtAdminId.Value               = model.AdminId.ToString();
                    this.txtManageBeginTime.Text        = model.ManageBeginTime.ToString();
                    this.txtManageEndTime.Text          = model.ManageEndTime.ToString();
                    this.txtName.Text                   = model.Name;
                    this.txtName.ReadOnly               = true;
                    this.ckbAllowModifyPassword.Checked = model.AllowModifyPassWord.Equals(1) ? true : false;
                    if (aInfo.AdminName == "admin")
                    {
                        this.ckbPower.Enabled = false;
                    }
                    this.ckbPower.SelectedValue = model.Power.ToString();
                    this.ckbState.Checked       = model.State.Equals(1) ? true : false;
                    ChangeHope.WebPage.WebControl.Validate(this.txtPasswordRe, "密码为空时,则不修改密码", "no", "", "");
                }
                model = null;
                bll   = null;
                return;
            }
            ChangeHope.WebPage.WebControl.Validate(this.txtPasswordRe, "密码为空时,则不修改密码", "isnull_8_20", "必填", "该项为必填项,且为8~20个字符");
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //#if DEBUG
                //                    //测试编译状态不用登陆
                //                    string pwd = ChangeHope.Common.DEncryptHelper.Encrypt("101administrator", 1);
                //                    bool loginResult = false;
                //                    YXShop.BLL.Admin.Administrators administrators = new YXShop.BLL.Admin.Administrators();
                //                    loginResult = AdminLogin("admin", pwd);
                //                    if (loginResult)
                //                    {
                //                         Response.Redirect("admin_index.aspx", true);
                //                    }
                //#endif

                if (ChangeHope.WebPage.PageRequest.GetFormString("Option") != string.Empty && ChangeHope.WebPage.PageRequest.GetFormString("id") != string.Empty)
                {
                    string types = Request.Form["Option"].Trim();
                    string StrID = ChangeHope.WebPage.PageRequest.GetFormString("id");
                    if (types == "sendAdminLoginCheckCode")
                    {
                        string userLoginName = ChangeHope.WebPage.PageRequest.GetFormString("toUID");
                        string userLoginPwd  = ChangeHope.WebPage.PageRequest.GetFormString("toPWD");
                        userLoginPwd = ChangeHope.Common.DEncryptHelper.Encrypt(userLoginPwd, 1);
                        SOSOshop.BLL.Administrators   bll   = new SOSOshop.BLL.Administrators();
                        SOSOshop.Model.Administrators model = bll.GetModelByAdminName(userLoginName);
                        string message = "";
                        //无数据
                        if (model == null)
                        {
                            message = "用户名错误!";
                        }
                        //密码错误
                        else if (!model.PassWord.ToLower().Equals(userLoginPwd.ToLower()))
                        {
                            message = "密码错误!";
                        }
                        //帐号被冻结
                        else if (model.State.Equals(1))
                        {
                            message = "您输入的账户以被冻结!";
                        }
                        //帐号已经过期
                        else if (model.ManageEndTime < DateTime.Now)
                        {
                            message = "你的帐户已经过期!";
                        }
                        else
                        {
                            string DstMobile = Convert.ToString(new SOSOshop.BLL.Db().ExecuteScalar("select LoginAuthenticationOfficePhone from yxs_administrators where adminid = " + model.AdminId)).Trim();
                            if (DstMobile.Trim() == "")
                            {
                                message = "no";
                            }
                            else
                            {
                                //设置Cookies 2分钟
                                string     checkCode = ChangeHope.Common.DEncryptHelper.GetRandWord(5);
                                HttpCookie cookie    = new HttpCookie("CheckCode", checkCode);
                                cookie.Expires = DateTime.Now.AddMinutes(-1000);
                                Response.Cookies.Add(cookie);
                                cookie         = new HttpCookie("CheckCode", checkCode);
                                cookie.Expires = DateTime.Now.AddMinutes(2);
                                Response.Cookies.Add(cookie);
                                //发送短信
                                ChangeHope.WebPage.Sms sms = new ChangeHope.WebPage.Sms();
                                string SmsMsg = model.Name + ",101后台管理员," + "需要登陆后台,请告知验证码:" + checkCode + "\r\n"; if (SmsMsg.Length > 120)
                                {
                                    SmsMsg = SmsMsg.Substring(0, 120);
                                }
                                string from    = "登陆后台的验证码";
                                string to      = model.Name;
                                bool   Success = false;
                                Success = (sms.Send(DstMobile, SmsMsg, from, to));
                                if (ChangeHope.WebPage.PageRequest.GetFormInt("add") != -1)
                                {
                                    sms.SaveDataBase(DstMobile, SmsMsg, from, to, Success);
                                }
                                else
                                {
                                    sms.UpdateDataBase(int.Parse(StrID), DstMobile, SmsMsg, from, to, Success);
                                }
                                if (Success)
                                {
                                    message = "ok";
                                    string adminname = Convert.ToString(new SOSOshop.BLL.Db().ExecuteScalar("select name from yxs_administrators where OfficePhone = '" + DstMobile + "'"));
                                    message += "," + from + "已经发送给" + (adminname.Trim() != "" ? adminname : DstMobile);
                                    ArrayList smsRecord = new ArrayList();
                                    if (Session["smsRecord"] != null)
                                    {
                                        smsRecord = Session["smsRecord"] as ArrayList;
                                    }
                                    if (smsRecord != null)
                                    {
                                        smsRecord.Add(checkCode);
                                    }
                                    Session["smsRecord"] = smsRecord;
                                }
                                else
                                {
                                    message = "短信发送失败!";
                                }
                            }
                        }
                        Response.Write(message);
                    }
                    Response.End();
                    return;
                }

                SOSOshop.BLL.SysParameter sp = new SOSOshop.BLL.SysParameter();
                WebName = sp.WebSiteName;
                if (SOSOshop.BLL.AdministrorManager.Get() != null)
                {
                    ChangeHope.WebPage.Script.Alert("提示:您已经登陆成功,转向后台管理页面");
                    ChangeHope.WebPage.Script.ParentPageRedirect(sp.DummyPaht + "admin/admin_index.aspx");
                    return;
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// 系统管理员登陆系统
        /// </summary>
        /// <param name="adminName"></param>
        /// <param name="adminPwd"></param>
        /// <returns></returns>
        public bool AdminLogin(string adminName, string adminPwd)
        {
            SOSOshop.BLL.Administrators   bll   = new SOSOshop.BLL.Administrators();
            SOSOshop.Model.Administrators model = bll.GetModelByAdminName(adminName);
            //无数据
            if (model == null)
            {
                message = "用户名或密码错误!";
                return(false);
            }
            //密码错误
            if (!model.PassWord.ToLower().Equals(adminPwd.ToLower()))
            {
                message = "用户名或密码错误!";
                model   = null;
                return(false);
            }

            //帐号被冻结
            if (model.State.Equals(1))
            {
                message = "您输入的账户以被冻结!";
                model   = null;
                return(false);
            }

            //帐号已经过期
            if (model.ManageEndTime < DateTime.Now)
            {
                message = "你的帐户已经过期!";
                model   = null;
                return(false);
            }

            //一人一机登陆验证
            //ChangeHope.Common.DEncryptHelper.Encrypt(model.Name, 1);
            //if (model.Name != "admin")
            //{
            //    object AllowOtherLogin = new SOSOshop.BLL.Db().ExecuteScalar("select top (1) AllowOtherLogin from yxs_CustomerSetting");
            //    if (AllowOtherLogin != null && AllowOtherLogin.ToString() == "0")
            //    {
            //        //查询登陆日志
            //        object adminid = new SOSOshop.BLL.Db().ExecuteScalar("select top (1) id from yxs_adminloginlog where " +
            //            "adminname = '" + model.Name + "' " +
            //            "and convert(char(10),loginintime,120) = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and loginintime = loginouttime " +
            //            "and loginip != '" + Request.UserHostAddress + "' " +
            //            "and operatenote = '登陆成功!' order by loginintime desc");
            //        if (adminid != null)
            //        {
            //            message = "你的帐户已经登陆!";
            //            model = null;
            //            return false;
            //        }
            //    }
            //}

            string DstMobile = Convert.ToString(new SOSOshop.BLL.Db().ExecuteScalar("select LoginAuthenticationOfficePhone from yxs_administrators where adminid = " + model.AdminId)).Trim();

            if (DstMobile.Trim() != "" && false)
            {
                //发送短信
                ArrayList smsRecord = new ArrayList();
                if (Session["smsRecord"] != null)
                {
                    smsRecord = Session["smsRecord"] as ArrayList;
                }
                bool ok = smsRecord != null && smsRecord.Count > 0 && txtCheckCode.Text.ToUpper() == smsRecord[smsRecord.Count - 1].ToString().ToUpper();
                if (!ok)
                {
                    message = "验证码错误!";
                    model   = null;
                    return(false);
                }
            }


            //初始化权限
            SOSOshop.Model.AdminInfo admin = new SOSOshop.Model.AdminInfo();
            if (model.Power.Equals(0))
            {
                admin.AdminPowerType = "all";
            }
            else
            {
                //非管理员权限,等待添加相关内容
                admin.AdminPowerType = "";
            }

            admin.AdminId   = model.AdminId;
            admin.AdminName = model.Name;
            admin.AdminRole = model.Role;
            SOSOshop.BLL.AdministrorManager.Set(admin);

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                1,
                admin.AdminName,
                DateTime.Now,
                DateTime.Now.AddMinutes(1000),
                true,
                ""
                );
            HttpCookie cookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName,
                                                          FormsAuthentication.Encrypt(ticket));

            cookie.Domain  = System.Configuration.ConfigurationManager.AppSettings["Domain"];
            cookie.Expires = DateTime.Now.AddHours(10);
            System.Web.HttpContext.Current.Response.Cookies.Add(cookie);


            admin   = null;
            message = "登陆成功!";
            return(true);
        }
        private void Save()
        {
            if (ChangeHope.Common.StringHelper.StringToDateTime(this.txtManageBeginTime.Text) > ChangeHope.Common.StringHelper.StringToDateTime(this.txtManageEndTime.Text))
            {
                this.ltlMsg.Text     = "保存失败!开始时间大于结局时间。";
                this.pnlMsg.CssClass = "actionErr";
                return;
            }
            if (!string.IsNullOrEmpty(this.txtPasswordRe.Text))
            {
                if (Library.Lang.DataValidator.isNumber(this.txtPasswordRe))
                {
                    this.ltlMsg.Text     = "保存失败!新密码不能全为数字!";
                    this.pnlMsg.CssClass = "actionErr";
                    pnlMsg.Visible       = true;
                    return;
                }
                if (this.txtPasswordRe.Text.Length < 8)
                {
                    this.ltlMsg.Text     = "保存失败!新密码的长度必须大于等于8位!";
                    this.pnlMsg.CssClass = "actionErr";
                    pnlMsg.Visible       = true;
                    return;
                }
            }

            SOSOshop.BLL.Administrators   bll   = new SOSOshop.BLL.Administrators();
            SOSOshop.Model.Administrators model = new SOSOshop.Model.Administrators();

            try
            {
                model.AdminId = ChangeHope.Common.StringHelper.StringToInt(this.txtAdminId.Value);
                if (model.AdminId > 0)
                {
                    model = bll.GetModel(model.AdminId);
                }
                model.AllowModifyPassWord = this.ckbAllowModifyPassword.Checked ? 1 : 0;
                model.ManageBeginTime     = ChangeHope.Common.StringHelper.StringToDateTime(this.txtManageBeginTime.Text);
                model.ManageEndTime       = ChangeHope.Common.StringHelper.StringToDateTime(this.txtManageEndTime.Text);
                model.Name     = this.txtName.Text;
                model.PassWord = this.txtPassword.Text;
                model.Power    = ChangeHope.Common.StringHelper.StringToInt(this.ckbPower.SelectedValue);
                model.State    = this.ckbState.Checked ? 1 : 0;
                if (model.AdminId > 0)
                {
                    bll.Update(model);
                }
                else
                {
                    model.Role            = "";
                    this.txtAdminId.Value = bll.Add(model).ToString();
                }
                this.ltlMsg.Text     = "保存成功!";
                this.pnlMsg.CssClass = "actionOk";

                if (this.txtAdminId.Value.Equals("0"))
                {
                    this.ltlMsg.Text     = "保存失败!已经有相同的用户名存在";
                    this.pnlMsg.CssClass = "actionErr";
                }
                else
                {
                    this.txtName.ReadOnly = true;
                    #region 后台用户操作日志记录
                    SOSOshop.Model.AdminInfo adminInfo = SOSOshop.BLL.AdministrorManager.Get();
                    SOSOshop.BLL.Logs.Log.LogAdminAdd("修改管理员", (adminInfo == null ? 0 : adminInfo.AdminId), (adminInfo == null ? "" : adminInfo.AdminName), 1);
                    #endregion
                }
                if (!enabled_edit_everyone || this.HyperLink1.Visible == false || this.Tr1.Visible == false)
                {
                    this.ltlMsg.Text    += "<script>setTimeout(function(){window.location='../systeminfo/site_sysinfo.aspx';},2000);</script>";
                    this.formtbl.Visible = false;
                }
            }
            catch (Exception ex)
            {
                this.ltlMsg.Text     = "保存失败:<br/>" + ex.ToString();
                this.pnlMsg.CssClass = "actionErr";
            }
            finally
            {
                this.pnlMsg.Visible = true;
                bll   = null;
                model = null;
            }
            Library.Client.Jscript.ExecuteJs(this, "skip();");
        }