public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //取值 int id = Convert.ToInt32(context.Request["Id"]); string title = context.Request["title"]; //接受文件 HttpPostedFile file = context.Request.Files["img"]; //判断 if (string.IsNullOrEmpty(title)) { context.Response.Write("kong"); } else { Ad ad = new Ad(); ad.Id = id; ad.Title = title; ad.ImgUrl = null; ad.CreateTime = DateTime.Now; ad.IsDelete = false; if (file.ContentLength <= 0) { ad.ImgUrl = new AdBll().GetModel(id).ImgUrl; } else { //重命名文件 //相对路径 string img = "../../Home/images/" + Guid.NewGuid().ToString() + ".jpg"; //绝对路径 string abName = context.Server.MapPath(img); file.SaveAs(abName); ad.ImgUrl = img; } AdBll bll = new AdBll(); bool flag = bll.Update(ad); if (flag) { context.Response.Write("ok"); } else { context.Response.Write("no"); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //取值 string id = context.Request["id"]; AdBll bll = new AdBll(); bool f*g = bll.Update(Convert.ToInt32(id)); if (f*g) { context.Response.Write("ok"); } else { context.Response.Write("no"); } }
protected void Page_Load(object sender, EventArgs e) { AdBll awbb = new AdBll(); string index = Request["index"]; if (string.IsNullOrEmpty(index)) { pageIndex = 1; } else { pageIndex = Convert.ToInt32(index); } //总页数 int total = awbb.GetRecordCount("IsDelete=0"); pageCount = Convert.ToInt32(Math.Ceiling((double)total / pageSize)); //集合 DataSet ds = awbb.GetListByPage(" IsDelete=0", "", (pageIndex - 1) * pageSize + 1, pageIndex * pageSize); AdList = awbb.DataTableToList(ds.Tables[0]); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //取值 string title = context.Request["title"]; //string img = context.Request["img"]; //接受文件 HttpPostedFile file = context.Request.Files["img"]; //重命名文件 //相对路径 string img = "../../Home/images/" + Guid.NewGuid().ToString() + ".jpg"; //绝对路径 string abName = context.Server.MapPath(img); file.SaveAs(abName); //判断 if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(img)) { context.Response.Write("kong"); } else { Ad ad = new Ad(); ad.Title = title; ad.ImgUrl = img; ad.CreateTime = DateTime.Now; ad.IsDelete = false; AdBll bll = new AdBll(); int row = bll.Add(ad); if (row > 0) { context.Response.Write("ok"); } else { context.Response.Write("no"); } } }