Beispiel #1
0
        public static string OperateRecords(string ids, int op)
        {
            string[] array = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            using (BLLAdminUser bll = new BLLAdminUser())
            {
                foreach (string id in array)
                {
                    switch (op)
                    {
                    case 7:                             //delete
                        if (bll.GetList().Count < 2)
                        {
                            return("最后一个管理员不能删除");
                        }
                        bll.Delete(id);

                        break;
                    }
                }

                if (bll.IsFail)
                {
                    return(ExceptionManager.GetErrorMsg(bll.DevNetException));
                }
            }
            return(string.Empty);
        }
Beispiel #2
0
        private void bindList()
        {
            SearchAdminUser cond = new SearchAdminUser();

            cond.Account  = txtAccount.Text.Trim();
            cond.TrueName = txtTrueName.Text.Trim();

            string sortby = ViewState["sort"] as string;

            if (String.IsNullOrEmpty(sortby))
            {
                sortby = AdminUser.AddDate_FieldName + " , DESC";
            }
            string[] sorts = sortby.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            Pagination pagina = new Pagination(pager.PageIndex, pager.PageSize, 0);

            using (BLLAdminUser bll = new BLLAdminUser())
            {
                List <AdminUser> lists = bll.GetPageList(cond, pagina, sorts[0].Trim(),
                                                         (ScriptQuery.SortEnum)
                                                         Enum.Parse(typeof(ScriptQuery.SortEnum), sorts[1].Trim(), true));

                pager.RecordCount = pagina.RecordCount;
                pager.PageCount   = pagina.PageCount;

                grid_friendlink.DataSource = lists;
                grid_friendlink.DataBind();
            }
        }
        protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
        {
            string scheckcode = chkcode.Text.Trim();

            if (!Session["CheckCode"].Equals(scheckcode))
            {
                JSMsg.ShowRegisterMsg(this, "验证码输入错误");
                chkcode.Focus();
                return;
            }

            BLLAdminUser bll       = new BLLAdminUser();
            string       sPassword = WebCommon.Md5Enctry(txtPwd.Text.Trim());

            try
            {
                if (txtAccount.Text.Trim() == "root" && sPassword == WebCommon.Md5Enctry("root"))
                {
                    AdminUser adminbestop = new AdminUser();
                    adminbestop.ID       = 999;
                    adminbestop.Account  = "root";
                    adminbestop.PassWord = WebCommon.Md5Enctry("root");
                    Session["admin"]     = adminbestop;
                    Response.Redirect("index.aspx");
                }
                AdminUser admin = bll.GetSingle(AdminUser.Account_FieldName, txtAccount.Text.Trim());

                if (admin == null)
                {
                    JSMsg.ShowRegisterMsg(this, "该用户不存在!");
                    return;
                }

                if (admin.PassWord != sPassword)
                {
                    JSMsg.ShowRegisterMsg(this, "用户名或密码错误");
                    txtAccount.Focus();
                    return;
                }


                bll.Update(
                    new string[] { AdminUser.LoginCounts_FieldName, AdminUser.LastLoginDate_FieldName, AdminUser.LoginIP_FieldName },
                    new object[] { ++admin.LoginCounts, DateTime.Now, StringPlus.GetIPAddress() }, admin.ID);

                Session["admin"] = admin;

                Response.Redirect("index.aspx");
            }
            catch (System.Exception ex)
            {
                JSMsg.ShowRegisterMsg(this, "登录失败!");
                Log.Error(ex.Message, ex);
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtAccount.Text.Trim() == "")
            {
                ShowMsg("请输入登录帐号");
                return;
            }

            if (id == 0)
            {
                if (txtPwd.Text.Trim() == "")
                {
                    ShowMsg("请输入登录密码");
                    return;
                }
            }

            if (txtPwd.Text.Trim() != txtPwdAgain.Text.Trim())
            {
                ShowMsg("两次输入密码不一致");
                return;
            }
            using (BLLAdminUser bll = new BLLAdminUser())
            {
                AdminUser admin = new AdminUser();
                if (id > 0)
                {
                    admin = bll.GetSingle(id);
                }
                admin.ID       = id;
                admin.Account  = txtAccount.Text.Trim();
                admin.TrueName = txtTrueName.Text;
                if (txtPwd.Text.Trim() != "")
                {
                    admin.PassWord = WebCommon.Md5Enctry(txtPwd.Text.Trim());
                }
                else
                {
                    admin.PassWord = admin.PassWord;
                }

                bll.Save(admin);

                if (bll.IsFail)
                {
                    ExceptionManager.ShowErrorMsg(this, bll.DevNetException);
                }
                else
                {
                    JSMsg.ShowWinRedirect(this, "保存成功", "wfAdminUser.aspx");
                }
            }
        }
        private void setInfo()
        {
            if (id > 0)
            {
                using (BLLAdminUser bll = new BLLAdminUser())
                {
                    AdminUser admin = bll.GetSingle(id);
                    if (admin != null)
                    {
                        txtAccount.Text  = admin.Account;
                        txtTrueName.Text = admin.TrueName;

                        lblPwd.Text  = "<span style=\"color:Red;\">*如不修改密码请留空</span> ";
                        lblAgin.Text = "<span style=\"color:Red;\">*如不修改密码请留空</span> ";
                    }
                }
            }
        }