Пример #1
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            DateTime dfrom = DateTime.Parse(tbDateFrom.Text);
            DateTime dto = DateTime.Parse(tbDateTo.Text).AddDays(1);

            using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
            {
                var list = from u in ctx.R_HelloEvoque
                           where u.HDate >= dfrom && u.HDate < dto
                           select new
                           {
                               ID = u.ID,
                               Name = u.HName,
                               Email = u.HEmail,
                               Phone = u.HPhone,
                               Sub = u.HSubscription,
                               Time = u.HDate,
                               Source = u.HSource,
                               Province = u.HProvince,
                               City = u.HCity,
                               Way = u.HWay,
                               Title = u.HTitle
                           };
                dataList.DataSource = list.ToList();
                dataList.DataBind();
            }
        }
Пример #2
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            DateTime dfrom = DateTime.Parse(tbDateFrom.Text);
            DateTime dto = DateTime.Parse(tbDateTo.Text).AddDays(1);

            using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
            {
                var list = from u in ctx.NSD_User
                           where u.AddTime >= dfrom && u.AddTime < dto
                           select new Discover24HoursEntity
                           {
                               Name = u.UName,
                               Title = u.UTitle,
                               Email = u.UEmail,
                               Province = u.UProvince,
                               City = u.UCity,
                               Mobile = u.UMobile,
                               HighScore = u.UScore,
                               Weibo = u.Weibo,
                               Place = u.Choose,
                               Time = u.AddTime
                           };
                dataList.DataSource = list.ToList();
                dataList.DataBind();
                /*if (list.Count() > 0)
                    btnDown.Enabled = true;
                else
                    btnDown.Enabled = false;*/
            }
        }
Пример #3
0
        protected void newSubmit_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
                {
                    var admin = from u in ctx.L_Administrators
                                where u.Username == newUser.Text.Trim()
                                select u.ID;

                    if (admin.Count() > 0)
                    {
                        Alert.ShowAlert(Page, "该登录名已存在,请重新输入!", Alert.AlertState.Nothing, string.Empty);
                        return;
                    }

                    L_Administrators ent = new L_Administrators();
                    ent.AddTime = DateTime.Now;
                    ent.DealerID = 0;
                    ent.DisplayName = newName.Text.Trim();
                    ent.Email = newEmail.Text.Trim();
                    ent.LastIP = Request.UserHostAddress;
                    ent.LastLogin = DateTime.Now;
                    ent.Username = newUser.Text.Trim();
                    ent.Password = Helper.GetPasswordString(ent.Username, newPass1.Text.Trim());
                    ent.RoleID = int.Parse(newRole.SelectedValue);
                    ent.Status = 1;

                    ctx.L_Administrators.InsertOnSubmit(ent);
                    ctx.SubmitChanges();
                }

                Alert.ShowAlert(HttpContext.Current, "添加成功!", Alert.AlertState.OpenInThisWindow, Request.Url.ToString());
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string cmd = Request.QueryString["m"];
                switch (cmd)
                {
                    case "detail":
                        jsBlock.Text = "<script type=\"text/javascript\">$($('.content-tab li')[1]).addClass(\"cur\");</script>";
                        CommandView.ActiveViewIndex = 1;
                        break;
                    case "add":
                        using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
                        {
                            var role = from r in ctx.L_Roles
                                       where r.Status == 1
                                       select new
                                       {
                                           ID = r.ID,
                                           Name = r.RoleName
                                       };
                            newRole.DataSource = role.ToList();
                            newRole.DataTextField = "Name";
                            newRole.DataValueField = "ID";
                        }
                        CreateView.DataBind();
                        jsBlock.Text = "<script type=\"text/javascript\">$($('.content-tab li')[2]).addClass(\"cur\");</script>";
                        CommandView.ActiveViewIndex = 2;
                        break;
                    default:
                        tabBack.Visible = false;
                        using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
                        {
                            var admin = from a in ctx.L_Administrators
                                        join r in ctx.L_Roles on a.RoleID equals r.ID
                                        where a.Status == 1
                                        select new
                                        {
                                            ID = a.ID,
                                            Name = a.Username,
                                            Display = a.DisplayName,
                                            Email = a.Email,
                                            Role = r.RoleName,
                                            AddTime = a.AddTime,
                                            LastLogin = a.LastLogin,
                                            LastIP = a.LastIP,
                                            Status = (UserStatus)a.Status
                                        };

                            dataList.DataSource = admin.ToList();
                            dataList.DataBind();
                        }
                        jsBlock.Text = "<script type=\"text/javascript\">$('.content-tab li:first').addClass(\"cur\");</script>";
                        CommandView.ActiveViewIndex = 0;
                        break;
                }
            }
        }
Пример #5
0
        protected void edtSubmit_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                int uid;
                if (!int.TryParse(Request.QueryString["id"], out uid))
                {
                    if (Request.QueryString["m"] == "profile")
                    {
                        uid = (int)Session["lr_admin_id"];
                    }
                    else
                    {
                        Alert.ShowAlert(Page, "参数非法!", Alert.AlertState.OpenInThisWindow, "AdminMgmt.aspx");
                        return;
                    }
                }
                using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
                {
                    L_Administrators admin;

                    if (lineAuth.Visible)
                    {
                        string oldpass = Helper.GetPasswordString((string)Session["lr_admin_user"], edtPass.Text.Trim());
                        admin = (from a in ctx.L_Administrators
                                 where a.ID == uid && a.Password == oldpass
                                 select a).SingleOrDefault();
                        if (admin == null)
                        {
                            Alert.ShowAlert(Page, "密码错误,请重试!", Alert.AlertState.Nothing, string.Empty);
                            return;
                        }
                    }
                    else
                    {
                        admin = (from u in ctx.L_Administrators
                                 where u.ID == uid
                                 select u).Single();
                    }

                    admin.DisplayName = edtName.Text.Trim();
                    if ((int)Session["lr_admin_id"] == uid && !string.IsNullOrEmpty(edtPass1.Text))
                    {
                        admin.Password = Helper.GetPasswordString(admin.Username, edtPass1.Text.Trim());
                    }
                    admin.Email = edtEmail.Text.Trim();
                    admin.RoleID = int.Parse(edtRole.SelectedValue);
                    ctx.SubmitChanges();
                }

                Alert.ShowAlert(HttpContext.Current, "修改成功!", Alert.AlertState.OpenInThisWindow, Request.Url.ToString());
            }
        }
Пример #6
0
        public void OnAcquireRequestState(Object obj, EventArgs e)
        {
            HttpApplication app = obj as HttpApplication;
            HttpContext cnt = app.Context;
            FileInfo info = new FileInfo(cnt.Request.Path);
            if (info.Extension != ".aspx")
            {
                return;
            }
            if (info.Name.ToLower() == "default.aspx" || info.Name.ToLower() == "captcha.aspx")
            {
                return;
            }

            if (CurrentCache["lr_roleData"] == null)
            {
                using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
                {
                    var role = from r in ctx.L_Roles
                               where r.Status == 1
                               select r;

                    CurrentCache.Insert("lr_roleData", role.ToList(), null, DateTime.Now.AddDays(15), Cache.NoSlidingExpiration);
                }
            }

            List<L_Roles> list = (List<L_Roles>)CurrentCache["lr_roleData"];
            if (cnt.Session["lr_admin_id"] != null && cnt.Session["lr_admin_role"] != null)
            {
                int rid = (int)cnt.Session["lr_admin_role"];
                var robj = list.Where(r => r.ID == rid).SingleOrDefault();
                if (robj == null)
                {
                    cnt.Session.Remove("lr_admin_rolename");
                    cnt.Response.Write("invalid role id");
                }
                else
                {
                    cnt.Session["lr_admin_rolename"] = robj.RoleName;
                }
            }
            else
            {
                cnt.Response.Redirect(string.Format("Default.aspx?rt={0}", HttpUtility.UrlEncode(cnt.Request.Url.ToString())));
            }

            if (_eventHandler != null)
                _eventHandler(this, null);
        }
Пример #7
0
        protected void btnDown_Click(object sender, EventArgs e)
        {
            DateTime dfrom = DateTime.Parse(tbDateFrom.Text);
            DateTime dto = DateTime.Parse(tbDateTo.Text).AddDays(1);

            using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
            {
                var list = from u in ctx.NSD_User
                           where u.AddTime >= dfrom && u.AddTime < dto
                           select new Discover24HoursEntity
                           {
                               ID = u.ID,
                               Name = u.UName,
                               Title = u.UTitle,
                               Email = u.UEmail,
                               Province = u.UProvince,
                               City = u.UCity,
                               Mobile = u.UMobile,
                               HighScore = u.UScore,
                               Weibo = u.Weibo,
                               Place = u.Choose,
                               Time = u.AddTime
                           };

                List<Discover24HoursEntity> data = list.ToList();
                if (data.Count == 0)
                    return;

                StringBuilder sb = new StringBuilder("ID,姓名,称呼,电子邮件,省份,城市,手机号,最高分,微博帐号,活动站点,注册时间");
                foreach (Discover24HoursEntity obj in data)
                {
                    sb.AppendLine();
                    sb.AppendFormat("{0},", obj.ID);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.Name));
                    sb.AppendFormat("{0},", obj.Title);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.Email));
                    sb.AppendFormat("{0},", obj.Province);
                    sb.AppendFormat("{0},", obj.City);
                    sb.AppendFormat("{0},", obj.Mobile);
                    sb.AppendFormat("{0},", obj.HighScore);
                    sb.AppendFormat("{0},", obj.Weibo);
                    sb.AppendFormat("{0},", obj.Place);
                    sb.AppendFormat("{0}", obj.Time);
                }
                string path = Helper.ExportAsCsvFile(sb);
                Response.Redirect(path);
            }
        }
Пример #8
0
        protected void btnDown_Click(object sender, EventArgs e)
        {
            DateTime dfrom = DateTime.Parse(tbDateFrom.Text);
            DateTime dto = DateTime.Parse(tbDateTo.Text).AddDays(1);

            using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
            {
                var list = from u in ctx.R_HelloEvoque
                           where u.HDate >= dfrom && u.HDate < dto
                           select u;

                var data = list.ToList();
                if (data.Count == 0)
                    return;

                StringBuilder sb = new StringBuilder("ID,HName,HTitle,HPhone,HEmail,HProvince,HCity,HWay,HSubscription,HIp,HDate,HSource");
                foreach (var obj in data)
                {
                    sb.AppendLine();
                    sb.AppendFormat("{0},", obj.ID);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.HName));
                    sb.AppendFormat("{0},", obj.HTitle);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.HPhone));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.HEmail));
                    sb.AppendFormat("{0},", obj.HProvince);
                    sb.AppendFormat("{0},", obj.HCity);
                    sb.AppendFormat("{0},", obj.HWay);
                    sb.AppendFormat("{0},", obj.HSubscription);
                    sb.AppendFormat("{0},", obj.HIp);
                    sb.AppendFormat("{0},", obj.HDate);
                    sb.AppendFormat("{0},", obj.HSource);
                }
                string path = Helper.ExportAsCsvFile(sb);
                Response.Redirect(path);
            }
        }
Пример #9
0
        private UserStatus ShowDetailByUserID(int uid)
        {
            using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
            {
                var user = (from a in ctx.L_Administrators
                            where a.ID == uid
                            select a).SingleOrDefault();

                var role = from r in ctx.L_Roles
                           where r.Status == 1
                           select new
                           {
                               ID = r.ID,
                               Name = r.RoleName
                           };
                if (user != null)
                {
                    edtRole.DataSource = role.ToList();
                    edtRole.DataTextField = "Name";
                    edtRole.DataValueField = "ID";
                    edtEmail.Text = user.Email;
                    edtName.Text = user.DisplayName;
                    edtRole.SelectedValue = user.RoleID.ToString();
                    edtUser.Text = user.Username;
                    edtStatus.Text = ((UserStatus)user.Status).ToString();
                    if ((UserStatus)user.Status == UserStatus.Banned)
                    {
                        edtBan.Text = "启用帐号";
                    }
                    else
                    {
                        edtBan.Text = "禁用帐号";
                    }
                    return (UserStatus)user.Status;
                }
                else
                {
                    Alert.ShowAlert(Page, "指定的用户不存在。", Alert.AlertState.OpenInThisWindow, "AdminMgmt.aspx");
                    return UserStatus.Deleted;
                }
            }
        }
Пример #10
0
        private void ResetPasswordAction()
        {
            int uid;
            if (!int.TryParse(Request.QueryString["id"], out uid))
            {
                Alert.ShowAlert(Page, "参数非法!", Alert.AlertState.OpenInThisWindow, "AdminMgmt.aspx");
                return;
            }
            string newpass = Helper.GetRandString(8);

            using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
            {
                var admin = (from u in ctx.L_Administrators
                             where u.ID == uid
                             select u).Single();

                Session["lr_admin_reset"] = new string[] { admin.Username, newpass };
                admin.Password = Helper.GetPasswordString(admin.Username, newpass);
                ctx.SubmitChanges();
            }
            Response.Redirect(string.Format("~/AdminMgmt.aspx?m=reset&id={0}", uid));
        }
Пример #11
0
        protected void toggleUserStatus(object sender, EventArgs e)
        {
            int uid;
            if (!int.TryParse(Request.QueryString["id"], out uid))
            {
                Alert.ShowAlert(Page, "参数非法!", Alert.AlertState.OpenInThisWindow, "AdminMgmt.aspx");
                return;
            }
            using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
            {
                var user = (from a in ctx.L_Administrators
                            where a.ID == uid && a.Status != (byte)UserStatus.Deleted
                            select a).Single();

                if (user.Status == 1)
                    user.Status = 2;
                else if (user.Status == 2)
                    user.Status = 1;
                ctx.SubmitChanges();
            }
            Alert.ShowAlert(Page, "操作成功!", Alert.AlertState.OpenInThisWindow, Request.Url.ToString());
        }
Пример #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string cmd = Request.QueryString["m"];
                switch (cmd)
                {
                    case "detail":
                        int uid;
                        if (!int.TryParse(Request.QueryString["id"], out uid))
                        {
                            Alert.ShowAlert(Page, "参数非法!", Alert.AlertState.OpenInThisWindow, "AdminMgmt.aspx");
                            return;
                        }
                        if ((int)Session["lr_admin_id"] == uid)
                        {
                            lineQuick.Visible = false;
                        }
                        else
                        {
                            linePass.Visible = false;
                        }
                        UserStatus stat = ShowDetailByUserID(uid);
                        if (stat == UserStatus.Banned)
                        {
                            lineEmail.Visible = false;
                            lineName.Visible = false;
                            lineRole.Visible = false;
                            btn_resetpass.Visible = false;
                            edtSubmit.Visible = false;
                        }
                        //jsBlock.Text = "<script type=\"text/javascript\">$($('.content-tab li')[1]).addClass(\"cur\");</script>";
                        DetailView.DataBind();
                        CommandView.ActiveViewIndex = 1;
                        break;
                    case "profile":
                        int sid = (int)Session["lr_admin_id"];
                        lineQuick.Visible = false;
                        lineAuth.Visible = true;
                        tabBack.Visible = false;
                        Label12.Text = "新密码<span class=\"desc\">(留空则不修改)</span>";
                        lbDetail.Text = "修改个人资料";
                        ShowDetailByUserID(sid);
                        DetailView.DataBind();
                        CommandView.ActiveViewIndex = 1;
                        break;
                    case "add":
                        using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
                        {
                            var role = from r in ctx.L_Roles
                                       where r.Status == 1
                                       select new
                                       {
                                           ID = r.ID,
                                           Name = r.RoleName
                                       };
                            newRole.DataSource = role.ToList();
                            newRole.DataTextField = "Name";
                            newRole.DataValueField = "ID";
                        }
                        newRole.SelectedValue = "2";
                        CreateView.DataBind();
                        jsBlock.Text = "<script type=\"text/javascript\">$($('.content-tab li')[2]).addClass(\"cur\");</script>";
                        CommandView.ActiveViewIndex = 2;
                        break;
                    case "reset":
                        if (Session["lr_admin_reset"] == null)
                        {
                            Response.Redirect("~/AdminMgmt.aspx");
                            return;
                        }
                        string[] args = (string[])Session["lr_admin_reset"];
                        rstUser.Text = args[0];
                        rstCode.Text = args[1];
                        Session.Remove("lr_admin_reset");
                        CommandView.ActiveViewIndex = 3;
                        break;
                    default:
                        tabBack.Visible = false;
                        using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
                        {
                            var admin = from a in ctx.L_Administrators
                                        join r in ctx.L_Roles on a.RoleID equals r.ID
                                        where a.Status != 3
                                        select new
                                        {
                                            ID = a.ID,
                                            Name = a.Username,
                                            Display = a.DisplayName,
                                            Email = a.Email,
                                            Role = r.RoleName,
                                            AddTime = a.AddTime,
                                            LastLogin = a.LastLogin,
                                            LastIP = a.LastIP,
                                            Status = (UserStatus)a.Status
                                        };

                            dataList.DataSource = admin.ToList();
                            dataList.DataBind();
                        }
                        jsBlock.Text = "<script type=\"text/javascript\">$('.content-tab li:first').addClass(\"cur\");</script>";
                        CommandView.ActiveViewIndex = 0;
                        break;
                }
            }
            else
            {
                switch (postbackArgs.Value)
                {
                    case "reset":
                        ResetPasswordAction();
                        break;
                    default:
                        return;
                }
                postbackArgs.Value = string.Empty;
            }
        }
Пример #13
0
        protected void btnGo_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                if (tbCode.Text.Trim().ToUpper() != (string)Session[Helper.CaptchaKey])
                {
                    //Alert.ShowAlert(Page, "验证码错误。", Alert.AlertState.Nothing, string.Empty);
                    msgError.Text = "验证码错误。";
                    return;
                }

                string passStr = Helper.GetPasswordString(tbName.Text, tbPass.Text);

                using (LandRoverDBDataContext ctx = new LandRoverDBDataContext())
                {
                    var admin = (from a in ctx.L_Administrators
                                 where a.Username == tbName.Text && a.Password == passStr
                                 select a).SingleOrDefault();

                    if (admin != null)
                    {
                        switch (admin.Status)
                        {
                            case 1:
                                admin.LastIP = Request.UserHostAddress;
                                admin.LastLogin = DateTime.Now;
                                ctx.SubmitChanges();

                                Session[Helper.UserKey] = admin.Username;
                                Session["lr_admin_id"] = admin.ID;
                                Session["lr_admin_user"] = admin.Username;
                                Session["lr_admin_name"] = admin.DisplayName;
                                Session["lr_admin_role"] = admin.RoleID;

                                string redirect = Request.QueryString["rt"];
                                if (string.IsNullOrEmpty(redirect))
                                {
                                    Response.Redirect("~/KeepMeInformed.aspx");
                                }
                                else
                                {
                                    Response.Redirect(redirect);
                                }
                                break;
                            case 2:
                                //Alert.ShowAlert(Page, "帐号被禁用,请联系管理员。", Alert.AlertState.Nothing, string.Empty);
                                msgError.Text = "帐号被禁用,请联系管理员。";
                                break;
                            default:
                                break;
                        }
                    }
                    else
                    {
                        //Alert.ShowAlert(Page, "用户名或密码错误。", Alert.AlertState.Nothing, string.Empty);
                        msgError.Text = "用户名或密码错误。";
                        return;
                    }
                }
            }
        }