コード例 #1
0
        /// <summary>
        /// 更新商品詳情文字
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase UpdateProductDetail()
        {
            Product p = new Product();
            Product old_p = new Product();
            string json = string.Empty;
            try
            {
                _productMgr = new ProductMgr(connectionString);
                if (!string.IsNullOrEmpty(Request.Params["product_id"]))
                {
                    p.Product_Id = uint.Parse(Request.Params["product_id"]);
                    old_p = _productMgr.Query(new Product { Product_Id = p.Product_Id }).FirstOrDefault();
                }
                p.product_detail_text = Request.Params["product_detail_text"];
                if (!string.IsNullOrEmpty(p.product_detail_text))
                {
                    p.product_detail_text = p.product_detail_text.Replace("\\", "\\\\");
                    p.product_detail_text = p.product_detail_text.Replace("\n", "<br/>");
                }
                Caller _caller = (Session["caller"] as Caller);
                if (old_p != null)
                {
                    if (old_p.detail_createdate == DateTime.MinValue)//新增
                    {
                        p.detail_createdate = DateTime.Now;
                        p.detail_created = _caller.user_id;
                        p.detail_update = p.detail_created;
                        p.detail_updatedate = p.detail_createdate;
                    }
                    else
                    {
                        p.detail_created = old_p.detail_created;
                        p.detail_createdate = old_p.detail_createdate;
                        p.detail_update = _caller.user_id;
                        p.detail_updatedate = DateTime.Now;
                    }
                }

                int i = _productMgr.UpdateProductDeatail(p);
                if (i > 0)
                {
                    json = "{success:true,msg:'修改成功!'}";//返回json數據
                }
                else
                {
                    json = "{success:false,msg:'修改失敗!'}";
                }
            }
            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,msg:'異常!'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }