public DataSet select(SeasonSelection po) { StringBuilder sql = new StringBuilder(); sql.Append("select * from SeasonSelection where 1=1"); if (!String.IsNullOrEmpty(po.ssType1)) { sql.Append(String.Format(" and ss_type1={0}", DbAccess.parse(po.ssType1))); } if (!String.IsNullOrEmpty(po.ssType2)) { sql.Append(String.Format(" and ss_type2={0}", DbAccess.parse(po.ssType2))); } if (!String.IsNullOrEmpty(po.ssContent)) { sql.Append(String.Format(" and ss_content={0}", DbAccess.parse(po.ssContent))); } if (!String.IsNullOrEmpty(po.ssId)) { sql.Append(String.Format(" and ss_id='{0}'", po.ssId)); } sql.Append(" order by ss_update_time desc"); return DbAccess.executeQuery(sql.ToString()); }
public int update(SeasonSelection po) { StringBuilder sql = new StringBuilder(); sql.Append("update SeasonSelection set "); sql.Append(String.Format("ss_type1={0},", DbAccess.parse(po.ssType1))); sql.Append(String.Format("ss_type2={0},", DbAccess.parse(po.ssType2))); sql.Append(String.Format("ss_content={0},", DbAccess.parse(po.ssContent))); sql.Append("ss_update_time=getdate()"); sql.Append(String.Format(" where ss_id='{0}'", po.ssId)); return DbAccess.executeUpdate(sql.ToString()); }
public int insert(SeasonSelection po) { StringBuilder sql = new StringBuilder(); sql.Append("insert into SeasonSelection values("); if (!String.IsNullOrEmpty(po.ssId)) { sql.Append(String.Format("{0},", DbAccess.parse(po.ssId))); } else { sql.Append("newid(), "); } sql.Append(String.Format("{0},", DbAccess.parse(po.ssType1))); sql.Append(String.Format("{0},", DbAccess.parse(po.ssType2))); sql.Append(String.Format("{0},", DbAccess.parse(po.ssContent))); sql.Append("getdate(), getdate())"); return DbAccess.executeUpdate(sql.ToString()); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string method = context.Request.Params["method"]; if ("list".Equals(method)) { string ajax = context.Request.Params["ajax"]; SeasonSelectionDAO dao = new SeasonSelectionDAO(); SeasonSelection ss = new SeasonSelection(); ss.ssType1 = context.Request.Params["ssType1"]; ss.ssType2 = context.Request.Params["ssType2"]; DataSet ds = dao.select(ss); string result = ""; if (String.IsNullOrEmpty(ajax)) { result = "_list = " + JsonCommon.ds2json(ds); } else { result = JsonCommon.ds2json(ds); } context.Response.Write(result); } else if ("detail".Equals(method)) { SeasonSelectionDAO dao = new SeasonSelectionDAO(); SeasonSelection ss = new SeasonSelection(); ss.ssId = context.Request.Params["ssId"]; DataSet ds = dao.select(ss); string json = JsonCommon.ds2json(ds); PictureDAO picDao = new PictureDAO(); Picture pic = new Picture(); pic.picTableName = "SeasonSelection"; pic.picTableId = ss.ssId; DataSet picDs = picDao.select(pic); string picJson = JsonCommon.ds2json(picDs); json = String.Format("[{0},{1}]", json, picJson); context.Response.Write(json); } else if ("save".Equals(method)) { string ssContent = HttpUtility.UrlDecode((context.Request.Params["ssContent"]).Replace("@", "%")); string ssType1 = context.Request.Params["ssType1"]; string ssType2 = context.Request.Params["ssType2"]; string ssId = context.Request.Params["ssId"]; SeasonSelectionDAO dao = new SeasonSelectionDAO(); SeasonSelection ss = new SeasonSelection(); ss.ssContent = ssContent; ss.ssType1 = ssType1; ss.ssType2 = ssType2; if (!String.IsNullOrEmpty(ssId)) { ss.ssId = ssId; dao.update(ss); } else { ss.ssId = Guid.NewGuid().ToString(); ssId = ss.ssId; dao.insert(ss); } string pics = context.Request.Params["pics"]; string disc = context.Request.Params["disc"]; PictureDAO picDao = new PictureDAO(); //删除要删除的图片 string delPics = context.Request.Params["delPic"]; if (!String.IsNullOrEmpty(delPics)) { string[] arrDelPics = delPics.Split(','); for (int i = 0; i < arrDelPics.Length; i++) { Picture p = new Picture(); p.picId = arrDelPics[i]; picDao.delete(p); } } if (!String.IsNullOrEmpty(pics)) { string[] arrPics = pics.Split(','); string[] arrDisc = disc.Split(','); for (int i = 0; i < arrPics.Length; i++) { string fileName = arrPics[i].Substring(arrPics[i].LastIndexOf("/") + 1); string fromPath = context.Server.MapPath(arrPics[i]); string toPath = context.Server.MapPath(FileHelper.Default_Pic_Forder + fileName); FileHelper.MoveTo(fromPath, toPath); Picture pic = new Picture(); pic.picTableId = ssId; pic.picTableName = "SeasonSelection"; pic.picDescrip = arrDisc[i]; pic.picExtension = fileName.Substring(fileName.LastIndexOf(".") + 1); pic.picName = fileName; pic.picPath = FileHelper.Default_Pic_Forder + fileName; picDao.insert(pic); } } } else if ("delete".Equals(method)) { string ssId = context.Request.Params["ssId"]; SeasonSelectionDAO dao = new SeasonSelectionDAO(); SeasonSelection ss = new SeasonSelection(); ss.ssId = ssId; dao.delete(ss); } }
public int delete(SeasonSelection po) { string sql = String.Format("delete from SeasonSelection where ss_id='{0}'", po.ssId); return DbAccess.executeUpdate(sql); }