﻿MainItem_Class = function() { };
////////////////////////////////////
MainItem_Class.prototype = {

    RightMenu: function() {
        var classPath = "Main.BL.MainItemBL";
        var methodName = "MainItemSelectAll";

        $.ajax({
            url: "Handler.ashx",
            dataType: "json",
            data: "ClassPath=" + classPath + "&MethodName=" + methodName,
            type: "POST",
            timeout: GlobalVariable.AjaxTimeOut,
            beforeSend: function() {
                Other.showNotify("Đang tải dữ liệu...");
            },
            success: function(result) {
                if (result.Objects != null) {
                    $("#C-Main-Right").setTemplateURL("./Template/MainItem/RightMenu.htm");
                    $("#C-Main-Right").processTemplate(result);
                }
            },
            error: function(xhr, message, ex) {
                //alert(GlobalVariable.MsgErrorLoadData);
            },
            complete: function() {
                Other.hideNotify();
                //Load TodayTemplate below
                eval(GlobalVariable.MainItem + ".TodayTemplate(1);");
                //Load TaiTroTemplate below
                eval(GlobalVariable.MainItem + ".TaiTroTemplate(1);");
            }
        });
    },


    //Use only for Listbox type///////////////////////////////////////////////
    ListAll: function(element) {
        var classPath = "Main.BL.MainItemBL";
        var methodName = "MainItemListAll";
        var data;

        $.ajax({
            url: "Handler.ashx",
            dataType: "json",
            data: "ClassPath=" + classPath + "&MethodName=" + methodName,
            type: "POST",
            timeout: GlobalVariable.AjaxTimeOut,
            success: function(result) {
                if (result.Success == "True") {
                    element.html(element.html() + result.Data);
                }
                else {
                    alert(GlobalVariable.MsgErrorLoadData);
                }
            },
            error: function(xhr, message, ex) {
                //alert(GlobalVariable.MsgErrorLoadData);
            },
            complete: function() {
                element.val(GlobalVariable.MainItem);
            }
        });
    }


};

var MainItem = new MainItem_Class();


