Example #1
0
 public JResult GetAllCity()
 {
     BaseDepartmentModel model = new BaseDepartmentModel();
     return _baseservice.GetAllDepartment(model);
 }
Example #2
0
 public JResult AddDepartment(BaseDepartmentModel model)
 {
     return _baseservice.AddDepartment(model);
 }
Example #3
0
 public JResult UpdateDepartment(BaseDepartmentModel model)
 {
     return _baseservice.UpdateDepartment(model);
 }
Example #4
0
        /// <summary>
        /// 获取所有部门
        /// </summary>
        /// <returns></returns>
        public IEnumerable<BaseDepartmentViewModel> GetAllDepartment(BaseDepartmentModel model)
        {
            StringBuilder sqlwhere = new StringBuilder();
            //innerid
            if (!string.IsNullOrWhiteSpace(model.id))
            {
                sqlwhere.AppendFormat(" and id ='{0}' ", model.id);
            }
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"select `id`, `name`, `areaid`, `tel`, `email`, `sort`, `remark`, `code`
                                from sys_department where 1=1 {0} order by sort asc ;", sqlwhere.ToString());

            var menuList = Helper.Query<BaseDepartmentViewModel>(sql.ToString());
            return menuList;
        }
Example #5
0
 /// <summary>
 /// 添加部门
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int AddDepartment(BaseDepartmentModel model)
 {
     const string sql = @"INSERT INTO `sys_department`
                         (`id`, `name`, `areaid`, `tel`, `email`, `sort`, `remark`, `code`)
                         VALUES
                         (uuid(), @name, @areaid, @tel, @email, @sort, @remark, @code);";
     using (var conn = Helper.GetConnection())
     {
         try
         {
             conn.Execute(sql, model);
             return 1;
         }
         catch (Exception ex)
         {
             return 0;
         }
     }
 }
Example #6
0
 /// <summary>
 /// 更新部门
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateDepartment(BaseDepartmentModel model)
 {
     var sql = new StringBuilder("update `sys_department` set ");
     sql.Append(Helper.CreateField(model).Trim().TrimEnd(','));
     sql.Append(" where id = @id");
     int result;
     try
     {
         result = Helper.Execute(sql.ToString(), model);
     }
     catch (Exception ex)
     {
         result = 0;
     }
     return result;
 }