async function getEventLookupCombo($combo, filter, code) {
    var id = $combo.attr('id');
    var url = "";
    var data = null;
    if (id === "cboKol") {
        url = "AccountingApi/GetKolList";
        data = { search: filter, selectedCode: code, pageNo: 1 };
    }
    else if (id === "cboMoain") {
        url = "AccountingApi/GetMoainList";
        data = { kolCode: $("#cboKol").lookupBuilder().getSelectedValue(), checkActive: true, search: filter, selectedCode: code, pageNo: 1 };
    }    
    if (url === "")
        return;

    await ajax({
        url: url,
        data: data,
        success: function (result) {
            if (id === "cboMoain") {
                var newResult = [{ Name: window.top.newAccount, Code: "-1" }];
                result = newResult.concat(result);
            }
            $combo.lookupBuilder().bindData(result);
        }
    });
}
function save() {
    var type = $("#hfType").val();
    var insertMethodName = type === "1" ? "InsertCost" : "InsertIncome";
    var updateMethodName = type === "1" ? "UpdateCost" : "UpdateIncome";
    var data = getJsonValue();
    var code = getQuery("code");
    data['Code'] = code || -1;
    data['Id'] = data["Id"] || -1;
    var exceptionText = checkValidation('');
    if (exceptionText === '') {
        ajax({
            loading: true,
            url: "TreasuryApi/" + (code ? updateMethodName : insertMethodName),
            data: data,
            success: function () {
                showMsgModal(2, window.top.savedSuccessfully);
                refreshParent('loadGrid()');
                closeTopModal();
            }
        });
    }
    else {
        showMsgModal(0, exceptionText);
    }
}
function setMoain() {
    $("#cboMoain").lookupBuilder().setSelectedValue("");
}
