public DataSet select(BrandStore po) { StringBuilder sql = new StringBuilder(); sql.Append("select * from BrandStore where 1=1"); if (!String.IsNullOrEmpty(po.bsCountry)) { sql.Append(String.Format(" and bs_country={0}", DbAccess.parse(po.bsCountry))); } if (!String.IsNullOrEmpty(po.bsCity)) { sql.Append(String.Format(" and bs_city={0}", DbAccess.parse(po.bsCity))); } if (!String.IsNullOrEmpty(po.bsContent)) { sql.Append(String.Format(" and bs_content={0}", DbAccess.parse(po.bsContent))); } if (!String.IsNullOrEmpty(po.bsId)) { sql.Append(String.Format(" and bs_id='{0}'", po.bsId)); } sql.Append(" order by bs_update_time desc"); return(DbAccess.executeQuery(sql.ToString())); }
public int update(BrandStore po) { StringBuilder sql = new StringBuilder(); sql.Append("update BrandStore set "); sql.Append(String.Format("bs_country={0},", DbAccess.parse(po.bsCountry))); sql.Append(String.Format("bs_city={0},", DbAccess.parse(po.bsCity))); sql.Append(String.Format("bs_content={0},", DbAccess.parse(po.bsContent))); sql.Append("bs_update_time=getdate()"); sql.Append(String.Format(" where bs_id='{0}'", po.bsId)); return(DbAccess.executeUpdate(sql.ToString())); }
public int insert(BrandStore po) { StringBuilder sql = new StringBuilder(); sql.Append("insert into BrandStore values( "); if (!String.IsNullOrEmpty(po.bsId)) { sql.Append(String.Format("{0},", DbAccess.parse(po.bsId))); } else { sql.Append("newid(), "); } sql.Append(String.Format("{0},", DbAccess.parse(po.bsCountry))); sql.Append(String.Format("{0},", DbAccess.parse(po.bsCity))); sql.Append(String.Format("{0},", DbAccess.parse(po.bsContent))); sql.Append("getdate(), getdate())"); return(DbAccess.executeUpdate(sql.ToString())); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); string method = context.Request.Params["method"]; if ("list".Equals(method)) { string ajax = context.Request.Params["ajax"]; BrandStoreDAO dao = new BrandStoreDAO(); BrandStore bs = new BrandStore(); bs.bsCountry = context.Request.Params["bsCountry"]; bs.bsCity = context.Request.Params["bsCity"]; DataSet ds = dao.select(bs); 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)) { BrandStoreDAO dao = new BrandStoreDAO(); BrandStore bs = new BrandStore(); bs.bsId = context.Request.Params["bsId"]; DataSet ds = dao.select(bs); string json = JsonCommon.ds2json(ds); PictureDAO picDao = new PictureDAO(); Picture pic = new Picture(); pic.picTableName = "BrandStore"; pic.picTableId = bs.bsId; 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 bsContent = HttpUtility.UrlDecode((context.Request.Params["bsContent"]).Replace("@", "%")); string bsCountry = context.Request.Params["bsCountry"]; string bsCity = context.Request.Params["bsCity"]; string bsId = context.Request.Params["bsId"]; BrandStoreDAO dao = new BrandStoreDAO(); BrandStore bs = new BrandStore(); bs.bsContent = bsContent; bs.bsCountry = bsCountry; bs.bsCity = bsCity; if (!String.IsNullOrEmpty(bsId)) { bs.bsId = bsId; dao.update(bs); } else { bs.bsId = Guid.NewGuid().ToString(); bsId = bs.bsId; dao.insert(bs); } 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 = bsId; pic.picTableName = "BrandStore"; 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 bsId = context.Request.Params["bsId"]; BrandStoreDAO dao = new BrandStoreDAO(); BrandStore bs = new BrandStore(); bs.bsId = bsId; dao.delete(bs); } }
public int delete(BrandStore po) { string sql = String.Format("delete from BrandStore where bs_id='{0}'", po.bsId); return(DbAccess.executeUpdate(sql)); }