Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(yny_002.Model.Token model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Token(");
            strSql.Append("TokenCode,Date,SXDate)");
            strSql.Append(" values (");
            strSql.Append("@TokenCode,@Date,@SXDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TokenCode", SqlDbType.VarChar,   1000),
                new SqlParameter("@Date",      SqlDbType.DateTime),
                new SqlParameter("@SXDate",    SqlDbType.DateTime)
            };
            parameters[0].Value = model.TokenCode;
            parameters[1].Value = model.Date;
            parameters[2].Value = model.SXDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(yny_002.Model.Token model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Token set ");
            strSql.Append("TokenCode=@TokenCode,");
            strSql.Append("Date=@Date,");
            strSql.Append("SXDate=@SXDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TokenCode", SqlDbType.VarChar,   1000),
                new SqlParameter("@Date",      SqlDbType.DateTime),
                new SqlParameter("@SXDate",    SqlDbType.DateTime),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.TokenCode;
            parameters[1].Value = model.Date;
            parameters[2].Value = model.SXDate;
            parameters[3].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        public static Model.Token GetModel()
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,TokenCode,Date,SXDate from Token ");
            strSql.Append(" order by Date desc;");
            yny_002.Model.Token model = new yny_002.Model.Token();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public static yny_002.Model.Token DataRowToModel(DataRow row)
 {
     yny_002.Model.Token model = new yny_002.Model.Token();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["TokenCode"] != null)
         {
             model.TokenCode = row["TokenCode"].ToString();
         }
         if (row["Date"] != null && row["Date"].ToString() != "")
         {
             model.Date = DateTime.Parse(row["Date"].ToString());
         }
         if (row["SXDate"] != null && row["SXDate"].ToString() != "")
         {
             model.SXDate = DateTime.Parse(row["SXDate"].ToString());
         }
     }
     return(model);
 }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static yny_002.Model.Token GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,TokenCode,Date,SXDate from Token ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static bool Update(yny_002.Model.Token model)
 {
     return(DAL.Token.Update(model));
 }
Beispiel #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(yny_002.Model.Token model)
 {
     return(DAL.Token.Add(model));
 }