/// <summary>
        /// 新增或修改供應商品牌信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase UpdVendorBrand()
        {
            List<VendorBrandSetQuery> stores = new List<VendorBrandSetQuery>();
            query = new VendorBrandSetQuery();
            VendorBrandSetQuery oldquery = new VendorBrandSetQuery();
            _IvendorBrandSet = new VendorBrandSetMgr(connectionString);
            _productMgr = new ProductMgr(connectionString);
            string json = string.Empty;
            string errorInfo = string.Empty;

            try
            {
                #region 獲取數據
                query.Brand_Id = UInt32.Parse(Request.Params["Brand_Id"]);
                oldquery = _IvendorBrandSet.GetModelById(Int32.Parse(Request.Params["Brand_Id"]));
                try
                {
                    query.Brand_Name = Request.Params["brandName"].ToString();
                }
                catch (Exception)
                {
                    query.Brand_Name = oldquery.Brand_Name;
                }
                try
                {
                    query.vendor_id = uint.Parse(Request.Params["vendorid"].ToString());
                }
                catch (Exception)
                {
                    query.vendor_id = oldquery.vendor_id;
                }
                try
                {
                    query.Brand_Sort = uint.Parse(Request.Params["brandsort"].ToString());
                }
                catch (Exception)
                {
                    query.Brand_Sort = oldquery.Brand_Sort;
                }
                try
                {
                    query.Brand_Status = uint.Parse(Request.Params["brandstatus"].ToString());
                }
                catch (Exception)
                {
                    query.Brand_Status = oldquery.Brand_Status;
                }
                try
                {
                    query.Image_Status = uint.Parse(Request.Params["imagestatus"].ToString());
                }
                catch (Exception)
                {
                    query.Image_Status = oldquery.Image_Status;
                }
                try
                {
                    query.Image_Link_Mode = uint.Parse(Request.Params["imagelinkmode"].ToString());
                }
                catch (Exception)
                {
                    query.Image_Link_Mode = oldquery.Image_Link_Mode;
                }
                try
                {
                    query.Image_Link_Url = Request.Params["imagelinkurl"].ToString();
                }
                catch (Exception)
                {
                    query.Image_Link_Url = oldquery.Image_Link_Url;
                }
                try
                {
                    query.Resume_Image_Link = Request.Params["resumeimagelink"].ToString();
                }
                catch (Exception)
                {
                    query.Resume_Image_Link = oldquery.Resume_Image_Link;
                }
                try
                {
                    query.Media_Report_Link_Url = Request.Params["mediareportlinkurl"].ToString();
                }
                catch (Exception)
                {
                    query.Media_Report_Link_Url = oldquery.Media_Report_Link_Url;
                }
                try
                {
                    query.Brand_Msg = Request.Params["brandmsg"].ToString();
                }
                catch (Exception)
                {
                    query.Brand_Msg = oldquery.Brand_Msg;
                }
                long start = CommonFunction.GetPHPTime(Request.Params["begin_time"].ToString());
                long end = CommonFunction.GetPHPTime(Request.Params["end_time"].ToString());
                try
                {
                    query.Brand_Msg_Start_Time = uint.Parse(start.ToString());
                }
                catch (Exception)
                {
                    query.Brand_Msg_Start_Time = oldquery.Brand_Msg_Start_Time;
                }
                try
                {
                    query.Brand_Msg_End_Time = uint.Parse(end.ToString());
                }
                catch (Exception)
                {
                    query.Brand_Msg_End_Time = oldquery.Brand_Msg_End_Time;
                }
                try
                {
                    query.Brand_Createdate = uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString());
                }
                catch (Exception)
                {
                    query.Brand_Createdate = oldquery.Brand_Createdate;
                }
                try
                {
                    query.classIds = Request["shopclass"].ToString();
                }
                catch (Exception)
                {
                    query.classIds = oldquery.classIds;
                }
                query.Brand_Ipfrom = Request.UserHostAddress;
                try
                {
                    query.Cucumber_Brand = uint.Parse(Request.Params["cucumberbrand"].ToString());
                }
                catch
                {
                    query.Cucumber_Brand = oldquery.Cucumber_Brand;
                }
                try
                {
                    query.Image_Name = Request.Params["imagename"].ToString();
                }
                catch (Exception)
                {
                    query.Image_Name = oldquery.Image_Name;
                }
                try
                {
                    query.Promotion_Banner_Image_Link = Request.Params["promotionbannerimagelink"].ToString();
                }
                catch (Exception)
                {
                    query.Promotion_Banner_Image_Link = oldquery.Promotion_Banner_Image_Link;
                }
                try
                {
                    query.short_description = Request.Params["short_description"].ToString();
                }
                catch (Exception)
                {
                    query.short_description = oldquery.short_description;
                }
                query.Image_Name = oldquery.Image_Name;
                query.Resume_Image = oldquery.Resume_Image;
                query.Promotion_Banner_Image = oldquery.Promotion_Banner_Image;
                query.brand_logo = oldquery.brand_logo;
                #endregion
                #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 i = 0; i < Request.Files.Count; i++)
                {
                    string fileName = string.Empty;     //當前文件名
                    HttpPostedFileBase file = Request.Files[i];
                    fileName = Path.GetFileName(file.FileName);
                    if (string.IsNullOrEmpty(fileName))
                    {
                        continue;
                    }

                    fileLoad = new FileManagement();
                    string oldFileName = string.Empty;  //舊文件名
                    string fileExtention = string.Empty;//當前文件的擴展名
                    bool result = false;
                    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)//上傳成功
                    {
                        //圖片上傳成功后記錄新圖片名稱
                        switch (i)
                        {
                            case 0:
                                query.Image_Name = fileName;
                                break;
                            case 1:
                                query.Resume_Image = fileName;
                                break;
                            case 2:
                                query.Promotion_Banner_Image = fileName;
                                break;
                            case 3:
                                query.brand_logo = fileName;
                                break;
                            default:
                                break;
                        }

                        //圖片上傳成功后如果存在舊圖片則根據舊圖片名刪除舊圖片
                        if (!string.IsNullOrEmpty(oldFileName))
                        {
                            switch (i)
                            {
                                case 0:
                                    oldFileName = oldquery.Image_Name;
                                    break;
                                case 1:
                                    oldFileName = oldquery.Resume_Image;
                                    break;
                                case 2:
                                    oldFileName = oldquery.Promotion_Banner_Image;
                                    break;
                                case 3:
                                    oldFileName = oldquery.brand_logo;
                                    break;
                                default:
                                    break;
                            }
                            DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                        }
                    }
                    else
                    {
                        //圖片上傳失敗則圖片名稱為原有圖片名稱
                        switch (i)
                        {
                            case 0:
                                query.Image_Name = oldquery.Image_Name;//形象圖片
                                break;
                            case 1:
                                query.Resume_Image = oldquery.Resume_Image;//安心聲明圖片
                                break;
                            case 2:
                                query.Promotion_Banner_Image = oldquery.Promotion_Banner_Image;//促銷圖片
                                break;
                            case 3:
                                query.brand_logo = oldquery.brand_logo;//品牌logo
                                break;
                            default:
                                break;
                        }

                        errorInfo += "第" + (i + 1) + "張" + ErrorMsg + "<br/>";
                        //json = "{success:false,msg:\"第" + i + "張" + ErrorMsg + ",之後圖片未作處理" + "\"}";
                    }
                }
                #endregion
                //更新數據庫記錄
                if (_IvendorBrandSet.Update(query) > 0)
                {
                    if (_productMgr.UpdateSaleStatusByCondition(new Product { Vendor_Id = query.vendor_id, Brand_Id = query.Brand_Id }))
                    {
                        json = "{success:true,msg:\"數據保存成功!\"}";
                    }
                }
                if (!string.IsNullOrEmpty(errorInfo))
                {
                    json = "{success:true,msg:\"<div>數據保存成功!<br/>但<br/>" + errorInfo + "</div>\"}";
                }
            }
            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:\"保存失敗,請稍后再試!\"}";
                if (!string.IsNullOrEmpty(errorInfo))
                {
                    json = "{success:false,msg:\"<div>保存失敗,請稍后再試!<br/>" + errorInfo + "</div>\"}";
                }
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase VendorEdit(VendorQuery venQuery, List<TableChangeLog> list)
        {
            string jsonStr = "{success:false}";
            _vendorMgr = new VendorMgr(connectionString);
            _productMgr = new ProductMgr(connectionString);
            try
            {
                if (_vendorMgr.Update(venQuery, list) > 0)
                {
                    //變更商品可販售狀態
                    if (_productMgr.UpdateSaleStatusByCondition(new Product { Vendor_Id = venQuery.vendor_id }))
                    {
                        jsonStr = "{success:true}";
                    }
                }
            }
            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);
                jsonStr = "{success:false}";
            }

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