public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            //获取id
            int id;
            int.TryParse(context.Request["id"].ToString(),out id);

            //删除数据
            BLL.Main mainBll = new BLL.Main();
            mainBll.Delete(id);

            //重定向
            context.Response.Redirect("../News/NewsListHandler.ashx");
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            //获得id
            int id;
            int.TryParse(context.Request["id"].ToString(),out id);
            BLL.Main mainBll = new BLL.Main();

            //展示数据
            if (context.Request["Action"]!="Edit")
            {
                string templePath = context.Request.MapPath("../Temple/EditTemple.htm");
                string result = File.ReadAllText(templePath);

                Main mainModle = mainBll.GetModel(id);
                result = result.Replace("@title", mainModle.title);
                result = result.Replace("@people", mainModle.people);
                result = result.Replace("@type", mainModle.type);
                result = result.Replace("@date", mainModle.Date.ToString());
                result = result.Replace("@id", id.ToString());

                context.Response.Write(result);
            }
                //保存数据到数据库,并跳转
            else
            {
                //代码生成器的方法是保存所有的数据
                //于是先查询出Model类,修改之,再保存
                Main mainModle=mainBll.GetModel(id);
                mainModle.ID = id;
                mainModle.type = context.Request["type"];
                mainModle.title = context.Request["title"];
                mainModle.people = context.Request["people"];
                mainModle.Date = DateTime.Parse(context.Request["date"]);
                mainBll.Update(mainModle);

                context.Response.Redirect("NewsListHandler.ashx");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            //获取数据,失败!!!Model中的Main与Bll中的Main重名
            BLL.Main mainBll = new BLL.Main();
            List<Main> modelList=mainBll.GetModelList(string.Empty);

            //拼接页面html
            StringBuilder sb = new StringBuilder();
            foreach (var item in modelList)
            {
                //<th>ID</th><th>标题</th><th>日期</th><th>创建人</th><th>操作</th>
                sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td><a href='DeleteHandler.ashx?id={0}'>删除</a>&nbsp;&nbsp;&nbsp;<a href='EditHandler.ashx?id={0}'>编辑</a></td></tr>", item.ID, item.title, item.Date, item.people);
            }

            //载入模板,生成html
            string templePath = context.Request.MapPath(@"../Temple/ListPageTemple.htm");
            string result = File.ReadAllText(templePath);
            result = result.Replace("@listTable", sb.ToString());

            context.Response.Write(result);
        }