public HttpResponseBase AddorEdit()
        {
            string json = string.Empty;
            string errorInfo = string.Empty;
            uint brand_id = 0;
            bool result = false;
            try
            {
                _promotionBannerMgr = new PromotionBannerMgr(mySqlConnectionString);
                int i = 0;
                PromotionBannerQuery query = new PromotionBannerQuery();
                PromotionBannerQuery oldquery = new PromotionBannerQuery();
                if (!string.IsNullOrEmpty(Request.Params["pb_id"]))
                {
                    oldquery.pb_id = Convert.ToInt32(Request.Params["pb_id"]);
                    List<PromotionBannerQuery> oldModel = _promotionBannerMgr.GetModelById(oldquery.pb_id);
                    if (oldModel != null)
                    {
                        query.pb_image = oldModel[0].pb_image;
                    }
                }
                #region 上傳圖片
                string path = Server.MapPath(xmlPath);
                SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MinValue");
                SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
                SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
                SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
                //擴展名、最小值、最大值
                string extention = extention_config.Value == "" ? extention_config.DefaultValue : extention_config.Value;
                string minValue = minValue_config.Value == "" ? minValue_config.DefaultValue : minValue_config.Value;
                string maxValue = maxValue_config.Value == "" ? maxValue_config.DefaultValue : maxValue_config.Value;
                string localPromoPath = imgLocalPath + brandPath;//圖片存儲地址
                FileManagement fileLoad = new FileManagement();
                for (int j = 0; j < Request.Files.Count; j++)
                {
                    string fileName = string.Empty;//當前文件名
                    HttpPostedFileBase file = Request.Files[j];
                    fileName = Path.GetFileName(file.FileName);
                    if (string.IsNullOrEmpty(fileName))
                    {
                        continue;
                    }

                    fileLoad = new FileManagement();
                    string oldFileName = string.Empty;  //舊文件名
                    string fileExtention = string.Empty;//當前文件的擴展名                 
                    string NewFileName = string.Empty;
                    string ServerPath = string.Empty;
                    string newRand = string.Empty;
                    string ErrorMsg = string.Empty;

                    newRand = hash.Md5Encrypt(fileLoad.NewFileName(fileName) + DateTime.Now.ToString(), "32");
                    fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                    NewFileName = newRand + fileExtention;

                    string folder1 = NewFileName.Substring(0, 2) + "/"; //圖片名前兩碼
                    string folder2 = NewFileName.Substring(2, 2) + "/"; //圖片名第三四碼

                    FTP f_cf = new FTP();
                    localPromoPath = imgLocalPath + brandPath + folder1 + folder2;  //圖片存儲地址
                    string s = localPromoPath.Substring(0, localPromoPath.Length - (brandPath + folder1 + folder2).Length + 1);
                    f_cf.MakeMultiDirectory(s, (brandPath + folder1 + folder2).Substring(1, (brandPath + folder1 + folder2).Length - 2).Split('/'), ftpuser, ftppwd);
                    ServerPath = Server.MapPath(imgLocalServerPath + brandPath + folder1 + folder2);
                    fileName = NewFileName;
                    NewFileName = localPromoPath + NewFileName;//絕對路徑
                    Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件

                    //上傳
                    result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                    if (result)//上傳成功
                    {
                        query.pb_image = fileName;
                    }
                    else
                    {
                        errorInfo += ErrorMsg;
                    }
                }
                #endregion               
                if (!string.IsNullOrEmpty(Request.Params["image_link"]))
                {
                    query.pb_image_link = Request.Params["image_link"];
                }
                if (!string.IsNullOrEmpty(Request.Params["begin_time"]))
                {
                    query.pb_startdate = Convert.ToDateTime(Request.Params["begin_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["end_time"]))
                {
                    query.pb_enddate = Convert.ToDateTime(Request.Params["end_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["vb_ids"]))
                {
                    query.brandIDS = Request.Params["vb_ids"].Substring(0, Request.Params["vb_ids"].LastIndexOf(','));
                }
                if (!string.IsNullOrEmpty(Request.Params["multi"]))
                {
                    query.multi = Convert.ToInt32(Request.Params["multi"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["pb_id"]))
                {
                    //編輯
                    query.pb_id = Convert.ToInt32(Request.Params["pb_id"]);
                    query.pb_muser = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id);
                    result = _promotionBannerMgr.UpdateImageInfo(query, out brand_id);
                    if (result && string.IsNullOrEmpty(errorInfo))
                    {
                        json = "{success:true}"; 
                    }
                    else if (result == false && brand_id != 0)
                    {
                        json = "{success:false,msg:\"" + brand_id + "\"}";//brand_id重複
                    }

                    else if (result && !string.IsNullOrEmpty(errorInfo))
                    {
                        json = "{success:true,msg:\"數據保存成功<br/>但圖片保存失敗 <br/>" + errorInfo + "\"}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                }
                else
                {
                    //新增
                    query.pb_kuser = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id);
                    query.pb_muser = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id);
                    result = _promotionBannerMgr.AddImageInfo(query, out brand_id);
                    if (result && string.IsNullOrEmpty(errorInfo))
                    {
                        json = "{success:true}";
                    }
                    else if (result == false && brand_id != 0)
                    {
                        json = "{success:false,msg:\"" + brand_id + "\"}";//brand_id重複
                    }
                    else if (result && !string.IsNullOrEmpty(errorInfo))
                    {
                        json = "{success:true,msg:\"數據保存成功<br/>但圖片保存失敗 <br/>" + errorInfo + "\"}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                }

            }
            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}";
            }


            this.Response.Clear();
            this.Response.Write(json.ToString());
            this.Response.End();
            return this.Response;
        }