var orderNo;
 
$(function () {  
    $("#tOrder tr td").click(function () {        
        if ($(this).index() > 0) {
            ShowDetail($(this).parent().attr("id"));
        }        
    });

    TdRowOverOut("tOrder");   
});
 
function DeleteOrder(orderNo) {

    synConfirm("警告：操作后将无法恢复。<br/>确定删除选中订单吗?", function () {
        $.blockUI({ message: '<h5>请稍候...</h5>' });
        $.ajax({
            url: "/Order/RealDelete",
            type: 'POST',
            cache: false,
            data: { OrderNumber: orderNo },
            success: function (result) {
                $.unblockUI();
                if (result.code == 0) {
                    location.reload();
                }
                else if (result.code == 1) {
                    alert(result.message);
                }

            },
            error: function (e) {
                $.unblockUI();
                alert('删除失败');
            }
        });
    });
}

function RestoreOrder(orderNo) {
    synConfirm("确定恢复选中订单吗?", function () {
        $.blockUI({ message: '<h5>请稍候...</h5>' });
        $.ajax({
            url: "/Order/Restore",
            type: 'POST',
            cache: false,
            data: { OrderNumber: orderNo },
            success: function (result) {
                $.unblockUI();
                if (result.code == 0) {
                    location.reload();
                }
                else if (result.code == 1) {
                    alert(result.message);
                }

            },
            error: function (e) {
                $.unblockUI();
                alert('恢复失败');
            }
        });
    });


}

function DownLoadFile(no) {
    location.href = "/Order/DownLoadAttachment?FileNo=" + no;
}
 

function btnDelete() {
    ClearErrorMsg();
    if (SelectedNumber() == 0) {

        return SetErrorMsg('请选择纪录');
    }
    

    DeleteOrder(GetSelectedIds());    
}

function btnRestore() {
    ClearErrorMsg();
    if (SelectedNumber() == 0) {
         
        return SetErrorMsg('请选择纪录');
    } 
    RestoreOrder(GetSelectedIds());
}

function GetSelectedName() {
    var result = "";
    $("#orderList").find("input[type=checkbox]").each(function (v, val) {
        if ($(val).prop("checked")) {
            result = $(val).parent().parent().find("td:eq(4)").html();           
        }
    });

    return result;
}

