2 using System.Collections.Generic;
3 using System.ComponentModel;
18 namespace sage.ew.formul.Forms
25 #region PROPIEDADES PRIVADAS 31 private BindingList<LineaGiro> _Giros = null;
37 private dynamic _oDocumento;
43 private bool _lHera = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_hera"));
52 #endregion PROPIEDADES PRIVADAS 55 #region PROPIEDADES PÚBLICAS 61 public dynamic _Documento
80 #endregion PROPIEDADES PÚBLICAS 91 InitializeComponent();
93 this._Pantalla =
"ALB_FPAG";
97 this.subscripcioEventos();
104 #endregion CONSTRUCTOR 107 #region MÉTODOS PRIVADOS 113 private void subscripcioEventos()
115 this.girosDocum._ManteGrid._DataSource_Row_Delete_Event +=
new objetos.UserControls.Mantegrid._DataSource_Row_Delete_Event_Handler(evento_girosMante__DataSource_Row_Delete_Event);
116 this.girosDocum._ManteGrid._DataSource_Row_New_Event +=
new objetos.UserControls.Mantegrid._DataSource_Row_New_Event_Handler(evento_girosMante__DataSource_Row_New_Event);
125 private void cancelarSubscripcioEventos()
127 this.girosDocum._ManteGrid._DataSource_Row_Delete_Event -=
new objetos.UserControls.Mantegrid._DataSource_Row_Delete_Event_Handler(evento_girosMante__DataSource_Row_Delete_Event);
128 this.girosDocum._ManteGrid._DataSource_Row_New_Event -=
new objetos.UserControls.Mantegrid._DataSource_Row_New_Event_Handler(evento_girosMante__DataSource_Row_New_Event);
138 private void evento_girosMante__DataSource_Row_New_Event(
int tnInsertLinea)
140 int lnMaxNumGiro = 0;
145 if (this._Giros.Count > 0)
147 lnMaxNumGiro = (from query in _Giros select query._NumGiro).Max();
148 lnMaxGiro = (from query in _Giros select query._Giro).Max();
149 loLineaGiro =
new LineaGiro() { _NumGiro = lnMaxNumGiro + 1, _Giro = lnMaxGiro+30, _Porcentaje=0 };
153 loLineaGiro =
new LineaGiro() { _NumGiro = 1, _Giro = 0, _Porcentaje = 100 };
156 _Giros.Add(loLineaGiro);
158 this.girosDocum._ManteGrid._Grid.DataSource = _Giros;
168 private void evento_girosMante__DataSource_Row_Delete_Event(DataGridViewRow trRowDelete)
170 if (this.girosDocum._ManteGrid._Grid.CurrentRow.Index >= 0)
172 this._Giros.RemoveAt(this.girosDocum._ManteGrid._Grid.CurrentRow.Index);
173 this.girosDocum._ManteGrid._Grid.DataSource = _Giros;
184 private void setGiros(BindingList<LineaGiro> girosDocumento)
186 _Giros =
new BindingList<LineaGiro>();
188 foreach (
LineaGiro loGiro
in girosDocumento)
194 BindingList<ILineaGiro> lstLineaGiro =
new BindingList<ILineaGiro>();
196 lstLineaGiro.Add(loGiro);
198 girosDocum._LineasGiros = lstLineaGiro;
200 girosDocum._ManteGrid._Grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
202 girosDocum._CheckMeses.Checked = this._Documento._Cabecera._GirosMesesCompletos;
211 private void ajustes_Pantalla()
220 this.cmbBancos.Visible =
false;
221 this.txtCuentaBancaria.Visible =
false;
222 this.ewLblBanco.Visible =
false;
223 this.ewLblCuentaBancaria.Visible =
false;
225 this.girosDocum.Anchor = AnchorStyles.None;
226 this.Height -= (this.girosDocum.Top - this.ewLblBanco.Top);
228 this.girosDocum.Top = this.ewLblBanco.Top;
230 this.girosDocum.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
233 this.
Top = (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2;
234 this.Left = (Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2;
246 private void frmDocVenGiros_Load(
object sender, EventArgs e)
253 this.ajustes_Pantalla();
257 if (this._Documento != null && this._Documento._EnUso || (
this._lHera &&
this._Documento._Cabecera._Exportar != null))
260 this.girosDocum._ReadOnly =
true;
271 this.
Text = this.
Text +
" (Sólo lectura)";
273 this.girosDocum._ReadOnly =
true;
285 private void btDocCancelar1_Click(
object sender, EventArgs e)
287 this.DialogResult = DialogResult.Cancel;
296 private void btDocAceptar1_Click(
object sender, EventArgs e)
299 if (this._Giros.Count > 0)
301 bool llGirosPrc0 =
false;
302 decimal lnPrcAcum = 0.0M;
303 foreach (
LineaGiro loGiro
in this._Giros)
314 string lcMensajeError =
"";
318 lcMensajeError =
"Tiene días de giro con % reparto importe a cero. Tiene que eliminar los mismos, o asignar un porcentaje de reparto.";
323 if (FUNCTIONS._Round(lnPrcAcum, 2) != 100)
325 lcMensajeError =
"La suma de los porcentajes reparto importe de cada registro no corresponde al 100%. Ajuste los % de reparto importe.";
331 FUNCTIONS._MessageBox(lcMensajeError,
"Giros", MessageBoxButtons.OK, MessageBoxIcon.Stop);
332 this.DialogResult = DialogResult.None;
347 int lnBancCli = Convert.ToInt32(this.cmbBancos.SelectedValue);
348 _Documento._Cabecera._Banc_Cli = (lnBancCli==0 ? 1:lnBancCli);
353 BindingList<LineaGiro> lstGirosNew =
new BindingList<LineaGiro>();
354 BindingList<int> lstGirosAnt =
new BindingList<int>();
355 foreach (
LineaGiro loLineaGiro
in this._Giros)
358 lstGirosAnt.Add(loLineaGiro.
_Giro);
363 _Documento._GirosPrc = lstGirosNew;
364 _Documento._Giros = lstGirosAnt;
365 this._Documento._Cabecera._GirosMesesCompletos = this.girosDocum._CheckMeses.Checked;
366 this.DialogResult = DialogResult.OK;
375 private void listBancos_SelectedIndexChanged(
object sender, EventArgs e)
380 txtCuentaBancaria._Banco = Convert.ToString(cmbBancos.SelectedValue);
389 private void cmbBancos_SelectedIndexChanged(
object sender, EventArgs e)
394 txtCuentaBancaria._Banco = Convert.ToString(cmbBancos.SelectedValue);
400 #endregion MÉTODOS PRIVADOS 403 #region MÉTODOS PROTECTED OVERRIDE 412 this.cancelarSubscripcioEventos();
420 #endregion MÉTODOS PROTECTED OVERRIDE 423 #region MÉTODOS PÚBLICOS 431 Dictionary<string, object> obj;
433 if (_Documento != null)
435 dynamic _oCuenta = null;
436 string lcCodigoCuenta =
string.Empty;
438 switch (this._TipoDocumentoGeneral)
441 this.ewLblCuenta.Text =
"Cliente";
442 _oCuenta = _Documento._Cabecera._oCliente;
445 lcCodigoCuenta = (
new Cliente(_oCuenta._Codigo))._Codigo_Equivalente_ERP();
447 lcCodigoCuenta = _oCuenta._Codigo;
451 this.ewLblCuenta.Text =
"Proveedor";
452 _oCuenta = _Documento._Cabecera._oProveedor;
453 lcCodigoCuenta = _oCuenta._Codigo;
459 this.txtCuenta.Text = String.Format(
"{0} - {1}", lcCodigoCuenta, _oCuenta._Nombre);
460 this.txtCuenta.ReadOnly =
true;
463 setGiros(_Documento._GirosPrc);
467 txtCuentaBancaria._Cliente = _Documento._Cabecera._oCliente;
469 cmbBancos.ValueMember =
"CODIGO";
470 cmbBancos.DisplayMember =
"BANCO";
471 cmbBancos.DataSource = _oCuenta._Bancos();
473 obj = _oCuenta._Banco_Predeterminado();
477 if (_Documento._Cabecera._Banc_Cli != 0)
478 cmbBancos.SelectedValue = _Documento._Cabecera._Banc_Cli;
480 cmbBancos.SelectedValue = Convert.ToString(obj[
"codigo"]);
482 txtCuentaBancaria._Banco = Convert.ToString(cmbBancos.SelectedValue);
491 #endregion MÉTODOS PÚBLICOS int _NumGiro
Número de giro, campo virtual, 1, 2, 3, etc. No se graba en base de datos, será un correlativo que se...
Clase de negocio para visualizar los giros.
static sage.ew.usuario.Usuario _This
Instancia estática del objeto usuario con los datos del usuario actual (wc_usuario) ...
decimal _Porcentaje
Porcentaje del importe de la factura a aplicar en el giro.
eTipoDocumentoGeneral
Enumeración pública para definir las diferentes categorias que tenemos de documentos (ventas...
Interface para usar en el usercontrol de giros que aparece en el mantenimiento de clientes...
bool _Opcesp(string tcCodigo)
Método que nos devuelve "true" en caso que el usuario actual tenga acceso a la opción especial con có...
Definición de la clase Usuario