public HttpResponseBase GetProTag() { string json = string.Empty; try { StringBuilder strJson = new StringBuilder(); _productTagMgr = new ProductTagMgr(connectionString); List<ProductTag> tags = _productTagMgr.Query(new ProductTag { tag_status = 1 }); if (tags != null) { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { uint productId = uint.Parse(Request.Form["ProductId"]); _productTagSetMgr = new ProductTagSetMgr(connectionString); List<ProductTagSet> tagSets = _productTagSetMgr.Query(new ProductTagSet { product_id = productId }); foreach (var item in tags) { strJson.AppendFormat("<input type='checkbox' id='tag_{0}' name='tags' value='{0}' ", item.tag_id); if (tagSets.Exists(m => m.tag_id == item.tag_id)) { strJson.Append("checked='true'"); } strJson.AppendFormat("/><label for='tag_{0}'><img src='{1}' style='margin-right:5px' /></label>", item.tag_id, imgServerPath + tagPath + GetDetailFolder(item.tag_filename) + item.tag_filename); } } else { int writerId = (Session["caller"] as Caller).user_id; _productTagSetTempMgr = new ProductTagSetTempMgr(connectionString); ProductTagSetTemp query = new ProductTagSetTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE }; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { query.product_id = Request.Form["OldProductId"]; } List<ProductTagSetTemp> tagSetTemps = _productTagSetTempMgr.Query(query); foreach (var item in tags) { strJson.AppendFormat("<input type='checkbox' id='tag_{0}' name='tags' value='{0}' ", item.tag_id); if (tagSetTemps.Exists(m => m.tag_id == item.tag_id)) { strJson.Append("checked='true'"); } strJson.AppendFormat("/><label for='tag_{0}'><img src='{1}' style='margin-right:5px' /></label>", item.tag_id, imgServerPath + tagPath + GetDetailFolder(item.tag_filename) + item.tag_filename); } } json = strJson.ToString(); } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetProTag() { string json = string.Empty; try { StringBuilder strJson = new StringBuilder(); _productTagMgr = new ProductTagMgr(connectionString); List<ProductTag> tags = _productTagMgr.Query(new ProductTag { tag_status = 1 }); if (tags != null) { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { uint productId = uint.Parse(Request.Form["ProductId"]); _productTagSetMgr = new ProductTagSetMgr(connectionString); List<ProductTagSet> tagSets = _productTagSetMgr.Query(new ProductTagSet { product_id = productId }); foreach (var item in tags) { if (tagSets.Exists(m => m.tag_id == item.tag_id)) { strJson.AppendFormat("<img src='{1}' style='margin-right:5px' /></label>", item.tag_id, imgServerPath + tagPath + GetDetailFolder(item.tag_filename) + item.tag_filename); } } } json = strJson.ToString(); if (string.IsNullOrEmpty(json)) { json = "暫無圖片"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetProTag() { string json = string.Empty; try { StringBuilder strJson = new StringBuilder(); _productTagMgr = new ProductTagMgr(connectionString); List<ProductTag> tags = _productTagMgr.Query(new ProductTag { tag_status = 1 }); if (tags != null) { uint pid = 0; string productID = string.Empty; if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { if (uint.TryParse(Request.Form["ProductId"].ToString(), out pid)) { pid = uint.Parse(Request.Form["ProductId"].ToString()); } else { productID = Request.Form["ProductId"].ToString(); } if (pid != 0) { _productTagSetMgr = new ProductTagSetMgr(connectionString); List<ProductTagSet> tagSets = _productTagSetMgr.Query(new ProductTagSet { product_id = pid }); foreach (var item in tags) { if (tagSets.Exists(m => m.tag_id == item.tag_id)) { strJson.AppendFormat("<img src='{1}' style='margin-right:5px' /></label>", item.tag_id, imgServerPath + tagPath + GetDetailFolder(item.tag_filename) + item.tag_filename); } } } else if (!string.IsNullOrEmpty(productID)) { _productTagSetTempMgr = new ProductTagSetTempMgr(connectionString); ProductTagSetTemp ptstQuery = new ProductTagSetTemp(); ptstQuery.product_id = productID; ptstQuery.Writer_Id = Convert.ToInt32((Session["vendor"] as BLL.gigade.Model.Vendor).vendor_id); List<ProductTagSetTemp> tagTempSets = _productTagSetTempMgr.QueryVendorTagSet(ptstQuery); foreach (var item in tags) { if (tagTempSets.Exists(m => m.tag_id == item.tag_id)) { strJson.AppendFormat("<img src='{1}' style='margin-right:5px' /></label>", item.tag_id, imgServerPath + tagPath + GetDetailFolder(item.tag_filename) + item.tag_filename); } } } json = strJson.ToString(); if (string.IsNullOrEmpty(json)) { json = "暫無圖片"; } } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetProTag() { string json = string.Empty; try { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; StringBuilder strJson = new StringBuilder(""); _productTagMgr = new ProductTagMgr(connectionString); //查找出全部標籤 List<ProductTag> tags = _productTagMgr.Query(new ProductTag { tag_status = 1 }); if (tags != null) { _productTagSetTempMgr = new ProductTagSetTempMgr(connectionString); //查找出此ProductId的 ProductTagSetTemp ptstQuery = new ProductTagSetTemp(); if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { string productId = Request.Form["ProductId"]; ptstQuery.product_id = productId; } //if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) //{ // ptstQuery.product_id = Request.Form["OldProductId"].ToString(); //} ptstQuery.Writer_Id = (int)vendorModel.vendor_id; ptstQuery.Combo_Type = COMBO_TYPE; List<ProductTagSetTemp> tagSets = _productTagSetTempMgr.QueryVendorTagSet(ptstQuery); foreach (var item in tags) { strJson.AppendFormat("<input type='checkbox' id='tag_{0}' name='tags' value='{0}' ", item.tag_id); if (tagSets.Exists(m => m.tag_id == item.tag_id)) { strJson.Append("checked='true'"); } strJson.AppendFormat("/><label for='tag_{0}'><img src='{1}' style='margin-right:5px' /></label>", item.tag_id, imgServerPath + tagPath + GetDetailFolder(item.tag_filename) + item.tag_filename); } } json = strJson.ToString(); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }