Ejemplo n.º 1
0
        /// <summary>
        /// 新增部门。
        /// </summary>
        /// <param name="dto">待新增部门的信息。</param>
        /// <returns>新部门的Id。</returns>
        public static string InsertDepartment(DepartmentDTO dto)
        {
            Db.SessionFactory.EvictQueries("Department");

            Department d = new Department();
            d.Id = IdGen.GetNextId(typeof(Department));
            d.Name = dto.Name;
            d.Phone = dto.Phone;
            d.ExtNumber = dto.ExtNumber;
            d.Fax = dto.Fax;
            d.Remark = dto.Remark;
            d.OrderId = dto.OrderId;

            if (dto.ParentDepartmentId != null && dto.ParentDepartmentId.Length > 0)
            {
                Department pd = Db.Session.Load(typeof(Department), dto.ParentDepartmentId) as Department;
                pd.AddSubDepartment(d);
            }

            Db.TransInsert(d);

            return d.Id;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新部门。
        /// </summary>
        /// <param name="dto">待更新部门的信息。</param>
        public static void UpdateDepartment(DepartmentDTO dto)
        {
            Db.SessionFactory.EvictQueries("Department");

            Department d = Db.Session.Load(typeof(Department), dto.Id) as Department;
            d.Name = dto.Name;
            d.Phone = dto.Phone;
            d.ExtNumber = dto.ExtNumber;
            d.Fax = dto.Fax;
            d.Remark = dto.Remark;
            d.OrderId = dto.OrderId;

            Db.TransUpdate(d);
        }