示例#1
0
 /**
  * 保存新增/编辑班级数据
  */
 public function updateclass()
 {
     $schcls_schid = Fn::getParam('schcls_schid');
     $schcls_id = Fn::getParam('schcls_id');
     if (!$schcls_schid && !$schcls_id) {
         message('参数错误');
     }
     $schcls_name = Fn::getParam('schcls_name');
     if (!$schcls_name) {
         message('班级名称不能为空');
     }
     $param = array();
     $param['schcls_name'] = trim($schcls_name);
     try {
         //编辑
         if ($schcls_id) {
             $class = SchoolModel::schoolClassInfo($schcls_id);
             if (!$class) {
                 message('班级不存在');
             }
             $schcls_schid = $class['schcls_schid'];
             $param['schcls_id'] = $schcls_id;
             $result = SchoolModel::setSchoolClass($param);
             if ($result) {
                 admin_log('edit', 'school_class', $schcls_id);
             }
         } else {
             $param['schcls_schid'] = $schcls_schid;
             $result = SchoolModel::addSchoolClass($param);
             if ($result) {
                 admin_log('edit', 'school_class', $result);
             }
         }
         message($result ? '操作成功' : '操作失败', '/admin/school/classlist/' . $schcls_schid);
     } catch (Exception $e) {
         message($e->getMessage());
     }
 }