/// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Interwebsite.Model.Attachment DataRowToModel(DataRow row)
 {
     Interwebsite.Model.Attachment model=new Interwebsite.Model.Attachment();
     if (row != null)
     {
         if(row["ID"]!=null && row["ID"].ToString()!="")
         {
             model.ID=int.Parse(row["ID"].ToString());
         }
         if(row["AttachmentName"]!=null)
         {
             model.AttachmentName=row["AttachmentName"].ToString();
         }
         if(row["UploadName"]!=null)
         {
             model.UploadName=row["UploadName"].ToString();
         }
         if(row["UploadTime"]!=null && row["UploadTime"].ToString()!="")
         {
             model.UploadTime=DateTime.Parse(row["UploadTime"].ToString());
         }
         if(row["AttachmentAddress"]!=null)
         {
             model.AttachmentAddress=row["AttachmentAddress"].ToString();
         }
     }
     return model;
 }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Interwebsite.Model.Attachment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Attachment(");
            strSql.Append("ID,AttachmentName,UploadName,UploadTime,AttachmentAddress)");
            strSql.Append(" values (");
            strSql.Append("@ID,@AttachmentName,@UploadName,@UploadTime,@AttachmentAddress)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",                SqlDbType.Int,         4),
                new SqlParameter("@AttachmentName",    SqlDbType.NVarChar,  100),
                new SqlParameter("@UploadName",        SqlDbType.NVarChar,   50),
                new SqlParameter("@UploadTime",        SqlDbType.DateTime),
                new SqlParameter("@AttachmentAddress", SqlDbType.NVarChar, 100)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.AttachmentName;
            parameters[2].Value = model.UploadName;
            parameters[3].Value = model.UploadTime;
            parameters[4].Value = model.AttachmentAddress;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Interwebsite.Model.Attachment DataRowToModel(DataRow row)
 {
     Interwebsite.Model.Attachment model = new Interwebsite.Model.Attachment();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["AttachmentName"] != null)
         {
             model.AttachmentName = row["AttachmentName"].ToString();
         }
         if (row["UploadName"] != null)
         {
             model.UploadName = row["UploadName"].ToString();
         }
         if (row["UploadTime"] != null && row["UploadTime"].ToString() != "")
         {
             model.UploadTime = DateTime.Parse(row["UploadTime"].ToString());
         }
         if (row["AttachmentAddress"] != null)
         {
             model.AttachmentAddress = row["AttachmentAddress"].ToString();
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Interwebsite.Model.Attachment GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,AttachmentName,UploadName,UploadTime,AttachmentAddress from Attachment ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Interwebsite.Model.Attachment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Attachment set ");
            strSql.Append("ID=@ID,");
            strSql.Append("AttachmentName=@AttachmentName,");
            strSql.Append("UploadName=@UploadName,");
            strSql.Append("UploadTime=@UploadTime,");
            strSql.Append("AttachmentAddress=@AttachmentAddress");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",                SqlDbType.Int,         4),
                new SqlParameter("@AttachmentName",    SqlDbType.NVarChar,  100),
                new SqlParameter("@UploadName",        SqlDbType.NVarChar,   50),
                new SqlParameter("@UploadTime",        SqlDbType.DateTime),
                new SqlParameter("@AttachmentAddress", SqlDbType.NVarChar, 100)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.AttachmentName;
            parameters[2].Value = model.UploadName;
            parameters[3].Value = model.UploadTime;
            parameters[4].Value = model.AttachmentAddress;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Interwebsite.Model.Attachment GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,AttachmentName,UploadName,UploadTime,AttachmentAddress from Attachment ");
            strSql.Append(" where ");
            SqlParameter[] parameters = {
            };

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