function act_onSampleCoefficient($cName, $sampleTypeId)
 {
     //启动一个系数,在一个事务中
     try {
         TransactionBaseModel::begin();
         $set = "SET is_open=0 ";
         $where = "WHERE cName<>'{$cName}' and sampleTypeId='{$sampleTypeId}' ";
         //先将该sampleTypeID下cName<>$cName的is_open设为0
         $affectRow1 = SampleCoefficientModel::updateSampleCoefficient($set, $where);
         $set = "SET is_open=1 ";
         $where = "WHERE cName='{$cName}' and sampleTypeId='{$sampleTypeId}' ";
         //将该sampleTypeID下$cName设为1
         $affectRow2 = SampleCoefficientModel::updateSampleCoefficient($set, $where);
         if (!$affectRow2) {
             //如果is_open=1没有更新的话,则表示已经启动或找不到该记录
             throw new Exception('update error');
         }
         TransactionBaseModel::commit();
         TransactionBaseModel::autoCommit();
         return 1;
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         self::$errCode = "1101";
         self::$errMsg = $e;
         return 0;
     }
 }
 function act_getCnameInfo()
 {
     $id = $_POST['id'];
     $list = SampleCoefficientModel::getSampleCoefficientList("distinct(cName)", "where sampleTypeId = '{$id}'");
     if ($list) {
         return $list;
     } else {
         self::$errCode = SampleCoefficientModel::$errCode;
         self::$errMsg = SampleCoefficientModel::$errMsg;
         return false;
     }
 }
 public function view_addSampleCoefficient()
 {
     if (!isset($_SESSION['userId'])) {
         //检测用户是否登陆
         header('location:index.php?mod=login&act=index');
         exit;
     }
     $sampleCoefficientAct = new SampleCoefficientAct();
     $cName = isset($_POST['cName']) ? post_check(trim($_POST['cName'])) : '';
     $sampleTypeId = isset($_POST['sampleTypeId']) ? post_check($_POST['sampleTypeId']) : '';
     $sizeCodeId = isset($_POST['sizeCodeId']) ? post_check($_POST['sizeCodeId']) : '';
     $Ac = isset($_POST['Ac']) ? post_check($_POST['Ac']) : '';
     $Re = isset($_POST['Re']) ? post_check($_POST['Re']) : '';
     $Al = isset($_POST['Al']) ? post_check($_POST['Al']) : '';
     $Rt = isset($_POST['Rt']) ? post_check($_POST['Rt']) : '';
     if (empty($cName) || empty($sampleTypeId) || empty($sizeCodeId) || trim($Ac) == '' || trim(Re) == '' || trim($Al) == '' || trim(RT) == '') {
         //为空时,跳转到列表页面,输出错误信息
         $status = '添加失败,存在必填项为空的字段';
         header("location:index.php?mod=sampleCoefficient&act=getSampleCoefficientList&status={$status}");
         exit;
     }
     $where = "WHERE cName='{$cName}' AND sampleTypeId='{$sampleTypeId}' AND sizeCodeId='{$sizeCodeId}' ";
     $sampleCoefficientList = $sampleCoefficientAct->act_getSampleCoefficientList('id', $where);
     if (!empty($sampleCoefficientList)) {
         $status = '添加失败,已有相同的系数、样本类型、样本大小记录';
         header("location:index.php?mod=sampleCoefficient&act=getSampleCoefficientList&status={$status}");
         exit;
     }
     $set = "SET cName='{$cName}',sampleTypeId='{$sampleTypeId}',sizeCodeId='{$sizeCodeId}',Ac='{$Ac}',Re='{$Re}',Al='{$Al}',Rt='{$Rt}' ";
     $affectRow = $sampleCoefficientAct->act_addSampleCoefficient($set);
     if ($affectRow >= 1) {
         $status = '添加成功';
     } else {
         $status = '添加失败';
     }
     header("location:index.php?mod=sampleCoefficient&act=getSampleCoefficientList&status={$status}");
 }