コード例 #1
0
 /// <summary>
 /// 获取体验券
 /// </summary>
 /// <param name="sql"></param>
 /// <returns></returns>
 public static List<Experience> GetExperienceList(string sql)
 {
     System.Data.Common.DbDataReader dbreader = null;
     List<Experience> list = new List<Experience>();
     try
     {
         dbreader = DbHelper.ExecuteReader(sql);
         while (dbreader.Read())
         {
             Experience exp = new Experience();
             exp.Id = DBNull.Value != dbreader["Id"] ? Convert.ToInt16(dbreader["Id"].ToString()) : 0;
             exp.Name = DBNull.Value != dbreader["EX_NAME"] ? dbreader["EX_NAME"].ToString() : string.Empty;
             exp.Type = DBNull.Value != dbreader["EX_TYPE"] ? Convert.ToInt16(dbreader["EX_TYPE"].ToString()) : 0;
             exp.Annount = DBNull.Value != dbreader["EX_ANMOUNT"] ? Convert.ToDecimal(dbreader["EX_ANMOUNT"].ToString()) : 0;
             exp.Rceharge = DBNull.Value != dbreader["EX_RECHARGE"] ? Convert.ToDecimal(dbreader["EX_RECHARGE"].ToString()) : 0;
             exp.Num = DBNull.Value != dbreader["EX_NUM"] ? Convert.ToInt16(dbreader["EX_NUM"].ToString()) : 0;
             //if (dbreader["EX_STARTDATE"] != null && !string.IsNullOrEmpty(dbreader["EX_STARTDATE"].ToString()))
             //    exp.StartDate = Convert.ToDateTime(dbreader["EX_STARTDATE"]);
             //if (dbreader["EX_ENDDATE"] != null && !string.IsNullOrEmpty(dbreader["EX_ENDDATE"].ToString()))
             //    exp.EndDate = Convert.ToDateTime(dbreader["EX_ENDDATE"]);
             if (System.DBNull.Value != dbreader["EX_STARTDATE"])
                 exp.StartDate = Convert.ToDateTime(dbreader["EX_STARTDATE"]);
             else
                 exp.StartDate = DateTime.MinValue;
             if (System.DBNull.Value != dbreader["EX_ENDDATE"])
                 exp.EndDate = Convert.ToDateTime(dbreader["EX_ENDDATE"]);
             else
                 exp.EndDate = DateTime.MinValue;
             //exp.EndDate = System.DBNull.Value != dbreader["EX_ENDDATE"] ? Convert.ToDateTime(dbreader["EX_ENDDATE"]) : DateTime.MinValue;
             exp.CreatID = DBNull.Value != dbreader["EX_CREATID"] ? dbreader["EX_CREATID"].ToString() : string.Empty;
             exp.Effective = DBNull.Value != dbreader["EX_EFFECTIVE"] ? Convert.ToInt16(dbreader["EX_EFFECTIVE"].ToString()) : 0;
             //exp.EffectiveTime = System.DBNull.Value != dbreader["EX_EFFECTIVETIME"] ? Convert.ToDateTime(dbreader["EX_EFFECTIVETIME"]) : DateTime.MinValue;
             if (System.DBNull.Value != dbreader["EX_EFFECTIVETIME"])
                 exp.EffectiveTime = Convert.ToDateTime(dbreader["EX_EFFECTIVETIME"]);
             else
                 exp.EffectiveTime = DateTime.MinValue;
             list.Add(exp);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
     finally
     {
         if (null != dbreader)
         {
             dbreader.Close();
             dbreader.Dispose();
         }
     }
     return list;
 }
コード例 #2
0
        /// <summary>
        /// 添加体验券
        /// </summary>
        /// <param name="loginId">登录标识</param>
        /// <param name="exp">体验券</param>
        /// <returns>ResultDesc</returns>
        public ResultDesc AddExperience(string loginId, Experience exp)
        {
            ResultDesc rsdc = new ResultDesc();
            var tdUser = new TradeUser();
            try
            {
                #region 判断登陆标识是否过期
                if (!ComFunction.ExistUserLoginID(loginId, ref tdUser))
                {
                    rsdc.Result = false;
                    rsdc.Desc = ResCode.UL003Desc;
                    return rsdc;
                }
                #endregion
                var sqlList = new List<string>();
                sqlList.Add(string.Format("INSERT INTO [TRADE_EXPERIENCE]([EX_NAME] ,[EX_TYPE] ,[EX_ANMOUNT] ,[EX_RECHARGE] ,[EX_NUM] ,[EX_STARTDATE] ,[EX_ENDDATE] ," +
                             "[EX_CREATID] ,[EX_EFFECTIVE],[EX_EFFECTIVETIME]) VALUES ('{0}',{1},{2},{3},{4},'{5}','{6}','{7}',{8},'{9}')",
                             exp.Name, exp.Type, exp.Annount, exp.Rceharge, exp.Num, exp.StartDate,
                             exp.EndDate, exp.CreatID, exp.Effective, exp.EffectiveTime
                    ));

                if (!ComFunction.SqlTransaction(sqlList))
                {
                    rsdc.Result = false;
                    rsdc.Desc = "添加体验券出错!";
                    return rsdc;
                }
                rsdc.Result = true;
                rsdc.Desc = "添加体验券成功!";
            }
            catch (Exception ex)
            {
                ComFunction.WriteErr(ex);
                rsdc.Result = false;
                rsdc.Desc = "";
            }
            return rsdc;
        }
コード例 #3
0
 /// <summary>
 /// 编辑体验券
 /// </summary>
 /// <param name="loginId">登录标识</param>
 /// <param name="exp">体验券</param>
 /// <returns>ResultDesc</returns>
 public ResultDesc EditExperience(string loginId, Experience exp)
 {
     ResultDesc rsdc = new ResultDesc();
     var tdUser = new TradeUser();
     try
     {
         #region 判断登陆标识是否过期
         if (!ComFunction.ExistUserLoginID(loginId, ref tdUser))
         {
             rsdc.Result = false;
             rsdc.Desc = ResCode.UL003Desc;
             return rsdc;
         }
         #endregion
         var sqlList = new List<string>();
         exp.StartDate = exp.StartDate != null && exp.StartDate == DateTime.MinValue ? DateTime.MinValue : exp.StartDate;
         exp.EndDate = exp.EndDate != null && exp.EndDate == DateTime.MinValue ? DateTime.MinValue : exp.EndDate;
         exp.EffectiveTime = exp.EffectiveTime != null && exp.EffectiveTime == DateTime.MinValue ? DateTime.MinValue : exp.EffectiveTime;
         sqlList.Add(string.Format("UPDATE [TRADE_EXPERIENCE] SET [EX_NAME] ='{0}',[EX_TYPE] ={1},[EX_ANMOUNT] = {2} ,[EX_RECHARGE] ={3} ,[EX_NUM] = {4} ," +
                                   "[EX_STARTDATE] = '{5}',[EX_ENDDATE] = '{6}'  ,[EX_CREATID] ='{7}' ,[EX_EFFECTIVE] ={8} ,[EX_EFFECTIVETIME] ='{9}' WHERE ID ={10}",
                      exp.Name, exp.Type, exp.Annount, exp.Rceharge, exp.Num, exp.StartDate,
                      exp.EndDate, exp.CreatID, exp.Effective, exp.EffectiveTime,
                      exp.Id));
         if (!ComFunction.SqlTransaction(sqlList))
         {
             rsdc.Result = false;
             rsdc.Desc = "编辑体验券出错!";
             return rsdc;
         }
         rsdc.Result = true;
         rsdc.Desc = "编辑体验券成功!";
     }
     catch (Exception ex)
     {
         ComFunction.WriteErr(ex);
         rsdc.Result = false;
         rsdc.Desc = "";
     }
     return rsdc;
 }