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_addScanSampleCoefficient() { if (!isset($_SESSION['userId'])) { //检测用户是否登陆 header('location:index.php?mod=login&act=index'); exit; } //设置修改页面上指定字段的值 $navarr = $navarr = array("<a href='index.php?mod=sampleStandard&act=skuTypeQcList'>IQC检测标准</a>", ">>", "<a href='index.php?mod=sampleCoefficient&act=getSampleCoefficientList'>系数列表</a>", ">>", "添加系数"); $this->smarty->assign('navarr', $navarr); $this->smarty->assign('module', '添加系数'); $this->smarty->assign('username', $_SESSION['userName']); $this->smarty->assign('sampleTypeList', SampleCoefficientModel::getSampleType()); //所有的样本类型 $this->smarty->assign('sizeCodeList', SampleCoefficientModel::getSizeCode()); //所有的样本大小 $this->smarty->display("addSampleCoefficient.html"); }
public static function getCoefficientSampleTypeName() { self::initDB(); $sql = "SELECT a.sampleTypeId,b.typeName FROM qc_sample_coefficient a,qc_sample_type b where a.sampleTypeId=b.id group by a.sampleTypeId"; $query = self::$dbConn->query($sql); if ($query) { $ret = self::$dbConn->fetch_array_all($query); return $ret; } else { self::$errCode = "2501"; self::$errMsg = "getCoefficientSampleTypeName"; return false; } }