示例#1
0
        /// <summary>
        /// 点击提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (ActionValidator("SystemSettingModify"))
            {
                if (!Page.IsValid)
                {
                    return;
                }

                _systemsettingmodel = _systemsettingbll.GetModel(1);
                //添加时间
                //_systemsettingmodel.AddTime = DateTime.Now;
                //系统名称
                _systemsettingmodel.SystemName    = txtSystemName.Text;
                _systemsettingmodel.Email         = TextBox1.Text;
                _systemsettingmodel.smtpSeverName = TextBox2.Text;
                _systemsettingmodel.EmailName     = TextBox3.Text;
                _systemsettingmodel.Emailpwd      = TextBox4.Text;
                //图片
                _systemsettingmodel.SystemPicture = HiddenFieldName1.Value;

                //更新一条数据
                if (_systemsettingbll.Update(_systemsettingmodel))
                {
                    AlertAndParentSkip("更新成功!", "SystemSetting.aspx");
                }
            }
        }
示例#2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Haikan.SchoolProjectsCore.MDB.Model.SystemSetting model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SystemSetting set ");
            strSql.Append("SystemName=@SystemName,");
            strSql.Append("SystemPicture=@SystemPicture,");
            strSql.Append("Email=@Email,");
            strSql.Append("smtpSeverName=@smtpSeverName,");
            strSql.Append("EmailName=@EmailName,");
            strSql.Append("Emailpwd=@Emailpwd,");
            strSql.Append("FileType=@FileType,");
            strSql.Append("IsIdentifyingCode=@IsIdentifyingCode");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SystemName",        SqlDbType.VarChar, 255),
                new SqlParameter("@SystemPicture",     SqlDbType.VarChar, 255),
                new SqlParameter("@Email",             SqlDbType.VarChar, 255),
                new SqlParameter("@smtpSeverName",     SqlDbType.VarChar, 255),
                new SqlParameter("@EmailName",         SqlDbType.VarChar, 255),
                new SqlParameter("@Emailpwd",          SqlDbType.VarChar, 255),
                new SqlParameter("@FileType",          SqlDbType.VarChar, 255),
                new SqlParameter("@IsIdentifyingCode", SqlDbType.Int,       4),
                new SqlParameter("@ID",                SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SystemName;
            parameters[1].Value = model.SystemPicture;
            parameters[2].Value = model.Email;
            parameters[3].Value = model.smtpSeverName;
            parameters[4].Value = model.EmailName;
            parameters[5].Value = model.Emailpwd;
            parameters[6].Value = model.FileType;
            parameters[7].Value = model.IsIdentifyingCode;
            parameters[8].Value = model.ID;

            int rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Haikan.SchoolProjectsCore.MDB.Model.SystemSetting DataRowToModel(DataRow row)
 {
     Haikan.SchoolProjectsCore.MDB.Model.SystemSetting model = new Haikan.SchoolProjectsCore.MDB.Model.SystemSetting();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["SystemName"] != null)
         {
             model.SystemName = row["SystemName"].ToString();
         }
         if (row["SystemPicture"] != null)
         {
             model.SystemPicture = row["SystemPicture"].ToString();
         }
         if (row["Email"] != null)
         {
             model.Email = row["Email"].ToString();
         }
         if (row["smtpSeverName"] != null)
         {
             model.smtpSeverName = row["smtpSeverName"].ToString();
         }
         if (row["EmailName"] != null)
         {
             model.EmailName = row["EmailName"].ToString();
         }
         if (row["Emailpwd"] != null)
         {
             model.Emailpwd = row["Emailpwd"].ToString();
         }
         if (row["FileType"] != null)
         {
             model.FileType = row["FileType"].ToString();
         }
         if (row["IsIdentifyingCode"] != null && row["IsIdentifyingCode"].ToString() != "")
         {
             model.IsIdentifyingCode = int.Parse(row["IsIdentifyingCode"].ToString());
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Haikan.SchoolProjectsCore.MDB.Model.SystemSetting model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SystemSetting(");
            strSql.Append("SystemName,SystemPicture,Email,smtpSeverName,EmailName,Emailpwd,FileType,IsIdentifyingCode)");
            strSql.Append(" values (");
            strSql.Append("@SystemName,@SystemPicture,@Email,@smtpSeverName,@EmailName,@Emailpwd,@FileType,@IsIdentifyingCode)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SystemName",        SqlDbType.VarChar, 255),
                new SqlParameter("@SystemPicture",     SqlDbType.VarChar, 255),
                new SqlParameter("@Email",             SqlDbType.VarChar, 255),
                new SqlParameter("@smtpSeverName",     SqlDbType.VarChar, 255),
                new SqlParameter("@EmailName",         SqlDbType.VarChar, 255),
                new SqlParameter("@Emailpwd",          SqlDbType.VarChar, 255),
                new SqlParameter("@FileType",          SqlDbType.VarChar, 255),
                new SqlParameter("@IsIdentifyingCode", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SystemName;
            parameters[1].Value = model.SystemPicture;
            parameters[2].Value = model.Email;
            parameters[3].Value = model.smtpSeverName;
            parameters[4].Value = model.EmailName;
            parameters[5].Value = model.Emailpwd;
            parameters[6].Value = model.FileType;
            parameters[7].Value = model.IsIdentifyingCode;

            object obj = DbHelperSql.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            // 读取系统名称
            _systemSetModel   = _systemSetBll.GetModel(2);
            LbSystemName.Text = _systemSetModel.SystemName;
            LbUserName.Text   = Session["TrueName"] + ",欢迎您";

            // 绑定用户名
            Label1.Text = Session["username"].ToString();

            // 菜单缓存
            var cookie = DataCache.GetCache("HaikanSchoolProjects-" + Session["userid"]);

            if (cookie != null)
            {
                MenuStr += cookie;
            }
            else
            {
                Response.Redirect("Login.aspx?info=菜单缓存清空");
            }

            // 绑定搜索框的自动完成
            PageUrl = _systemPage.GetPageUrlByAuto();

            // 绑定用户头像
            if (!string.IsNullOrEmpty(Session["HeadPort"] as string))
            {
                Image = "/UploadFiles/SystemManage/" + Session["HeadPort"];
            }
            else
            {
                Image = "/libs/haikan/img/avatars/user.png";
            }

            // Logo
            LeftImage = "/libs/haikan/img/avatars/logo_white.png";
        }
示例#6
0
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            //按钮权限
            btnSubmit.Visible = ActionValidator("SystemSettingAdd");

            // 对所有控件进行赋值
            _systemsettingmodel = _systemsettingbll.GetModel(2);

            //系统名称
            txtSystemName.Text = _systemsettingmodel.SystemName;

            TextBox1.Text          = _systemsettingmodel.Email;
            TextBox2.Text          = _systemsettingmodel.smtpSeverName;
            TextBox3.Text          = _systemsettingmodel.EmailName;
            TextBox4.Text          = _systemsettingmodel.Emailpwd;
            HiddenFieldName1.Value = _systemsettingmodel.SystemPicture;
            UploadFilseNameinfo    = HiddenFieldName1.Value;
        }
示例#7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Haikan.SchoolProjectsCore.MDB.Model.SystemSetting GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,SystemName,SystemPicture,Email,smtpSeverName,EmailName,Emailpwd,FileType,IsIdentifyingCode from SystemSetting ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Haikan.SchoolProjectsCore.MDB.Model.SystemSetting model = new Haikan.SchoolProjectsCore.MDB.Model.SystemSetting();
            DataSet ds = DbHelperSql.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#8
0
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            // 获取全局配置中的系统名称
            _systemSetModel     = _systemSetBll.GetModel(_systemSetBll.GetMaxId());
            lblSystemTitle.Text = SystemTitle = _systemSetModel.SystemName;

            //对接统一身份认证
            //if (ConfigurationManager.AppSettings["HaikanPassport_IfUse"].ToLower() == "true")
            //{
            //    if (Session["HaikanSchoolProjects.Cert"] != null)
            //    {
            //        //分站凭证存在
            //        //Response.Write("恭喜,分站凭证存在,您被授权访问该页面!");
            //    }
            //    else
            //    {
            //        //令牌验证结果返回
            //        if (Request.QueryString["token"] != null)
            //        {
            //            //持有令牌
            //            if (Request.QueryString["token"] != "$token$")
            //            {
            //                var tokenValue = Request.QueryString["token"];

            //                //调用WebService获取主站凭证
            //                //防止令牌伪造
            //                //此处还可使用公钥私钥的非对称加密策略
            //                passportservice.PassportService passportService = new passportservice.PassportService();
            //                object cert = passportService.TokenGetCert(tokenValue);
            //                if (cert != null)
            //                {
            //                    // 将token写入Session
            //                    Session["HaikanSchoolProjects.Token"] = tokenValue;

            //                    //令牌正确,产生分站凭证
            //                    Session["HaikanSchoolProjects.Cert"] = cert;
            //                    //Response.Write("恭喜,令牌存在,您被授权访问该页面!");
            //                }
            //                else
            //                {
            //                    //令牌错误,去Passport登录
            //                    Response.Redirect(HaikanPassportHelper.TokenReplace());
            //                }
            //            }
            //            //未持有令牌,去Passport登录
            //            else
            //            {
            //                Response.Redirect(HaikanPassportHelper.TokenReplace());
            //            }
            //        }
            //        //未进行令牌验证,去Passport验证
            //        else
            //        {
            //            //当前url附加上token参数
            //            Response.Redirect(HaikanPassportHelper.TokenUrl());
            //        }
            //    }

            //    // 进入用户认证的阶段
            //    if (!IsPostBack)
            //    {
            //        var userinfo = Session["HaikanSchoolProjects.Cert"];
            //        var blowFish = new BlowFish();
            //        var deText = blowFish.Decrypt(ConfigurationManager.AppSettings["HaikanPassport_ApiKey"], userinfo.ToString());
            //        string[] arr = deText.Split('&');

            //        if (arr.Length < 2)
            //        {
            //            Alert("API密钥不正确!");
            //            return;
            //        }

            //        // 获取该用户的相关信息
            //        var ds = _systemUserBll.GetModelList("UserName='******' and (UserPWD = '" +
            //                                             DesEncrypt.GetMd5String(arr[1]) + "' or UserPWD = '" + arr[1] +
            //                                             "')");

            //        if (ds.Count <= 0)
            //        {
            //            Session.Abandon();
            //            Alert("对不起,没有找到对应的用户!");
            //            Response.Redirect(HaikanPassportHelper.TokenReplace());
            //            return;
            //        }

            //        _systemUserModel = ds[0];
            //        if (_systemUserModel.IsEnter == 1)
            //        {
            //            Alert("对不起,您已被禁止登录!");
            //            return;
            //        }

            //        // 获取角色和权限
            //        var roleId = Convert.ToInt32(_systemUserModel.RoleID);
            //        _systemRolesModel = _systemRolesBll.GetModel(roleId);
            //        if (_systemRolesModel != null)
            //        {
            //            Session["roleId"] = _systemUserModel.RoleID;
            //            Session["RoleName"] = _systemRolesModel.RoleName;
            //            Session["ActionStr"] = _systemRolesModel.Actionstr;
            //        }
            //        else
            //        {
            //            Session["roleId"] = "";
            //            Session["RoleName"] = "";
            //            Session["ActionStr"] = "";
            //        }

            //        // 个人信息
            //        Session["userid"] = _systemUserModel.ID;
            //        Session["TrueName"] = _systemUserModel.TrueName;
            //        Session["username"] = _systemUserModel.UserName;
            //        Session["Department"] = _systemUserModel.DepartmentID;
            //        Session["BirthDay"] = _systemUserModel.BirthDay;
            //        Session["IdentityCard"] = _systemUserModel.SFZSerils; //身份证号码
            //        Session["Sex"] = _systemUserModel.Sex;
            //        Session["JiaRuBenDanWeiTime"] = _systemUserModel.JiaRuBenDanWeiTime; // 入职时间
            //        Session["TelephoneNumber"] = _systemUserModel.TelphoneNumber; // 联系电话

            //        // 左侧菜单,保存到cookies中
            //        var menuStr = BindStr();
            //        if (menuStr != "")
            //        {
            //            DataCache.SetCache("HaikanSchoolProjects-" + Session["userid"], menuStr);
            //        }

            //        // 跳转到主界面
            //        Response.Redirect("/General/Main.aspx");
            //    }
            //}

            if (IsPostBack)
            {
                return;
            }

            // 清除浏览器缓存
            _systemPage.ClearClientPageCache();

            //是否显示验证码,如果不为0就隐藏
            if (_systemSetModel.IsIdentifyingCode.ToString() != "0")
            {
                Panelyzm.Visible = false;
            }

            //判断是否有cookie值,如果有就读取出来
            var cookies = Request.Cookies["RememberPWD"];

            if (cookies == null || !cookies.HasKeys)
            {
                return;
            }

            TxtUserName.Text = cookies["Name"];
            TxtUserPwd.Attributes.Add("value", cookies["UserPwd"]);

            chkRemembered.Checked = true;
        }
示例#9
0
        /// <summary>
        /// 点击登陆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            // 先判断验证码
            _systemSetModel = _systemSetBll.GetModel(_systemSetBll.GetMaxId());
            // 判断是否需要验证码
            if (_systemSetModel.IsIdentifyingCode.ToString() == "0")
            {
                if (Session["yzm"] != null && !string.Equals(Session["yzm"].ToString(), TxtYZM.Text, StringComparison.CurrentCultureIgnoreCase))
                {
                    Alert("验证码错误");
                    return;
                }
            }

            // sql注入风险检查
            if (SystemPage.SqlFilter(TxtUserName.Text.Trim()) || SystemPage.SqlFilter(TxtUserPwd.Text.Trim()))
            {
                Alert("帐号错误,请注意非法字符!");
                return;
            }

            // 密码可能是原文或者md5加密后的
            var strWhere = "UserName = '******' and (UserPWD = '" + DesEncrypt.GetMd5String(TxtUserPwd.Text.Trim()) + "' or UserPWD = '" + TxtUserPwd.Text.Trim() + "')";

            var d = _systemUserBll.GetList(" UserName='******'");

            if (d.Tables[0].Rows.Count > 0)
            {
                // 检测是否非法登录3次
                var verify = _illegalityLogin.PwdIsCorrect(TxtUserName.Text.Trim(), 3, TxtUserPwd.Text.Trim());

                if (verify == "成功")
                {
                    // 获取该用户的相关信息
                    var ds = _systemUserBll.GetModelList(strWhere);

                    if (ds.Count <= 0)
                    {
                        Alert("对不起,没有找到对应的用户!");
                        return;
                    }

                    _systemUserModel = ds[0];
                    if (_systemUserModel == null)
                    {
                        Alert("对不起,没有找到对应的用户!");
                        return;
                    }

                    if (_systemUserModel.IsEnter == 1)
                    {
                        Alert("对不起,您已被禁止登录!");
                        return;
                    }

                    // 获取角色和权限
                    var roleId = Convert.ToInt32(_systemUserModel.RoleID);
                    _systemRolesModel = _systemRolesBll.GetModel(roleId);
                    if (_systemRolesModel != null)
                    {
                        Session["roleId"]    = _systemUserModel.RoleID;
                        Session["RoleName"]  = _systemRolesModel.RoleName;
                        Session["ActionStr"] = _systemRolesModel.Actionstr;
                    }

                    // 个人信息
                    Session["userid"]             = _systemUserModel.ID;
                    Session["TrueName"]           = _systemUserModel.TrueName;
                    Session["username"]           = TxtUserName.Text.Trim();
                    Session["Department"]         = _systemUserModel.DepartmentID;
                    Session["BirthDay"]           = _systemUserModel.BirthDay;
                    Session["IdentityCard"]       = _systemUserModel.SFZSerils;          //身份证号码
                    Session["Sex"]                = _systemUserModel.Sex;
                    Session["JiaRuBenDanWeiTime"] = _systemUserModel.JiaRuBenDanWeiTime; // 入职时间
                    Session["TelephoneNumber"]    = _systemUserModel.TelphoneNumber;     // 联系电话

                    // 判断是否选择了记住密码
                    if (chkRemembered.Checked)
                    {
                        var cookie = new HttpCookie("RememberPWD");
                        cookie.Values.Add("Name", TxtUserName.Text.Trim());

                        // 如果长度大于20,可以判定为md5加密后的密码,直接保存即可,否则需要加密后保存
                        cookie.Values.Add("UserPwd",
                                          TxtUserPwd.Text.Trim().Length > 20
                                ? TxtUserPwd.Text.Trim()
                                : DesEncrypt.GetMd5String(TxtUserPwd.Text.Trim()));

                        cookie.Expires = DateTime.Now.AddDays(60.0);// 有效期2个月
                        HttpContext.Current.Response.Cookies.Add(cookie);
                    }

                    // 左侧菜单,保存到cookies中
                    var menuStr = BindStr();
                    if (menuStr != "")
                    {
                        DataCache.SetCache("HaikanSchoolProjects-" + Session["userid"], menuStr);
                    }

                    // 跳转到主界面
                    Response.Redirect("/General/Main.aspx");
                }
                else
                {
                    Alert(verify);
                }
            }
            else
            {
                Alert("不存在该用户");
            }
        }