2 using System.ComponentModel;
14 using System.Collections.Generic;
27 public bool ModoPlantilla
29 get {
return _lModoPlantilla; }
32 var hayCambio = (value != _lModoPlantilla);
33 _lModoPlantilla = value;
37 ConfigurarGridSecundarias();
41 private bool _lModoPlantilla =
false;
49 InitializeComponent();
53 _nDecimales = Convert.ToInt32(EW_GLOBAL._GetVariable(
"wn_decimales"));
54 _lSecundar = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_secundar"));
55 _lSecManual = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_secman"));
56 _lSecRepAsiAutomatico = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_repasi"));
57 _lSecRepPorcentaje = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_distsec"));
58 _lTodacuen = (Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_todacuen")));
59 _lSoloNivelesDefinidos = (Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_solonivdef")));
61 _lColNivel2Visible = !Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_Secunico"));
63 _nAnchoCodigoAnaliticoCompleto = Convert.ToInt16(Convert.ToInt16(EW_GLOBAL._Empresa != null ? EW_GLOBAL._GetLenCampo(
KeyDiccionarioLenCampos.wn_analiticocompleto) : 9));
67 _Grid = mantegridSecundarias._Grid;
69 ewtextboxTotalSecundarias.ReadOnly =
true;
70 ewlabelTotalNA2.Visible = _lColNivel2Visible;
71 ewtextboxTotalSecundarias1.Visible = _lColNivel2Visible;
75 ConfigurarSecundarias();
76 SubscripcionEventos();
80 # endregion Constructor 82 # region Propiedades privadas 84 private bool _lSecManual =
false;
85 private bool _lSecundar =
true;
86 private bool _lSecRepAsiAutomatico =
false;
87 private bool _lSecRepPorcentaje =
false;
88 private bool _lColNivel2Visible =
true;
89 private ewbutton _oBotonOpciones = null;
91 private bool _bReadOnly =
false;
92 private bool _lFocusLineasAsiento =
false;
97 private string _lcPlanContable =
string.Empty;
98 private int _nPlanAnalitico = 1;
99 private int _nAnchoCodigoAnaliticoCompleto = 5;
104 private bool _lTodacuen =
false;
108 private bool _lSoloNivelesDefinidos = (Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_solonivdef")));
109 private bool _lColPorcentajeVisible = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"Wl_DistSec"));
114 private int _nLenAnalitica
123 private int _nAnchoColumnaAnalitica
127 int lnDigitos = 0, lnLongCuentaAnalitica = 0;
129 if (_lPlanAnaliticoCompleto)
130 lnDigitos = _nLenAnalitica;
134 lnLongCuentaAnalitica = Convert.ToInt32(Math.Max(lnDigitos, 8) * mantegridSecundarias._Grid.Font.Size);
136 return lnLongCuentaAnalitica;
144 private bool _lPlanAnaliticoCompleto
146 get {
return ((EW_GLOBAL._Empresa != null ? (EW_GLOBAL._Empresa._ImputarPor == 0) :
false)); }
152 private string _cHeaderCodigoPlanAnaliticoCompleto
156 if (_oNegocio != null)
166 private string _cHeaderDefiniciónPlanAnaliticoCompleto
170 return "Nombre del " + _cHeaderCodigoPlanAnaliticoCompleto;
174 # endregion Propiedades privadas 176 # region Propiedades públicas 177 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
186 public bool _ReadOnly
188 get {
return _bReadOnly; }
193 mantegridSecundarias._ReadOnly = _bReadOnly;
202 mantegridSecundarias._Grid.Columns[
"CuentaNA1"].ReadOnly =
true;
204 if (!_lPlanAnaliticoCompleto)
205 mantegridSecundarias._Grid.Columns[
"CuentaNA2"].ReadOnly =
true;
208 mantegridSecundarias._Grid.Columns[
"NombreNA1"].ReadOnly =
true;
210 if (!_lPlanAnaliticoCompleto)
211 mantegridSecundarias._Grid.Columns[
"NombreNA2"].ReadOnly =
true;
219 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
231 RefrescarDescripcionNivelAnalitico();
239 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
240 public string _PlanContable
244 if (_Negocio != null)
245 return _cPlanContable;
251 _lcPlanContable = value;
253 if (_lPlanAnaliticoCompleto)
254 _btBrowSecundar.
_Plan = value;
256 _cPlanContable = value;
259 RefrescarDescripcionNivelAnalitico();
262 private string _cPlanContable =
string.Empty;
266 return _Negocio.GetLineasPlan(_PlanContable);
273 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
274 public int _PlanAnalitico
278 return _nPlanAnalitico;
282 if (value >= 1 && value <= 2 &&
283 _nPlanAnalitico != value)
285 _nPlanAnalitico = value;
315 # endregion Propiedades públicas 318 public event _FocusLineaRelacionadaHandler _FocusLineaRelacionada;
326 public delegate
void _FocusLineaRelacionadaHandler();
336 public delegate
void _RefreshImagenPlanAnaliticoHandler();
340 #region Métodos privados 341 private void InstanciarBotones()
356 private void Binding()
358 if (
string.IsNullOrWhiteSpace(_PlanContable))
370 mantegridSecundarias._Grid.DataSource = _Negocio.GetLineasPlan(_PlanContable);
374 ConfigurarGridSecundarias();
375 RefrescarTotalSecundarias();
386 toCol.ValueType = typeof(decimal);
387 toCol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
395 toCol.ThousandsSeparator =
false;
401 private void RefrescarTotalSecundarias()
403 decimal lnTotalSecundarias = 0;
404 decimal lnTotalSecundarias1 = 0;
407 if (!
string.IsNullOrWhiteSpace(_PlanContable))
409 lnTotalSecundarias = TotalSecundariasN1();
410 lnTotalSecundarias1 = TotalSecundariasN2();
414 var mascara =
ModoPlantilla ? _oMascaraTpc : _oMascaraImport;
417 if (SecundariasDescuadradas(tnNA: 1))
420 loColor = SystemColors.ControlText;
422 if (ewtextboxTotalSecundarias._PropiedadesDeEstilos._ColorFuenteBloqueado != loColor)
423 ewtextboxTotalSecundarias._PropiedadesDeEstilos._ColorFuenteBloqueado = loColor;
425 ewtextboxTotalSecundarias.Text = lnTotalSecundarias.ToString(mascara._Mascara_Net);
428 if (SecundariasDescuadradas(tnNA: 2))
431 loColor = SystemColors.ControlText;
433 if (ewtextboxTotalSecundarias1._PropiedadesDeEstilos._ColorFuenteBloqueado != loColor)
434 ewtextboxTotalSecundarias1._PropiedadesDeEstilos._ColorFuenteBloqueado = loColor;
436 ewtextboxTotalSecundarias1.Text = lnTotalSecundarias1.ToString(mascara._Mascara_Net);
442 private void SubscripcionEventos()
459 btBrowser lobtBrowser = BuscarBotonBrowser();
460 if (lobtBrowser != null)
470 Validating +=
new CancelEventHandler(Secundarias_Validating);
472 mantegridSecundarias._Grid.CellValueChanged +=
new DataGridViewCellEventHandler(MantegridSecundariasCellValueChanged);
473 mantegridSecundarias._Grid.CellBeginEdit +=
new DataGridViewCellCancelEventHandler(MantegridSecundariasCellBeginEdit);
477 if (_lPlanAnaliticoCompleto)
479 mantegridSecundarias._Row_New_Before += MantegridSecundarias__Row_New_BeforeAnaliticaCompleta;
480 mantegridSecundarias._Grid.EditingControlShowing += MantegridSecundarias_EditingControlShowing;
483 mantegridSecundarias._Grid.RowPrePaint +=
new DataGridViewRowPrePaintEventHandler(_Grid_RowPrePaint);
485 mantegridSecundarias._DataSource_Row_Delete_Event += MantegridSecundarias__DataSource_Row_Delete_Event_PlanAnalitico;
491 private void CancelarSubscripcionEventos()
505 btBrowser lobtBrowser = BuscarBotonBrowser();
506 if (lobtBrowser != null)
516 Validating -=
new CancelEventHandler(Secundarias_Validating);
518 mantegridSecundarias._Grid.CellValueChanged -=
new DataGridViewCellEventHandler(MantegridSecundariasCellValueChanged);
519 mantegridSecundarias._Grid.CellBeginEdit -=
new DataGridViewCellCancelEventHandler(MantegridSecundariasCellBeginEdit);
523 if (_lPlanAnaliticoCompleto)
525 mantegridSecundarias._Row_New_Before -= MantegridSecundarias__Row_New_BeforeAnaliticaCompleta;
526 mantegridSecundarias._Grid.EditingControlShowing -= MantegridSecundarias_EditingControlShowing;
529 mantegridSecundarias._Grid.RowPrePaint -=
new DataGridViewRowPrePaintEventHandler(_Grid_RowPrePaint);
538 void MantegridSecundarias__Row_New_Before(ref
bool tlOk,
bool tlInsert =
false)
540 if (_lSecManual ==
false)
552 if (mantegridSecundarias._Grid.CurrentCell == null)
554 FUNCTIONS._MessageBox(
"Para insertar un nuevo registro de nivel 2 debe estar situado previamente en un registro con nivel 2 declarado.",
"Niveles analíticos", MessageBoxButtons.OK, MessageBoxIcon.Stop);
560 int lnFilaGridSecundarias = mantegridSecundarias._Grid.CurrentCell.RowIndex;
561 DataGridViewRow loRow = mantegridSecundarias._Grid.Rows[lnFilaGridSecundarias];
564 if (
string.IsNullOrWhiteSpace(loIAsientosSecundarias._Secundaria) ||
string.IsNullOrWhiteSpace(loIAsientosSecundarias._Secnivel2))
566 FUNCTIONS._MessageBox(
"Para insertar un nuevo registro de nivel 2 debe estar situado previamente en un registro con nivel 2 declarado.",
"Niveles analíticos", MessageBoxButtons.OK, MessageBoxIcon.Stop);
580 void MantegridSecundarias__Row_New_After(DataGridViewRow tdgvRowLastInsert,
bool tlInsert)
582 if (mantegridSecundarias._Grid.CurrentRow == null)
589 if (tdgvRowLastInsert.Index == 0)
590 mantegridSecundarias._Grid.CurrentCell = mantegridSecundarias._Grid.CurrentRow.Cells[
"CuentaNA1"];
596 int lnFilaDesdeInsert = mantegridSecundarias._Grid.CurrentCell.RowIndex;
598 if (lnFilaDesdeInsert <= mantegridSecundarias._Grid.Rows.Count && !_lPlanAnaliticoCompleto)
599 mantegridSecundarias._Grid.CurrentCell = mantegridSecundarias._Grid.Rows[lnFilaDesdeInsert].Cells[
"CuentaNA2"];
601 mantegridSecundarias._Grid.CurrentCell = mantegridSecundarias._Grid.CurrentRow.Cells[
"CuentaNA1"];
611 private void MantegridSecundarias_EditingControlShowing(
object sender, DataGridViewEditingControlShowingEventArgs e)
613 if (mantegridSecundarias._Grid.CurrentCell == null)
616 string lcColumna = ColumnaActual();
618 if (lcColumna ==
"CuentaNA1")
620 e.Control.PreviewKeyDown -= Control_PreviewKeyDownNivel;
621 e.Control.PreviewKeyDown += Control_PreviewKeyDownNivel;
629 private void MantegridSecundarias__DataSource_Row_Delete_Event_PlanAnalitico(DataGridViewRow trRowDelete)
631 RefreshImagenPlanAnalitico();
639 private void MantegridSecundarias__Row_New_BeforeAnaliticaCompleta(ref
bool tlOk,
bool tlInsert =
false)
641 if (mantegridSecundarias._Grid.CurrentCell == null)
644 string lcColumna = ColumnaActual();
646 if (lcColumna ==
"CuentaNA1")
648 var linea = ObteneLineaDatosSecundarias(); ;
650 if (linea != null &&
string.IsNullOrWhiteSpace(linea._Secundaria))
662 if (mantegridSecundarias._Grid.CurrentCell == null)
665 int lnFilaGridSecundarias = mantegridSecundarias._Grid.CurrentCell.RowIndex;
666 DataGridViewRow loRow = mantegridSecundarias._Grid.Rows[lnFilaGridSecundarias];
678 private void Control_PreviewKeyDownNivel(
object sender, PreviewKeyDownEventArgs e)
680 string lcColumna = ColumnaActual();
682 string lcCodigo =
string.Empty;
683 DataGridViewTextBoxEditingControl loTextbox = null;
684 List<Keys> lstKeys =
new List<Keys>() { Keys.Enter, Keys.Tab, Keys.Up, Keys.Down, Keys.Right, Keys.Left };
686 if (lstKeys.Contains(e.KeyCode))
688 loTextbox = (DataGridViewTextBoxEditingControl)sender;
689 lcCodigo = loTextbox.Text.Trim();
695 if (!
string.IsNullOrWhiteSpace(lcCodigo) && lcCodigo.Length != _nAnchoCodigoAnaliticoCompleto && lcCodigo.All(c =>
char.IsDigit(c)) && !ExisteNivelAnalitico(lcCodigo))
696 loTextbox.Text = BrowserRaizNivelAnalitico(lcCodigo);
713 private string BrowserRaizNivelAnalitico(
string tcRaiz)
718 _btBrowSecundar.PerformClick();
723 return _btBrowSecundar.
_Codigo;
731 private bool ExisteNivelAnalitico(
string tcRaiz)
733 if (_btBrowSecundar == null)
742 var loExiste = _btBrowSecundar.
_DatatablePersonalizado.AsEnumerable().Where(row => Convert.ToString(row.Field<
string>(
"codigo")).Trim() == tcRaiz).FirstOrDefault();
744 return (loExiste != null && !
string.IsNullOrWhiteSpace(Convert.ToString(loExiste[
"codigo"])));
750 private void RefrescarDescripcionNivelAnalitico()
752 if (!
string.IsNullOrWhiteSpace(_PlanContable))
754 ewPanelTituloSecundarias.Visible =
true;
755 ewPanelTituloSecundarias._MostrarLineaTitulo =
false;
757 string lcNombre =
string.Empty;
759 if (_lPlanAnaliticoCompleto)
764 ewPanelTituloSecundarias._Titulo = $
"CA cta. {_Negocio._Cuenta}, {lcNombre}";
766 ewPanelTituloSecundarias._Titulo = $
"Códigos analíticos cta. {_Negocio._Cuenta}, {lcNombre}";
774 ewPanelTituloSecundarias._Titulo = $
"NA cta. {_Negocio._Cuenta}, {lcNombre}";
776 ewPanelTituloSecundarias._Titulo = $
"Niveles analíticos cta. {_Negocio._Cuenta}, {lcNombre}";
781 ewPanelTituloSecundarias.Visible =
false;
790 void _Grid_RowPrePaint(
object sender, DataGridViewRowPrePaintEventArgs e)
792 DataGridViewRow loRow = mantegridSecundarias._Grid.Rows[e.RowIndex];
795 if (
string.IsNullOrWhiteSpace(linea._Secundaria))
797 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe"].Style.Format =
"#";
798 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje"].Style.Format =
"#";
802 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe"].Style.Format = mantegridSecundarias._Grid.DefaultCellStyle.Format;
803 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje"].Style.Format = mantegridSecundarias._Grid.DefaultCellStyle.Format;
806 if (
string.IsNullOrWhiteSpace(linea._Secnivel2))
808 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].Style.Format =
"#";
813 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].Style.Format = mantegridSecundarias._Grid.DefaultCellStyle.Format;
819 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].Style.Format = mantegridSecundarias._Grid.DefaultCellStyle.Format;
823 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].Style.Format =
"#";
826 var esPrimeraSecunadaria = _Negocio.EsPrimeraSecundaria(linea);
827 if (!esPrimeraSecunadaria)
830 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"CuentaNA1"].Style.ForeColor =mantegridSecundarias._Grid.DefaultCellStyle.BackColor;
831 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"CuentaNA1"].ReadOnly =
true;
832 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"CuentaNA1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionBackColor;
834 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"NombreNA1"].Style.ForeColor =mantegridSecundarias._Grid.DefaultCellStyle.BackColor;
835 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"NombreNA1"].ReadOnly =
true;
836 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"NombreNA1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionBackColor;
838 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.BackColor;
839 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe"].ReadOnly =
true;
840 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionBackColor;
842 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje"].Style.ForeColor =mantegridSecundarias._Grid.DefaultCellStyle.BackColor;
843 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje"].ReadOnly =
true;
844 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionBackColor;
847 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.ForeColor;
848 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].ReadOnly =
false;
849 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionForeColor;
851 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.ForeColor;
852 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].ReadOnly =
false;
853 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionForeColor;
857 if (esPrimeraSecunadaria)
859 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"CuentaNA1"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.ForeColor;
860 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"CuentaNA1"].ReadOnly = !_lSecManual;
861 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"CuentaNA1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionForeColor;
863 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"NombreNA1"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.ForeColor;
864 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"NombreNA1"].ReadOnly =
true;
865 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"NombreNA1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionForeColor;
867 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.ForeColor;
868 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe"].ReadOnly =
false;
869 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionForeColor;
871 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.ForeColor;
872 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje"].ReadOnly = _lColNivel2Visible;
873 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionForeColor;
875 if (
string.IsNullOrWhiteSpace(linea._Secnivel2))
877 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.BackColor;
878 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].ReadOnly =
true;
879 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionBackColor;
885 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.ForeColor;
886 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].ReadOnly =
false;
887 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Importe1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionForeColor;
892 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.ForeColor;
893 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].ReadOnly =
false;
894 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionForeColor;
898 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].Style.ForeColor = mantegridSecundarias._Grid.DefaultCellStyle.BackColor;
899 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].ReadOnly =
true;
900 mantegridSecundarias._Grid.Rows[e.RowIndex].Cells[
"Porcentaje1"].Style.SelectionForeColor = mantegridSecundarias._Grid.DefaultCellStyle.SelectionBackColor;
915 Control[] loBotonBrowserCol = mantegridSecundarias.Controls.Find(
"btBrowserCol",
true);
917 if (loBotonBrowserCol != null && loBotonBrowserCol.Count() > 0 && loBotonBrowserCol[0] is
btBrowser)
918 loBoton = ((
btBrowser)loBotonBrowserCol[0]);
928 private void MantegridSecundarias__BeforeColChange(DataGridViewColumn tdgvCurrentCol, ref
bool tlOk)
930 RefreshImagenPlanAnalitico();
932 if (!_lFocusLineasAsiento)
934 DataGridViewCell loCell = mantegridSecundarias._Grid.CurrentCell;
935 if (loCell.OwningColumn.Name ==
"Importe1")
937 if ((_FocusLineaRelacionada != null) && SecundariasRepartidas())
938 _lFocusLineasAsiento =
true;
942 if (_lFocusLineasAsiento)
944 _lFocusLineasAsiento =
false;
946 _FocusLineaRelacionada();
955 private void MantegridSecundariasCellBeginEdit(
object sender, DataGridViewCellCancelEventArgs e)
957 string lcColumna = ColumnaActual();
959 if (lcColumna ==
"Importe" || lcColumna ==
"Porcentaje")
961 var linea = ObtenerNegocioDeLaLinea();
963 if (linea != null &&
string.IsNullOrWhiteSpace(linea._Secundaria))
967 if (lcColumna ==
"Importe1")
969 var linea = ObtenerNegocioDeLaLinea();
971 if (linea != null &&
string.IsNullOrWhiteSpace(linea._Secnivel2))
975 if (lcColumna ==
"Porcentaje1")
977 var linea = ObtenerNegocioDeLaLinea();
979 if (linea != null &&
string.IsNullOrWhiteSpace(linea._Secnivel2) && !linea._PrimeraSecundaria)
983 if (lcColumna ==
"Importe" || lcColumna ==
"Importe1")
985 if (EsLineaDeCuadreEnModoEjecucion())
987 string lcDefMens = (_lPlanAnaliticoCompleto ?
"código" :
"nivel");
988 string lcDefMensUp = lcDefMens.Substring(0, 1).ToUpper() + lcDefMens.Substring(1).ToLower();
990 FUNCTIONS._MessageBox(
"Esta analítica corresponde a una línea de cuadre. El importe se calculará automáticamente.", lcDefMensUp.Trim() +
" analíticos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
997 RefreshImagenPlanAnalitico();
1000 private bool EsLineaDeCuadreEnModoEjecucion()
1002 var linea = ObtenerNegocioDeLaLinea();
1004 if (!ModoPlantilla && linea.PerteneceLineaCuadre())
1013 private void RefreshImagenPlanAnalitico()
1015 _RefreshImagenPlanAnalitico?.Invoke();
1023 private void MantegridSecundariasCellValueChanged(
object sender, DataGridViewCellEventArgs e)
1025 string lcColumna =
string.Empty;
1026 bool llRefrescarTotal =
false;
1027 bool llFocus =
false;
1029 DataGridViewCell loCell = mantegridSecundarias._Grid.CurrentCell;
1034 lcColumna = loCell.OwningColumn.Name;
1041 if (
string.IsNullOrWhiteSpace(linea._Secundaria))
1043 if (!
string.IsNullOrWhiteSpace(linea._Nombre))
1046 llRefrescarTotal =
true;
1049 if (linea._ImporteNA1 != 0)
1051 linea._ImporteNA1 = 0;
1052 llRefrescarTotal =
true;
1061 if (
string.IsNullOrWhiteSpace(lineax._Secnivel2))
1063 if (!
string.IsNullOrWhiteSpace(lineax._Nombre))
1066 llRefrescarTotal =
true;
1069 lineax._ImporteNA2 = lineax._ImporteNA1;
1071 llRefrescarTotal =
true;
1076 llRefrescarTotal =
true;
1080 llRefrescarTotal =
true;
1085 llRefrescarTotal =
true;
1089 llRefrescarTotal =
true;
1097 if (llRefrescarTotal)
1099 RefrescarTotalSecundarias();
1101 if ((_FocusLineaRelacionada != null) && llFocus && SecundariasRepartidas())
1102 _lFocusLineasAsiento =
true;
1110 private string ColumnaActual()
1112 string lcColumna =
string.Empty;
1114 if (mantegridSecundarias._Grid.CurrentRow != null)
1116 DataGridViewCell loCell = mantegridSecundarias._Grid.CurrentCell;
1118 int lnIndice = mantegridSecundarias._Grid.CurrentRow.Index;
1120 lcColumna = loCell.OwningColumn.Name;
1131 private void MantegridSecundariasLeave(
object sender, EventArgs e)
1133 DataGridViewSelectionMode oldmode = mantegridSecundarias._Grid.SelectionMode;
1134 mantegridSecundarias._Grid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
1135 mantegridSecundarias._Grid.ClearSelection();
1136 mantegridSecundarias._Grid.SelectionMode = oldmode;
1138 mantegridSecundarias._Grid.FirstDisplayedCell = null;
1145 private void GridSecundariasAsiento__Click_After(
bool tlAceptar)
1147 Control[] loBotonBrowserCol = mantegridSecundarias.Controls.Find(
"btBrowserCol",
true);
1149 if (loBotonBrowserCol != null && loBotonBrowserCol.Count() > 0 && loBotonBrowserCol[0] is
btBrowser)
1151 RecuperarSecundariasSeleccionadas((
btBrowser)loBotonBrowserCol[0]);
1159 private void _btBrowSecundar__Click_After(
bool tlAceptar)
1161 RecuperarSecundariasSeleccionadas(_btBrowSecundar);
1169 private void GridSecundariasAsiento__Click_Before(ref
bool tlOk)
1171 btBrowser lobtBrowser = BuscarBotonBrowser();
1173 if (lobtBrowser != null)
1175 btBrowser lobtBrowSecundar = ConfigurarBrowserSecundarias(lobtBrowser);
1176 if (lobtBrowSecundar != null)
1189 private void _btBrowSecundar__Click_Before(ref
bool tlOk)
1191 btBrowser lobtBrowSecundar = ConfigurarBrowserSecundarias(_btBrowSecundar);
1192 if (lobtBrowSecundar != null)
1206 string lcColumna =
string.Empty;
1208 if (_lSoloNivelesDefinidos)
1210 int lnNivel = _nPlanAnalitico;
1212 if (_lPlanAnaliticoCompleto)
1213 lcColumna = (_nPlanAnalitico == 1 ?
"CuentaNA1" :
"CuentaNA2");
1216 lcColumna = ColumnaActual();
1217 if (lcColumna ==
"CuentaNA1")
1219 else if (lcColumna ==
"CuentaNA2")
1233 loBrowSecundar.
_Nivel = lnNivel;
1234 loBrowSecundar.
_Plan = _PlanContable;
1237 toBrowSecundar = loBrowSecundar;
1241 lcColumna = ColumnaActual();
1243 string lcNivel =
string.Empty;
1245 if (lcColumna ==
"CuentaNA1")
1247 else if (lcColumna ==
"CuentaNA2")
1253 toBrowSecundar.
_Condicion =
" nivel = " + lcNivel;
1256 if (_lPlanAnaliticoCompleto)
1257 toBrowSecundar.
_Titulo = TituloPlanAnaliticoCompleto(lcColumna);
1259 return toBrowSecundar;
1265 private string TituloPlanAnaliticoCompleto(
string lcColumna)
1267 string lcDescripcionPlan =
string.Empty;
1283 return "Listado de códigos analíticos del plan " + lcDescripcionPlan;
1290 private void RecuperarSecundariasSeleccionadas(
btBrowser toBtBrowser)
1295 foreach (
string lcSecundaria
in toBtBrowser.
_Codigo_List.Keys)
1308 private bool SecundariasRepartidas(
bool tlMensaje =
false,
bool tlSinReparto =
false)
1312 return (!SecundariasDescuadradas(tlMensaje) && (tlSinReparto || TotalSecundariasN1() != 0 || TotalSecundariasN2() != 0));
1327 private bool SecundariasDescuadradas(
bool tlMensaje =
false,
int tnNA = 0)
1329 bool llDescuadre =
false;
1330 decimal importeSecNivel1 = 0M;
1331 decimal importeSecNivel2 = 0M;
1332 string lcMensaje =
"";
1333 string lcSimbolo =
"";
1334 string lcDefMens = (_lPlanAnaliticoCompleto ?
"código" :
"nivel");
1335 string lcDefMensUp = lcDefMens.Substring(0, 1).ToUpper() + lcDefMens.Substring(1).ToLower();
1338 decimal importeLinea = TotalMaximoDeseado();
1341 importeSecNivel1 = TotalSecundariasN1();
1342 importeSecNivel2 = TotalSecundariasN2();
1346 importeSecNivel1 = importeSecNivel2 = (tnNA == 1 ? TotalSecundariasN1() : TotalSecundariasN2());
1349 llDescuadre = (importeSecNivel1 != 0 && (importeLinea != importeSecNivel1 || importeLinea != importeSecNivel2));
1351 if (tlMensaje && llDescuadre)
1358 var errorPoncentajeExcecido = $
"La suma del porcentaje del plan analítico {_PlanContable.Trim()} debe ser 100";
1360 FUNCTIONS._MessageBox(errorPoncentajeExcecido, lcDefMensUp.Trim() +
" analíticos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
1364 if (importeLinea != importeSecNivel1)
1366 if (_lPlanAnaliticoCompleto)
1368 lcMensaje = $
" Plan {NombreDelPlan(_PlanContable)} Códigos analíticos Importe " + importeSecNivel1.ToString(_oMascaraImport.
_Mascara_Net) + lcSimbolo + Environment.NewLine;
1372 lcMensaje =
" Plan " + _PlanContable.Trim() +
" Nivel analítico 1 Importe " + importeSecNivel1.ToString(_oMascaraImport.
_Mascara_Net) + lcSimbolo + Environment.NewLine;
1376 if (_lColNivel2Visible && !_lPlanAnaliticoCompleto)
1378 if (importeLinea != importeSecNivel2)
1380 lcMensaje = lcMensaje +
" Plan " + _PlanContable.Trim() +
" Nivel analítico 2 Importe " + importeSecNivel2.ToString(_oMascaraImport.
_Mascara_Net) + lcSimbolo;
1384 var lcMensajeImp =
string.Empty;
1385 if (_lPlanAnaliticoCompleto)
1387 lcMensajeImp =
"El importe de los códigos analíticos declarados no coincide con el importe de la cuenta " + _Negocio._Cuenta.Trim() +
1388 " Importe " + TotalMaximoDeseado().ToString(_oMascaraImport.
_Mascara_Net) + lcSimbolo +
".";
1392 lcMensajeImp =
"El importe de los niveles analíticos declarados no coincide con el importe de la cuenta " + _Negocio._Cuenta.Trim() +
1393 " Importe " + TotalMaximoDeseado().ToString(_oMascaraImport.
_Mascara_Net) + lcSimbolo +
".";
1396 lcDefMens = (_lPlanAnaliticoCompleto ?
"códigos" :
"niveles");
1397 lcDefMensUp = lcDefMens.Substring(0, 1).ToUpper() + lcDefMens.Substring(1).ToLower();
1401 FUNCTIONS._MessageBox(lcMensajeImp + Environment.NewLine + Environment.NewLine +
1402 lcMensaje, lcDefMensUp.Trim() +
" analíticos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
1406 HayDescuadre = llDescuadre;
1410 private string NombreDelPlan(
string codigoPlan)
1418 public bool HayDescuadre {
get;
private set; }
1426 private void Secundarias_Validating(
object sender, CancelEventArgs e)
1428 RefreshImagenPlanAnalitico();
1431 if (!ModoPlantilla && SecundariasDescuadradas(
true))
1445 private void FocusGrid()
1447 DataGridViewCell loCell = mantegridSecundarias._Grid.CurrentCell;
1451 int lnRow = mantegridSecundarias._Grid.CurrentRow.Index;
1452 string lcColumna = loCell.OwningColumn.Name;
1454 if (mantegridSecundarias._Grid.Rows.Count > 0)
1455 mantegridSecundarias._Grid.Rows[lnRow].Cells[lcColumna].Selected =
true;
1465 private void MantegridSecundarias__DataSource_Row_Delete_Event(DataGridViewRow trRowDelete)
1467 DialogResult loResult;
1469 loResult = FUNCTIONS._MessageBox(
"¿Seguro que desea borrar la línea seleccionada?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, DialogResult.No);
1471 if (loResult == DialogResult.Yes)
1473 var linea = ObtenerNegocioDeLaLinea();
1479 _Negocio._Items.Remove(linea);
1481 GestionFocoAsiento();
1490 private void GestionFocoAsiento()
1492 if (_lPlanAnaliticoCompleto)
1494 if (((BindingList<SecundariasPredefinidos.Secundaria>)mantegridSecundarias._Grid.DataSource).Count == 0)
1505 private void PasarFocoGrid()
1507 Timer loTimer =
new Timer
1511 loTimer.Tick += TimerPasarFocoGrid_Tick;
1520 private void TimerPasarFocoGrid_Tick(
object sender, EventArgs e)
1522 ((Timer)sender).Stop();
1523 ((Timer)sender).Dispose();
1526 _FocusLineaRelacionada();
1538 private void MantegridSecundarias__DataSource_Row_New_Event(
int tnInsertLinea)
1540 _Negocio._AddSecundaria(_PlanContable, tnInsertLinea);
1553 if (mantegridSecundarias._Grid.CurrentRow != null)
1555 DataGridViewCell loCell = mantegridSecundarias._Grid.CurrentCell;
1561 return loIAsientosLineaSecundaria;
1567 private void NavegarMantenimientoNivelesAnaliticos()
1569 string lcColumna = ColumnaActual();
1570 string lcCodigo =
string.Empty;
1572 var linea = ObtenerNegocioDeLaLinea();
1579 lcCodigo = linea._Secundaria;
1583 lcCodigo = linea._Secnivel2;
1588 _btManteSecundar.
_Codigo = lcCodigo;
1589 _btManteSecundar.PerformClick();
1596 private void AddButtonOpciones()
1598 Control loBotonInsertar = mantegridSecundarias.Controls[
"btInsertar"];
1599 if (loBotonInsertar != null)
1603 _oBotonOpciones.FlatStyle = FlatStyle.Flat;
1604 _oBotonOpciones.FlatAppearance.BorderSize = 0;
1605 _oBotonOpciones.Anchor = ((
System.Windows.Forms.AnchorStyles)((
System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Right)));
1607 _oBotonOpciones.
_Tooltip =
"Opciones planes analíticos";
1608 _oBotonOpciones.Click +=
new EventHandler(Opciones_Click);
1610 _oBotonOpciones.UseVisualStyleBackColor =
true;
1612 mantegridSecundarias.Controls.Add(_oBotonOpciones);
1614 Size loSize = loBotonInsertar.Size;
1617 _oBotonOpciones.Size = loSize;
1619 Point loPoint = loBotonInsertar.Location;
1620 loPoint.X = loPoint.X + (loBotonInsertar.Size.Width - loSize.Width);
1622 _oBotonOpciones.Location = loPoint;
1633 private void Opciones_Click(
object sender, EventArgs e)
1636 string lcColumna = ColumnaActual();
1642 if (_lColPorcentajeVisible)
1644 loMenuContext_Opciones.Items.Add(
"Repartir porcentaje");
1645 loMenuContext_Opciones.Items[lnItem].Name =
"Reparto";
1646 loMenuContext_Opciones.Items[
"Reparto"].Click +=
new EventHandler(RepartoPorcentajeSecundarias_Click);
1647 loMenuContext_Opciones.Items[
"Reparto"].ToolTipText =
"Reparto proporcional del porcentaje en niveles analíticos";
1648 loMenuContext_Opciones.Items[
"Reparto"].Enabled = !
_ReadOnly;
1654 loMenuContext_Opciones.Items.Add(
"Añadir desglose analítico de plan");
1655 loMenuContext_Opciones.Items[lnItem].Name =
"InsertarTodas";
1656 loMenuContext_Opciones.Items[
"InsertarTodas"].Click +=
new EventHandler(InsertarTodas_Click);
1657 loMenuContext_Opciones.Items[
"InsertarTodas"].ToolTipText =
"Añade los registros de desglose analítico asociados al plan";
1658 loMenuContext_Opciones.Items[
"InsertarTodas"].Enabled = !
_ReadOnly;
1661 loMenuContext_Opciones.Items.Add(
"Añadir desglose analítico de cuenta");
1662 loMenuContext_Opciones.Items[lnItem].Name =
"DesgloseCuenta";
1663 loMenuContext_Opciones.Items[
"DesgloseCuenta"].Click +=
new EventHandler(DesgloseCuenta_Click);
1664 loMenuContext_Opciones.Items[
"DesgloseCuenta"].ToolTipText =
"Añade los registros de desglose analítico asociados a la cuenta";
1665 loMenuContext_Opciones.Items[
"DesgloseCuenta"].Enabled = !
_ReadOnly;
1668 loMenuContext_Opciones.Items.Add(
"Borrar todos");
1669 loMenuContext_Opciones.Items[lnItem].Name =
"BorrarTodas";
1670 loMenuContext_Opciones.Items[
"BorrarTodas"].Click +=
new EventHandler(BorrarTodas_Click);
1671 loMenuContext_Opciones.Items[
"BorrarTodas"].ToolTipText =
"Borra todos los registros de los niveles analíticos";
1672 loMenuContext_Opciones.Items[
"BorrarTodas"].Enabled = !
_ReadOnly;
1676 if (_lSecManual && _lColNivel2Visible && !_lPlanAnaliticoCompleto)
1678 loMenuContext_Opciones.Items.Add(
"Insertar");
1679 loMenuContext_Opciones.Items[lnItem].Name =
"Insertar";
1680 loMenuContext_Opciones.Items[
"Insertar"].Click +=
new EventHandler(Insertar_Click);
1681 loMenuContext_Opciones.Items[
"Insertar"].ToolTipText =
"Insertar registro de cuenta de nivel 2 bajo registro de nivel 1";
1682 loMenuContext_Opciones.Items[
"Insertar"].Enabled = !
_ReadOnly;
1686 loMenuContext_Opciones.Items.Add(
"Desglose");
1687 loMenuContext_Opciones.Items[lnItem].Name =
"Desglose";
1688 loMenuContext_Opciones.Items[
"Desglose"].Click +=
new EventHandler(VerDesglose_Click);
1689 loMenuContext_Opciones.Items[
"Desglose"].ToolTipText =
"Muestra el desglose analítico del plan";
1690 loMenuContext_Opciones.Items[
"Desglose"].Enabled =
_ReadOnly;
1695 loMenuContext_Opciones.Items.Add(
"Reparto proporcional");
1696 loMenuContext_Opciones.Items[lnItem].Name =
"Reparto";
1697 loMenuContext_Opciones.Items[
"Reparto"].Click +=
new EventHandler(RepartoImporteSecundarias_Click);
1698 loMenuContext_Opciones.Items[
"Reparto"].ToolTipText =
"Reparto proporcional de importe de cuenta en niveles analíticos";
1699 loMenuContext_Opciones.Items[
"Reparto"].Enabled = !
_ReadOnly;
1704 loMenuContext_Opciones.Items.Add(
"Añadir desglose analítico de cuenta");
1705 loMenuContext_Opciones.Items[lnItem].Name =
"DesgloseCuenta";
1706 loMenuContext_Opciones.Items[
"DesgloseCuenta"].Click +=
new EventHandler(DesgloseCuenta_Click);
1707 loMenuContext_Opciones.Items[
"DesgloseCuenta"].ToolTipText =
"Añade los registros de desglose analítico asociados a la cuenta";
1708 loMenuContext_Opciones.Items[
"DesgloseCuenta"].Enabled = !
_ReadOnly;
1711 loMenuContext_Opciones.Items.Add(
"Borrar todos");
1712 loMenuContext_Opciones.Items[lnItem].Name =
"BorrarTodos";
1713 loMenuContext_Opciones.Items[
"BorrarTodos"].Click +=
new EventHandler(BorrarTodas_Click);
1714 loMenuContext_Opciones.Items[
"BorrarTodos"].ToolTipText =
"Borra todos los registros de los niveles analíticos";
1715 loMenuContext_Opciones.Items[
"BorrarTodos"].Enabled = !
_ReadOnly;
1718 if (_lColNivel2Visible && !_lPlanAnaliticoCompleto)
1720 loMenuContext_Opciones.Items.Add(
"Insertar");
1721 loMenuContext_Opciones.Items[lnItem].Name =
"Insertar";
1722 loMenuContext_Opciones.Items[
"Insertar"].Click +=
new EventHandler(Insertar_Click);
1723 loMenuContext_Opciones.Items[
"Insertar"].ToolTipText =
"Insertar registro de cuenta de nivel 2 bajo registro de nivel 1";
1724 loMenuContext_Opciones.Items[
"Insertar"].Enabled = !
_ReadOnly;
1731 loMenuContext_Opciones.Items.Add(
"Mantenimiento de niveles analíticos");
1732 loMenuContext_Opciones.Items[lnItem].Name =
"Mantenimiento";
1733 loMenuContext_Opciones.Items[
"Mantenimiento"].Click +=
new EventHandler(NavegarMantenimientoNivelesAnaliticos_Click);
1734 loMenuContext_Opciones.Items[
"Mantenimiento"].ToolTipText =
"Mantenimiento de niveles analíticos";
1735 loMenuContext_Opciones.Items[
"Mantenimiento"].Enabled = (lcColumna ==
"CuentaNA1" || lcColumna ==
"CuentaNA2");
1736 loMenuContext_Opciones.Items[
"Mantenimiento"].Enabled = !
_ReadOnly;
1741 loMenuContext_Opciones.Show(Cursor.Position.X, Cursor.Position.Y);
1749 private void Insertar_Click(
object sender, EventArgs e)
1752 mantegridSecundarias._Fila_Insert();
1760 private void RepartoPorcentajeSecundarias_Click(
object sender, EventArgs e)
1762 RepartirPorcentaje(accionDeUsuario:
true);
1771 private void InsertarTodas_Click(
object sender, EventArgs e)
1773 _Negocio._InsertarTodas(_PlanContable);
1775 RefreshImagenPlanAnalitico();
1783 private void DesgloseCuenta_Click(
object sender, EventArgs e)
1786 if (!_Negocio.CuentaCompleta())
1788 string lcDefMens = (_lPlanAnaliticoCompleto ?
"códigos" :
"niveles");
1789 FUNCTIONS._MessageBox(
"Se requiere una cuenta completa para poder cargar su detalle analítico.", lcDefMens.Substring(0, 1).ToUpper() + lcDefMens.Substring(1).ToLower() +
" analíticos", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2);
1794 if(!_Negocio.TengoDatosDelPlanEnCuentas(_Negocio._Cuenta, _PlanContable))
1796 string lcDefMens = (_lPlanAnaliticoCompleto ?
"códigos" :
"niveles");
1797 var plan = _lPlanAnaliticoCompleto ? NombreDelPlan(_PlanContable) : _PlanContable;
1798 FUNCTIONS._MessageBox($
"La cuenta no tiene desglose analítico para el plan {plan}.", lcDefMens.Substring(0, 1).ToUpper() + lcDefMens.Substring(1).ToLower() +
" analíticos", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2);
1802 _Negocio._InsertarRestoDesdeCuentas(_PlanContable);
1804 RefreshImagenPlanAnalitico();
1813 private void BorrarTodas_Click(
object sender, EventArgs e)
1815 if (
string.IsNullOrWhiteSpace(_PlanContable))
1818 if (_Negocio.GetLineasPlan(_PlanContable).Count() == 0)
1820 FUNCTIONS._MessageBox(
"No hay registros de niveles analíticos para borrar.", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2, DialogResult.OK);
1824 if ((FUNCTIONS._MessageBox(
"¿Seguro que desea borrar todos los registros de los niveles analíticos?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, DialogResult.Yes) == DialogResult.Yes))
1827 _Negocio._BorrarTodas(_PlanContable);
1829 RefreshImagenPlanAnalitico();
1833 GestionFocoAsiento();
1841 private void VerDesglose_Click(
object sender, EventArgs e)
1843 if(
string.IsNullOrWhiteSpace(_PlanContable) || _Negocio._Items.Count == 0)
1845 string lcDefMens = (_lPlanAnaliticoCompleto ?
"códigos" :
"niveles");
1846 FUNCTIONS._MessageBox($
"No hay datos para mostrar desglose.", lcDefMens.Substring(0, 1).ToUpper() + lcDefMens.Substring(1).ToLower() +
" analíticos", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2);
1849 _Negocio._VerDesglose(_PlanContable);
1857 private void RepartoImporteSecundarias_Click(
object sender, EventArgs e)
1859 RepartirImporte(accionDeUsuario:
true);
1867 private void NavegarMantenimientoNivelesAnaliticos_Click(
object sender, EventArgs e)
1869 NavegarMantenimientoNivelesAnaliticos();
1876 private void ConfigurarSecundarias()
1878 mantegridSecundarias._Grid.AllowUserToOrderColumns =
false;
1882 mantegridSecundarias._RecuadroVisible =
false;
1884 AddButtonOpciones();
1888 mantegridSecundarias._MostrarBrowMante =
true;
1897 Point loPoint = mantegridSecundarias._Grid.Location;
1898 Size loSize = mantegridSecundarias._Grid.Size;
1900 mantegridSecundarias._MostrarBrowMante =
false;
1901 mantegridSecundarias._Borrar_Visible =
false;
1902 mantegridSecundarias._Anadir_Visible =
false;
1905 mantegridSecundarias._Grid.Location = loPoint;
1906 mantegridSecundarias._Grid.Size = loSize;
1909 ewPanelTituloSecundarias.Location =
new Point(loPoint.X, ewPanelTituloSecundarias.Location.Y);
1912 ConfigurarGridSecundarias();
1919 private void RevisarTextTotales()
1922 if (_lPlanAnaliticoCompleto)
1923 ewlabelTotalNA2.Text =
ModoPlantilla ?
"Total % CA:" :
"Total CA:";
1926 ewlabelTotalNA1.Text =
ModoPlantilla ?
"Total % NA1:" :
"Total NA1:";
1927 ewlabelTotalNA2.Text =
ModoPlantilla ?
"Total % NA2:" :
"Total NA2:";
1934 private void ConfigurarGridSecundarias()
1939 mantegridSecundarias._Grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
1940 mantegridSecundarias._Grid.AutoGenerateColumns =
false;
1942 string lcCaption =
"";
1944 ConfigurarGridSecundariasNivelAnalitico1(lcCaption);
1946 if (!_lPlanAnaliticoCompleto)
1947 ConfigurarGridSecundariasNivelAnalitico2(lcCaption);
1949 RevisarTextTotales();
1953 ewlabelTotalNA1.Visible = _lSecRepPorcentaje && !_lPlanAnaliticoCompleto;
1954 ewlabelTotalNA2.Visible = _lSecRepPorcentaje;
1955 ewtextboxTotalSecundarias.Visible = _lSecRepPorcentaje && !_lPlanAnaliticoCompleto;
1956 ewtextboxTotalSecundarias1.Visible = _lSecRepPorcentaje;
1965 private void ConfigurarGridSecundariasNivelAnalitico1(
string tcCaption)
1968 if (!mantegridSecundarias._Grid.Columns.Contains(
"CuentaNA1"))
1969 Documento_Add_Columna_Analitica_Grid(tnDisplayIndex: 0);
1971 if (mantegridSecundarias._Grid.Columns.Contains(
"NombreNA1"))
1972 mantegridSecundarias._Grid.Columns.Remove(
"NombreNA1");
1977 ldgtbColDefinicion1.Name =
"NombreNA1";
1978 ldgtbColDefinicion1.DataPropertyName = _lPlanAnaliticoCompleto ?
"_NombreNA1NA2" :
"_Nombre";
1979 ldgtbColDefinicion1.HeaderText =
"Nombre";
1980 ldgtbColDefinicion1.ValueType = typeof(
string);
1981 ldgtbColDefinicion1.MinimumWidth = 200;
1982 ldgtbColDefinicion1.DisplayIndex = 1;
1983 ldgtbColDefinicion1._NoParar =
true;
1984 ldgtbColDefinicion1.ReadOnly =
true;
1986 if (_lPlanAnaliticoCompleto)
1987 ldgtbColDefinicion1.ToolTipText =
"Nombre analítico";
1989 ldgtbColDefinicion1.ToolTipText =
"Nombre del nivel analítico 1";
1991 ldgtbColDefinicion1.SortMode = DataGridViewColumnSortMode.NotSortable;
1992 mantegridSecundarias._Grid.Columns.Add(ldgtbColDefinicion1);
1996 if (mantegridSecundarias._Grid.Columns.Contains(
"Importe"))
1997 mantegridSecundarias._Grid.Columns.Remove(
"Importe");
2001 ldgtbColImporte.Name =
"Importe";
2002 ldgtbColImporte.DataPropertyName = _lPlanAnaliticoCompleto ?
"_ImporteNA2" :
"_ImporteNA1";
2003 ldgtbColImporte.HeaderText =
"Importe " + tcCaption;
2004 ldgtbColImporte.MinimumWidth = 100;
2005 ldgtbColImporte.DisplayIndex = 2;
2008 NumeriUpDownColProperties(ldgtbColImporte, _oMascaraImport);
2010 ldgtbColImporte.SortMode = DataGridViewColumnSortMode.NotSortable;
2012 mantegridSecundarias._Grid.Columns.Add(ldgtbColImporte);
2015 if (mantegridSecundarias._Grid.Columns.Contains(
"Porcentaje"))
2016 mantegridSecundarias._Grid.Columns.Remove(
"Porcentaje");
2018 var propiedad =
"_Porcentaje";
2019 if (_lPlanAnaliticoCompleto)
2020 propiedad =
"_Porcentaje";
2023 if(_lColNivel2Visible)
2024 propiedad =
"_Porcentaje1";
2026 propiedad =
"_Porcentaje";
2030 ldgtbColPorcentaje.Name =
"Porcentaje";
2031 ldgtbColPorcentaje.DataPropertyName = propiedad;
2032 ldgtbColPorcentaje.HeaderText = _lPlanAnaliticoCompleto ? $
"% código analítico" : $
"% C.NA1";
2033 ldgtbColPorcentaje.MinimumWidth = 100;
2034 ldgtbColPorcentaje.DisplayIndex = 3;
2035 ldgtbColPorcentaje.Visible =
ModoPlantilla && _lColPorcentajeVisible;
2036 ldgtbColPorcentaje.ReadOnly = _lColNivel2Visible && !_lPlanAnaliticoCompleto;
2038 NumeriUpDownColProperties(ldgtbColPorcentaje, _oMascaraTpc);
2040 ldgtbColPorcentaje.SortMode = DataGridViewColumnSortMode.NotSortable;
2042 mantegridSecundarias._Grid.Columns.Add(ldgtbColPorcentaje);
2050 private void ConfigurarGridSecundariasNivelAnalitico2(
string tcCaption)
2053 if (!mantegridSecundarias._Grid.Columns.Contains(
"CuentaNA2"))
2057 ldgtbColCuenta2.Name =
"CuentaNA2";
2058 ldgtbColCuenta2.DataPropertyName =
"_Secnivel2";
2059 ldgtbColCuenta2.HeaderText =
"C.NA2";
2060 ldgtbColCuenta2.ValueType = typeof(
string);
2061 ldgtbColCuenta2.MinimumWidth = _nAnchoColumnaAnalitica;
2062 ldgtbColCuenta2.DisplayIndex = 4;
2063 ldgtbColCuenta2.ToolTipText =
"Código nivel analítico 2";
2064 ldgtbColCuenta2.SortMode = DataGridViewColumnSortMode.NotSortable;
2065 ldgtbColCuenta2.Visible = _lColNivel2Visible;
2066 ldgtbColCuenta2.MaxInputLength = _nLenAnalitica;
2070 mantegridSecundarias._TeclaF4(
"CuentaNA2", _btBrowSecundar);
2071 mantegridSecundarias._TeclaF5(
"CuentaNA2", _btManteSecundar);
2074 mantegridSecundarias._Grid.Columns.Add(ldgtbColCuenta2);
2079 if (mantegridSecundarias._Grid.Columns.Contains(
"NombreNA2"))
2080 mantegridSecundarias._Grid.Columns.Remove(
"NombreNA2");
2084 ldgtbColDefinicion2.Name =
"NombreNA2";
2085 ldgtbColDefinicion2.DataPropertyName =
"_Nombre2";
2086 ldgtbColDefinicion2.HeaderText =
"Nombre";
2087 ldgtbColDefinicion2.ValueType = typeof(
string);
2088 ldgtbColDefinicion2.MinimumWidth = 200;
2089 ldgtbColDefinicion2.DisplayIndex = 5;
2090 ldgtbColDefinicion2._NoParar =
true;
2091 ldgtbColDefinicion2.ReadOnly =
true;
2092 ldgtbColDefinicion2.Visible = _lColNivel2Visible;
2094 ldgtbColDefinicion2.ToolTipText =
"Nombre del nivel analítico 2";
2095 ldgtbColDefinicion2.SortMode = DataGridViewColumnSortMode.NotSortable;
2096 mantegridSecundarias._Grid.Columns.Add(ldgtbColDefinicion2);
2100 if (mantegridSecundarias._Grid.Columns.Contains(
"Importe1"))
2101 mantegridSecundarias._Grid.Columns.Remove(
"Importe1");
2105 ldgtbColImporte1.Name =
"Importe1";
2106 ldgtbColImporte1.DataPropertyName =
"_ImporteNA2";
2107 ldgtbColImporte1.HeaderText =
"Importe " + tcCaption;
2108 ldgtbColImporte1.MinimumWidth = 100;
2109 ldgtbColImporte1.DisplayIndex = 6;
2110 ldgtbColImporte1.Visible = _lColNivel2Visible && !
ModoPlantilla;
2112 NumeriUpDownColProperties(ldgtbColImporte1, _oMascaraImport);
2114 ldgtbColImporte1.SortMode = DataGridViewColumnSortMode.NotSortable;
2116 mantegridSecundarias._Grid.Columns.Add(ldgtbColImporte1);
2120 if (mantegridSecundarias._Grid.Columns.Contains(
"Porcentaje1"))
2121 mantegridSecundarias._Grid.Columns.Remove(
"Porcentaje1");
2125 ldgtbColPorcentaje1.Name =
"Porcentaje1";
2126 ldgtbColPorcentaje1.DataPropertyName =
"_Porcentaje";
2127 ldgtbColPorcentaje1.HeaderText = $
"% C.NA2";
2128 ldgtbColPorcentaje1.MinimumWidth = 100;
2129 ldgtbColPorcentaje1.DisplayIndex = 7;
2130 ldgtbColPorcentaje1.Visible = _lColNivel2Visible &&
ModoPlantilla && _lColPorcentajeVisible;
2132 NumeriUpDownColProperties(ldgtbColPorcentaje1, _oMascaraTpc);
2134 ldgtbColPorcentaje1.SortMode = DataGridViewColumnSortMode.NotSortable;
2136 mantegridSecundarias._Grid.Columns.Add(ldgtbColPorcentaje1);
2145 private void Documento_Add_Columna_Analitica_Grid(
int tnDisplayIndex = 0)
2147 string lcName =
string.Empty;
2148 string lcDataPropertyName =
string.Empty;
2149 string lcHeaderText =
string.Empty;
2150 string lcToolTipText =
string.Empty;
2152 ConfigurarPropiedadesColumnaAnalitica(ref lcName, ref lcDataPropertyName, ref lcHeaderText, ref lcToolTipText);
2157 ldgtbColPlanContable1.Name = lcName;
2158 ldgtbColPlanContable1.DataPropertyName = lcDataPropertyName;
2159 ldgtbColPlanContable1.HeaderText = lcHeaderText;
2160 ldgtbColPlanContable1.ValueType = typeof(
string);
2161 ldgtbColPlanContable1.Width = _nAnchoColumnaAnalitica;
2162 ldgtbColPlanContable1.MinimumWidth = _nAnchoColumnaAnalitica;
2164 ldgtbColPlanContable1.DisplayIndex = tnDisplayIndex;
2165 ldgtbColPlanContable1.ToolTipText = lcToolTipText;
2166 ldgtbColPlanContable1.SortMode = DataGridViewColumnSortMode.NotSortable;
2170 mantegridSecundarias._TeclaF4(lcName, _btBrowSecundar);
2171 if (!_lPlanAnaliticoCompleto)
2172 mantegridSecundarias._TeclaF5(lcName, _btManteSecundar);
2175 mantegridSecundarias._Grid.Columns.Add(ldgtbColPlanContable1);
2187 private void ConfigurarPropiedadesColumnaAnalitica(ref
string tcName, ref
string tcDataPropertyName, ref
string tcHeaderText, ref
string tcToolTipText)
2189 tcName = $
"CuentaNA1";
2191 var prefijoPorcentaje =
ModoPlantilla && _lColPorcentajeVisible ?
"% " :
"";
2193 if (_lPlanAnaliticoCompleto)
2195 tcDataPropertyName =
"_CuentaNA1NA2";
2196 tcHeaderText = prefijoPorcentaje +
"Código analítico";
2197 tcToolTipText =
"Código analítico";
2201 tcDataPropertyName = $
"_Secundaria";
2202 tcHeaderText = prefijoPorcentaje +
"C.NA1";
2203 tcToolTipText = $
"Código nivel analítico 1";
2228 private decimal TotalMaximoDeseado()
2230 decimal lnTotalDebeHaber = decimal.Zero;
2238 if (_oNegocio != null)
2242 return lnTotalDebeHaber;
2249 private decimal TotalSecundariasN1()
2251 decimal importe = decimal.Zero;
2253 if (_oNegocio != null)
2262 return _oNegocio.
TotalN1(_PlanContable);
2273 private decimal TotalSecundariasN2()
2275 decimal importe = decimal.Zero;
2277 if (_oNegocio != null)
2286 return _oNegocio.
TotalN2(_PlanContable);
2293 # endregion Métodos privados 2295 # region Métodos públicos 2302 private bool RepartirImporte(
bool accionDeUsuario =
false)
2305 var cantidadSecundarias = loSecundarias.AsEnumerable().Count(lin => lin._Secundaria != null && !
string.IsNullOrWhiteSpace(lin._Secundaria));
2307 string lcDefMens = (_lPlanAnaliticoCompleto ?
"códigos" :
"niveles");
2309 if (cantidadSecundarias == 0)
2311 if (accionDeUsuario)
2312 FUNCTIONS._MessageBox($
"No hay {lcDefMens} analíticos a recalcular.", lcDefMens.Substring(0, 1).ToUpper() + lcDefMens.Substring(1).ToLower() +
" analíticos", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2);
2317 _Negocio._RepartirImporte(_PlanContable, accionDeUsuario);
2321 _RefrescarSecundarias();
2331 private bool RepartirPorcentaje(
bool accionDeUsuario =
false)
2335 var cantidadSecundarias = loSecundarias.AsEnumerable().Count(lin => lin._Secundaria != null && !
string.IsNullOrWhiteSpace(lin._Secundaria));
2337 string lcDefMens = (_lPlanAnaliticoCompleto ?
"códigos" :
"niveles");
2339 if (cantidadSecundarias == 0)
2341 if (accionDeUsuario)
2342 FUNCTIONS._MessageBox($
"No hay {lcDefMens} analíticos a recalcular.", lcDefMens.Substring(0, 1).ToUpper() + lcDefMens.Substring(1).ToLower() +
" analíticos", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2);
2348 _Negocio._RepartirPorcentaje(_PlanContable);
2362 RefrescarTotalSecundarias();
2364 mantegridSecundarias._Grid.Refresh();
2372 if (_Grid.Rows.Count > 0)
2375 _Grid.Rows[0].Cells[
"CuentaNA1"].Selected =
true;
2378 if (ModoPlantilla && _lColPorcentajeVisible)
2380 _Grid.Rows[0].Cells[
"Porcentaje"].Selected =
true;
2384 _Grid.Rows[0].Cells[
"Importe"].Selected =
true;
2391 #endregion Métodos públicos 2393 #region Métodos protected override 2394 protected override void OnHandleCreated(EventArgs e)
2400 base.OnHandleCreated(e);
2402 if (_lSecundar && _lPlanAnaliticoCompleto)
2404 ewlabelTotalNA1.Visible =
false;
2405 ewtextboxTotalSecundarias.Visible =
false;
2417 string lcColumna =
string.Empty, lcNameButton =
string.Empty;
2419 if (ActiveControl == mantegridSecundarias)
2421 if ((keyData == Keys.Left && ColumnaActual() ==
"CuentaNA1") && _FocusLineaRelacionada != null && SecundariasRepartidas(
true,
true))
2423 base.ProcessCmdKey(ref msg, keyData);
2424 _FocusLineaRelacionada();
2428 if (keyData == Keys.Add || keyData == Keys.Subtract)
2430 lcColumna = ColumnaActual();
2432 if (lcColumna ==
"_Secnivel1" || lcColumna ==
"_Secnivel2")
2434 if (keyData == Keys.Add)
2435 lcNameButton =
"btBrowserCol";
2437 lcNameButton =
"btManteCol";
2439 ewbutton lobtBrowserCol = ((
ewbutton)mantegridSecundarias.Controls[lcNameButton]);
2441 if (lobtBrowserCol != null)
2443 if (lcNameButton ==
"btManteCol")
2445 var linea = ObtenerNegocioDeLaLinea();
2449 string lcCuenta = lcColumna ==
"_Secnivel1" ? linea._Secundaria : linea._Secnivel2;
2451 ((
btMante)lobtBrowserCol)._Codigo = lcCuenta;
2455 lobtBrowserCol.PerformClick();
2461 else if (keyData == Keys.F5 && !_lSecManual)
2463 lcColumna = ColumnaActual();
2465 if (lcColumna ==
"_Secnivel1" || lcColumna ==
"_Secnivel2")
2467 NavegarMantenimientoNivelesAnaliticos();
2471 else if (keyData == Keys.Escape && SecundariasDescuadradas(
true))
2475 return base.ProcessCmdKey(ref msg, keyData);
2477 # endregion Métodos protected override decimal _Rango_Max
Valor máximo según la máscara. Es la máscara de VFP convertida a decimal
delegate void _DataSource_Row_Delete_Event_Handler(DataGridViewRow trRowDelete)
Se dispara al borrar un registro cuando el DataSource no es un DataTable
_RefreshImagenPlanAnaliticoHandler _RefreshImagenPlanAnalitico
Declaramos evento nuevo para poder refrescar la imagen relacionada con la linea relacionada ...
String _CondicionAutomatica
Texto para el filtro automático
void _RefrescarSecundarias()
Refrescamos las secundarias desde el formulario de asientos
virtual DataTable _DatatablePersonalizado
Datatable personalizado
_Click_After_Handler _Click_After
_Click_After_Handler
static System.Drawing.Bitmap settings_16
Busca un recurso adaptado de tipo System.Drawing.Bitmap.
decimal TotalN1(string plan)
Obtiene una suma de los importes de N1
bool _AplicarEstilos
Aplicar estilo al control
void _RefreshDatatablePersonalizado(bool lbRefrescar=false)
Refresco del datatable personalizado Necesario al cambiar las propiedades relacionadas con la opción ...
Clase para gestionar la información de planes analíticos asociados a una línea de asiento predefinido...
delegate void _DataSource_Row_New_Event_Handler(int tnInsertLinea)
Se dispara al añadir un nuevo registro cuando el DataSource no es un DataTable
Browser, basat en sage.ew.objetos.ewbutton
Muestra el browser de cuentas secundarias
Mostra el manteniment de comptes secundaries carregant el registre corresponent al _Codigo ...
string _Nombre
Nombre de la secundaria
delegate void _Click_Before_Handler(ref Boolean tlOk)
_Click_Before_Handler
Usercontrol de grid de secundarias de la pantalla de asientos
Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc.
KeyDiccionarioMascara
Clave para diccionario de máscaras
delegate void _Row_New_Before_Handler(ref bool tlOk, bool tlInsert=false)
Se dispara antes de insertar una nueva fila
void _Focus()
Pasamos el foco a la grid y activamos la celda
KeyDiccionarioLenCampos
Clave del diccionario LenCampos
Clase del objeto grid para Sage50
override bool ProcessCmdKey(ref Message msg, Keys keyData)
Gestión de las teclas rápidas de Contaplus: F4(+) y F5(-)
string _Plan
Plan a presentar con la opción de TRABAJAR SOLO CON NIVELES DEFINIDOS EN CADA PLAN ANALÍTICO ...
int _Num_Decimales
Número de decimales de la máscara
delegate void _Row_New_After_Handler(DataGridViewRow tdgvRowLastInsert, bool tlInsert)
Se dispara despues de insertar una nueva fila
ModoPlantilla
Posibles Modos de Plantillas
delegate void _Click_After_Handler(Boolean tlAceptar)
_Click_After_Handler
Custom column type dedicated to the DataGridViewNumericUpDownCell cell type.
Boolean _CondicionAutomaticaActiva
Filtrar automáticamente los registros si al acceder a los F4
Muestra el mantenimiento correspondiente a _Form con el registro correspondiente al _Codigo ...
ewgrid _Grid
Tenemos la referencia pública a la grid
delegate void _BeforeColChange_Handler(DataGridViewColumn tdgvCurrentCol, ref bool tlOk)
Se dispara antes de que se cambie la celda seleccionada en el grid
Proporciona características adicionales de las máscaras de Eurowin
string _Codigo
valor del registro seleccionado por parte del usuario (readonly)
_Click_Before_Handler _Click_Before
_Click_Before_Handler
string _Titulo
Titulo de la ventana
decimal TotalN2(string plan)
Obtiene una suma de los importes de N2
string _Nombre2
Nombre de la secundaria de nivel 2
decimal TotalPorcentajeN2(string plan)
Obtiene una suma de los porcentajes de N2
decimal _Rango_Min
Valor mínimo según la máscara. Es la máscara de VFP convertida a decimal y en negativo ...
string _Mascara_Net
Máscara convertida en formato .Net
decimal TotalPorcentajeN1(string plan)
Obtiene una suma de los porcentajes de N1
Dictionary< string, object > _Codigo_List
Contendra los registros seleccionados si la propiedad _Seleccion_Multiple esta activada ...
static string _DefinicionPlanAnalitico(string tcCodigo)
Definición planes analíticos
decimal TotalLineaPredefinido()
Recupera el importe de la línea de predefinido asociada
int _Nivel
Nivel a presentar con la opción de TRABAJAR SOLO CON NIVELES DEFINIDOS EN CADA PLAN ANALÍTICO ...
string _Condicion
condición que se podrá especificar en el momento de realizar la consulta SQL
Presenta un datagridview con botones añadir y borrar tipo Mantegrid de Eurowin
Base per a les columnes estandar