Example #1
0
 //赋值操作
 private void ShowInfo(int editID)
 {
     DtCms.BLL.Admin   bll   = new DtCms.BLL.Admin();
     DtCms.Model.Admin model = new DtCms.Model.Admin();
     model            = bll.GetModel(editID);
     txtUserName.Text = model.UserName;
     if (model.IsLock == 1)
     {
         this.rblIsLock.Items[1].Selected = true;
     }
     else
     {
         this.rblIsLock.Items[0].Selected = true;
     }
     txtReadName.Text  = model.ReadName;
     txtUserEmail.Text = model.UserEmail;
     this.strLevel     = model.UserLevel;
     this.strType      = model.UserType;
     if (model.UserType == 1)
     {
         this.rblUserType.Items[0].Selected = true;
     }
     if (model.UserType == 2)
     {
         this.rblUserType.Items[1].Selected = true;
     }
     if (model.UserType == 3)
     {
         this.rblUserType.Items[2].Selected = true;
     }
 }
Example #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DtCms.BLL.Admin   bll   = new DtCms.BLL.Admin();
            DtCms.Model.Admin model = bll.GetModel(this.Id);

            string UserPwd   = txtUserPwd.Text.Trim();
            string UserLevel = string.Empty;
            int    UserType  = Convert.ToInt32(rblUserType.SelectedValue);

            if (UserType > 1)
            {
                UserLevel = "," + Request.Form["cbLevel"].Trim() + ",";
            }
            if (UserPwd != null && UserPwd != "")
            {
                model.UserPwd = DtCms.Common.DESEncrypt.Encrypt(UserPwd);
            }
            model.ReadName  = txtReadName.Text.Trim();
            model.UserEmail = txtUserEmail.Text.Trim();
            model.UserType  = UserType;
            model.IsLock    = Convert.ToInt32(rblIsLock.SelectedValue);
            model.UserLevel = UserLevel;

            bll.Update(model);
            JscriptPrint("管理员修改成功啦!", "List.aspx", "Success");
        }
Example #3
0
        /// <summary>
        /// 根据用户名取得一行数据给MODEL
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public DtCms.Model.Admin GetModel(string UserName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 * from Administrator");
            strSql.Append(" where UserName=@UserName ");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@UserName", OleDbType.VarWChar, 30)
            };
            parameters[0].Value = UserName;

            DtCms.Model.Admin model = new DtCms.Model.Admin();
            DataSet           ds    = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.UserName  = ds.Tables[0].Rows[0]["UserName"].ToString();
                model.UserPwd   = ds.Tables[0].Rows[0]["UserPwd"].ToString();
                model.ReadName  = ds.Tables[0].Rows[0]["ReadName"].ToString();
                model.UserEmail = ds.Tables[0].Rows[0]["UserEmail"].ToString();
                model.UserType  = int.Parse(ds.Tables[0].Rows[0]["UserType"].ToString());
                model.UserLevel = ds.Tables[0].Rows[0]["UserLevel"].ToString();
                model.IsLock    = int.Parse(ds.Tables[0].Rows[0]["IsLock"].ToString());
            }
            return(model);
        }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(DtCms.Model.Admin model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Administrator set ");
            strSql.Append("UserName=@UserName,");
            strSql.Append("UserPwd=@UserPwd,");
            strSql.Append("ReadName=@ReadName,");
            strSql.Append("UserEmail=@UserEmail,");
            strSql.Append("UserType=@UserType,");
            strSql.Append("UserLevel=@UserLevel,");
            strSql.Append("IsLock=@IsLock");
            strSql.Append(" where Id=@Id ");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@UserName",  OleDbType.VarWChar, 30),
                new OleDbParameter("@UserPwd",   OleDbType.VarWChar, 50),
                new OleDbParameter("@ReadName",  OleDbType.VarWChar, 30),
                new OleDbParameter("@UserEmail", OleDbType.VarWChar, 50),
                new OleDbParameter("@UserType",  OleDbType.Integer,   4),
                new OleDbParameter("@UserLevel", SqlDbType.NText),
                new OleDbParameter("@IsLock",    OleDbType.Integer,   4),
                new OleDbParameter("@Id",        OleDbType.Integer, 4)
            };
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.UserPwd;
            parameters[2].Value = model.ReadName;
            parameters[3].Value = model.UserEmail;
            parameters[4].Value = model.UserType;
            parameters[5].Value = model.UserLevel;
            parameters[6].Value = model.IsLock;
            parameters[7].Value = model.Id;

            DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);
        }
Example #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(DtCms.Model.Admin model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Administrator(");
            strSql.Append("UserName,UserPwd,ReadName,UserEmail,UserType,UserLevel,IsLock)");
            strSql.Append(" values (");
            strSql.Append("@UserName,@UserPwd,@ReadName,@UserEmail,@UserType,@UserLevel,@IsLock)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@UserName",  OleDbType.VarWChar, 30),
                new OleDbParameter("@UserPwd",   OleDbType.VarWChar, 50),
                new OleDbParameter("@ReadName",  OleDbType.VarWChar, 30),
                new OleDbParameter("@UserEmail", OleDbType.VarWChar, 50),
                new OleDbParameter("@UserType",  OleDbType.Integer,   4),
                new OleDbParameter("@UserLevel", SqlDbType.NText),
                new OleDbParameter("@IsLock",    OleDbType.Integer, 4)
            };
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.UserPwd;
            parameters[2].Value = model.ReadName;
            parameters[3].Value = model.UserEmail;
            parameters[4].Value = model.UserType;
            parameters[5].Value = model.UserLevel;
            parameters[6].Value = model.IsLock;

            DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);
        }
Example #6
0
        //保存
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DtCms.Model.Admin model     = new DtCms.Model.Admin();
            DtCms.BLL.Admin   bll       = new DtCms.BLL.Admin();
            string            userLevel = string.Empty;
            string            userName  = txtUserName.Text.Trim();
            string            userPwd   = DtCms.Common.DESEncrypt.Encrypt(txtUserPwd.Text.Trim());
            string            readName  = txtReadName.Text.Trim();
            string            userEmail = txtUserEmail.Text.Trim();
            int userType = Convert.ToInt32(rblUserType.SelectedValue);
            int isLock   = Convert.ToInt32(rblIsLock.SelectedValue);

            if (bll.Exists(userName))
            {
                JscriptMsg(350, 230, "错误提示", "<b>出现错误了!</b>用户名已存在,请输入别的管理帐号吧!", "", "Error");
                return;
            }
            if (userType > 1)
            {
                userLevel = "," + Request.Form["cbLevel"].Trim() + ",";
            }

            model.UserName  = userName;
            model.UserPwd   = userPwd;
            model.ReadName  = readName;
            model.UserEmail = userEmail;
            model.UserType  = userType;
            model.IsLock    = isLock;
            model.UserLevel = userLevel;

            bll.Add(model);
            JscriptPrint("添加管理员成功啦!", "list.aspx", "Success");
        }
Example #7
0
        protected void loginsubmit_Click(object sender, ImageClickEventArgs e)
        {
            string UserName = txtUserName.Text.Trim();
            string UserPwd  = txtUserPwd.Text.Trim();

            if (UserName.Equals("") || UserPwd.Equals(""))
            {
                lbMsg.Text = "请输入您要登录用户名或密码";
            }
            else
            {
                if (Session["AdminLoginSun"] == null)
                {
                    Session["AdminLoginSun"] = 1;
                }
                else
                {
                    Session["AdminLoginSun"] = Convert.ToInt32(Session["AdminLoginSun"]) + 1;
                }
                //判断登录
                if (Session["AdminLoginSun"] != null && Convert.ToInt32(Session["AdminLoginSun"]) > 3)
                {
                    lbMsg.Text = "登录错误超过3次,请关闭浏览器重新登录。";
                }
                else if (bll.chkAdminLogin(UserName, UserPwd))
                {
                    DtCms.Model.Admin model = new DtCms.Model.Admin();
                    model = bll.GetModel(UserName);
                    Session["AdminNo"]    = model.Id;
                    Session["AdminName"]  = model.UserName;
                    Session["AdminType"]  = model.UserType;
                    Session["AdminLevel"] = model.UserLevel;
                    //设置超时时间
                    Session.Timeout          = 45;
                    Session["AdminLoginSun"] = null;
                    //Syscms.Model.websetModel webset = new Syscms.Bll.webSetBll().loadConfig(Server.MapPath(ConfigurationManager.AppSettings["Configpath"].ToString()));
                    //Syscms.Common.FsLog.SaveLogs(webset.weblogPath, model.UserName, "登录");
                    Response.Redirect("admin_index.aspx");
                }
                else
                {
                    lbMsg.Text = "您输入的用户名或密码不正确";
                }
            }
        }
Example #8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DtCms.Model.Admin GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,UserName,UserPwd,ReadName,UserEmail,UserType,UserLevel,IsLock from Administrator ");
            strSql.Append(" where Id=@Id ");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@Id", OleDbType.Integer, 4)
            };
            parameters[0].Value = Id;

            DtCms.Model.Admin model = new DtCms.Model.Admin();
            DataSet           ds    = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.UserName  = ds.Tables[0].Rows[0]["UserName"].ToString();
                model.UserPwd   = ds.Tables[0].Rows[0]["UserPwd"].ToString();
                model.ReadName  = ds.Tables[0].Rows[0]["ReadName"].ToString();
                model.UserEmail = ds.Tables[0].Rows[0]["UserEmail"].ToString();
                if (ds.Tables[0].Rows[0]["UserType"].ToString() != "")
                {
                    model.UserType = int.Parse(ds.Tables[0].Rows[0]["UserType"].ToString());
                }
                model.UserLevel = ds.Tables[0].Rows[0]["UserLevel"].ToString();
                if (ds.Tables[0].Rows[0]["IsLock"].ToString() != "")
                {
                    model.IsLock = int.Parse(ds.Tables[0].Rows[0]["IsLock"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }