$(document).ready(function () {
    closeLoading();
    $("#divMain").show();
    if (getQuery("code")) {
        $("#txtCode").prop("disabled", true);
    }
});
function save() {
    var data = getJsonValue("");
    var exceptionText = checkValidation("");
    var code = getQuery("code");
    var parentCode = getQuery("p");
    if (exceptionText === "") {
        if (parentCode)
            data["ParentCode"] = parentCode;
        if (code)
            data["Code"] = code;
        data["level"] = getQuery("depth");
        ajax({
            loading: true,
            url: "SaleApi/" + (code === "" ? "InsertProductGroup" : "UpdateProductGroup"),
            data: data,
            success: function (result) {
                var parentMethod = "";
                if (code)
                    parentMethod = "editNodeToTree('" + data["Name"] + "','" + (data["Id"] || "")+"')";
                else
                    parentMethod = "addNodeToTree(" + result.ReturnValue + ",'" + data["Name"] + "','" + (data["Id"] || "") + "')";
                refreshParent(parentMethod);
                closeTopModal();
            }
        });
    }
    else {
        showMsgModal(0, exceptionText);
    }
}
function openSetting() {
    openInModal('', 'Setting/OpeningStoreSetting?type=2&g=1', window.top.setting, '450', '340', true)
}
function refresh() {
    redirectUrl("../sale/productgroupsave");
}

