Saturday, March 15, 2014

/*==== Created By :  Rubol
*     Date Created : June 29,2013
========================================*/

var fundTotAnnualPerformanceContent = {};

fundTotAnnualPerformanceContent = {


    addFundTotAnnualPerformance: function (mStarInvestmentId) {
        $("#divAvgAnnualReturn").dialog({
            title: 'Fund Performance Form',
            width: 900,
            height: 650,
            closed: false,
            cache: false,
            minimizable: true,
            maximizable: true,
            collapsible: true,
            draggable: true,
            href: util.FullURLByAction('FundTotAnnualPerformance/Create?mStarInvestmentId=' + mStarInvestmentId),
            modal: true,
            onLoad: function () {

                $('#FARShortName').val($('#FundName').val());
                $('#FARLegalName').val($('#LegalName').val());
                $('#FARFundFamily').val($('#FundFamilyName').val());
                $('#FARTicker').val($('#Ticker').val());

                $('#FARInceptionDate').val($('#InceptionDate').val());
                $('#FARInvestmentType').val($('#FundForm #RKFundTypeId').data("kendoDropDownList").text());
                $('#FARFundCategory').val($('#MorningstarCategory').val());
                $('#FARCUSIP').val($('#CUSIP').val());
                $('#FARMorningstarID').val($('#MstarInvestmentID').val());

                $('#FARAsOfDate').val($('#AsOfDate').val());


                $('#FARExpenseRatioNet').val($('#NetExpenseRatio').val());
                $('#FARExpenseRatioAnn').val($('#AnnualReportNetExpenseRatio').val());
                $('#FARActual12b1').val($('#Actual12B1').val());

                //$('#primarybenchmark').hide();
            },
            toolbar: [{
                iconCls: 'delete-icon',
                text: 'Delete',
                handler: function () {
                    fundTotAnnualPerformanceContent.deleteFundTotAnnualPerformance(null)
                }

            }, {
                iconCls: 'save-icon',
                text: 'Save',
                handler: function () {
                    fundTotAnnualPerformanceContent.SaveFundTotAnnualPerformance()
                }
            }],
        });
    },

    SaveFundTotAnnualPerformance: function () {
        $.ajax({
            url: util.FullURLByAction('FundTotAnnualPerformance/SaveFundTotAnnualPerformance'),
            type: 'POST',
            data: $('#AvgAnnualReturnForm').serialize(),
            dataType: 'json',
            success: function (result) {
                $("#divAvgAnnualReturn").dialog("close");
                if (result.Success == true) {
                    $.messager.alert('Data Save', 'Data Successfully Saved!', 'info');
                    fundTotAnnualPerformanceContent.refreshFundTotAnnualPerformance();
                }
                else {
                    alert('Error occured while saving: ' + result.ErrorMessage);
                }
            }
        });
    },

    editFundTotAnnualPerformance: function (id) {

        //var node = $tg.datagrid('getSelected');

        if (id != '00000000-0000-0000-0000-000000000000') {
            $("#divAvgAnnualReturn").dialog({
                title: 'Fund Performance Form',
                width: 900,
                height: 650,
                closed: false,
                cache: false,
                minimizable: true,
                maximizable: true,
                collapsible: true,
                draggable: true,
                href: util.FullURLByAction('FundTotAnnualPerformance/Edit/' + id),
                modal: true,
                onLoad: function () {

                    $('#FARShortName').val($('#FundName').val());
                    $('#FARLegalName').val($('#LegalName').val());
                    $('#FARFundFamily').val($('#FundFamilyName').val());
                    $('#FARTicker').val($('#Ticker').val());

                    $('#FARInceptionDate').val($('#InceptionDate').val());
                    $('#FARInvestmentType').val($('#FundForm #RKFundTypeId').data("kendoDropDownList").text());
                    $('#FARFundCategory').val($('#MorningstarCategory').val());
                    $('#FARCUSIP').val($('#CUSIP').val());
                    $('#FARMorningstarID').val($('#MstarInvestmentID').val());

                    $('#FARAsOfDate').val($('#AsOfDate').val());

                    $('#FARExpenseRatioNet').val($('#NetExpenseRatio').val());
                    $('#FARExpenseRatioAnn').val($('#AnnualReportNetExpenseRatio').val());
                    $('#FARActual12b1').val($('#Actual12B1').val());

                    //$('#primarybenchmark').hide();
                },
                toolbar: [{
                    iconCls: 'delete-icon',
                    text: 'Delete',
                    handler: function () {
                        fundTotAnnualPerformanceContent.deleteFundTotAnnualPerformance(id)
                    }

                }, {
                    iconCls: 'save-icon',
                    text: 'Save',
                    handler: function () {
                        fundTotAnnualPerformanceContent.SaveFundTotAnnualPerformance()
                    }
                }],
            });
        }
    },

    deleteFundTotAnnualPerformance: function (id) {
        //var node = $tg.datagrid('getSelected');
        debugger;
        if (id != '00000000-0000-0000-0000-000000000000') {
            $.messager.confirm('Confirm', 'Are you sure you want to delete the record?', function (r) {
                if (r) {
                    $.ajax({
                        url: util.FullURLByAction('FundTotAnnualPerformance/DeleteFundTotAnnualPerformance/' + id),
                        type: 'POST',
                        async: false,
                        success: function (result) {
                            if (result) {
                                $("#divAvgAnnualReturn").dialog("close");
                                fundTotAnnualPerformanceContent.refreshFundTotAnnualPerformance();

                            }

                        }
                    });
                }
            });
        }
    },

    addPrimaryBenchmark: function (mStarInvestmentId) {
        $("#divPrimaryBenchMark").dialog({
            title: 'Fund Performance Form',
            width: 950,
            height: 400,
            closed: false,
            cache: false,
            href: util.FullURLByAction('FundTotAnnualPerformance/CreatePrimaryBenchmark?mStarInvestmentId=' + mStarInvestmentId),
            modal: true,
            onLoad: function () {

                $('#BenchmarkId').val($('#MorningstarPrimaryBenchmarkID').val());
                $('#BenchmarkName').val($('#MorningstarPrimaryBenchmarkName').val());
                //$('#BenchmarkDateCreated').val($('#FundFamilyName').val());

                //$('#avgExpenses').hide();
                //$('#avgStatus').hide();
                //$('#avgDetails').hide();
                //$('#avgOverview').hide();

            },
            toolbar: [{
                iconCls: 'delete-icon',
                text: 'Delete',
                handler: function () {
                    fundTotAnnualPerformanceContent.deleteFundPrimaryBenchMark(null)
                }

            }, {
                iconCls: 'save-icon',
                text: 'Save',
                handler: function () {
                    fundTotAnnualPerformanceContent.SavePrimaryBenchmark()
                }
            }],
        });
    },
    SavePrimaryBenchmark: function (id) {
        $.ajax({
            url: util.FullURLByAction('FundTotAnnualPerformance/SaveFundTotAnnualPerformance'),
            type: 'POST',
            data: $('#PrimaryBenchmarkReturnForm').serialize(),
            dataType: 'json',
            success: function (result) {
                $("#divPrimaryBenchMark").dialog("close");
                if (result.Success == true) {
                    $.messager.alert('Data Save', 'Data Successfully Saved!', 'info');
                    fundTotAnnualPerformanceContent.refreshFundPrimaryBenchmark();
                }
                else {
                    alert('Error occured while saving: ' + result.ErrorMessage);
                }
            }
        });
    },

    editPrimaryBenchmark: function (id) {

        //var node = $tg.datagrid('getSelected');

        if (id != '00000000-0000-0000-0000-000000000000') {
            $("#divPrimaryBenchMark").dialog({
                title: 'Fund Performance Form',
                width: 950,
                height: 400,
                closed: false,
                cache: false,
                href: util.FullURLByAction('FundTotAnnualPerformance/EditPrimaryBenchMark/' + id),
                modal: true,
                onLoad: function () {

                    $('#BenchmarkId').val($('#MorningstarPrimaryBenchmarkID').val());
                    $('#BenchmarkName').val($('#MorningstarPrimaryBenchmarkName').val());
                    //$('#BenchmarkDateCreated').val($('#FundFamilyName').val());

                    //$('#avgExpenses').hide();
                    //$('#avgStatus').hide();
                    //$('#avgDetails').hide();
                    //$('#avgOverview').hide();

                },
                toolbar: [{
                    iconCls: 'deletge-icon',
                    text: 'Delete',
                    handler: function () {
                        fundTotAnnualPerformanceContent.deleteFundPrimaryBenchMark(id)
                    }

                }, {
                    iconCls: 'save-icon',
                    text: 'Save',
                    handler: function () {
                        fundTotAnnualPerformanceContent.SavePrimaryBenchmark()
                    }
                }],
            });
        }
    },

    deleteFundPrimaryBenchMark: function (id) {
        //var node = $tg.datagrid('getSelected');
        if (id != '00000000-0000-0000-0000-000000000000') {
            $.messager.confirm('Confirm', 'Are you sure you want to delete the record?', function (r) {
                if (r) {
                    $.ajax({
                        url: util.FullURLByAction('FundTotAnnualPerformance/DeleteFundTotAnnualPerformance/' + id),
                        type: 'POST',
                        async: false,
                        success: function (result) {
                            if (result) {
                                $("#divPrimaryBenchMark").dialog("close");
                                fundTotAnnualPerformanceContent.refreshFundPrimaryBenchmark();
                            }
                        }
                    });
                }
            });
        }
    },

    refreshFundTotAnnualPerformance: function () {
        $("#grid-FundAvgAnnualReturn").data("kendoGrid").dataSource.read();
    },

    refreshFundPrimaryBenchmark: function () {
        $("#grid-FundPrimaryBenchMark").data("kendoGrid").dataSource.read();
    }
};


$(document).ready(function () {

    $("#add-AvgAnnualReturn").click(function () {

        fundTotAnnualPerformanceContent.addFundTotAnnualPerformance($('#MstarInvestmentID').val());
    });


    $("#edit-AvgAnnualReturn").click(function () {
        var grid = $("#grid-FundAvgAnnualReturn").data("kendoGrid");
        var row = grid.select();
        var dataItem = grid.dataItem(row);
        if (!dataItem) $.messager.confirm('Warning', 'Please select a row first.');
        var id = dataItem.Id;
        fundTotAnnualPerformanceContent.editFundTotAnnualPerformance(id);
    });

    $("#grid-FundAvgAnnualReturn", this).dblclick(function (e) {

        var grid = $("#grid-FundAvgAnnualReturn").data("kendoGrid");
        var row = grid.select();
        var dataItem = grid.dataItem(row);
        var id = dataItem.Id;
        fundTotAnnualPerformanceContent.editFundTotAnnualPerformance(id);
    });



    $("#add-PrimaryBenchMark").click(function () {
        fundTotAnnualPerformanceContent.addPrimaryBenchmark($('#MstarInvestmentID').val());
    });


    $("#edit-PrimaryBenchMark").click(function () {
        var grid = $("#grid-FundPrimaryBenchMark").data("kendoGrid");
        var row = grid.select();
        var dataItem = grid.dataItem(row);
        if (!dataItem) $.messager.confirm('Warning', 'Please select a row first.');
        var id = dataItem.Id;
        fundTotAnnualPerformanceContent.editPrimaryBenchmark(id);
    });

    $("#grid-FundPrimaryBenchMark", this).dblclick(function (e) {

        var grid = $("#grid-FundPrimaryBenchMark").data("kendoGrid");
        var row = grid.select();
        var dataItem = grid.dataItem(row);
        var id = dataItem.Id;
        fundTotAnnualPerformanceContent.editPrimaryBenchmark(id);
    });


});




No comments:

Post a Comment