Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Mail_Test.Model.fjlist model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update fjlist set ");
            strSql.Append("mailid=@mailid,");
            strSql.Append("filename=@filename");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@mailid",   SqlDbType.Int,       4),
                new SqlParameter("@filename", SqlDbType.VarChar, 150),
                new SqlParameter("@id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.mailid;
            parameters[1].Value = model.filename;
            parameters[2].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Mail_Test.Model.fjlist model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into fjlist(");
            strSql.Append("mailid,filename)");
            strSql.Append(" values (");
            strSql.Append("@mailid,@filename)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@mailid",   SqlDbType.Int,     4),
                new SqlParameter("@filename", SqlDbType.VarChar, 150)
            };
            parameters[0].Value = model.mailid;
            parameters[1].Value = model.filename;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 存储附件信息
        /// </summary>
        /// <param name="flist"></param>
        /// <param name="mailid"></param>
        private void savefj(ArrayList flist, int mailid)
        {
            fjlist bf = new fjlist();

            foreach (string file in flist)
            {
                Mail_Test.Model.fjlist model = new Mail_Test.Model.fjlist();
                model.mailid   = mailid;
                model.filename = file;
                bf.Add(model);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Mail_Test.Model.fjlist DataRowToModel(DataRow row)
 {
     Mail_Test.Model.fjlist model = new Mail_Test.Model.fjlist();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["mailid"] != null && row["mailid"].ToString() != "")
         {
             model.mailid = int.Parse(row["mailid"].ToString());
         }
         if (row["filename"] != null)
         {
             model.filename = row["filename"].ToString();
         }
     }
     return(model);
 }
Esempio n. 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Mail_Test.Model.fjlist GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

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

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