public HttpResponseBase GetProNotice() { string json = string.Empty; try { StringBuilder strJson = new StringBuilder(); _productNoticeMgr = new ProductNoticeMgr(connectionString); List<ProductNotice> notices = _productNoticeMgr.Query(new ProductNotice { notice_status = 1 }); if (notices != null) { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { uint productId = uint.Parse(Request.Form["ProductId"]); _productNoticeSetMgr = new ProductNoticeSetMgr(connectionString); List<ProductNoticeSet> noticeSets = _productNoticeSetMgr.Query(new ProductNoticeSet { product_id = productId }); foreach (var item in notices) { strJson.AppendFormat("<input type='checkbox' id='notice_{0}' name='notices' value='{0}' ", item.notice_id); if (noticeSets.Exists(m => m.notice_id == item.notice_id)) { strJson.Append("checked='true'"); } strJson.AppendFormat("/><label for='notice_{0}'>{1}</label>", item.notice_id, item.notice_name); } } else { int writerId = (Session["caller"] as Caller).user_id; _productNoticeSetTempMgr = new ProductNoticeSetTempMgr(connectionString); _productTempMgr = new ProductTempMgr(connectionString); ProductNoticeSetTemp query = new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE }; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { query.product_id = Request.Form["OldProductId"]; } List<ProductNoticeSetTemp> noticeSetTemps = _productNoticeSetTempMgr.Query(query); ProductTemp proTemp = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE }); bool check = (proTemp != null && !string.IsNullOrEmpty(proTemp.Page_Content_2)) ? false : true; foreach (var item in notices) { strJson.AppendFormat("<input type='checkbox' id='notice_{0}' name='notices' value='{0}' ", item.notice_id); if (check || noticeSetTemps.Exists(m => m.notice_id == item.notice_id)) { strJson.Append("checked='true'"); } strJson.AppendFormat("/><label for='notice_{0}'>{1}</label>", item.notice_id, item.notice_name); } } 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 GetProNotice() { string json = string.Empty; try { StringBuilder strJson = new StringBuilder(); _productNoticeMgr = new ProductNoticeMgr(connectionString); List<ProductNotice> notices = _productNoticeMgr.Query(new ProductNotice { notice_status = 1 }); if (notices != null) { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { uint productId = uint.Parse(Request.Form["ProductId"]); _productNoticeSetMgr = new ProductNoticeSetMgr(connectionString); List<ProductNoticeSet> noticeSets = _productNoticeSetMgr.Query(new ProductNoticeSet { product_id = productId }); foreach (var item in notices) { if (noticeSets.Exists(m => m.notice_id == item.notice_id)) { strJson.AppendFormat("{0}", item.notice_name); } } } 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 GetProNotice() { string json = string.Empty; try { StringBuilder strJson = new StringBuilder(); _productNoticeMgr = new ProductNoticeMgr(connectionString); List<ProductNotice> notices = _productNoticeMgr.Query(new ProductNotice { notice_status = 1 }); if (notices != null) { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { uint pid = 0; string prodID = string.Empty; if (uint.TryParse(Request.Form["ProductId"].ToString(), out pid)) { pid = uint.Parse(Request.Form["ProductId"]); } else { prodID = Request.Form["ProductId"].ToString(); } if (pid != 0) { _productNoticeSetMgr = new ProductNoticeSetMgr(connectionString); List<ProductNoticeSet> noticeSets = _productNoticeSetMgr.Query(new ProductNoticeSet { product_id = pid }); foreach (var item in notices) { if (noticeSets.Exists(m => m.notice_id == item.notice_id)) { strJson.AppendFormat("{0}", item.notice_name); } } } else if (!string.IsNullOrEmpty(prodID)) { _productNoticeSetTempMgr = new ProductNoticeSetTempMgr(connectionString); ProductNoticeSetTemp queryProductNotice = new ProductNoticeSetTemp(); queryProductNotice.product_id = prodID; queryProductNotice.Writer_Id = Convert.ToInt32((Session["vendor"] as BLL.gigade.Model.Vendor).vendor_id); List<ProductNoticeSetTemp> noticeTempSets = _productNoticeSetTempMgr.QueryVendorProdNotice(queryProductNotice); foreach (var item in notices) { if (noticeTempSets.Exists(m => m.notice_id == item.notice_id)) { strJson.AppendFormat("{0}", item.notice_name); } } } } 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 GetProNotice() { string json = string.Empty; try { //獲取當前登入的供應商 BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; StringBuilder strJson = new StringBuilder(""); _productNoticeMgr = new ProductNoticeMgr(connectionString); List<ProductNotice> notices = _productNoticeMgr.Query(new ProductNotice { notice_status = 1 }); if (notices != null) { _productNoticeSetTempMgr = new ProductNoticeSetTempMgr(connectionString); ProductNoticeSetTemp queryProductNotice = new ProductNoticeSetTemp(); if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { string productId = Request.Form["ProductId"].ToString(); queryProductNotice.product_id = productId; } //if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) //{ // queryProductNotice.product_id = Request.Form["OldProductId"].ToString(); //} queryProductNotice.Writer_Id = (int)vendorModel.vendor_id; queryProductNotice.Combo_Type = COMBO_TYPE; List<ProductNoticeSetTemp> noticeSets = _productNoticeSetTempMgr.QueryVendorProdNotice(queryProductNotice); _productTempMgr = new ProductTempMgr(connectionString); ProductTemp proTemp = _productTempMgr.GetProTempByVendor(new ProductTemp { Writer_Id = (int)vendorModel.vendor_id, Combo_Type = COMBO_TYPE, Product_Id = queryProductNotice.product_id, Create_Channel = 2 }).FirstOrDefault(); bool check = (proTemp != null && !string.IsNullOrEmpty(proTemp.Page_Content_2)) ? false : true; foreach (var item in notices) { strJson.AppendFormat("<input type='checkbox' id='notice_{0}' name='notices' value='{0}' ", item.notice_id); if (check || noticeSets.Exists(m => m.notice_id == item.notice_id)) { strJson.Append("checked='true'"); } strJson.AppendFormat("/><label for='notice_{0}'>{1}</label>", item.notice_id, item.notice_name); } } 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; }