Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(IPSP.Model.T_FileFolder model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_FileFolder(");
            strSql.Append("s_FolderName,n_UpperFolderID,s_FolderCategory,n_UserID)");
            strSql.Append(" values (");
            strSql.Append("@s_FolderName,@n_UpperFolderID,@s_FolderCategory,@n_UserID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_FolderName",     SqlDbType.NVarChar, 50),
                new SqlParameter("@n_UpperFolderID",  SqlDbType.Int,       4),
                new SqlParameter("@s_FolderCategory", SqlDbType.NVarChar, 10),
                new SqlParameter("@n_UserID",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.s_FolderName;
            parameters[1].Value = model.n_UpperFolderID;
            parameters[2].Value = model.s_FolderCategory;
            parameters[3].Value = model.n_UserID;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public IPSP.Model.T_FileFolder DataRowToModel(DataRow row)
 {
     IPSP.Model.T_FileFolder model = new IPSP.Model.T_FileFolder();
     if (row != null)
     {
         if (row["n_FolderID"] != null && row["n_FolderID"].ToString() != "")
         {
             model.n_FolderID = int.Parse(row["n_FolderID"].ToString());
         }
         if (row["s_FolderName"] != null)
         {
             model.s_FolderName = row["s_FolderName"].ToString();
         }
         if (row["n_UpperFolderID"] != null && row["n_UpperFolderID"].ToString() != "")
         {
             model.n_UpperFolderID = int.Parse(row["n_UpperFolderID"].ToString());
         }
         if (row["s_FolderCategory"] != null)
         {
             model.s_FolderCategory = row["s_FolderCategory"].ToString();
         }
         if (row["n_UserID"] != null && row["n_UserID"].ToString() != "")
         {
             model.n_UserID = int.Parse(row["n_UserID"].ToString());
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(IPSP.Model.T_FileFolder model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_FileFolder set ");
            strSql.Append("s_FolderName=@s_FolderName,");
            strSql.Append("s_FolderCategory=@s_FolderCategory");
            strSql.Append(" where n_FolderID=@n_FolderID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_FolderName",     SqlDbType.NVarChar, 50),
                new SqlParameter("@s_FolderCategory", SqlDbType.NVarChar, 10),
                new SqlParameter("@n_FolderID",       SqlDbType.Int,       4),
                new SqlParameter("@n_UpperFolderID",  SqlDbType.Int,       4),
                new SqlParameter("@n_UserID",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.s_FolderName;
            parameters[1].Value = model.s_FolderCategory;
            parameters[2].Value = model.n_FolderID;
            parameters[3].Value = model.n_UpperFolderID;
            parameters[4].Value = model.n_UserID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public IPSP.Model.T_FileFolder GetModel(int n_FolderID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 n_FolderID,s_FolderName,n_UpperFolderID,s_FolderCategory,n_UserID from T_FileFolder ");
            strSql.Append(" where n_FolderID=@n_FolderID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@n_FolderID", SqlDbType.Int, 4)
            };
            parameters[0].Value = n_FolderID;

            IPSP.Model.T_FileFolder model = new IPSP.Model.T_FileFolder();
            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(IPSP.Model.T_FileFolder model)
 {
     return(dal.Update(model));
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(IPSP.Model.T_FileFolder model)
 {
     return(dal.Add(model));
 }