Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(IPSP.Model.T_Right model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Right(");
            strSql.Append("s_RightName,n_ParentID,s_Description,s_CodeName,s_FromModule)");
            strSql.Append(" values (");
            strSql.Append("@s_RightName,@n_ParentID,@s_Description,@s_CodeName,@s_FromModule)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_RightName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@n_ParentID",    SqlDbType.Int,        4),
                new SqlParameter("@s_Description", SqlDbType.NVarChar, 100),
                new SqlParameter("@s_CodeName",    SqlDbType.NVarChar, 100),
                new SqlParameter("@s_FromModule",  SqlDbType.NVarChar, 100)
            };
            parameters[0].Value = model.s_RightName;
            parameters[1].Value = model.n_ParentID;
            parameters[2].Value = model.s_Description;
            parameters[3].Value = model.s_CodeName;
            parameters[4].Value = model.s_FromModule;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public IPSP.Model.T_Right DataRowToModel(DataRow row)
 {
     IPSP.Model.T_Right model = new IPSP.Model.T_Right();
     if (row != null)
     {
         if (row["n_RightID"] != null && row["n_RightID"].ToString() != "")
         {
             model.n_RightID = int.Parse(row["n_RightID"].ToString());
         }
         if (row["s_RightName"] != null)
         {
             model.s_RightName = row["s_RightName"].ToString();
         }
         if (row["n_ParentID"] != null && row["n_ParentID"].ToString() != "")
         {
             model.n_ParentID = int.Parse(row["n_ParentID"].ToString());
         }
         if (row["s_Description"] != null)
         {
             model.s_Description = row["s_Description"].ToString();
         }
         if (row["s_CodeName"] != null)
         {
             model.s_CodeName = row["s_CodeName"].ToString();
         }
         if (row["s_FromModule"] != null)
         {
             model.s_FromModule = row["s_FromModule"].ToString();
         }
     }
     return(model);
 }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(IPSP.Model.T_Right model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Right set ");
            strSql.Append("s_RightName=@s_RightName,");
            strSql.Append("n_ParentID=@n_ParentID,");
            strSql.Append("s_Description=@s_Description,");
            strSql.Append("s_CodeName=@s_CodeName,");
            strSql.Append("s_FromModule=@s_FromModule");
            strSql.Append(" where n_RightID=@n_RightID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_RightName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@n_ParentID",    SqlDbType.Int,        4),
                new SqlParameter("@s_Description", SqlDbType.NVarChar, 100),
                new SqlParameter("@s_CodeName",    SqlDbType.NVarChar, 100),
                new SqlParameter("@s_FromModule",  SqlDbType.NVarChar, 100),
                new SqlParameter("@n_RightID",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.s_RightName;
            parameters[1].Value = model.n_ParentID;
            parameters[2].Value = model.s_Description;
            parameters[3].Value = model.s_CodeName;
            parameters[4].Value = model.s_FromModule;
            parameters[5].Value = model.n_RightID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public IPSP.Model.T_Right GetModel(int n_RightID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 n_RightID,s_RightName,n_ParentID,s_Description,s_CodeName,s_FromModule from T_Right ");
            strSql.Append(" where n_RightID=@n_RightID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@n_RightID", SqlDbType.Int, 4)
            };
            parameters[0].Value = n_RightID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(IPSP.Model.T_Right model)
 {
     return(dal.Update(model));
 }
Beispiel #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(IPSP.Model.T_Right model)
 {
     return(dal.Add(model));
 }