Ejemplo n.º 1
0
        public HttpResponseBase QueryProduct()
        {
            string json = "{success:true,data:[]}";
            try
            {
                Product product = null;
                Caller caller = Session["caller"] as Caller;
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
                {
                    uint product_id = 0;
                    if (uint.TryParse(Request.Form["ProductId"], out product_id))
                    {
                        _productMgr = new ProductMgr(connectionString);
                        product = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                        if (product.Product_alt == "")
                        {
                            product.Product_alt = product.Product_Name;
                        }//add by wwei0216w 2015/4/15 //如果商品說明為空則將商品名稱賦予product_alt
                    }
                }
                else//查詢temp表
                {
                    _productTempMgr = new ProductTempMgr(connectionString);
                    int writerId = caller.user_id;
                    ProductTemp query = new ProductTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE };
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        query.Product_Id = Request.Form["OldProductId"];
                    }
                    product = _productTempMgr.GetProTemp(query);
                    if (product.Product_alt == "")
                    {
                        product.Product_alt = product.Product_Name;
                    }//add by wwei0216w 2015/4/15 //如果商品說明為空則將商品名稱賦予product_alt
                }
                if (product != null)
                {
                    if (!string.IsNullOrEmpty(product.Product_Image))
                    {
                        product.Product_Image = imgServerPath + prodPath + GetDetailFolder(product.Product_Image) + product.Product_Image;
                    }
                    else
                    {
                        product.Product_Image = imgServerPath + "/product/nopic_150.jpg";
                    }
                    if (!string.IsNullOrEmpty(product.Mobile_Image)) //edit by wwei0216w 2015/3/18 添加關於手機說明圖的操作
                    {
                        prodPath = prodMobile640; //add by wwei0216w 2015/4/1 添加原因:手機圖片要放在640*640路徑下
                        product.Mobile_Image = imgServerPath + prodPath + GetDetailFolder(product.Mobile_Image) + product.Mobile_Image;
                    }
                    else
                    {
                        product.Mobile_Image = imgServerPath + "/product/nopic_150.jpg";
                        //product.Mobile_Image = imgServerPath + "/Content/img/click_up_img.jpg";
                    }
                    #region 庫存是否可編輯
                    //edit by xiangwang 0413w 2014/10/09
                    if (Request.UrlReferrer.AbsolutePath == "/Product/productStock")
                    {
                        IFgroupImplMgr _fgroupMgr = new FgroupMgr(connectionString);
                        product.IsEdit = _fgroupMgr.QueryStockPrerogative(caller.user_email, Server.MapPath(xmlPath));

                        //if (caller.user_email == "*****@*****.**" || caller.user_email == "*****@*****.**")
                        //{
                        //    product.IsEdit = true;
                        //}



                    }
                    #endregion
                }
                json = "{success:true,data:" + JsonConvert.SerializeObject(product) + "}";
            }
            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 = "[]";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }