Example #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CardCenter.Entity.NoticeList DataRowToModel(DataRow row)
 {
     CardCenter.Entity.NoticeList model = new CardCenter.Entity.NoticeList();
     if (row != null)
     {
         if (row["Guid"] != null)
         {
             model.Guid = row["Guid"].ToString();
         }
         if (row["FileName"] != null)
         {
             model.FileName = row["FileName"].ToString();
         }
         if (row["FileExtension"] != null)
         {
             model.FileExtension = row["FileExtension"].ToString();
         }
         if (row["FileSize"] != null && row["FileSize"].ToString() != "")
         {
             model.FileSize = int.Parse(row["FileSize"].ToString());
         }
         if (row["NoticeType"] != null && row["NoticeType"].ToString() != "")
         {
             model.NoticeType = int.Parse(row["NoticeType"].ToString());
         }
         if (row["SavePath"] != null)
         {
             model.SavePath = row["SavePath"].ToString();
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
         if (row["CreateUser"] != null)
         {
             model.CreateUser = row["CreateUser"].ToString();
         }
         if (row["IsDelete"] != null && row["IsDelete"].ToString() != "")
         {
             if ((row["IsDelete"].ToString() == "1") || (row["IsDelete"].ToString().ToLower() == "true"))
             {
                 model.IsDelete = true;
             }
             else
             {
                 model.IsDelete = false;
             }
         }
     }
     return(model);
 }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CardCenter.Entity.NoticeList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update NoticeList set ");
            strSql.Append("FileName=@FileName,");
            strSql.Append("FileExtension=@FileExtension,");
            strSql.Append("FileSize=@FileSize,");
            strSql.Append("NoticeType=@NoticeType,");
            strSql.Append("SavePath=@SavePath,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("CreateUser=@CreateUser,");
            strSql.Append("IsDelete=@IsDelete");
            strSql.Append(" where Guid=@Guid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FileName",      SqlDbType.NVarChar,   64),
                new SqlParameter("@FileExtension", SqlDbType.NVarChar,   16),
                new SqlParameter("@FileSize",      SqlDbType.Int,         4),
                new SqlParameter("@NoticeType",    SqlDbType.Int,         4),
                new SqlParameter("@SavePath",      SqlDbType.NVarChar,  256),
                new SqlParameter("@CreateTime",    SqlDbType.DateTime),
                new SqlParameter("@CreateUser",    SqlDbType.NVarChar,   64),
                new SqlParameter("@IsDelete",      SqlDbType.Bit,         1),
                new SqlParameter("@Guid",          SqlDbType.NVarChar, 64)
            };
            parameters[0].Value = model.FileName;
            parameters[1].Value = model.FileExtension;
            parameters[2].Value = model.FileSize;
            parameters[3].Value = model.NoticeType;
            parameters[4].Value = model.SavePath;
            parameters[5].Value = model.CreateTime;
            parameters[6].Value = model.CreateUser;
            parameters[7].Value = model.IsDelete;
            parameters[8].Value = model.Guid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CardCenter.Entity.NoticeList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into NoticeList(");
            strSql.Append("Guid,FileName,FileExtension,FileSize,NoticeType,SavePath,CreateTime,CreateUser,IsDelete)");
            strSql.Append(" values (");
            strSql.Append("@Guid,@FileName,@FileExtension,@FileSize,@NoticeType,@SavePath,@CreateTime,@CreateUser,@IsDelete)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Guid",          SqlDbType.NVarChar,   64),
                new SqlParameter("@FileName",      SqlDbType.NVarChar,   64),
                new SqlParameter("@FileExtension", SqlDbType.NVarChar,   16),
                new SqlParameter("@FileSize",      SqlDbType.Int,         4),
                new SqlParameter("@NoticeType",    SqlDbType.Int,         4),
                new SqlParameter("@SavePath",      SqlDbType.NVarChar,  256),
                new SqlParameter("@CreateTime",    SqlDbType.DateTime),
                new SqlParameter("@CreateUser",    SqlDbType.NVarChar,   64),
                new SqlParameter("@IsDelete",      SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.Guid;
            parameters[1].Value = model.FileName;
            parameters[2].Value = model.FileExtension;
            parameters[3].Value = model.FileSize;
            parameters[4].Value = model.NoticeType;
            parameters[5].Value = model.SavePath;
            parameters[6].Value = model.CreateTime;
            parameters[7].Value = model.CreateUser;
            parameters[8].Value = model.IsDelete;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CardCenter.Entity.NoticeList GetModel(string Guid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Guid,FileName,FileExtension,FileSize,NoticeType,SavePath,CreateTime,CreateUser,IsDelete from NoticeList ");
            strSql.Append(" where Guid=@Guid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Guid", SqlDbType.NVarChar, 64)
            };
            parameters[0].Value = Guid;

            CardCenter.Entity.NoticeList model = new CardCenter.Entity.NoticeList();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

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