Esempio n. 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public VipSoft.Model.Coupon DataRowToModel(DataRow row)
 {
     VipSoft.Model.Coupon model=new VipSoft.Model.Coupon();
     if (row != null)
     {
         if(row["ID"]!=null && row["ID"].ToString()!="")
         {
             model.ID=int.Parse(row["ID"].ToString());
         }
         if(row["Title"]!=null)
         {
             model.Title=row["Title"].ToString();
         }
         if(row["Prefix"]!=null)
         {
             model.Prefix=row["Prefix"].ToString();
         }
         if(row["StartCouponNumber"]!=null)
         {
             model.StartCouponNumber=row["StartCouponNumber"].ToString();
         }
         if(row["StartTime"]!=null && row["StartTime"].ToString()!="")
         {
             model.StartTime=DateTime.Parse(row["StartTime"].ToString());
         }
         if(row["EndTime"]!=null && row["EndTime"].ToString()!="")
         {
             model.EndTime=DateTime.Parse(row["EndTime"].ToString());
         }
         if(row["Money"]!=null && row["Money"].ToString()!="")
         {
             model.Money=decimal.Parse(row["Money"].ToString());
         }
         if(row["ShopIDInfo"]!=null)
         {
             model.ShopIDInfo=row["ShopIDInfo"].ToString();
         }
         if(row["GoodsClassInfo"]!=null)
         {
             model.GoodsClassInfo=row["GoodsClassInfo"].ToString();
         }
         if(row["Remark"]!=null)
         {
             model.Remark=row["Remark"].ToString();
         }
     }
     return model;
 }
Esempio n. 2
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public VipSoft.Model.Coupon DataRowToModel(DataRow row)
		{
			VipSoft.Model.Coupon model=new VipSoft.Model.Coupon();
			if (row != null)
			{
				if(row["ID"]!=null && row["ID"].ToString()!="")
				{
					model.ID=int.Parse(row["ID"].ToString());
				}
				if(row["Title"]!=null)
				{
					model.Title=row["Title"].ToString();
				}
				if(row["Prefix"]!=null)
				{
					model.Prefix=row["Prefix"].ToString();
				}
				if(row["StartCouponNumber"]!=null)
				{
					model.StartCouponNumber=row["StartCouponNumber"].ToString();
				}
				if(row["StartTime"]!=null && row["StartTime"].ToString()!="")
				{
					model.StartTime=DateTime.Parse(row["StartTime"].ToString());
				}
				if(row["EndTime"]!=null && row["EndTime"].ToString()!="")
				{
					model.EndTime=DateTime.Parse(row["EndTime"].ToString());
				}
				if(row["Money"]!=null && row["Money"].ToString()!="")
				{
					model.Money=decimal.Parse(row["Money"].ToString());
				}
				if(row["ShopIDInfo"]!=null)
				{
					model.ShopIDInfo=row["ShopIDInfo"].ToString();
				}
				if(row["GoodsClassInfo"]!=null)
				{
					model.GoodsClassInfo=row["GoodsClassInfo"].ToString();
				}
				if(row["Remark"]!=null)
				{
					model.Remark=row["Remark"].ToString();
				}
			}
			return model;
		}
Esempio n. 3
0
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(VipSoft.Model.Coupon model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update Coupon set ");
			strSql.Append("Title=@Title,");
			strSql.Append("Prefix=@Prefix,");
			strSql.Append("StartCouponNumber=@StartCouponNumber,");
			strSql.Append("StartTime=@StartTime,");
			strSql.Append("EndTime=@EndTime,");
			strSql.Append("Money=@Money,");
			strSql.Append("ShopIDInfo=@ShopIDInfo,");
			strSql.Append("GoodsClassInfo=@GoodsClassInfo,");
			strSql.Append("Remark=@Remark");
			strSql.Append(" where ID=@ID");
			SqlParameter[] parameters = {
					new SqlParameter("@Title", SqlDbType.VarChar,50),
					new SqlParameter("@Prefix", SqlDbType.VarChar,20),
					new SqlParameter("@StartCouponNumber", SqlDbType.VarChar,20),
					new SqlParameter("@StartTime", SqlDbType.DateTime),
					new SqlParameter("@EndTime", SqlDbType.DateTime),
					new SqlParameter("@Money", SqlDbType.Money,8),
					new SqlParameter("@ShopIDInfo", SqlDbType.VarChar,255),
					new SqlParameter("@GoodsClassInfo", SqlDbType.VarChar,255),
					new SqlParameter("@Remark", SqlDbType.VarChar,1000),
					new SqlParameter("@ID", SqlDbType.Int,4)};
			parameters[0].Value = model.Title;
			parameters[1].Value = model.Prefix;
			parameters[2].Value = model.StartCouponNumber;
			parameters[3].Value = model.StartTime;
			parameters[4].Value = model.EndTime;
			parameters[5].Value = model.Money;
			parameters[6].Value = model.ShopIDInfo;
			parameters[7].Value = model.GoodsClassInfo;
			parameters[8].Value = model.Remark;
			parameters[9].Value = model.ID;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
Esempio n. 4
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public VipSoft.Model.Coupon GetModel(int ID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 ID,Title,Prefix,StartCouponNumber,StartTime,EndTime,Money,ShopIDInfo,GoodsClassInfo,Remark from Coupon ");
			strSql.Append(" where ID=@ID");
			SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)
			};
			parameters[0].Value = ID;

			VipSoft.Model.Coupon model=new VipSoft.Model.Coupon();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}
Esempio n. 5
0
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(VipSoft.Model.Coupon model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into Coupon(");
			strSql.Append("Title,Prefix,StartCouponNumber,StartTime,EndTime,Money,ShopIDInfo,GoodsClassInfo,Remark)");
			strSql.Append(" values (");
			strSql.Append("@Title,@Prefix,@StartCouponNumber,@StartTime,@EndTime,@Money,@ShopIDInfo,@GoodsClassInfo,@Remark)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@Title", SqlDbType.VarChar,50),
					new SqlParameter("@Prefix", SqlDbType.VarChar,20),
					new SqlParameter("@StartCouponNumber", SqlDbType.VarChar,20),
					new SqlParameter("@StartTime", SqlDbType.DateTime),
					new SqlParameter("@EndTime", SqlDbType.DateTime),
					new SqlParameter("@Money", SqlDbType.Money,8),
					new SqlParameter("@ShopIDInfo", SqlDbType.VarChar,255),
					new SqlParameter("@GoodsClassInfo", SqlDbType.VarChar,255),
					new SqlParameter("@Remark", SqlDbType.VarChar,1000)};
			parameters[0].Value = model.Title;
			parameters[1].Value = model.Prefix;
			parameters[2].Value = model.StartCouponNumber;
			parameters[3].Value = model.StartTime;
			parameters[4].Value = model.EndTime;
			parameters[5].Value = model.Money;
			parameters[6].Value = model.ShopIDInfo;
			parameters[7].Value = model.GoodsClassInfo;
			parameters[8].Value = model.Remark;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipSoft.Model.Coupon GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,Title,Prefix,StartCouponNumber,StartTime,EndTime,Money,ShopIDInfo,GoodsClassInfo,Remark from Coupon ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)
            };
            parameters[0].Value = ID;

            VipSoft.Model.Coupon model=new VipSoft.Model.Coupon();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }