Esempio n. 1
0
 /// <summary>
 /// 新增公告类型
 /// </summary>
 /// <returns></returns>
 public ActionResult AddNewsType()
 {
     try
     {
         UserEntity     uInfo   = ViewData["Account"] as UserEntity;
         NewsTypeEntity typeAdd = new NewsTypeEntity();
         typeAdd.ftypename  = Request["TypeName"];
         typeAdd.fsort      = int.Parse(Request["Sort"] == null ? "0" : Request["Sort"]);
         typeAdd.CreateBy   = uInfo.AccountName;
         typeAdd.CreateTime = DateTime.Now;
         typeAdd.UpdateBy   = uInfo.AccountName;
         typeAdd.UpdateTime = DateTime.Now;
         bool exists = new NewsTypeBLL().Exists(typeAdd.ftypename);
         if (exists)
         {
             return(Content("{\"msg\":\"添加失败,类型名称已存在!\",\"success\":false}"));
         }
         else
         {
             int typeId = new NewsTypeBLL().Add(typeAdd);
             if (typeId > 0)
             {
                 return(Content("{\"msg\":\"添加成功!\",\"success\":true}"));
             }
             else
             {
                 return(Content("{\"msg\":\"添加失败!\",\"success\":false}"));
             }
         }
     }
     catch (Exception ex)
     {
         return(Content("{\"msg\":\"添加失败," + ex.Message + "\",\"success\":false}"));
     }
 }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            if (context.Session["id"] != null)
            {
                string temp = File.ReadAllText(context.Server.MapPath("drugstore_admin_settings.html"));
                List <GoodsTypeModel> dt = GoodsTypeBLL.GetGoodsTypeList();
                StringBuilder         sb = new StringBuilder();
                if (dt != null)
                {
                    foreach (GoodsTypeModel item in dt)
                    {
                        sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td><a href='ProcessAdminSettingsForm.ashx?goods_id_delete={0}'class='btn btn-danger'>删除</a></td></tr>", item.GoodsTypeid, item.GoodsTypename);
                    }
                }


                temp = temp.Replace("@product_content", sb.ToString());

                List <NewsTypeModel> dt2 = NewsTypeBLL.GetNewsList();
                StringBuilder        sb2 = new StringBuilder();
                foreach (NewsTypeModel item in dt2)
                {
                    sb2.AppendFormat("<tr><td>{0}</td><td>{1}</td><td><a href='ProcessAdminSettingsForm.ashx?news_id_delete={0}'class='btn btn-danger'>删除</a></td></tr>", item.NewsTypeid, item.NewsTypename);
                }
                temp = temp.Replace("@admin", context.Session["admin_name"].ToString());
                temp = temp.Replace("@news_content", sb2.ToString());
                context.Response.Write(temp);
            }
            else
            {
                context.Response.Redirect("~/admin_login.html");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            if (context.Session["id"] != null)
            {
                context.Response.ContentType = "text/html";
                string    news_id  = context.Request.QueryString["news_id"];
                string    temp     = File.ReadAllText(context.Server.MapPath("drugstore_admin_news_save.html"));
                NewsModel news     = NewsBLL.GetANews(news_id);
                int       newsType = news.NewsType;
                temp = temp.Replace("@news_title", news.NewsTitle);
                temp = temp.Replace("@news_content", news.NewsContent);


                List <NewsTypeModel> newsTypeList = NewsTypeBLL.GetNewsList();
                StringBuilder        sb           = new StringBuilder();
                string selectedHtml = "";
                foreach (NewsTypeModel item in newsTypeList)
                {
                    if (newsType == item.NewsTypeid)
                    {
                        selectedHtml = "selected = 'true'";
                    }
                    sb.AppendFormat("<option value='{0}' {2}>{1}</option>", item.NewsTypeid.ToString(), item.NewsTypename, selectedHtml);
                    selectedHtml = "";
                }
                temp = temp.Replace("@newstype_content", sb.ToString());
                temp = temp.Replace("@News_id", news_id);
                temp = temp.Replace("@admin", context.Session["admin_name"].ToString());
                context.Response.Write(temp);
            }
            else
            {
                context.Response.Redirect("~/admin_login.html");
            }
        }
Esempio n. 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string type = "全部新闻";
            string temp = File.ReadAllText(context.Server.MapPath("drugstore_news.html"));

            //
            List <NewsModel> newsList = new List <NewsModel>();

            if (context.Request.QueryString["type"] != null)
            {
                int newsType = Int32.Parse(context.Request.QueryString["type"].ToString());
                newsList = NewsBLL.GetNewsListByType(newsType);
            }
            else
            {
                newsList = NewsBLL.GetHotNewsList();
            }

            StringBuilder sb = new StringBuilder();

            int count = 1;

            if (newsList != null)
            {
                foreach (NewsModel item in newsList)
                {
                    //item["News_newstype"]

                    string newsTypeName = NewsTypeBLL.GetNameById(item.NewsType);
                    sb.AppendFormat("<tr><td>{0}</td><td><a href='ProcessNewsDetail.ashx?news_id={1}'>{2}</a></td><td>{3}</td><td>{4}</td></tr>", count, item.NewsId, item.NewsTitle, item.NewsViewCount.ToString(), newsTypeName);
                    count++;
                }
            }


            List <NewsTypeModel> newsTypeList = NewsTypeBLL.GetNewsList();
            StringBuilder        sb3          = new StringBuilder();

            foreach (NewsTypeModel item in newsTypeList)
            {
                sb3.AppendFormat("<a href='ProcessNews.ashx?type={0}' class='list-group-item'>{1}</a>", item.NewsTypeid, item.NewsTypename);
            }


            temp = temp.Replace("@news_type", sb3.ToString());
            temp = temp.Replace("@type", type);
            temp = temp.Replace("@content", sb.ToString());
            if (context.Session["users_id"] != null)
            {
                temp = temp.Replace("@user_name", context.Session["user_name"].ToString());
            }
            else
            {
                temp = temp.Replace("@user_name", "游客");
            }
            context.Response.Write(temp);
        }
Esempio n. 5
0
        public ActionResult GetAllNewsTypeInfo()
        {
            string strWhere = "1=1";
            string sort     = Request["sort"] == null ? "id" : Request["sort"];
            string order    = Request["order"] == null ? "asc" : Request["order"];

            if (!string.IsNullOrEmpty(Request["FTypeName"]) && !SqlInjection.GetString(Request["FTypeName"]))
            {
                strWhere += " and ftypename like '%" + Request["FTypeName"] + "%'";
            }
            //首先获取前台传递过来的参数
            int    pageindex  = Request["page"] == null ? 1 : Convert.ToInt32(Request["page"]);
            int    pagesize   = Request["rows"] == null ? 10 : Convert.ToInt32(Request["rows"]);
            int    totalCount = 0; //输出参数
            string strJson    = new NewsTypeBLL().GetPager("tbNewsType", "[id],[ftypename],fsort,CreateTime,CreateBy,UpdateTime,UpdateBy", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);

            return(Content("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}"));
        }
Esempio n. 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            if (context.Session["id"] != null)
            {
                string temp = File.ReadAllText(context.Server.MapPath("drugstore_admin_news_add.html"));

                List <NewsTypeModel> newsTypeList = NewsTypeBLL.GetNewsList();
                StringBuilder        sb           = new StringBuilder();
                foreach (NewsTypeModel item in newsTypeList)
                {
                    sb.AppendFormat("<option value='{0}'>{1}</option>", item.NewsTypeid.ToString(), item.NewsTypename);
                }
                temp = temp.Replace("@newstype_content", sb.ToString());
                temp = temp.Replace("@admin", context.Session["admin_name"].ToString());
                context.Response.Write(temp);
            }
            else
            {
                context.Response.Redirect("~/admin_login.html");
            }
        }
Esempio n. 7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            if (context.Session["id"] != null)
            {
                string temp = File.ReadAllText(context.Server.MapPath("drugstore_admin_news.html"));

                List <NewsModel> newsList = NewsBLL.GetNewsList();
                StringBuilder    sb       = new StringBuilder();
                foreach (NewsModel item in newsList)
                {
                    string newsTypeName = NewsTypeBLL.GetNameById(item.NewsType);
                    sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td><a href='ProcessAdminDeleteNews.ashx?news_id={0}' class='btn btn-danger'>删除</a>&nbsp;<a href='ProcessAdminNewsSaveIndex.ashx?news_id={0}' class='btn btn-primary'>修改</a>&nbsp;<a href='ProcessAdminNewsPreview.ashx?news_id={0}' class='btn btn-warning'>预览</a></td></tr>", item.NewsId, item.NewsTitle, item.NewsViewCount, item.NewsSource, newsTypeName);
                }
                temp = temp.Replace("@content", sb.ToString());
                temp = temp.Replace("@admin", context.Session["admin_name"].ToString());
                context.Response.Write(temp);
            }
            else
            {
                context.Response.Redirect("~/admin_login.html");
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 编辑公告类型
        /// </summary>
        /// <returns></returns>
        public ActionResult EditNewsType()
        {
            try
            {
                UserEntity uInfo = ViewData["Account"] as UserEntity;

                int    id           = Convert.ToInt32(Request["id"]);
                string originalName = Request["originalName"];

                NewsTypeEntity typeEdit = new NewsTypeBLL().GetModel(id);
                typeEdit.ftypename  = Request["TypeName"];
                typeEdit.fsort      = int.Parse(Request["Sort"] == null ? "0" : Request["Sort"]);
                typeEdit.UpdateBy   = uInfo.AccountName;
                typeEdit.UpdateTime = DateTime.Now;
                bool exists = new NewsTypeBLL().Exists(typeEdit.ftypename);
                if (typeEdit.ftypename != originalName && exists)
                {
                    return(Content("{\"msg\":\"修改失败,类型名称已存在!\",\"success\":false}"));
                }
                else
                {
                    int result = new NewsTypeBLL().Update(typeEdit);
                    if (result > 0)
                    {
                        return(Content("{\"msg\":\"修改成功!\",\"success\":true}"));
                    }
                    else
                    {
                        return(Content("{\"msg\":\"修改失败!\",\"success\":false}"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Content("{\"msg\":\"修改失败," + ex.Message + "\",\"success\":false}"));
            }
        }
Esempio n. 9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            if (context.Session["id"] != null)
            {
                string product_id      = context.Request.Form["product_id"];
                string product_name    = context.Request.Form["product_name"];
                string product_action  = context.Request.Form["product_action"];
                string goods_id_delete = context.Request.QueryString["goods_id_delete"];

                string news_id        = context.Request.Form["news_id"];
                string news_name      = context.Request.Form["news_name"];
                string news_action    = context.Request.Form["news_action"];
                string news_id_delete = context.Request.QueryString["news_id_delete"];

                if (product_action == "0")
                {
                    if (product_name != null)
                    {
                        int i = GoodsTypeBLL.GoodsType1(product_name);
                        if (i > 0)
                        {
                            context.Response.Write(product_name + "添加成功<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                            //return;
                        }
                        else
                        {
                            context.Response.Write(product_name + "添加失败<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                            //return;
                        }
                    }
                    else
                    {
                        context.Response.Write("添加时请填写类型名<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                        //return;
                    }
                }
                else if (product_action == "1")
                {
                    if (product_id != null && product_name != null)
                    {
                        int i = GoodsTypeBLL.GoodsType2(product_name, product_id);
                        if (i > 0)
                        {
                            context.Response.Write(product_name + "修改成功<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                            //return;
                        }
                        else
                        {
                            context.Response.Write(product_name + "修改失败<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                            //return;
                        }
                    }
                }
                else if (goods_id_delete != null)
                {
                    int i = GoodsTypeBLL.GoodsType3(goods_id_delete);
                    if (i > 0)
                    {
                        context.Response.Write(product_name + "删除成功<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                        //return;
                    }
                    else
                    {
                        context.Response.Write(product_name + "删除失败<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                        //return;
                    }
                }
                else if (news_action == "0")
                {
                    if (news_name != null)
                    {
                        int i = NewsTypeBLL.NewsType2(news_name);
                        if (i > 0)
                        {
                            context.Response.Write(news_name + "添加成功<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                            //return;
                        }
                        else
                        {
                            context.Response.Write(news_name + "添加失败<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                            //return;
                        }
                    }
                    else
                    {
                        context.Response.Write("添加时请填写类型名<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                        //return;
                    }
                }
                else if (news_action == "1")
                {
                    if (news_id != null && news_name != null)
                    {
                        int i = NewsTypeBLL.NewsType1(news_name, news_id);
                        if (i > 0)
                        {
                            context.Response.Write(news_name + "修改成功<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                            //return;
                        }
                        else
                        {
                            context.Response.Write(news_name + "修改失败<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                            //return;
                        }
                    }
                }
                else if (news_id_delete != null)
                {
                    int i = NewsTypeBLL.NewsType3(news_id_delete);
                    if (i > 0)
                    {
                        context.Response.Write(news_name + "删除成功<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                        //return;
                    }
                    else
                    {
                        context.Response.Write(news_name + "删除失败<a href='ProcessAdminSettings.ashx'>返回设置页面</a>");
                        //return;
                    }
                }

                context.Response.Write(product_id + "ProcessAdminSettingsForm" + product_name);
            }
            else
            {
                context.Response.Redirect("~/admin_login.html");
            }
        }
Esempio n. 10
0
        public ActionResult GetAllNewsTypeDrop()
        {
            string roleJson = new NewsTypeBLL().GetAllNewsTypeInfo("1=1");

            return(Content(roleJson));
        }