public HttpResponseBase UpdateTrial()
        {
            string jsonStr = String.Empty;
            int isTranInt = 0;
            try
            {
                string trial_id = Request.Params["trial_id"].ToString();
                string isEdit = Request.Params["isEdit"].ToString();
                _promotionsAmountTrialMgr = new PromotionsAmountTrialMgr(mySqlConnectionString);
                _ucMgr = new UserConditionMgr(mySqlConnectionString);
                PromotionsAmountTrialQuery model = new PromotionsAmountTrialQuery();
                PromotionsAmountTrialQuery OldModel = new PromotionsAmountTrialQuery();


                #region 第一面板數據
                if (!string.IsNullOrEmpty(Request.Params["trial_id"]))
                {
                    model.id = Convert.ToInt32(Request.Params["trial_id"]);
                    OldModel = _promotionsAmountTrialMgr.Select(model.id);
                }
                if (!string.IsNullOrEmpty(Request.Params["name"]))
                {//活動名稱
                    model.name = Request.Params["name"].ToString();
                }


                int event_type = 0;
                if (!string.IsNullOrEmpty(Request.Params["event_type"]))
                {
                    if (int.TryParse(Request.Params["event_type"], out event_type))
                    {
                        if (event_type == 1)
                        {
                            model.event_type = "T1";
                        }
                        else if (event_type == 2)
                        {
                            model.event_type = "T2";
                        }
                    }
                }
                model.event_id = CommonFunction.GetEventId(model.event_type, model.id.ToString());

                int paper_id = 0;
                if (int.TryParse(Request.Params["paper_id"].ToString(), out paper_id))
                {
                    model.paper_id = paper_id;
                }
                if (!string.IsNullOrEmpty(Request.Params["event_url"].ToString()))
                {
                    model.url = Request.Params["event_url"];
                }
                if (!string.IsNullOrEmpty(Request.Params["start_date"]))
                {
                    model.start_date = Convert.ToDateTime(Request.Params["start_date"].ToString());
                }

                if (!string.IsNullOrEmpty(Request.Params["end_date"]))
                {
                    model.end_date = Convert.ToDateTime(Request.Params["end_date"].ToString());
                }
                //活動描述
                if (!string.IsNullOrEmpty(Request.Params["event_desc"]))
                {
                    model.event_desc = Request.Params["event_desc"].ToString();
                }

                #endregion
                #region 第二面板數據
                if (!string.IsNullOrEmpty(Request.Params["group_id"].ToString()))
                {
                    if (int.TryParse(Request.Params["group_id"].ToString(), out isTranInt))
                    {
                        model.group_id = Convert.ToInt32(Request.Params["group_id"].ToString());
                    }
                    else
                    {
                        model.group_id = OldModel.group_id;
                    }
                    //當編輯活動時將會員條件改為會員群組則刪除原有的會員條件
                    if (OldModel.condition_id != 0)
                    {
                        UserCondition uc = new UserCondition();
                        uc.condition_id = OldModel.condition_id;

                        if (_ucMgr.Delete(uc) > 0)
                        {
                            jsonStr = "{success:true}";
                            model.condition_id = 0;
                        }
                        else
                        {
                            jsonStr = "{success:false,msg:'user_condition刪除出錯!'}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr.ToString());
                            this.Response.End();
                            return this.Response;
                        }
                    }
                    //當活動設置完會員條件又改為會員群組時刪除設置的會員條件
                    if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0")
                    {
                        UserCondition uc = new UserCondition();
                        uc.condition_id = Convert.ToInt32(Request.Params["condition_id"]);
                        if (_ucMgr.Delete(uc) > 0)
                        {
                            jsonStr = "{success:true}";
                            model.condition_id = 0;
                        }
                        else
                        {
                            jsonStr = "{success:false,msg:'user_condition刪除出錯!'}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr.ToString());
                            this.Response.End();
                            return this.Response;
                        }
                    }
                }
                else if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0")
                {
                    model.condition_id = Convert.ToInt32(Request.Params["condition_id"].ToString());
                    model.group_id = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["count_by"]))
                {
                    model.count_by = Convert.ToInt32(Request.Params["count_by"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["numLimit"]))
                {
                    model.num_limit = Convert.ToInt32(Request.Params["numLimit"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["gift_mundane"]))
                {
                    model.gift_mundane = Convert.ToInt32(Request.Params["gift_mundane"].ToString());
                }

                if (!string.IsNullOrEmpty(Request.Params["IsRepeat"]))
                {
                    model.repeat = Convert.ToInt32(Request.Params["IsRepeat"].ToString()) == 1 ? true : false;
                }

                if (!string.IsNullOrEmpty(Request.Params["freight_type"].ToString()))
                {
                    if (int.TryParse(Request.Params["freight_type"].ToString(), out isTranInt))
                    {
                        model.freight_type = Convert.ToInt32(Request.Params["freight_type"].ToString());
                    }
                    else
                    {
                        model.freight_type = OldModel.freight_type;
                    }
                }

                if (!string.IsNullOrEmpty(Request.Params["device_name"]))
                {
                    model.device = Convert.ToInt32(Request.Params["device_name"].ToString());
                }

                if (!string.IsNullOrEmpty(Request.Params["site"].ToString()))//修改時傳的值為siteName
                {

                    Regex reg = new Regex("^([0-9]+,)*([0-9]+)$");
                    if (reg.IsMatch(Request.Params["site"].ToString()))
                    {
                        model.site = Request.Params["site"].ToString();// 將站台改為多選 edit by shuangshuang0420j 20140925 10:08
                    }
                    else
                    {
                        model.site = OldModel.site;
                    }
                }

                #endregion

                #region 第三面板數據

                if (!string.IsNullOrEmpty(Request.Params["product_id"]))
                {
                    model.product_id = Convert.ToInt32(Request.Params["product_id"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["product_name"]))
                {
                    model.product_name = Request.Params["product_name"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["sale_product_id"]))
                {
                    model.sale_productid = Convert.ToInt32(Request.Params["sale_product_id"].ToString());
                }
                model.category_id = Convert.ToUInt32(Request.Params["category_id"].ToString());
                model.brand_id = Convert.ToInt32(Request.Params["brand_id"].ToString());
                model.market_price = Convert.ToInt32(Request.Params["market_price"].ToString());
                model.show_number = Convert.ToInt32(Request.Params["show_number"].ToString());
                model.apply_limit = Convert.ToInt32(Request.Params["apply_limit"].ToString());
                model.apply_sum = Convert.ToInt32(Request.Params["apply_sum"].ToString());

                #region 上傳圖片
                try
                {
                    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 + promoPath;//圖片存儲地址


                    string fileName = string.Empty;//當前文件名
                    string fileExtention = string.Empty;//當前文件的擴展名
                    bool result = false;
                    string NewFileName = string.Empty;//編譯后的文件名
                    string oldFile = "";
                    string ServerPath = string.Empty;
                    string ErrorMsg = string.Empty;


                    //判斷目錄是否存在,不存在則創建
                    CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), promoPath.Substring(1, promoPath.Length - 2).Split('/'));

                    FileManagement fileLoad = new FileManagement();

                    for (int iFile = 0; iFile < Request.Files.Count; iFile++)
                    {
                        if (iFile == 0 && !string.IsNullOrEmpty(Request.Params["prod_file"]))
                        {
                            model.product_img = Request.Params["prod_file"].ToString().Substring(Request.Params["prod_file"].ToString().LastIndexOf("/") + 1);
                        }
                        else
                        {

                            HttpPostedFileBase file = Request.Files[iFile];

                            Random rand = new Random();
                            int newRand = rand.Next(1000, 9999);

                            fileName = Path.GetFileName(file.FileName);
                            if (fileName != "")
                            {

                                switch (iFile)
                                {
                                    case 1:
                                        oldFile = OldModel.event_img_small;
                                        break;
                                    case 2:
                                        oldFile = OldModel.event_img;
                                        break;
                                    case 0:
                                        oldFile = OldModel.product_img;
                                        break;
                                }

                                FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                List<string> tem = ftp.GetFileList();
                                if (tem.Contains(oldFile))
                                {
                                    FTP ftps = new FTP(localPromoPath + oldFile, ftpuser, ftppwd);
                                    ftps.DeleteFile(localPromoPath + oldFile);//刪除ftp:71.159上的舊圖片
                                    DeletePicFile(ServerPath + oldFile);//刪除本地圖片
                                }

                                fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                                NewFileName = model.event_id + newRand + fileExtention;

                                fileName = NewFileName;
                                NewFileName = localPromoPath + NewFileName;//絕對路徑
                                ServerPath = Server.MapPath(imgLocalServerPath + promoPath);
                                try
                                {
                                    //上傳
                                    result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                    if (result)//上傳成功
                                    {
                                        switch (iFile)
                                        {
                                            case 1:
                                                model.event_img_small = fileName;
                                                break;
                                            case 2:
                                                model.event_img = fileName;
                                                break;
                                            case 0:
                                                model.product_img = fileName;
                                                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);
                                }
                            }
                            else
                            {
                                switch (iFile)
                                {
                                    case 1:
                                        model.event_img_small = OldModel.event_img_small;
                                        break;
                                    case 2:
                                        model.event_img = OldModel.event_img;
                                        break;
                                    case 0:
                                        model.product_img = OldModel.product_img;
                                        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);
                }

                #endregion

                #endregion


                #region     更新表結構
                if (string.IsNullOrEmpty(isEdit))//新增數據
                {
                    model.active = 0;//默認不啟用
                    model.status = 1;//第二步保存為有效數據
                    model.kuser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    model.created = DateTime.Now;
                    model.muser = model.kuser;
                    model.modified = model.created;
                    if (_promotionsAmountTrialMgr.Update(model) > 0)
                    {

                        jsonStr = "{success:true,msg:0}";//返回json數據
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:0}";//返回json數據
                    }
                }
                else//編輯數據
                {
                    model.active = OldModel.active;
                    model.status = OldModel.status;
                    model.kuser = OldModel.kuser;
                    model.created = OldModel.created;
                    model.muser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    model.modified = DateTime.Now;
                    if (_promotionsAmountTrialMgr.Update(model) > 0)
                    {

                        jsonStr = "{success:true,msg:0}";//返回json數據
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:0}";//返回json數據
                    }
                }
                #endregion
            }
            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,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase SecondSaveFare()
        {
            string jsonStr = String.Empty;
            int stringTranInt = 0;//使用tryParse使string轉換為int時保存轉換的值
            try
            {
                string rowID = Request.Params["rowid"].ToString() ?? "0";
                string isEdit = Request.Params["isEdit"].ToString() ?? "";
                _promoAmountFareMgr = new PromotionsAmountFareMgr(mySqlConnectionString);
                PromotionsAmountFareQuery model = new PromotionsAmountFareQuery();

                PromotionsAmountFareQuery OldModel = _promoAmountFareMgr.Select(Convert.ToInt32(rowID));

                #region 獲取數據
                if (!string.IsNullOrEmpty(Request.Params["rowid"]))
                {
                    model.id = Convert.ToInt32(Request.Params["rowid"]);
                }
                else
                {
                    model.id = 0;
                }
                model.category_id = OldModel.category_id;
                if (!string.IsNullOrEmpty(Request.Params["name"]))
                {
                    model.name = Request.Params["name"].ToString();
                }
                else
                {
                    model.name = OldModel.name;
                }
                if (!string.IsNullOrEmpty(Request.Params["desc"]))
                {
                    model.event_desc = Request.Params["desc"].ToString();
                }

                else
                {
                    model.event_desc = OldModel.event_desc;
                }
                if (!string.IsNullOrEmpty(Request.Params["vendor_coverage"]))
                {
                    model.vendor_coverage = Convert.ToInt32(Request.Params["vendor_coverage"].ToString());
                }
                else
                {
                    model.vendor_coverage = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["sclass_id"]))
                {
                    if (int.TryParse(Request.Params["sclass_id"].ToString(), out stringTranInt))
                    {
                        model.class_id = Convert.ToInt32(Request.Params["sclass_id"].ToString() == "" ? "0" : Request.Params["sclass_id"].ToString());
                    }
                    else
                    {
                        model.class_id = OldModel.class_id;
                    }
                }
                else
                {
                    model.class_id = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["sbrand_id"]))
                {
                    if (int.TryParse(Request.Params["sbrand_id"].ToString(), out stringTranInt))
                    {
                        model.brand_id = Convert.ToInt32(Request.Params["sbrand_id"].ToString() == "" ? "0" : Request.Params["sbrand_id"].ToString());

                    }
                    else
                    {
                        model.brand_id = OldModel.brand_id;
                    }
                }
                else
                {
                    model.brand_id = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["allClass"]))
                {
                    model.allClass = Convert.ToInt32(Request.Params["allClass"].ToString() == "1" ? "1" : "0");
                    if (1 == model.allClass)
                    {
                        model.product_id = 999999;
                    }

                }
                else
                {
                    model.allClass = 0;
                }

                if (!string.IsNullOrEmpty(Request.Params["event_type"]))
                {
                    //獲取event_type和category_father_id
                    _parasrcMgr = new ParameterMgr(mySqlConnectionString);
                    List<Parametersrc> fatherIdResult = _parasrcMgr.QueryUsed(new Parametersrc { ParameterType = "event_type", parameterName = Request.Params["event_type"].ToString(), Used = 1 });
                    if (fatherIdResult.Count == 1)
                    {
                        model.event_type = fatherIdResult[0].ParameterCode;
                        model.category_father_id = Convert.ToUInt32(fatherIdResult[0].ParameterProperty);
                    }
                }

                if (!string.IsNullOrEmpty(Request.Params["amount"]))
                {
                    model.amount = Convert.ToInt32(Request.Params["amount"].ToString());
                }
                else
                {
                    model.amount = OldModel.amount;
                }
                if (!string.IsNullOrEmpty(Request.Params["quantity"]))
                {
                    model.quantity = Convert.ToInt32(Request.Params["quantity"].ToString());
                }
                else
                {
                    model.quantity = OldModel.quantity;
                }
                if (!string.IsNullOrEmpty(Request.Params["fare_percent"]))
                {
                    model.fare_percent = Convert.ToInt32(Request.Params["fare_percent"].ToString());
                }
                else
                {
                    model.fare_percent = OldModel.fare_percent;
                }
                if (!string.IsNullOrEmpty(Request.Params["off_times"]))
                {
                    model.off_times = Convert.ToInt32(Request.Params["off_times"].ToString());
                }
                else
                {
                    model.off_times = OldModel.off_times;
                }
                if (model.id != 0)
                {
                    model.event_id = BLL.gigade.Common.CommonFunction.GetEventId(model.event_type, model.id.ToString());
                }

                if (Request.Params["group_id"].ToString() != "")
                {//會員群組不為空時,要清空已存在的會員條件
                    if (!string.IsNullOrEmpty(Request.Params["group_id"].ToString()) && int.TryParse(Request.Params["group_id"].ToString(), out stringTranInt))//group_id
                    {
                        model.group_id = Convert.ToInt32(Request.Params["group_id"].ToString());
                    }
                    else
                    {
                        model.group_id = OldModel.group_id;
                    }
                    if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0")
                    {
                        UserCondition uc = new UserCondition();
                        uc.condition_id = Convert.ToInt32(Request.Params["condition_id"]);
                        _ucMgr = new UserConditionMgr(mySqlConnectionString);
                        if (_ucMgr.Delete(uc) > 0)
                        {
                            jsonStr = "{success:true}";
                            model.condition_id = 0;
                        }
                        else
                        {
                            jsonStr = "{success:false,msg:3}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr.ToString());
                            this.Response.End();
                            return this.Response;
                        }
                    }

                }
                else if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0")
                {
                    try//condition_id
                    {
                        model.condition_id = Convert.ToInt32(Request.Params["condition_id"].ToString());
                    }
                    catch (Exception)
                    {
                        model.condition_id = OldModel.condition_id;
                    }
                    model.group_id = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["type"]) && int.TryParse(Request.Params["type"].ToString(), out stringTranInt))
                {
                    model.type = Convert.ToInt32(Request.Params["type"].ToString());
                }
                else
                {
                    model.type = OldModel.type;
                }
                if (!string.IsNullOrEmpty(Request.Params["deliver"].ToString()) && int.TryParse(Request.Params["deliver"].ToString(), out stringTranInt))
                {
                    model.delivery_store = Convert.ToInt32(Request.Params["deliver"].ToString());
                }
                else
                {
                    model.delivery_store = OldModel.delivery_store;
                }
                if (!string.IsNullOrEmpty(Request.Params["devicename"].ToString()))
                {
                    model.device = Convert.ToInt32(Request.Params["devicename"].ToString());
                }
                else
                {
                    model.device = OldModel.device;
                }
                if (!string.IsNullOrEmpty(Request.Params["payment"].ToString()))
                {
                    Regex reg = new Regex("^([0-9]+,)*[0-9]+$");
                    if (reg.IsMatch(Request.Params["payment"].ToString()))
                    {
                        model.payment_code = Request.Params["payment"].ToString();
                    }
                    else
                    {
                        model.payment_code = OldModel.payment_code;
                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["start_time"].ToString()))
                {
                    model.start = Convert.ToDateTime(Request.Params["start_time"].ToString());
                }
                else
                {
                    model.start = OldModel.start_time;
                }
                if (!string.IsNullOrEmpty(Request.Params["end_time"].ToString()))
                {
                    model.end = Convert.ToDateTime(Request.Params["end_time"].ToString());
                }
                else
                {
                    model.end = OldModel.end_time;
                }
                if (!string.IsNullOrEmpty(Request.Params["site"].ToString()))
                {
                    Regex reg = new Regex("^([0-9]+,)*[0-9]+$");
                    if (reg.IsMatch(Request.Params["site"].ToString()))
                    {
                        model.site = Request.Params["site"].ToString();
                    }
                    else
                    {
                        model.site = OldModel.site;
                    }
                }

                model.status = 1;
                if (!string.IsNullOrEmpty(Request.Params["url_by"].ToString()))
                {
                    model.url_by = Convert.ToInt32(Request.Params["url_by"].ToString());
                }
                else
                {
                    model.url_by = OldModel.url_by;
                }

                #endregion
                ////講圖片和鏈接保存至product_category中

                if (model.url_by == 1)
                {
                    #region 上傳圖片
                    try
                    {
                        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 + promoPath;//圖片存儲地址

                        Random rand = new Random();
                        int newRand = rand.Next(1000, 9999);//獲取隨機數重命名圖片


                        if (Request.Files.Count > 0)
                        {

                            HttpPostedFileBase file = Request.Files[0];
                            string fileName = string.Empty;//當前文件名

                            string fileExtention = string.Empty;//當前文件的擴展名

                            fileName = Path.GetFileName(file.FileName);
                            if (fileName != "")
                            {
                                // string returnName = imgServerPath;
                                bool result = false;
                                string NewFileName = string.Empty;

                                fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                                NewFileName = model.event_id + newRand + fileExtention;

                                string ServerPath = string.Empty;
                                //判斷目錄是否存在,不存在則創建
                                CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), promoPath.Substring(1, promoPath.Length - 2).Split('/'));
                                fileName = NewFileName;
                                NewFileName = localPromoPath + NewFileName;//絕對路徑
                                ServerPath = Server.MapPath(imgLocalServerPath + promoPath);
                                string ErrorMsg = string.Empty;
                                //上傳之前刪除已有的圖片
                                string oldFileName = OldModel.banner_image;
                                FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                List<string> tem = ftp.GetFileList();
                                if (tem.Contains(oldFileName))
                                {
                                    FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                    ftps.DeleteFile(localPromoPath + oldFileName);//刪除ftp:71.159上的舊圖片
                                    DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                }
                                FileManagement fileLoad = new FileManagement();
                                //上傳
                                result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                if (result)//上傳成功
                                {
                                    model.banner_image = fileName;
                                }

                            }
                            else
                            {
                                model.banner_image = OldModel.banner_image;
                            }

                        }
                    }
                    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,msg:0}";
                        model.banner_image = OldModel.banner_image;
                    }

                    #endregion
                    if (!string.IsNullOrEmpty(Request.Params["banner_url"].ToString()))
                    {
                        model.category_link_url = Request.Params["banner_url"].ToString();
                    }
                    else
                    {
                        model.category_link_url = OldModel.category_link_url;
                    }

                }
                else//url_by=0
                {
                    //刪除上傳的圖片
                    string oldFileName = OldModel.banner_image;
                    FTP ftp = new FTP(imgLocalPath + promoPath, ftpuser, ftppwd);
                    List<string> tem = ftp.GetFileList();
                    if (tem.Contains(oldFileName))
                    {
                        FTP ftps = new FTP(imgLocalPath + promoPath + oldFileName, ftpuser, ftppwd);
                        ftps.DeleteFile(imgLocalPath + promoPath + oldFileName);//刪除ftp:71.159上的舊圖片
                        DeletePicFile(Server.MapPath(imgLocalServerPath + promoPath) + oldFileName);//刪除本地圖片
                    }
                    model.category_link_url = "";
                    model.banner_image = "";
                }

                _promoAmountFareMgr = new PromotionsAmountFareMgr(mySqlConnectionString);
                if (string.IsNullOrEmpty(isEdit))
                {
                    model.kuser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    model.created = DateTime.Now;
                    model.muser = model.kuser;
                    model.modified = model.created;
                    if (_promoAmountFareMgr.ReSave(model) > 0)
                    {
                        jsonStr = "{success:true,msg:0}";//返回json數據
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:0}";//返回json數據
                    }
                }
                else
                {
                    model.kuser = OldModel.kuser;
                    model.created = OldModel.created;
                    model.muser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    model.modified = DateTime.Now;
                    if (_promoAmountFareMgr.Update(model, OldModel.event_id) > 0)
                    {
                        jsonStr = "{success:true,msg:0}";//返回json數據
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:0}";//返回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);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }