Esempio n. 1
0
 public HttpResponseBase PromoShareList()
 {
     PromoShareMasterQuery query = new PromoShareMasterQuery();
     DataTable _dt = new DataTable();
     string json = string.Empty;
     int  totalCount = 0;
     try
     {
         query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
         query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
         if (!string.IsNullOrEmpty(Request.Params["ddlstatus"]))
         {
         query.promo_active = Convert.ToInt32(Request.Params["ddlstatus"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["promo_name_list"]))
         { 
          query.promo_name=Request.Params["promo_name_list"];
         }
         PshareMgr = new PromoShareMasterMgr(mySqlConnectionString);
         _dt = PshareMgr.GetList(query, out totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(_dt, 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,totalCount:0,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Esempio n. 2
0
 /// <summary>
 /// 通過查詢條件獲取PromoShareMaster列表
 /// </summary>
 /// <param name="query">查詢條件</param>
 /// <param name="totalCount">數據總條數</param>
 /// <returns>PromoShareMaster列表</returns>
 public DataTable GetList(PromoShareMasterQuery query, out int totalCount)
 {
     try
     {
         return _PshareDao.GetList(query,out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("PromoShareMasterMgr-->GetList-->" + ex.Message, ex);
     }
 }
Esempio n. 3
0
 public HttpResponseBase InsertIntoPromoShareMaster()
 {
     PromoShareMasterQuery query = new PromoShareMasterQuery();
     string json = string.Empty;
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["promo_name"]))
         {
             query.promo_name = Request.Params["promo_name"];
         }
         if (!string.IsNullOrEmpty(Request.Params["promo_desc"]))
         {
             query.promo_desc = Request.Params["promo_desc"];
         }
         if (!string.IsNullOrEmpty(Request.Params["promo_start"]))
         {
             query.promo_start = Convert.ToDateTime(Request.Params["promo_start"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["promo_end"]))
         {
             query.promo_end = Convert.ToDateTime(Request.Params["promo_end"]);
         }
         PshareMgr = new PromoShareMasterMgr(mySqlConnectionString);
         int PromoId = PshareMgr.Add(query);
         string strPromoId ="SH";
         if (PromoId > 0)
         {
             if (PromoId.ToString().Length < 6)
             {
                 for (int i = 0; i < 6 - PromoId.ToString().Length; i++)
                 {
                     strPromoId += "0";
                 }
             }
             strPromoId += PromoId.ToString();
             query = new PromoShareMasterQuery();
             query.promo_event_id = strPromoId;
             query.promo_id = PromoId;
             query.eventId = true;
             if (PshareMgr.Update(query) > 0)
             {
                 json = "{success:'true',strPromoId:'" + strPromoId + "',PromoId:'" + PromoId + "'}";
             }
             else
             {
                 json = "{success:false}";
             }
         }
         else
         {
             json = "{success:false}";
         }
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Esempio n. 4
0
 /// <summary>
 /// 通過查詢條件獲取PromoShareMaster列表
 /// </summary>
 /// <param name="query">查詢條件</param>
 /// <param name="totalCount">數據總條數</param>
 /// <returns>PromoShareMaster列表</returns>
 public DataTable GetList(PromoShareMasterQuery query, out int totalCount)
 {
     DataTable _dtable = new DataTable();
     StringBuilder sbSql = new StringBuilder();
     StringBuilder sbSqlCondition = new StringBuilder();
     totalCount = 0;
     sbSql.Append("  SELECT psm.promo_id,psm.promo_event_id,psm.promo_name,psm.promo_desc,psm.promo_start,psm.promo_end,psm.promo_active,psc.this_promo_id ");
     sbSqlCondition.Append(" FROM promo_share_master psm   LEFT JOIN ( SELECT DISTINCT(promo_id) as this_promo_id FROM promo_share_condition ) psc on psc.this_promo_id=psm.promo_id WHERE 1=1 ");
     if (!string.IsNullOrEmpty(query.promo_active.ToString()))
     {
         if (query.promo_active != 2)
         {
             sbSqlCondition.AppendFormat(" and psm.promo_active= '{0}' ", query.promo_active);
         }
     }
     if (!string.IsNullOrEmpty(query.promo_name))
     {
         sbSqlCondition.AppendFormat(" and psm.promo_name like '%{0}%' ", query.promo_name);
     }
     try
     {
         if (query.IsPage)
         {
             DataTable dt = _access.getDataTable("select count(*) as totalCount " + sbSqlCondition.ToString());
             if (dt != null && dt.Rows.Count > 0)
             {
                 totalCount = Convert.ToInt32(dt.Rows[0]["totalCount"]);
             }
         }
         sbSqlCondition.AppendFormat("order by psm.promo_id desc limit {0},{1} ", query.Start, query.Limit);
         _dtable = _access.getDataTable(sbSql.Append(sbSqlCondition).ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("PromoShareMasterDao-->GetList-->" + ex.Message + sbSql.Append(sbSqlCondition).ToString(), ex);
     }
     return _dtable;
 }