Ejemplo n.º 1
0
        /// <summary>
        /// 增加部门
        /// </summary>
        /// <param name="department">
        /// 部门对象
        /// </param>
        /// <returns>
        /// 主键编号
        /// </returns>
        public int Insert(System_Department department)
        {
            if (department == null)
            {
                throw new ArgumentNullException("department");
            }

            int id;
            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         department.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Principal",
                                         SqlDbType.NVarChar,
                                         department.Principal,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "PrincipalMobile",
                                         SqlDbType.NVarChar,
                                         department.PrincipalMobile,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Headcount",
                                         SqlDbType.Int,
                                         department.Headcount,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Description",
                                         SqlDbType.NVarChar,
                                         department.Description ?? string.Empty,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "CreateTime",
                                         SqlDbType.DateTime,
                                         department.CreateTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ReferenceID",
                                         SqlDbType.Int,
                                         null,
                                         ParameterDirection.Output)
                                 };

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

            return id;
        }
 /// <summary>
 /// 修改部门
 /// </summary>
 /// <param name="department">
 /// 部门对象
 /// </param>
 public void ModifyDepartment(System_Department department)
 {
     this.systemDepartmentDA.Update(department);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改部门
        /// </summary>
        /// <param name="department">
        /// 部门对象
        /// </param>
        public void Update(System_Department department)
        {
            if (department == null)
            {
                throw new ArgumentNullException("department");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ID",
                                         SqlDbType.Int,
                                         department.ID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         department.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Principal",
                                         SqlDbType.NVarChar,
                                         department.Principal,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "PrincipalMobile",
                                         SqlDbType.NVarChar,
                                         department.PrincipalMobile,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Headcount",
                                         SqlDbType.Int,
                                         department.Headcount,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Description",
                                         SqlDbType.NVarChar,
                                         department.Description,
                                         ParameterDirection.Input)
                                 };

            try
            {
                this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_System_Department_Update", parameters, null);
            }
            catch (Exception exception)
            {
                throw new Exception("Exception - SystemDepartmentDA - Update", exception);
            }
        }
 /// <summary>
 /// 添加部门
 /// </summary>
 /// <param name="department">
 /// 部门对象
 /// </param>
 /// <returns>
 /// 部门编号
 /// </returns>
 public int AddDepartment(System_Department department)
 {
     return this.systemDepartmentDA.Insert(department);
 }