Add.ashx:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string title = context.Request["txttitle"];
string people=context.Request["txtPeople"];
try
{
BLL.HKSJ_Main mainServer = new BLL.HKSJ_Main();
Model.HKSJ_Main main = new Model.HKSJ_Main();
main.content = string.Empty;
main.Date = DateTime.Now;
main.picUrl = string.Empty;
main.people = people;
main.title = title;
main.type = string.Empty;
mainServer.Add(main);
context.Response.Write("OK");
}
catch(Exception ex)
{
context.Response.Write("后台变态了。。。。");
}
}
Delete.ashx:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
int id = int.Parse(context.Request["id"]??"0");
try
{
BLL.HKSJ_Main mainServer = new BLL.HKSJ_Main();
mainServer.Delete(id);
context.Response.Write("ok");
}
catch (Exception ex)
{
context.Response.Write("删除失败");
}
}
Edit.ashx:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
int id = int.Parse(context.Request["hidId"] ?? "0");
string title = context.Request["txtEditTitle"];
string people = context.Request["txtEditPeople"];
try
{
BLL.HKSJ_Main mainServer = new BLL.HKSJ_Main();
var editMain = mainServer.GetModel(id);
editMain.people = people;
editMain.title = title;
if (mainServer.Update(editMain))
{
context.Response.Write("OK");
}
else
{
context.Response.Write("修改失败");
}
}
catch (Exception ex)
{
context.Response.Write("异常");
}
}