protected void Page_Load(object sender, EventArgs e)
        {
            int id = int.Parse(Request["id"] ?? "0");
            HKSJ_Main bllMain = new HKSJ_Main();
            if (!IsPostBack)
            {
                modelMain=bllMain.GetModel(id) ;
            }
            else
            {
                //新闻并不是全部都修改,所以先有原来的新闻信息,再修改其部分,最后保存

                //本来以为在第二次的modelMain里面保留了上次的记录,那么直接修改这个对象,再保存,然而事实是这个对象并未保存,第二次访问时为null
                //Response.Clear();
                //Response.Write(modelMain.title);
                //Response.End();

                //必须查询一次数据库,把这调新闻查询出来,在修改,再保存
                News.Model.HKSJ_Main saveModel = bllMain.GetModel(id);
                saveModel.people = Request["people"];
                saveModel.type = Request["type"];
                saveModel.title = Request["title"];
                saveModel.content = Request["content"];
                bllMain.Update(saveModel);

                Response.Clear();
                Response.Write("ok");
                Response.End();
            }
        }
        protected void btnAddNews_Click(object sender, EventArgs e)
        {
            //数据获取
            News.Model.HKSJ_Main modelMain = new News.Model.HKSJ_Main();
            modelMain.people = this.txtPeople.Text;
            modelMain.title = this.txtTitle.Text;
            modelMain.picUrl = "";
            modelMain.type = "";
            modelMain.content = this.txtBoxContent.Text;
            modelMain.Date = DateTime.Now;

            //添加
            bllMain.Add(modelMain);
            Response.Redirect("NewsShow.aspx");
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            //我应该查询出来后在修改,毕竟不一定全修改
            News.Model.HKSJ_Main mainModel = new News.Model.HKSJ_Main();
            mainModel.ID = int.Parse(context.Request["ID"]);
            mainModel.people = context.Request["people"];
            mainModel.picUrl = "";
            mainModel.title = context.Request["title"]??"";
            mainModel.content = context.Request["content"];
            mainModel.Date = DateTime.Now;
            mainModel.type = "";

            HKSJ_Main bllMain = new HKSJ_Main();
            bllMain.Update(mainModel);
            context.Response.Write("ok");
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            News.Model.HKSJ_Main modelMain = new News.Model.HKSJ_Main();

            modelMain.people = context.Request["txtPeople"];
            modelMain.title = context.Request["txtTitle"];
            modelMain.content = context.Request["txtContent"];
            modelMain.Date = DateTime.Now;
            modelMain.picUrl = string.Empty;
            modelMain.type = string.Empty;

            News.BLL.HKSJ_Main BllMain = new News.BLL.HKSJ_Main();
            if (BllMain.Add(modelMain) > 0)
            {
                context.Response.Write("ok");
            }
            else
            {
                context.Response.Write("error");
            }
        }