Пример #1
0
 /// <summary>
 /// 添加系统菜单
 /// </summary>
 /// <param name="menu">
 /// 菜单对象
 /// </param>
 /// <returns>
 /// 菜单编号
 /// </returns>
 public int AddMenu(System_Menu menu)
 {
     return this.systemMenuDA.Insert(menu);
 }
Пример #2
0
        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="menu">
        /// 菜单对象
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// 参数为空异常
        /// </exception>
        /// <exception cref="Exception">
        /// 数据库操作异常
        /// </exception>
        public void Update(System_Menu menu)
        {
            if (menu == null)
            {
                throw new ArgumentNullException("menu");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ID",
                                         SqlDbType.Int,
                                         menu.ID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "PermissionID",
                                         SqlDbType.Int,
                                         menu.PermissionID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ParentID",
                                         SqlDbType.Int,
                                         menu.ParentID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Layer",
                                         SqlDbType.Int,
                                         menu.Layer,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         menu.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "URL",
                                         SqlDbType.VarChar,
                                         menu.URL,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Sorting",
                                         SqlDbType.Int,
                                         menu.Sorting,
                                         ParameterDirection.Input)
                                 };

            try
            {
                this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_System_Menu_Update", parameters, null);
            }
            catch (Exception exception)
            {
                throw new Exception("Exception - SystemMenuDA - Update", exception);
            }
        }
Пример #3
0
 /// <summary>
 /// 修改系统菜单
 /// </summary>
 /// <param name="menu">
 /// 菜单对象
 /// </param>
 public void ModifyMenu(System_Menu menu)
 {
     this.systemMenuDA.Update(menu);
 }
Пример #4
0
        /// <summary>
        /// 添加菜单
        /// </summary>
        /// <param name="menu">
        /// 菜单对象
        /// </param>
        /// <returns>
        /// 主键编号
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// 参数为空异常
        /// </exception>
        /// <exception cref="Exception">
        /// 数据库操作异常
        /// </exception>
        public int Insert(System_Menu menu)
        {
            if (menu == null)
            {
                throw new ArgumentNullException("menu");
            }

            int id;
            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "PermissionID",
                                         SqlDbType.Int,
                                         menu.PermissionID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ParentID",
                                         SqlDbType.Int,
                                         menu.ParentID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Layer",
                                         SqlDbType.Int,
                                         menu.Layer,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         menu.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "URL",
                                         SqlDbType.VarChar,
                                         menu.URL,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Sorting",
                                         SqlDbType.Int,
                                         menu.Sorting,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "CreateTime",
                                         SqlDbType.DateTime,
                                         menu.CreateTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ReferenceID",
                                         SqlDbType.Int,
                                         null,
                                         ParameterDirection.Output)
                                 };

            try
            {
                this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_System_Menu_Insert", parameters, null);
                id = (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value;
            }
            catch (Exception exception)
            {
                throw new Exception("Exception - SystemMenuDA - Insert", exception);
            }

            return id;
        }