Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(VipSoft.Model.CardType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CardType set ");
            strSql.Append("Type=@Type,");
            strSql.Append("IsExpenseGoods=@IsExpenseGoods,");
            strSql.Append("IsExpensePoint=@IsExpensePoint,");
            strSql.Append("IsPointAuto=@IsPointAuto");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Type",           SqlDbType.Int, 4),
                new SqlParameter("@IsExpenseGoods", SqlDbType.Bit, 1),
                new SqlParameter("@IsExpensePoint", SqlDbType.Bit, 1),
                new SqlParameter("@IsPointAuto",    SqlDbType.Bit, 1),
                new SqlParameter("@ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Type;
            parameters[1].Value = model.IsExpenseGoods;
            parameters[2].Value = model.IsExpensePoint;
            parameters[3].Value = model.IsPointAuto;
            parameters[4].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VipSoft.Model.CardType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CardType(");
            strSql.Append("Type,IsExpenseGoods,IsExpensePoint,IsPointAuto)");
            strSql.Append(" values (");
            strSql.Append("@Type,@IsExpenseGoods,@IsExpensePoint,@IsPointAuto)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Type",           SqlDbType.Int, 4),
                new SqlParameter("@IsExpenseGoods", SqlDbType.Bit, 1),
                new SqlParameter("@IsExpensePoint", SqlDbType.Bit, 1),
                new SqlParameter("@IsPointAuto",    SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.Type;
            parameters[1].Value = model.IsExpenseGoods;
            parameters[2].Value = model.IsExpensePoint;
            parameters[3].Value = model.IsPointAuto;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public VipSoft.Model.CardType DataRowToModel(DataRow row)
 {
     VipSoft.Model.CardType model = new VipSoft.Model.CardType();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Type"] != null && row["Type"].ToString() != "")
         {
             model.Type = int.Parse(row["Type"].ToString());
         }
         if (row["IsExpenseGoods"] != null && row["IsExpenseGoods"].ToString() != "")
         {
             if ((row["IsExpenseGoods"].ToString() == "1") || (row["IsExpenseGoods"].ToString().ToLower() == "true"))
             {
                 model.IsExpenseGoods = true;
             }
             else
             {
                 model.IsExpenseGoods = false;
             }
         }
         if (row["IsExpensePoint"] != null && row["IsExpensePoint"].ToString() != "")
         {
             if ((row["IsExpensePoint"].ToString() == "1") || (row["IsExpensePoint"].ToString().ToLower() == "true"))
             {
                 model.IsExpensePoint = true;
             }
             else
             {
                 model.IsExpensePoint = false;
             }
         }
         if (row["IsPointAuto"] != null && row["IsPointAuto"].ToString() != "")
         {
             if ((row["IsPointAuto"].ToString() == "1") || (row["IsPointAuto"].ToString().ToLower() == "true"))
             {
                 model.IsPointAuto = true;
             }
             else
             {
                 model.IsPointAuto = false;
             }
         }
     }
     return(model);
 }
Exemple #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public VipSoft.Model.CardType DataRowToModel(DataRow row)
 {
     VipSoft.Model.CardType model=new VipSoft.Model.CardType();
     if (row != null)
     {
         if(row["ID"]!=null && row["ID"].ToString()!="")
         {
             model.ID=int.Parse(row["ID"].ToString());
         }
         if(row["Type"]!=null && row["Type"].ToString()!="")
         {
             model.Type=int.Parse(row["Type"].ToString());
         }
         if(row["IsExpenseGoods"]!=null && row["IsExpenseGoods"].ToString()!="")
         {
             if((row["IsExpenseGoods"].ToString()=="1")||(row["IsExpenseGoods"].ToString().ToLower()=="true"))
             {
                 model.IsExpenseGoods=true;
             }
             else
             {
                 model.IsExpenseGoods=false;
             }
         }
         if(row["IsExpensePoint"]!=null && row["IsExpensePoint"].ToString()!="")
         {
             if((row["IsExpensePoint"].ToString()=="1")||(row["IsExpensePoint"].ToString().ToLower()=="true"))
             {
                 model.IsExpensePoint=true;
             }
             else
             {
                 model.IsExpensePoint=false;
             }
         }
         if(row["IsPointAuto"]!=null && row["IsPointAuto"].ToString()!="")
         {
             if((row["IsPointAuto"].ToString()=="1")||(row["IsPointAuto"].ToString().ToLower()=="true"))
             {
                 model.IsPointAuto=true;
             }
             else
             {
                 model.IsPointAuto=false;
             }
         }
     }
     return model;
 }
Exemple #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipSoft.Model.CardType GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Type,IsExpenseGoods,IsExpensePoint,IsPointAuto from CardType ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            VipSoft.Model.CardType model = new VipSoft.Model.CardType();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipSoft.Model.CardType GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,Type,IsExpenseGoods,IsExpensePoint,IsPointAuto from CardType ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)
            };
            parameters[0].Value = ID;

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