public int Update(PromoAdditionalPrice m, PromoAdditionalPriceQuery mq)
 {
     int id = 0;
     StringBuilder sb = new StringBuilder();
     MySqlCommand mySqlCmd = new MySqlCommand();
     MySqlConnection mySqlConn = new MySqlConnection(connStr);
     try
     {
         if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
         {
             mySqlConn.Open();
         }
         mySqlCmd.Connection = mySqlConn;
         mySqlCmd.Transaction = mySqlConn.BeginTransaction();
         mySqlCmd.CommandType = System.Data.CommandType.Text;
         sb.Append(_prodPromoDao.DeleteProdProm(mq.event_id));
         sb.AppendFormat(@"UPDATE promo_additional_price SET condition_id='{1}',group_id='{2}',`start`='{3}',`end`='{4}',modified='{5}',deliver_type='{6}',device='{7}',muser='******',website='{9}',event_name='{10}',event_desc='{11}',fixed_price='{12}',buy_limit='{13}',url_by='{14}',discount='{15}',active={16} where id={0} ; ", m.id, m.condition_id, m.group_id, CommonFunction.DateTimeToString(m.starts), CommonFunction.DateTimeToString(m.end), CommonFunction.DateTimeToString(m.modified), m.deliver_type, m.device, m.muser, m.website, m.event_name, m.event_desc, m.fixed_price, m.buy_limit, m.url_by, m.discount, m.active);
         #region 操作修改ProductCategory
         ProductCategoryDao _categoryDao = new ProductCategoryDao(connStr);
         ProductCategory pcmodel = _categoryDao.GetModelById(Convert.ToUInt32(m.category_id));
         pcmodel.category_id = Convert.ToUInt32(m.category_id);
         pcmodel.banner_image = mq.banner_image;
         pcmodel.category_link_url = mq.category_link_url;
         pcmodel.category_name = m.event_name;
         pcmodel.category_display = Convert.ToUInt32(m.status);
         pcmodel.category_ipfrom = mq.category_ipfrom;
         pcmodel.category_updatedate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
         sb.Append(_proCateDao.UpdateProdCate(pcmodel));
         #endregion
         mySqlCmd.CommandText = sb.ToString();
         id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         mySqlCmd.Transaction.Commit();
     }
     catch (Exception ex)
     {
         mySqlCmd.Transaction.Rollback();
         throw new Exception("PromoAdditionalPriceDao-->Update-->" + ex.Message + mySqlCmd.CommandText.ToString(), ex);
     }
     finally
     {
         mySqlConn.Close();
     }
     return id;
 }
        public string CategoryID(PromoAdditionalPrice m)
        {//判斷是否選擇了促銷商品
            m.Replace4MySQL();
            StringBuilder sb = new StringBuilder();
            DataTable dt, dt_cateOne, dt_cateTwo, dt_cate;
            try
            {
                dt = _access.getDataTable(String.Format("select category_id, left_category_id,right_category_id from promo_additional_price where id={0} ", m.id));

                if (m.event_type != "A1")
                {
                    if (dt.Rows.Count > 0)
                    {
                        dt_cateOne = _access.getDataTable(String.Format("SELECT product_id FROM product_category_set WHERE category_id={0} ", dt.Rows[0][1].ToString()));
                        if (dt_cateOne.Rows.Count > 0)
                        {
                            dt_cateTwo = _access.getDataTable(String.Format("SELECT product_id FROM product_category_set WHERE category_id={0} ", dt.Rows[0][2].ToString()));
                            if (dt_cateTwo.Rows.Count > 0)
                                return "true";
                            else
                                return "two";
                        }
                        else
                            return "one";
                    }
                    else
                        return "false";
                }
                else
                {
                    if (dt.Rows.Count > 0)
                    {
                        dt_cate = _access.getDataTable(String.Format("SELECT product_id FROM product_category_set WHERE category_id={0}  ", dt.Rows[0][0].ToString()));
                        if (dt_cate.Rows.Count > 0)
                        {
                            return "true";
                        }
                        else
                            return "false";
                    }
                    else
                        return "false";
                }


            }
            catch (Exception ex)
            {
                throw new Exception("PromoAdditionalPriceDao-->CategoryID-->" + ex.Message, ex);
            }
        }
 private string SavePromoAdditionalPrice(PromoAdditionalPrice papModel)
 {
     StringBuilder sbSql = new StringBuilder();
     try
     {
         sbSql.AppendFormat("insert into promo_additional_price (event_name,event_desc,event_type,kuser,created,active,category_id,left_category_id,right_category_id) values('{0}','{1}','{2}','{3}','{4}',{5},'{6}',{7},{8});select @@identity;", papModel.event_name, papModel.event_desc, papModel.event_type, papModel.kuser, CommonFunction.DateTimeToString(papModel.created), papModel.active, papModel.category_id, papModel.left_category_id, papModel.right_category_id);
     }
     catch (Exception ex)
     {
         throw new Exception("PromoAdditionalPriceDao-->SavePromoAdditionalPrice-->" + ex.Message, ex);
     }
     return sbSql.ToString();
 }
        //public List<PromoAdditionalPriceQuery> QueryAll(PromoAdditionalPriceQuery query, out int totalCount)
        //{//促銷商品類別和銀行沒有加!
        //    StringBuilder str = new StringBuilder();
        //    StringBuilder strall = new StringBuilder();
        //    StringBuilder strcounts = new StringBuilder();
        //    try
        //    {
        //        strcounts.AppendFormat("select count(PA.id) as totalcounts from promo_additional_price as PA ");
        //        strall.AppendFormat("SELECT CONCAT(PA.event_type ,right(CONCAT('00000000',PA.id),6)) as 'event_id',PA.id,PA.deliver_type,PA.website,PA.device,event_name,event_desc,PC.banner_image,PC.category_link_url,VUG.group_name,fixed_price,buy_limit,TP.parameterName as deliver_name,TP1.parameterName as device_name,`start` as starts,`end`,active,PA.condition_id,PA.category_id,PA.discount,PA.left_category_id,PA.right_category_id,PA.url_by from promo_additional_price AS PA ");
        //        str.AppendFormat(" left join vip_user_group as VUG on PA.group_id=VUG.group_id ");
        //        str.AppendFormat(" LEFT JOIN product_category as PC ON PA.category_id=PC.category_id ");
        //        str.AppendFormat(" LEFT JOIN t_parametersrc as TP on PA.deliver_type = TP.parameterCode AND TP.parameterType='product_freight'");
        //        str.AppendFormat(" left join t_parametersrc as TP1 on PA.device = TP1.parameterCode AND TP1.parameterType='device'");
        //        str.AppendFormat(" left join (select * from  t_parametersrc  where parameterType='event_type' ) ET ON PA.event_type = ET.parameterCode");
        //        str.AppendFormat(" where PA.status=1 and PA.event_type= '{0}'", query.event_type);
        //        totalCount = 0;
        //        if (query.expired == 1)//是未過期
        //        {
        //            str.AppendFormat(" and end >= '{0}'", CommonFunction.DateTimeToString(DateTime.Now));
        //        }
        //        else if (query.expired == 0)
        //        {
        //            str.AppendFormat(" and end < '{0}'", CommonFunction.DateTimeToString(DateTime.Now));
        //        }
        //        totalCount = 0;
        //        if (query.IsPage)
        //        {
        //            System.Data.DataTable _dt = _access.getDataTable(strcounts.ToString() + str.ToString());
        //            if (_dt != null && _dt.Rows.Count > 0)
        //            {
        //                totalCount = Convert.ToInt32(_dt.Rows[0]["totalcounts"]);
        //            }
        //            str.AppendFormat("order by PA.id DESC limit {0},{1} ", query.Start, query.Limit);
        //        }
        //        return _access.getDataTableForObj<PromoAdditionalPriceQuery>(strall.ToString() + str.ToString());
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception("PromoAdditionalPriceDao-->QueryAll-->" + ex.Message + strall.ToString() + str.ToString(), ex);
        //    }
        //}
        #endregion

        #region 不同商品固定價 同品加固定價 不同品加不同價格 新增第一步 +int InsertFirst(PromoAdditionalPrice model)
        public int InsertFirst(PromoAdditionalPrice model)
        {
            model.Replace4MySQL();
            int id = 0;
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connStr);
            string mysql = string.Empty;
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;

                string father_id = _access.getDataTable(string.Format("SELECT parameterProperty from t_parametersrc where parameterCode='{0}'", model.event_type)).Rows[0][0].ToString();
                //insert ProductCategory 獲取category_id
                ProductCategory pmodel = new ProductCategory();
                pmodel.category_father_id = Convert.ToUInt32(father_id);
                pmodel.category_name = model.event_name;
                pmodel.category_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
                pmodel.category_display = 0;
                mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
                model.category_id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                mysql = mySqlCmd.CommandText;
                //修改表serial
                Serial serial = new Serial();
                serial.Serial_id = 12;
                serial.Serial_Value = Convert.ToUInt32(model.category_id);
                mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serial);
                id = Convert.ToInt32(mySqlCmd.ExecuteScalar());

                if (model.event_type != "A1")
                {
                    pmodel.category_father_id = Convert.ToUInt32(model.category_id);
                    pmodel.category_name = "左邊";
                    mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
                    model.left_category_id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    //修改表serial
                    Serial serialred = new Serial();
                    serialred.Serial_id = 12;
                    serialred.Serial_Value = Convert.ToUInt32(model.left_category_id);
                    mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serialred);
                    id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    //mySqlCmd.CommandText = string.Format("INSERT INTO product_category(category_father_id,category_name,category_display,category_show_mode,category_createdate,status) values('{0}','{1}','{2}','{3}','{4}',1); select @@identity ;", model.category_id, "紅", "1", "0", CommonFunction.GetPHPTime(model.created.ToString()));
                    pmodel.category_name = "右邊";
                    mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
                    model.right_category_id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    //修改表serial
                    Serial serialgreen = new Serial();
                    serialgreen.Serial_id = 12;
                    serialgreen.Serial_Value = Convert.ToUInt32(model.right_category_id);
                    mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serialgreen);
                    id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    PromoAdditionalPrice papModel = new PromoAdditionalPrice();
                    papModel.event_name = model.event_name;
                    papModel.event_desc = model.event_desc;
                    papModel.event_type = model.event_type;
                    papModel.kuser = model.kuser;
                    papModel.created = Convert.ToDateTime(CommonFunction.DateTimeToString(model.created));
                    papModel.active = model.active;
                    papModel.category_id = model.category_id;
                    papModel.status = 0;
                    papModel.left_category_id = model.left_category_id;
                    papModel.right_category_id = model.right_category_id;
                    mySqlCmd.CommandText = SavePromoAdditionalPrice(papModel);
                    mysql = mysql + mySqlCmd.CommandText;
                    id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    mySqlCmd.Transaction.Commit();
                }
                else
                {
                    //insert PromoAdditionalPrice 主表 狀態為0
                    PromoAdditionalPrice papModel = new PromoAdditionalPrice();
                    papModel.event_name = model.event_name;
                    papModel.event_desc = model.event_desc;
                    papModel.event_type = model.event_type;
                    papModel.kuser = model.kuser;
                    papModel.created = Convert.ToDateTime(CommonFunction.DateTimeToString(model.created));
                    papModel.active = model.active;
                    papModel.category_id = model.category_id;
                    papModel.status = 0;
                    mySqlCmd.CommandText = SavePromoAdditionalPrice(papModel);
                    mysql = mysql + mySqlCmd.CommandText;
                    id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    mySqlCmd.Transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception("PromoAdditionalPriceDao-->InsertFirst-->" + ex.Message + mysql.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
            return id;
        }
        public HttpResponseBase PromoAdditionalPriceEdit()
        {
            string jsonStr = String.Empty;
            _promoadditionproceMgr = new PromoAdditionalPriceMgr(mySqlConnectionString);
            PromoAdditionalPrice model = new PromoAdditionalPrice();
            PromoAdditionalPrice oldermodel = new PromoAdditionalPrice();
            PromoAdditionalPriceQuery PPQuery = new PromoAdditionalPriceQuery();
            ProductCategory olderpcmodel = new ProductCategory();
            PromoAdditionalPriceQuery oldPPQuery = new PromoAdditionalPriceQuery();
            if (!String.IsNullOrEmpty(Request.Params["rowid"]))
            {
                try
                {
                    model.id = Convert.ToInt32(Request.Params["rowid"].ToString());
                    oldermodel = _promoadditionproceMgr.GetModel(model.id);
                    model.category_id = oldermodel.category_id;
                    olderpcmodel = _produCateMgr.GetModelById(Convert.ToUInt32(model.category_id));
                    model.event_name = Request.Params["event_name"].ToString();
                    model.event_desc = Request.Params["event_desc"].ToString();
                    model.event_type = oldermodel.event_type;
                    if (!string.IsNullOrEmpty(Request.Params["url_by"]))
                    {
                        model.url_by =Convert.ToInt32(Request.Params["url_by"]);
                    }
                    #region 會員群組 會員條件
                    if (Request.Params["group_id"].ToString() != "")
                    {
                        try//group_id
                        {
                            model.group_id = Convert.ToInt32(Request.Params["group_id"].ToString());
                        }
                        catch (Exception)
                        {
                            model.group_id = oldermodel.group_id;
                        }
                        model.condition_id = 0;
                    }
                    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 = oldermodel.condition_id;
                        }
                        model.group_id = 0;
                    }
                    #endregion
                    model.deliver_type = Convert.ToInt32(Request.Params["deliver_id"].ToString());
                    model.device = Request.Params["device_id"].ToString();
                    model.website = Request.Params["side"].ToString();
                    PPQuery.event_id = GetEventId(model.event_type, model.id.ToString());
                    try
                    {
                        model.fixed_price = Convert.ToInt32(Request.Params["fixed_price"].ToString());
                    }
                    catch (Exception)
                    {
                        model.fixed_price = oldermodel.fixed_price;
                    }
                    try
                    {
                        model.buy_limit = Convert.ToInt32(Request.Params["buy_limit"].ToString());
                    }
                    catch (Exception)
                    {
                        model.fixed_price = oldermodel.fixed_price;
                    }
                    model.starts = Convert.ToDateTime(Request.Params["starts"].ToString());
                    //string s = Request.Params["starts"];
                    //model.starts = DateTime.Parse(Request.Params["starts"]);
                    model.end = Convert.ToDateTime(Request.Params["end"].ToString());
                    model.muser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    model.modified = DateTime.Now;
                    //20140925 add 折扣
                    if (model.event_type == "A3")
                    {
                        model.discount = Int32.Parse(Request.Params["discount"].ToString());
                    }
                    else
                    {
                        model.discount = 0;
                    }
                    PPQuery.category_ipfrom = Request.UserHostAddress;
                    PPQuery.event_id = GetEventId(model.event_type, model.id.ToString());
                    try//存連接地址
                    {
                        PPQuery.category_link_url = Request.Params["banner_url"].ToString();
                        if (PPQuery.category_link_url == "" || PPQuery.category_link_url == null)
                        {
                            model.url_by = 0;
                            //刪除上傳的圖片
                            string oldFileName = olderpcmodel.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);//刪除本地圖片
                            }
                            PPQuery.category_link_url = "";
                            PPQuery.banner_image = "";
                        }
                        else
                        {
                            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);
                                FileManagement fileLoad = new FileManagement();
                                for (int iFile = 0; iFile < Request.Files.Count; iFile++)
                                {
                                    HttpPostedFileBase file = Request.Files[iFile];
                                    string fileName = string.Empty;//當前文件名
                                    string fileExtention = string.Empty;//當前文件的擴展名
                                    fileName = Path.GetFileName(file.FileName);
                                    // string returnName = imgServerPath;
                                    bool result = false;
                                    string NewFileName = string.Empty;
                                    fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                                    NewFileName = PPQuery.event_id + newRand + fileExtention;
                                    string ServerPath = string.Empty;
                                    //判斷目錄是否存在,不存在則創建
                                    //string[] mapPath = new string[1];
                                    //mapPath[0] = promoPath.Substring(1, promoPath.Length - 2);
                                    //string s = localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1);
                                    CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), promoPath.Substring(1, promoPath.Length - 2).Split('/'));
                                    //  returnName += promoPath + NewFileName;
                                    fileName = NewFileName;
                                    NewFileName = localPromoPath + NewFileName;//絕對路徑
                                    ServerPath = Server.MapPath(imgLocalServerPath + promoPath);
                                    string ErrorMsg = string.Empty;
                                    //上傳之前刪除已有的圖片
                                    string oldFileName = olderpcmodel.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);//刪除本地圖片
                                    }
                                    try
                                    {
                                        //上傳
                                        result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                        if (result)//上傳成功
                                        {
                                            PPQuery.banner_image = fileName;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        PPQuery.banner_image = olderpcmodel.banner_image;
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                PPQuery.banner_image = olderpcmodel.banner_image;
                            }
                            #endregion
                        }
                    }
                    catch (Exception)
                    {
                        PPQuery.category_link_url = oldPPQuery.category_link_url;
                    }
                    model.active = false;
                    if (_promoadditionproceMgr.CategoryID(model).ToString() == "true")
                    {

                        _promoadditionproceMgr.Update(model, PPQuery);
                        jsonStr = "{success:true}";
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:3}";
                    }
                }
                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);
            this.Response.End();
            return this.Response;
        }
 public HttpResponseBase SaveOne()
 {
     string jsonStr = String.Empty;
     try
     {
         PromoAdditionalPrice model = new PromoAdditionalPrice();
         _promoadditionproceMgr = new PromoAdditionalPriceMgr(mySqlConnectionString);
         if (!String.IsNullOrEmpty(Request.Params["rowid"]))
         {
         }
         else
         {
             model.event_name = Request.Params["name"].ToString();
             model.event_desc = Request.Params["desc"].ToString();
             model.event_type = Request.Params["event"].ToString();
             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;
             model.id = _promoadditionproceMgr.InsertFirst(model); // _promopairMgr.Save(model);
             model = _promoadditionproceMgr.GetModel(model.id);  //_promopairMgr.Select(query);
             string event_id = GetEventId(model.event_type, model.id.ToString());
             if (model.id > 0)
             {
                 jsonStr = "{success:true,\"id\":\"" + model.id + "\",\"cateID\":\"" + model.category_id + "\",\"event_id\":\"" + event_id + "\",\"cateOne\":\"" + model.left_category_id + "\",\"cateTwo\":\"" + model.right_category_id + "\" }";
             }
             else
             {
                 jsonStr = "{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);
         jsonStr = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(jsonStr.ToString());
     this.Response.End();
     return this.Response;
 }
        //public HttpResponseBase PromoAdditionalPriceList()
        //{
        //    PromoAdditionalPriceQuery query = new PromoAdditionalPriceQuery();
        //    List<PromoAdditionalPriceQuery> store = new List<PromoAdditionalPriceQuery>();
        //    string json = string.Empty;
        //    try
        //    {
        //        query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
        //        if (!string.IsNullOrEmpty(Request.Params["limit"]))
        //        {
        //            query.Limit = Convert.ToInt32(Request.Params["limit"]);
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["ddlSel"]))
        //        {
        //            query.expired = Convert.ToInt32(Request.Params["ddlSel"]);
        //        }

        //        query.event_type = Request.Params["event_type"];
        //        _promoadditionproceMgr = new PromoAdditionalPriceMgr(mySqlConnectionString);
        //        int totalCount = 0;
        //        store = _promoadditionproceMgr.Query(query, out totalCount);
        //        IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
        //        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
        //        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

        //        foreach (var item in store)
        //        {
        //            if (item.banner_image != "")
        //            {
        //                item.banner_image = imgServerPath + promoPath + item.banner_image;
        //            }
        //            else
        //            {
        //                item.banner_image = defaultImg;
        //            }
        //        }
        //        json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回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);
        //        json = "{success:false,totalCount:0,data:[]}";
        //    }
        //    this.Response.Clear();
        //    this.Response.Write(json);
        //    this.Response.End();
        //    return this.Response;
        //}
        #endregion

        #region 不同商品固定價 同品加固定價 不同品加不同價格  刪除+HttpResponseBase PromoAdditionalPriceDelete()
        public HttpResponseBase PromoAdditionalPriceDelete()
        {
            PromoAdditionalPrice pap = new PromoAdditionalPrice();
            string jsonStr = String.Empty;
            _promoadditionproceMgr = new PromoAdditionalPriceMgr(mySqlConnectionString);
            if (!String.IsNullOrEmpty(Request.Params["rowID"]))
            {
                try
                {
                    foreach (string rid in Request.Params["rowID"].ToString().Split('|'))
                    {
                        if (rid != null)
                        {
                            int id = 0;

                            try
                            {
                                id = Convert.ToInt32(rid);
                            }
                            catch (Exception)
                            {

                            }

                            pap = _promoadditionproceMgr.GetModel(id);
                            var eventid = CommonFunction.GetEventId(pap.event_type, pap.id.ToString());

                            if (!string.IsNullOrEmpty(rid))
                            {
                                if (_promoadditionproceMgr.Delete(Convert.ToInt32(rid), eventid) > 0)
                                {
                                    jsonStr = "{success:true}";
                                }
                                else
                                {
                                    jsonStr = "{success:false}";
                                }
                            }
                        }
                    }
                    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);
            this.Response.End();
            return this.Response;
        }