コード例 #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(ADT.XingZhi.Models.S.File model)
 {
     try
     {
         StringBuilder strSql = new StringBuilder();
         strSql.Append("INSERT INTO [S_FILE] (");
         strSql.Append("F_ID,F_PATH,F_TITLE,F_EXT,F_SIZE,F_OBJECTTYPE,F_CREATEBY,F_CREATETIME,F_IP,F_EXTRA)");
         strSql.Append(" VALUES (");
         strSql.Append("@id,@path,@title,@ext,@size,@objectType,@createby,@createtime,@ip,@extra)");
         SqlParameter[] param =
         {
             new SqlParameter("@id",         SqlDbType.VarChar,    36),
             new SqlParameter("@path",       SqlDbType.VarChar,   100),
             new SqlParameter("@title",      SqlDbType.NVarChar,  100),
             new SqlParameter("@extension",  SqlDbType.VarChar,    10),
             new SqlParameter("@size",       SqlDbType.BigInt),
             new SqlParameter("@objectType", SqlDbType.VarChar,    30),
             new SqlParameter("@createby",   SqlDbType.NVarChar,   30),
             new SqlParameter("@createtime", SqlDbType.DateTime),
             new SqlParameter("@ip",         SqlDbType.VarChar,    30),
             new SqlParameter("@extra",      SqlDbType.VarChar, 255)
         };
         param[0].Value = model.Id;
         param[1].Value = model.Path;
         param[2].Value = model.Title;
         param[3].Value = model.Ext;
         param[4].Value = model.Size;
         param[5].Value = model.ObjectType;
         param[6].Value = model.CreateBy;
         param[7].Value = model.CreateTime;
         param[8].Value = model.IP;
         param[9].Value = model.Extra;
         return(SqlHelper.ExecuteNonQuery(DefaultConnection.ConnectionStringByDefaultDB, CommandType.Text, strSql.ToString(), param));
     }
     catch (ArgumentNullException ex)
     {
         logger.Error("调用方法Add(ADT.XingZhi.Models.S.File model)发生ArgumentNullException", ex);
     }
     catch (SqlException ex)
     {
         logger.Error("调用方法Add(ADT.XingZhi.Models.S.File model)发生SqlException", ex);
     }
     catch (Exception ex)
     {
         logger.Error("调用方法Add(ADT.XingZhi.Models.S.File model)发生Exception", ex);
     }
     return(-1);
 }
コード例 #2
0
 /// <summary>
 /// 保存一条数据
 /// </summary>
 public int Add(ADT.XingZhi.Models.S.File model)
 {
     return(dal.Add(model));
 }