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

            strSql.Append("update OperateRecord set ");
            strSql.Append("Time=@Time,");
            strSql.Append("Contents=@Contents,");
            strSql.Append("KeyID=@KeyID,");
            strSql.Append("TableName=@TableName");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Time",      SqlDbType.DateTime),
                new SqlParameter("@Contents",  SqlDbType.NVarChar, 500),
                new SqlParameter("@KeyID",     SqlDbType.Int,        4),
                new SqlParameter("@TableName", SqlDbType.NVarChar,  50),
                new SqlParameter("@ID",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Time;
            parameters[1].Value = model.Contents;
            parameters[2].Value = model.KeyID;
            parameters[3].Value = model.TableName;
            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 Maticsoft.Model.OperateRecord DataRowToModel(DataRow row)
 {
     Maticsoft.Model.OperateRecord model = new Maticsoft.Model.OperateRecord();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Time"] != null && row["Time"].ToString() != "")
         {
             model.Time = DateTime.Parse(row["Time"].ToString());
         }
         if (row["Contents"] != null)
         {
             model.Contents = row["Contents"].ToString();
         }
         if (row["KeyID"] != null && row["KeyID"].ToString() != "")
         {
             model.KeyID = int.Parse(row["KeyID"].ToString());
         }
         if (row["TableName"] != null)
         {
             model.TableName = row["TableName"].ToString();
         }
     }
     return(model);
 }
Exemple #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.OperateRecord model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OperateRecord(");
            strSql.Append("Time,Contents,KeyID,TableName)");
            strSql.Append(" values (");
            strSql.Append("@Time,@Contents,@KeyID,@TableName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Time",      SqlDbType.DateTime),
                new SqlParameter("@Contents",  SqlDbType.NVarChar, 500),
                new SqlParameter("@KeyID",     SqlDbType.Int,        4),
                new SqlParameter("@TableName", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Time;
            parameters[1].Value = model.Contents;
            parameters[2].Value = model.KeyID;
            parameters[3].Value = model.TableName;

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

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

            strSql.Append("select  top 1 ID,Time,Contents,KeyID,TableName from OperateRecord ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

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