예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SteelManagement.Model.ActionRecords model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ActionRecords set ");
            strSql.Append("EntryTime=@EntryTime,");
            strSql.Append("UserId=@UserId,");
            strSql.Append("ActType=@ActType,");
            strSql.Append("ActId=@ActId");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EntryTime", SqlDbType.DateTime),
                new SqlParameter("@UserId",    SqlDbType.Int,        4),
                new SqlParameter("@ActType",   SqlDbType.VarChar,   50),
                new SqlParameter("@ActId",     SqlDbType.Int,        4),
                new SqlParameter("@Id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.EntryTime;
            parameters[1].Value = model.UserId;
            parameters[2].Value = model.ActType;
            parameters[3].Value = model.ActId;
            parameters[4].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SteelManagement.Model.ActionRecords DataRowToModel(DataRow row)
 {
     SteelManagement.Model.ActionRecords model = new SteelManagement.Model.ActionRecords();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["EntryTime"] != null && row["EntryTime"].ToString() != "")
         {
             model.EntryTime = DateTime.Parse(row["EntryTime"].ToString());
         }
         if (row["UserId"] != null && row["UserId"].ToString() != "")
         {
             model.UserId = int.Parse(row["UserId"].ToString());
         }
         if (row["ActType"] != null)
         {
             model.ActType = row["ActType"].ToString();
         }
         if (row["ActId"] != null && row["ActId"].ToString() != "")
         {
             model.ActId = int.Parse(row["ActId"].ToString());
         }
     }
     return(model);
 }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SteelManagement.Model.ActionRecords model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ActionRecords(");
            strSql.Append("EntryTime,UserId,ActType,ActId)");
            strSql.Append(" values (");
            strSql.Append("@EntryTime,@UserId,@ActType,@ActId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EntryTime", SqlDbType.DateTime),
                new SqlParameter("@UserId",    SqlDbType.Int,        4),
                new SqlParameter("@ActType",   SqlDbType.VarChar,   50),
                new SqlParameter("@ActId",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.EntryTime;
            parameters[1].Value = model.UserId;
            parameters[2].Value = model.ActType;
            parameters[3].Value = model.ActId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SteelManagement.Model.ActionRecords GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,EntryTime,UserId,ActType,ActId from ActionRecords ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }