protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string cId = Request.QueryString["id"]; if (string.IsNullOrEmpty(cId)) { return; } caseInfo = CaseInfoManage.GetById(Convert.ToInt32(cId)); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { allNews = NewsManage.GetAll(); Repeater1.DataSource = allNews; Repeater1.DataBind(); //查询所有信息 allCase = CaseInfoManage.GetAll(); RepCase.DataSource = allCase; RepCase.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //allCase = CaseInfoManage.GetAll(); string page = Request.QueryString["pageIndex"]; int totalCount; int pageIndex = string.IsNullOrEmpty(page) ? 1 : Convert.ToInt32(page); allCase = CaseInfoManage.GetByPaging(pageIndex, pageSize, out totalCount); caseLi.DataSource = allCase; caseLi.DataBind(); int totalPage = (int)Math.Ceiling((double)totalCount / pageSize); //总页数 pageBar = Utility.Paging.PageList(pageIndex, totalPage); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string action = context.Request["Action"]; string id = context.Request["Uid"]; int uid = 0; if (!string.IsNullOrEmpty(action)) { if (action == "add") { string title = context.Request.Form["title"]; string content = context.Request.Form["hidContent"]; string uploadFile = context.Request.Form["hidImgPath"]; bool b = true; CheckEmpty(out b, title, content, uploadFile); if (!b) { context.Response.Write("empty"); return; } Mc.Model.CaseInfo caseInfo = new Model.CaseInfo() { Title = title, Content = content, ImgPath = uploadFile }; try { int count = CaseInfoManage.Add(caseInfo); if (count > 0) { context.Response.Write("ok"); } } catch (Exception ex) { LogHelper.WriteLog(typeof(ProcessCase), ex.Message); } } else if (action == "modify") { if (string.IsNullOrEmpty(id)) { context.Response.Write("参数有误"); return; } if (int.TryParse(id, out uid)) { string title = context.Request.Form["title"]; string content = context.Request.Form["content"]; string uploadFile = context.Request.Form["hidImgPath"]; Mc.Model.CaseInfo caseInfo = CaseInfoManage.GetById(uid); if (caseInfo != null) { caseInfo.Title = title; caseInfo.Content = content; caseInfo.ImgPath = uploadFile; try { int count = CaseInfoManage.Modify(caseInfo); if (count > 0) { context.Response.Write("yes"); } } catch (Exception ex) { LogHelper.WriteLog(typeof(ProcessCase), ex.Message); } } } } else if (action == "detail") { if (string.IsNullOrEmpty(id)) { context.Response.Write("参数有误"); return; } if (int.TryParse(id, out uid)) { Mc.Model.CaseInfo caseInfo = CaseInfoManage.GetById(uid); if (caseInfo != null) { context.Response.Write(new JavaScriptSerializer().Serialize(caseInfo)); } } } else if (action == "delete") { if (string.IsNullOrEmpty(id)) { context.Response.Write("参数有误"); return; } if (int.TryParse(id, out uid)) { try { int count = CaseInfoManage.Delete(uid); if (count > 0) { context.Response.Write("ok"); } } catch (Exception ex) { LogHelper.WriteLog(typeof(ProcessCase), ex.Message); } } } else { context.Response.Write("action参数有误"); } } else { context.Response.Write("action参数有误"); } }