btNavigateMante.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using sage.ew.objetos;
6 using sage.ew.listados.Clases;
7 using System.Data;
8 using System.Windows.Forms;
9 using sage.ew.global;
10 using sage.ew.functions;
11 
12 namespace sage.ew.botones
13 {
17  public class btNavigateMante : ewbutton
18  {
19  #region PROPIEDADES PRIVADAS
20 
21  private string _cAnyActual = Convert.ToString(EW_GLOBAL._GetVariable("wc_any"));
22 
26  protected gridViewList _oGrid = null;
27 
31  protected string _cClave = "";
32 
36  protected string _cMante = "";
37 
41  protected List<String> _oClaves;
42 
46  protected IListados _oListado = null;
47  #endregion
48 
49 
50  #region PROPIEDADES PUBLICAS
51 
55  public gridViewList _Grid
56  {
57  get { return _oGrid; }
58  set { _oGrid = value; }
59  }
60 
64  public string _Clave
65  {
66  get { return _cClave; }
67  set { _cClave = value; }
68  }
69 
73  public IListados _Listado
74  {
75  get { return _oListado; }
76  set { _oListado = value; }
77  }
78  #endregion
79 
80 
81  #region CONSTRUCTORES
82 
90  public btNavigateMante(IListados toListado, gridViewList toGridViewList, String tcMante, String tcClave)
91  {
92  this._oListado = toListado;
93  this._oGrid = toGridViewList;
94  this._cMante = tcMante;
95  this._cClave = tcClave;
96 
97  this.Click += new EventHandler(btNavigate_Click);
98  }
99 
104  {
105  }
106  #endregion
107 
108 
109  #region METODOS PRIVADAS
110 
111  private void btNavigate_Click(object sender, EventArgs e)
112  {
113  DataRow loRowOriSel = null;
114  btNavigateMante oBtNvg = (btNavigateMante)sender;
115 
116  int lnIndex = oBtNvg._oGrid.CurrentCellAddress.Y;
117 
118  if (oBtNvg._oListado != null && oBtNvg._oGrid != null && !string.IsNullOrWhiteSpace(oBtNvg._cClave) && !String.IsNullOrWhiteSpace(oBtNvg._cMante) && lnIndex > -1) //PE-91647 Se controla que tenga un indice válido
119  {
120  // Obtener id interno de la fila seleccionada del grid
121  DataRow loRowSel = ((DataRowView)oBtNvg._oGrid.Rows[lnIndex].DataBoundItem).Row;
122  int lnId = ((loRowSel != null) ? Convert.ToInt32(loRowSel["_ids50"]) : -1);
123 
124  // A partir del id interno, buscar la fila correspondiente en el datatable original con todos los campos
125  DataRow[] loRows = new DataRow[0];
126 
127  if (lnId >= 0)
128  {
129  DataTable ldtOri = oBtNvg._oListado._ResultadoOriginalCombinado;
130  loRows = ldtOri.Select(String.Format("_ids50 = {0}", lnId));
131  }
132 
133  loRowOriSel = (loRows.Length > 0) ? loRows[0] : oBtNvg._oListado._ResultadoOriginalCombinado.Rows[lnIndex];
134 
135  if (loRowOriSel.Table.Columns.Contains(oBtNvg._Clave) && loRowOriSel != null)
136  {
137  String lcCodigo = Convert.ToString(loRowOriSel[oBtNvg._Clave]);
138 
139  if (!String.IsNullOrEmpty(lcCodigo.Trim()))
140  {
141  // Revisar si estamos en el ejercicio actual
142  if (loRowOriSel.Table.Columns.Contains("ejercicio"))
143  {
144  if (!string.IsNullOrWhiteSpace(Convert.ToString(loRowOriSel["ejercicio"])) && _cAnyActual != Convert.ToString(loRowOriSel["ejercicio"]))
145  {
146  FUNCTIONS._MessageBox("No se permite la navegación a mantenimientos/documentos de otro ejercicio diferente al ejercicio activo (" + _cAnyActual + ").", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, DialogResult.OK);
147  return;
148  }
149  }
150 
151  oBtNvg._oListado._NavigateMante(oBtNvg._cClave, loRowOriSel, NombreMante(oBtNvg, lcCodigo), lcCodigo);
152  }
153  }
154  }
155  }
156 
164  private string NombreMante(btNavigateMante toButtonNavigateMante,string tcCodigoMante)
165  {
166  string lcMante = toButtonNavigateMante._cMante.ToUpper();
167 
168  if (lcMante == "CLIENTES" && functions.FUNCTIONS.Es_ClientePotencial(tcCodigoMante))
169  lcMante = "AGENDA";
170 
171  return lcMante;
172  }
173 
174  #endregion
175  }
176 }
DataTable _ResultadoOriginalCombinado
Resultado despues de añadir las columnas perssonalizadas
Definition: IListados.cs:831
string _Clave
Clave interna que servirá para navegar a la pantalla que corresponda ...
Interficie de listados que todo listado de Eurowin TPV deberá cumplir para toda clase que se defina c...
Definition: IListados.cs:20
gridViewList _oGrid
Referencia a la grid del listado ...
List< String > _oClaves
Lista de Claves
void _NavigateMante(string tcKeyNavigate, DataRow trRowList, String tcNombreMante, String tcCodigo)
Método que permite capturar cuando el usuario pulsa sobre un botón añadido a traves de las columnas d...
btNavigateMante(IListados toListado, gridViewList toGridViewList, String tcMante, String tcClave)
Constructor
Clase de grid de listados, esta es la grid que se mostrará en el formulario de resultados de un lista...
string _cClave
Clave interna que servirá para navegar a la pantalla que corresponda ...
Base para los botones de Eurowin
string _cMante
Clave interna que servirá para navegar a la pantalla que corresponda ...
IListados _oListado
Referencia interna al objeto Listados ...
Botón para navegación a documentos desde pantalla que muestra el resultado de un listado.