public HttpResponseBase ISVendorProduct() { string resultStr = "{success:false}"; try { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; int writer_id = Convert.ToInt32(vendorModel.vendor_id); VendorBrand vb = new VendorBrand(); vb.Vendor_Id = vendorModel.vendor_id;//todo:獲取該供應商下的所有品牌,暫時寫死 vbMgr = new VendorBrandMgr(connectionString); List<VendorBrand> brandList = vbMgr.GetProductBrandList(vb); uint brand = 0; if (!string.IsNullOrEmpty(Request.Form["ProductId"]))//編輯數據 { uint product_id = 0; if (uint.TryParse(Request.Form["ProductId"], out product_id)) //正式表數據 { _productMgr = new ProductMgr(connectionString); Product p = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); if (p != null) { brand = p.Brand_Id; } } else {//臨時表數據 _productTempMgr = new ProductTempMgr(connectionString); ProductTemp pTemp = _productTempMgr.GetProTempByVendor(new ProductTemp { Product_Id = Request.Form["ProductId"], Writer_Id = writer_id, Create_Channel = 2, Temp_Status = 12 }).FirstOrDefault(); if (pTemp != null) { brand = pTemp.Brand_Id; } } foreach (VendorBrand item in brandList) { if (brand == item.Brand_Id) { resultStr = "{success:true}"; break; } } } } 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); resultStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
/// <summary> /// 獲得品牌 /// </summary> /// <returns></returns> public HttpResponseBase GetVendorBrand() { VendorBrand vb = new VendorBrand(); List<VendorBrand> store = new List<VendorBrand>(); string json = string.Empty; try { vbMgr = new VendorBrandMgr(connectionString); if (!string.IsNullOrEmpty(Request.Params["vendor_id"])) { vb.Vendor_Id = uint.Parse(Request.Params["vendor_id"]); } store = vbMgr.GetProductBrandList(vb); json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented) + "}";//返回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); json = "{success:false,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase BrandStore() { string json = string.Empty; try { VendorBrandQuery query = new VendorBrandQuery(); List<VendorBrand> store = new List<VendorBrand>(); query.Brand_Status = 1; _vendorBrand = new BLL.gigade.Mgr.VendorBrandMgr(mySqlConnectionString); store = _vendorBrand.GetProductBrandList(query); json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented) + "}"; } 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); json = "{success:false,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }