﻿var ipage = -1;

function ImprimirPagina()
{
  if (window.print)
    window.print();
}

function ShowHideCustomizationWindow(aGrid)
{
  if (aGrid == null) return;
  if (aGrid.IsCustomizationWindowVisible())
    aGrid.HideCustomizationWindow();
  else aGrid.ShowCustomizationWindow();
}

function ToolBarProcess(cControl, sComando, bEstado)
{
  if (cControl == null || sComando == null) return;
  switch (sComando)
  {
    //case 'Propiedades': 
    //case 'Enviar': 
    //case 'AbrirExpandir': cControl.ExpandDetailRow(cControl.GetFocusedRowIndex()); break;
    case 'eventProcesar': if (confirm('¿Está seguro de procesar el registro seleccionado?'))
        cControl.PerformCallback(sComando); break;
    case 'eventAnular': if (confirm('¿Está seguro de anular el registro seleccionado?'))
        cControl.PerformCallback(sComando); break;
    case 'eventClonar': if (confirm('¿Está seguro de clonar el registro seleccionado?'))
        cControl.PerformCallback(sComando); break;
    case 'eventEliminar': if (confirm('¿Está seguro de eliminar el registro seleccionado?'))
        cControl.PerformCallback(sComando); break;
    case 'gridSelectCols': ShowHideCustomizationWindow(cControl); break;
    default: cControl.PerformCallback(sComando + ':' + bEstado); break;
  }
}

function OnCallBackComplete(s, e)
{
  LoadingPanel.Hide();
  if (e.result != '') alert(e.result);
}

function ChangeIGV(s, e)
{
  COS_IGV.SetNumber(s.GetNumber() * 0.19);
  ChangeTOTAL(s, e);
}

function ChangeTOTAL(s, e)
{
  COS_TOTAL.SetNumber(COS_BASIMP.GetNumber() + COS_IGV.GetNumber() + COS_ISC.GetNumber() + COS_OTROS.GetNumber());
}

function OnDepartamentosChanged(cbComboBox)
{
  if (cbComboBox == cbDepartamentos) { cbProvincias.PerformCallback(cbComboBox.GetValue().toString()); cbDistritos.ClearItems(); cbCiudades.ClearItems(); }
  else if (cbComboBox == cbProvincias) { cbDistritos.PerformCallback(cbComboBox.GetValue().toString()); cbCiudades.ClearItems(); }
  else if (cbComboBox == cbDistritos) cbCiudades.PerformCallback(cbComboBox.GetValue().toString());
}

function OnDepartamentoChanged(cbComboBox)
{
  if (cbComboBox == cbDepartamentos) { cbProvincias.PerformCallback(cbComboBox.GetValue().toString()); cbDistritos.ClearItems(); }
  else if (cbComboBox == cbProvincias) { cbDistritos.PerformCallback(cbComboBox.GetValue().toString()); }
}