Ejemplo n.º 1
0
if ($_GET['action'] == "delete_array") {
    $selectid = $_GET['selectid'];
    $selectid = explode(",", $selectid);
    try {
        //开启事务
        $CaiWu = new CaiWu($db);
        $db->StartTrans();
        for ($i = 0; $i < sizeof($selectid); $i++) {
            if ($selectid[$i] != "") {
                $billid = $selectid[$i];
                $sql = "update buyplanmain set user_flag=-1 where billid={$billid} and user_flag>-1";
                $rs = $db->Execute($sql);
                if ($rs === false) {
                    throw new Exception("不存在此记录");
                }
                $CaiWu->deleteFukuanReocordByBillid($billid);
                $CaiWu->deleteshoupiaoByBillid($billid);
            }
        }
        $db->CompleteTrans();
        page_css("");
        //是否事务出现错误
        if ($db->HasFailedTrans()) {
            throw new Exception($db->ErrorMsg());
        } else {
            $return = FormPageAction("action", "init_default");
            print_infor("采购单已撤销", 'trip', "location='?{$return}'", "?{$return}", 0);
        }
    } catch (Exception $e) {
        print "<script language=javascript>alert('错误:" . $e->getMessage() . "');window.history.back(-1);</script>";
    }