public HttpResponseBase PromotionsBonusSerialListsExport()
        {
            List<PromotionsBonusSerial> stores = new List<PromotionsBonusSerial>();
            List<PromotionsBonusSerial> mystores = new List<PromotionsBonusSerial>();
            string json = "false";
            _promBnusSeral = new PromotionsBonusSerialMgr(mySqlConnectionString);
            int id = 0;
            if (!string.IsNullOrEmpty(Request.Params["ids"]))
            {
                id = Convert.ToInt32(Request.Params["ids"]);
            }
            stores = _promBnusSeral.QueryById(id);
            int j = 1;
            for (int i = 0; i < stores.Count; i++)
            {
                PromotionsBonusSerial query = new PromotionsBonusSerial();
                query.id = stores[i].id;
                query.active = stores[i].active;
                query.promotion_id = stores[i].promotion_id;
                query.serial = stores[i].serial;
                query.myid = j++;
                mystores.Add(query);
            }
            DataTable dtHZ = new DataTable();
            string newExcelName = string.Empty;
            dtHZ.Columns.Add("編號", typeof(string));
            dtHZ.Columns.Add("序號", typeof(string));
            dtHZ.Columns.Add("ACTIVE", typeof(string));
            try
            {
                foreach (PromotionsBonusSerial dr_v in mystores)
                {
                    DataRow dr = dtHZ.NewRow();
                    dr[0] = dr_v.myid.ToString();
                    dr[1] = dr_v.serial.ToString();
                    dr[2] = dr_v.active.ToString();
                    dtHZ.Rows.Add(dr);
                }

                string[] colname = new string[dtHZ.Columns.Count];
                string filename = "promotions_bonus_serial.csv";
                newExcelName = Server.MapPath(excelPath) + filename;
                for (int i = 0; i < dtHZ.Columns.Count; i++)
                {
                    colname[i] = dtHZ.Columns[i].ColumnName;
                }

                if (System.IO.File.Exists(newExcelName))
                {
                    System.IO.File.Delete(newExcelName);
                }

                CsvHelper.ExportDataTableToCsv(dtHZ, newExcelName, colname, true);
                json = "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);

            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        //public HttpResponseBase PromotionsBonusSerialLists()
        //{
        //    List<PromotionsBonusSerial> stores = new List<PromotionsBonusSerial>();
        //    List<PromotionsBonusSerial> mystores = new List<PromotionsBonusSerial>();
        //    _promBnusSeral = new PromotionsBonusSerialMgr(mySqlConnectionString);
        //    string json = string.Empty;
        //    try
        //    {
        //        int id = Convert.ToInt32(Request.Params["ids"]);
        //        stores = _promBnusSeral.QueryById(id);
        //        int i;
        //        int j = 1;
        //        for (i = 0; i < stores.Count; i++)
        //        {
        //            PromotionsBonusSerial query = new PromotionsBonusSerial();
        //            query.id = stores[i].id;
        //            query.active = stores[i].active;
        //            query.promotion_id = stores[i].promotion_id;
        //            query.serial = stores[i].serial;
        //            query.myid = j++;
        //            mystores.Add(query);
        //        }
        //        json = "{success:true,data:" + JsonConvert.SerializeObject(mystores) + "}";//返回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:true,data:[]}";
        //    }
        //    this.Response.Clear();
        //    this.Response.Write(json);
        //    this.Response.End();
        //    return this.Response;
        //}
        #endregion
        public HttpResponseBase PromotionsBonusSerialLists2()
        {
            string json = string.Empty;
            int totalcount = 0;
            PromotionsBonusSerial query = new PromotionsBonusSerial();
            query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
            query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
            List<PromotionsBonusSerial> stores = new List<PromotionsBonusSerial>();
            _promBnusSeral = new PromotionsBonusSerialMgr(mySqlConnectionString);
            query.promotion_id = Convert.ToInt32(Request.Params["ids"]);
         
            try
            {
               // int id = Convert.ToInt32(Request.Params["ids"]);
                stores = _promBnusSeral.QueryById(query, out totalcount);
                int j = 1;
                for (int i = 0; i < stores.Count; i++)
                {
                    stores[i].myid = j++;
                }
               // json = "{success:true,data:" + JsonConvert.SerializeObject(stores) + "}";//返回json數據
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalcount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";
            }
            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:true,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }