diff --git a/Exferia_Compras/Exferia_Compras/3_Vistas/Controladoras/P_ImportacionFacturaE_Controladora.cs b/Exferia_Compras/Exferia_Compras/3_Vistas/Controladoras/P_ImportacionFacturaE_Controladora.cs new file mode 100644 index 0000000..46cb411 --- /dev/null +++ b/Exferia_Compras/Exferia_Compras/3_Vistas/Controladoras/P_ImportacionFacturaE_Controladora.cs @@ -0,0 +1,164 @@ +using Exferia_Aplicacion.General; +using Exferia_Compras._1_Datos; +using Exferia_Compras._3_Vistas.Listados; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Exferia_Compras._3_Vistas.Controladoras +{ + public class P_ImportacionFacturaE_Controladora + + { + #region Variables Generales + private P_ImportacionFacturaE g_frm_P_ImportacionFactureaE = null;//Variable que enlaza con la pantalla asociada + + //Clases de Negocio + private COM_DevolucionesPagos_Bolsa_Datos g_obj_COM_DevolucionesPagos_Bolsa_Datos = new COM_DevolucionesPagos_Bolsa_Datos(); + + #region BOLSA LISTADO + private BackgroundWorker g_obj_TareaAsincrona_Rellenar_Listado; + private bool g_bol_TareaAsincrona_Rellenar_Listado_Cancelar = false; + + public List g_lst_Valores = null; + + public List g_lst_ColumnasAMostrar_BOLSA = new List(); + public ABS_Listado_COM_DevolucionesPagos_Bolsa g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa = null; + public Dictionary g_dct_ListadoFiltros_BOLSA = new Dictionary(); + private int g_int_TotalRegistrosInsertados_BOLSA = 0; + public List g_lst_INTERNO_ComboBox_Modelo_Filtros_BOLSA = new List(); + + #endregion + + #endregion + + #region Constructor + public P_ImportacionFacturaE_Controladora(P_ImportacionFacturaE _frm_P_DevolucionPago_Bolsa) + { + g_frm_P_ImportacionFactureaE = _frm_P_DevolucionPago_Bolsa; + + g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa = new ABS_Listado_COM_DevolucionesPagos_Bolsa(g_frm_P_ImportacionFactureaE.P_Base_ValoresGenerales.lng_idEmpresa); + } + #endregion + + #region Recargar Listado + public void Recargar_Listado(bool _bol_Recargar_Desde_BD) + { + try + { + // Si la tarea asincrona esta en marcha la paro + if (g_obj_TareaAsincrona_Rellenar_Listado != null) + { + g_bol_TareaAsincrona_Rellenar_Listado_Cancelar = true; + + while (g_obj_TareaAsincrona_Rellenar_Listado.IsBusy) + Application.DoEvents(); + + g_bol_TareaAsincrona_Rellenar_Listado_Cancelar = false; + + //Vaciar + g_frm_P_ImportacionFactureaE.Exferia_DataGridView_Listado.Rows.Clear(); + g_int_TotalRegistrosInsertados_BOLSA = 0; + g_frm_P_ImportacionFactureaE.Exferia_BarraProgreso_Bolsa.Exferia_BarraProgreso_Total = 0; + g_frm_P_ImportacionFactureaE.Exferia_BarraProgreso_Bolsa.Exferia_BarraProgreso_Actualizar = 0; + } + else + { + g_bol_TareaAsincrona_Rellenar_Listado_Cancelar = false; + + g_obj_TareaAsincrona_Rellenar_Listado = new BackgroundWorker(); + g_obj_TareaAsincrona_Rellenar_Listado.DoWork += new DoWorkEventHandler(TareaAsincrona_Rellenar_Listado_DoWork); + g_obj_TareaAsincrona_Rellenar_Listado.ProgressChanged += new ProgressChangedEventHandler(TareaAsincrona_Rellenar_Listado_ProgressChanged); + g_obj_TareaAsincrona_Rellenar_Listado.RunWorkerCompleted += new RunWorkerCompletedEventHandler(TareaAsincrona_Rellenar_Listado_Completed); + g_obj_TareaAsincrona_Rellenar_Listado.WorkerReportsProgress = true; + } + + //(Tarea Asincrona) Cargar Datos ################################################################## + g_obj_TareaAsincrona_Rellenar_Listado.RunWorkerAsync(_bol_Recargar_Desde_BD); + //################################################################################################# + } + catch (Exception ex) + { + throw new Control_Errores("", ex, nameof(P_DevolucionPago_Bolsa_Controladora) + "/" + nameof(Recargar_Listado), true); + } + } + private void TareaAsincrona_Rellenar_Listado_DoWork(object sender, DoWorkEventArgs e) + { + try + { + bool bol_Recargar_Desde_DB = (bool)e.Argument; + + //RECARGAR DESDE BASE DE DATOS + if (bol_Recargar_Desde_DB) + { + g_lst_Valores = g_obj_COM_DevolucionesPagos_Bolsa_Datos.Obtener_Listado(g_frm_P_ImportacionFactureaE.P_Base_ValoresGenerales.lng_idEmpresa, + ((g_frm_P_ImportacionFactureaE.P_Base_ValoresGenerales != null && g_frm_P_ImportacionFactureaE.P_Base_ValoresGenerales.EjercicioActivo != null) ? g_frm_P_ImportacionFactureaE.P_Base_ValoresGenerales.EjercicioActivo.id : -1), + g_lst_ColumnasAMostrar_BOLSA, + null, + null); + + } + + if (g_lst_Valores != null && g_lst_Valores.Count > 0) + { + g_frm_P_ImportacionFactureaE.Exferia_BarraProgreso_Bolsa.Exferia_BarraProgreso_Total = g_lst_Valores.Count; + + object[] row; + foreach (dynamic dnm_Valor in g_lst_Valores) + { + //Se Cancelo la tarea asincrona --------------------------- + if (g_bol_TareaAsincrona_Rellenar_Listado_Cancelar || g_frm_P_ImportacionFactureaE.IsDisposed) + { + return; + } + + //Añadir Fila con Columnas ............................. + row = Funciones_Listado.Transformar_Dynamic_A_Row(dnm_Valor, g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa); + + //Llamar al Progress + g_int_TotalRegistrosInsertados_BOLSA += 1; + + ((BackgroundWorker)sender).ReportProgress(1, row); + + //Application.DoEvents(); + Thread.Sleep(1); + } + } + } + catch (ThreadAbortException ex) + { + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa_Controladora) + "/" + nameof(TareaAsincrona_Rellenar_Listado_DoWork)); + } + catch (Control_Errores) + { } + catch (Exception ex) + { + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa_Controladora) + "/" + nameof(TareaAsincrona_Rellenar_Listado_DoWork)); + } + } + private void TareaAsincrona_Rellenar_Listado_ProgressChanged(object sender, ProgressChangedEventArgs e) + { + try + { + if (!g_frm_P_ImportacionFactureaE.IsDisposed) + { + g_frm_P_ImportacionFactureaE.Exferia_DataGridView_Listado.Rows.Add((object[])e.UserState); + + g_frm_P_ImportacionFactureaE.Exferia_BarraProgreso_Bolsa.Exferia_BarraProgreso_Actualizar = g_int_TotalRegistrosInsertados_BOLSA; + } + } + catch (Exception) + { } + + } + private void TareaAsincrona_Rellenar_Listado_Completed(object sender, RunWorkerCompletedEventArgs e) + { } + #endregion + + } +} diff --git a/Exferia_Compras/Exferia_Compras/3_Vistas/P_ImportacionFacturaE.Designer.cs b/Exferia_Compras/Exferia_Compras/3_Vistas/P_ImportacionFacturaE.Designer.cs new file mode 100644 index 0000000..79c65eb --- /dev/null +++ b/Exferia_Compras/Exferia_Compras/3_Vistas/P_ImportacionFacturaE.Designer.cs @@ -0,0 +1,297 @@ +namespace Exferia_Compras._3_Vistas +{ + partial class P_ImportacionFacturaE + { + /// + /// Variable del diseñador necesaria. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Limpiar los recursos que se estén usando. + /// + /// true si los recursos administrados se deben desechar; false en caso contrario. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Código generado por el Diseñador de Windows Forms + + /// + /// Método necesario para admitir el Diseñador. No se puede modificar + /// el contenido de este método con el editor de código. + /// + private void InitializeComponent() + { + this.pnl_Contenedor_Inferior = new System.Windows.Forms.Panel(); + this.panel1 = new Exferia_Controles.Exferia_Panel_Degradado(); + this.exferia_Label3 = new Exferia_Controles.Exferia_Label(); + this.exferia_Label2 = new Exferia_Controles.Exferia_Label(); + this.ex_lbl_P_FacturaCabecera_Anexo_Empresa = new Exferia_Controles.Exferia_Label(); + this.ex_txt_P_ImportacionFacturaE_path = new Exferia_Controles.Exferia_TextBox(); + this.ex_pgb_P_ImportacionFacturaE_BarraProgreso = new Exferia_Controles.Exferia_BarraProgreso(); + this.ex_btn_P_ImportacionFacturaE_actualizaListado = new Exferia_Controles.Exferia_Button(); + this.exferia_Label1 = new Exferia_Controles.Exferia_Label(); + this.ex_dgv_P_ImportacionFacturaE_Listado = new Exferia_Controles.Exferia_DataGridView(); + this.ex_btn_P_ImportacionFacturaE_Importar = new Exferia_Controles.Exferia_Button(); + this.P_ImportacionFacturaE_Total = new Exferia_Controles.Exferia_Label_SinColor(); + this.P_ImportacionFacturaE_Comprador = new Exferia_Controles.Exferia_Label_SinColor(); + this.P_ImportacionFacturaE_vendedor = new Exferia_Controles.Exferia_Label_SinColor(); + this.pnl_Contenedor_Inferior.SuspendLayout(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ex_dgv_P_ImportacionFacturaE_Listado)).BeginInit(); + this.SuspendLayout(); + // + // pnl_Contenedor_Inferior + // + this.pnl_Contenedor_Inferior.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnl_Contenedor_Inferior.BackColor = System.Drawing.Color.Transparent; + this.pnl_Contenedor_Inferior.Controls.Add(this.panel1); + this.pnl_Contenedor_Inferior.Controls.Add(this.ex_txt_P_ImportacionFacturaE_path); + this.pnl_Contenedor_Inferior.Controls.Add(this.ex_pgb_P_ImportacionFacturaE_BarraProgreso); + this.pnl_Contenedor_Inferior.Controls.Add(this.ex_btn_P_ImportacionFacturaE_actualizaListado); + this.pnl_Contenedor_Inferior.Controls.Add(this.exferia_Label1); + this.pnl_Contenedor_Inferior.Controls.Add(this.ex_dgv_P_ImportacionFacturaE_Listado); + this.pnl_Contenedor_Inferior.Location = new System.Drawing.Point(5, 72); + this.pnl_Contenedor_Inferior.Name = "pnl_Contenedor_Inferior"; + this.pnl_Contenedor_Inferior.Size = new System.Drawing.Size(743, 583); + this.pnl_Contenedor_Inferior.TabIndex = 69; + // + // panel1 + // + this.panel1.Controls.Add(this.P_ImportacionFacturaE_vendedor); + this.panel1.Controls.Add(this.P_ImportacionFacturaE_Comprador); + this.panel1.Controls.Add(this.P_ImportacionFacturaE_Total); + this.panel1.Controls.Add(this.exferia_Label3); + this.panel1.Controls.Add(this.exferia_Label2); + this.panel1.Controls.Add(this.ex_lbl_P_FacturaCabecera_Anexo_Empresa); + this.panel1.Exferia_Panel_Degradado_Color_Borde = System.Drawing.Color.White; + this.panel1.Exferia_Panel_Degradado_Color_Desde = System.Drawing.Color.White; + this.panel1.Exferia_Panel_Degradado_Color_Hasta = System.Drawing.Color.White; + this.panel1.Exferia_Panel_Degradado_TipoDegradado = System.Drawing.Drawing2D.LinearGradientMode.Vertical; + this.panel1.Location = new System.Drawing.Point(505, 35); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(210, 520); + this.panel1.TabIndex = 51; + // + // exferia_Label3 + // + this.exferia_Label3.AutoSize = true; + this.exferia_Label3.Location = new System.Drawing.Point(21, 129); + this.exferia_Label3.Name = "exferia_Label3"; + this.exferia_Label3.Size = new System.Drawing.Size(70, 13); + this.exferia_Label3.TabIndex = 183; + this.exferia_Label3.Text = "Total Factura"; + // + // exferia_Label2 + // + this.exferia_Label2.AutoSize = true; + this.exferia_Label2.Location = new System.Drawing.Point(21, 82); + this.exferia_Label2.Name = "exferia_Label2"; + this.exferia_Label2.Size = new System.Drawing.Size(58, 13); + this.exferia_Label2.TabIndex = 182; + this.exferia_Label2.Text = "Comprador"; + // + // ex_lbl_P_FacturaCabecera_Anexo_Empresa + // + this.ex_lbl_P_FacturaCabecera_Anexo_Empresa.AutoSize = true; + this.ex_lbl_P_FacturaCabecera_Anexo_Empresa.Location = new System.Drawing.Point(21, 30); + this.ex_lbl_P_FacturaCabecera_Anexo_Empresa.Name = "ex_lbl_P_FacturaCabecera_Anexo_Empresa"; + this.ex_lbl_P_FacturaCabecera_Anexo_Empresa.Size = new System.Drawing.Size(53, 13); + this.ex_lbl_P_FacturaCabecera_Anexo_Empresa.TabIndex = 181; + this.ex_lbl_P_FacturaCabecera_Anexo_Empresa.Text = "Vendedor"; + // + // ex_txt_P_ImportacionFacturaE_path + // + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_Bloqueable = true; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_BordeColor_Foco = System.Drawing.Color.Red; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_BordeColor_Normal = System.Drawing.Color.Black; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_Fondo = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_MaxLength = 199; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_Multiline = false; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_NoBloquear = true; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_Obligatorio = false; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_PasswordChar = '\0'; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_Permitir_CambioFuenteAutomatico = true; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_ReadOnly = false; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_ScrollBars = System.Windows.Forms.ScrollBars.None; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_SelectionLength = 0; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_SelectionStart = 0; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_TabStop_Txt = true; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_TextAlign = System.Windows.Forms.HorizontalAlignment.Left; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_Texto_Inicial = ""; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_Tipo_Decimal_Decimales = 2; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_Tipo_Decimal_Enteros = 9; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_Tipos = Exferia_Aplicacion.General.Enumerados.G_ENUM_TEXTBOX_TIPODATO.Textos; + this.ex_txt_P_ImportacionFacturaE_path.Exferia_TextBox_UseSystemPasswordChar = false; + this.ex_txt_P_ImportacionFacturaE_path.Location = new System.Drawing.Point(65, 7); + this.ex_txt_P_ImportacionFacturaE_path.Name = "ex_txt_P_ImportacionFacturaE_path"; + this.ex_txt_P_ImportacionFacturaE_path.Padding = new System.Windows.Forms.Padding(2); + this.ex_txt_P_ImportacionFacturaE_path.Size = new System.Drawing.Size(407, 22); + this.ex_txt_P_ImportacionFacturaE_path.TabIndex = 50; + // + // ex_pgb_P_ImportacionFacturaE_BarraProgreso + // + this.ex_pgb_P_ImportacionFacturaE_BarraProgreso.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.ex_pgb_P_ImportacionFacturaE_BarraProgreso.BackColor = System.Drawing.Color.Transparent; + this.ex_pgb_P_ImportacionFacturaE_BarraProgreso.Exferia_BarraProgreso_Total = 0; + this.ex_pgb_P_ImportacionFacturaE_BarraProgreso.Location = new System.Drawing.Point(4, 558); + this.ex_pgb_P_ImportacionFacturaE_BarraProgreso.Name = "ex_pgb_P_ImportacionFacturaE_BarraProgreso"; + this.ex_pgb_P_ImportacionFacturaE_BarraProgreso.Size = new System.Drawing.Size(495, 21); + this.ex_pgb_P_ImportacionFacturaE_BarraProgreso.TabIndex = 48; + // + // ex_btn_P_ImportacionFacturaE_actualizaListado + // + this.ex_btn_P_ImportacionFacturaE_actualizaListado.BackColor = System.Drawing.Color.Maroon; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Exferia_Button_Bloqueable = true; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Exferia_Button_Imagen = Exferia_Aplicacion.General.Imagenes.G_ENUM_IMAGENES.G_IMG_ORDEN_ASC; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Exferia_Button_Permitir_CambioFuenteAutomatico = true; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Exferia_Button_ReadOnly = false; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Exferia_Button_TabStop = false; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Exferia_Button_ToolTip = "Cambiar Orden del Listado"; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.FlatAppearance.BorderSize = 0; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Location = new System.Drawing.Point(478, 9); + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Name = "ex_btn_P_ImportacionFacturaE_actualizaListado"; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Size = new System.Drawing.Size(21, 21); + this.ex_btn_P_ImportacionFacturaE_actualizaListado.TabIndex = 47; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.TabStop = false; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Tag = "0"; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.UseVisualStyleBackColor = false; + this.ex_btn_P_ImportacionFacturaE_actualizaListado.Click += new System.EventHandler(this.ex_btn_P_ImportacionFacturaE__ActualizaListado_Click); + // + // exferia_Label1 + // + this.exferia_Label1.AutoSize = true; + this.exferia_Label1.Font = new System.Drawing.Font("Corbel", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.exferia_Label1.Location = new System.Drawing.Point(5, 13); + this.exferia_Label1.Name = "exferia_Label1"; + this.exferia_Label1.Size = new System.Drawing.Size(54, 13); + this.exferia_Label1.TabIndex = 40; + this.exferia_Label1.Text = "Directorio"; + // + // ex_dgv_P_ImportacionFacturaE_Listado + // + this.ex_dgv_P_ImportacionFacturaE_Listado.AllowUserToAddRows = false; + this.ex_dgv_P_ImportacionFacturaE_Listado.AllowUserToDeleteRows = false; + this.ex_dgv_P_ImportacionFacturaE_Listado.AllowUserToOrderColumns = true; + this.ex_dgv_P_ImportacionFacturaE_Listado.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.ex_dgv_P_ImportacionFacturaE_Listado.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; + this.ex_dgv_P_ImportacionFacturaE_Listado.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.ex_dgv_P_ImportacionFacturaE_Listado.EnableHeadersVisualStyles = false; + this.ex_dgv_P_ImportacionFacturaE_Listado.Location = new System.Drawing.Point(3, 35); + this.ex_dgv_P_ImportacionFacturaE_Listado.Name = "ex_dgv_P_ImportacionFacturaE_Listado"; + this.ex_dgv_P_ImportacionFacturaE_Listado.RowHeadersVisible = false; + this.ex_dgv_P_ImportacionFacturaE_Listado.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.ex_dgv_P_ImportacionFacturaE_Listado.ShowCellErrors = false; + this.ex_dgv_P_ImportacionFacturaE_Listado.Size = new System.Drawing.Size(496, 520); + this.ex_dgv_P_ImportacionFacturaE_Listado.TabIndex = 43; + // + // ex_btn_P_ImportacionFacturaE_Importar + // + this.ex_btn_P_ImportacionFacturaE_Importar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.ex_btn_P_ImportacionFacturaE_Importar.BackColor = System.Drawing.Color.Maroon; + this.ex_btn_P_ImportacionFacturaE_Importar.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ex_btn_P_ImportacionFacturaE_Importar.Exferia_Button_Bloqueable = true; + this.ex_btn_P_ImportacionFacturaE_Importar.Exferia_Button_Imagen = Exferia_Aplicacion.General.Imagenes.G_ENUM_IMAGENES.G_IMG_EXCEL; + this.ex_btn_P_ImportacionFacturaE_Importar.Exferia_Button_Permitir_CambioFuenteAutomatico = true; + this.ex_btn_P_ImportacionFacturaE_Importar.Exferia_Button_ReadOnly = false; + this.ex_btn_P_ImportacionFacturaE_Importar.Exferia_Button_TabStop = false; + this.ex_btn_P_ImportacionFacturaE_Importar.Exferia_Button_ToolTip = "Exportar a Excel ()"; + this.ex_btn_P_ImportacionFacturaE_Importar.FlatAppearance.BorderSize = 0; + this.ex_btn_P_ImportacionFacturaE_Importar.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.ex_btn_P_ImportacionFacturaE_Importar.Location = new System.Drawing.Point(754, 72); + this.ex_btn_P_ImportacionFacturaE_Importar.Name = "ex_btn_P_ImportacionFacturaE_Importar"; + this.ex_btn_P_ImportacionFacturaE_Importar.Size = new System.Drawing.Size(31, 36); + this.ex_btn_P_ImportacionFacturaE_Importar.TabIndex = 68; + this.ex_btn_P_ImportacionFacturaE_Importar.TabStop = false; + this.ex_btn_P_ImportacionFacturaE_Importar.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.ex_btn_P_ImportacionFacturaE_Importar.UseVisualStyleBackColor = false; + this.ex_btn_P_ImportacionFacturaE_Importar.Click += new System.EventHandler(this.ex_btn_P_ImportacionFacturaE_importar_Click); + // + // P_ImportacionFacturaE_Total + // + this.P_ImportacionFacturaE_Total.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.P_ImportacionFacturaE_Total.BackColor = System.Drawing.Color.Gainsboro; + this.P_ImportacionFacturaE_Total.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.P_ImportacionFacturaE_Total.Location = new System.Drawing.Point(21, 148); + this.P_ImportacionFacturaE_Total.Name = "P_ImportacionFacturaE_Total"; + this.P_ImportacionFacturaE_Total.Size = new System.Drawing.Size(167, 23); + this.P_ImportacionFacturaE_Total.TabIndex = 445; + this.P_ImportacionFacturaE_Total.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // P_ImportacionFacturaE_Comprador + // + this.P_ImportacionFacturaE_Comprador.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.P_ImportacionFacturaE_Comprador.BackColor = System.Drawing.Color.Gainsboro; + this.P_ImportacionFacturaE_Comprador.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.P_ImportacionFacturaE_Comprador.Location = new System.Drawing.Point(21, 100); + this.P_ImportacionFacturaE_Comprador.Name = "P_ImportacionFacturaE_Comprador"; + this.P_ImportacionFacturaE_Comprador.Size = new System.Drawing.Size(167, 23); + this.P_ImportacionFacturaE_Comprador.TabIndex = 446; + this.P_ImportacionFacturaE_Comprador.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // P_ImportacionFacturaE_vendedor + // + this.P_ImportacionFacturaE_vendedor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.P_ImportacionFacturaE_vendedor.BackColor = System.Drawing.Color.Gainsboro; + this.P_ImportacionFacturaE_vendedor.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.P_ImportacionFacturaE_vendedor.Location = new System.Drawing.Point(21, 55); + this.P_ImportacionFacturaE_vendedor.Name = "P_ImportacionFacturaE_vendedor"; + this.P_ImportacionFacturaE_vendedor.Size = new System.Drawing.Size(167, 23); + this.P_ImportacionFacturaE_vendedor.TabIndex = 447; + this.P_ImportacionFacturaE_vendedor.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // P_ImportacionFacturaE + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.ClientSize = new System.Drawing.Size(797, 670); + this.Controls.Add(this.pnl_Contenedor_Inferior); + this.Controls.Add(this.ex_btn_P_ImportacionFacturaE_Importar); + this.Name = "P_ImportacionFacturaE"; + this.Load += new System.EventHandler(this.P_DevolucionPago_Bolsa_Load); + this.Shown += new System.EventHandler(this.P_DevolucionPago_Bolsa_Shown); + this.Controls.SetChildIndex(this.ex_btn_P_ImportacionFacturaE_Importar, 0); + this.Controls.SetChildIndex(this.pnl_Contenedor_Inferior, 0); + this.pnl_Contenedor_Inferior.ResumeLayout(false); + this.pnl_Contenedor_Inferior.PerformLayout(); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ex_dgv_P_ImportacionFacturaE_Listado)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Panel pnl_Contenedor_Inferior; + private Exferia_Controles.Exferia_BarraProgreso ex_pgb_P_ImportacionFacturaE_BarraProgreso; + private Exferia_Controles.Exferia_Button ex_btn_P_ImportacionFacturaE_actualizaListado; + private Exferia_Controles.Exferia_Label exferia_Label1; + public Exferia_Controles.Exferia_DataGridView ex_dgv_P_ImportacionFacturaE_Listado; + private Exferia_Controles.Exferia_Button ex_btn_P_ImportacionFacturaE_Importar; + private Exferia_Controles.Exferia_TextBox ex_txt_P_ImportacionFacturaE_path; + private Exferia_Controles.Exferia_Panel_Degradado panel1; + private Exferia_Controles.Exferia_Label exferia_Label3; + private Exferia_Controles.Exferia_Label exferia_Label2; + private Exferia_Controles.Exferia_Label ex_lbl_P_FacturaCabecera_Anexo_Empresa; + private Exferia_Controles.Exferia_Label_SinColor P_ImportacionFacturaE_vendedor; + private Exferia_Controles.Exferia_Label_SinColor P_ImportacionFacturaE_Comprador; + private Exferia_Controles.Exferia_Label_SinColor P_ImportacionFacturaE_Total; + } +} diff --git a/Exferia_Compras/Exferia_Compras/3_Vistas/P_ImportacionFacturaE.cs b/Exferia_Compras/Exferia_Compras/3_Vistas/P_ImportacionFacturaE.cs new file mode 100644 index 0000000..76f4d6c --- /dev/null +++ b/Exferia_Compras/Exferia_Compras/3_Vistas/P_ImportacionFacturaE.cs @@ -0,0 +1,941 @@ +using Exferia_Aplicacion.General; +using Exferia_Aplicacion.Visualizacion; +using Exferia_Controles; +using Exferia_General; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.Linq; +using static Exferia_Aplicacion.General.Enumerados; +using Exferia_Aplicacion.Modelos_Listado_Filtros; +using ClosedXML.Excel; +using System.Reflection; +using Exferia_Formularios; +using Exferia_Compras._3_Vistas.Controladoras; + +namespace Exferia_Compras._3_Vistas +{ + public partial class P_ImportacionFacturaE : Exferia_Formularios.P_Base_Mantenimientos + { + #region Variables General + private P_ImportacionFacturaE_Controladora g_obj_Controladora; + + public INTERNO_OpcionesDetalle_Modelo g_mdl_INTERNO_OpcionesDetalle_Modelo = null; + + private bool g_bol_ConstructorPantalla_Terminado_Correctamente = true; + internal List g_lst_INTERNO_Permisos_Modelo = null; + + //Clientes a Seleccionar + private INTERNO_ConfiguracionPantalla_Modelo g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA = null; + #endregion + + #region Objetos en Pantalla + //Exferia_BarraProgreso + internal Exferia_BarraProgreso Exferia_BarraProgreso_Bolsa { get { return ex_pgb_P_ImportacionFacturaE_BarraProgreso; } } + + //Exferia_DataGridView + internal Exferia_DataGridView Exferia_DataGridView_Listado { get { return ex_dgv_P_ImportacionFacturaE_Listado; } } + + + #endregion + + + #region Constructor + public P_ImportacionFacturaE(INTERNO_ValoresGenerales_Modelo _mdl_INTERNO_ValoresGenerales_Modelo, DateTime _dtt_FechaTrabajo) + { + InitializeComponent(); + + try + { + Repintar.Empezar(this); + + CheckForIllegalCrossThreadCalls = false; + + //Empresa seleccionada y fecha de trabajo .................................................... + P_Base_ValoresGenerales = _mdl_INTERNO_ValoresGenerales_Modelo; + P_Base_FechaTrabajo = _dtt_FechaTrabajo; + + //Datos de Opciones detalle + g_mdl_INTERNO_OpcionesDetalle_Modelo = Datos_Generales.PRV_Opciones_Buscar_Detalles(Variables.G_STR_OPCION_COM_DEVOLUCIONPAGO_BOLSA); + + //Instanciar Controladora + g_obj_Controladora = new P_ImportacionFacturaE_Controladora(this); + + //Buscar los Permisos + g_lst_INTERNO_Permisos_Modelo = Datos_Generales.Permisos_Buscar(Variables.G_STR_OPCION_COM_DEVOLUCIONPAGO_BOLSA); + + //Titulo de la Pantalla ............................................................................. + P_Base_TituloPantalla = g_mdl_INTERNO_OpcionesDetalle_Modelo.descripcion_TituloMantenimiento; + + if (Variables.G_DCT_CONFIGURACIONPANTALLA != null && Variables.G_DCT_CONFIGURACIONPANTALLA.Count > 0) + { + //Listado bolsa + if (Variables.G_DCT_CONFIGURACIONPANTALLA.ContainsKey(g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.NOMBRELISTADO_ALMACENARCONFIGURACION())) + { + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA = Variables.G_DCT_CONFIGURACIONPANTALLA[g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.NOMBRELISTADO_ALMACENARCONFIGURACION()]; + } + } + + // Label con Empresa Seleccionada + if (P_Base_ValoresGenerales != null) + { + try + { + P_Base_Mantenimientos_InformacionEmpresaSeleccionada = P_Base_ValoresGenerales.str_Empresa_Descripcion + " - " + + "(" + P_Base_FechaTrabajo.ToString("dd/MM/yyyy") + ")"; + } + catch (Exception ex) + { + //No se muestra mensaje pero se guarda en el log + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa) + "/" + nameof(P_DevolucionPago_Bolsa)); + } + } + //.................................................................................................... + + //Bloquear pantalla hasta que termine la carga por defecto ..... + Enabled = false; + //............................................................. + } + catch (Control_Errores) + { + g_bol_ConstructorPantalla_Terminado_Correctamente = false; + } + catch (Exception ex) + { + g_bol_ConstructorPantalla_Terminado_Correctamente = false; + + //No se muestra mensaje pero se guarda en el log + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa) + "/" + nameof(P_DevolucionPago_Bolsa)); + } + finally + { + //Bloquear pantalla hasta que termine la carga por defecto ..... + Enabled = true; + //............................................................. + } + } + #endregion + + #region Inicio de pantalla + + private void P_DevolucionPago_Bolsa_Load(object sender, EventArgs e) + { + try + { + #region LISTADO BOLSA + //Crear Columnas Listado + CrearColumnas_Listado(); + + //Poner el tipo de orden si lo hubiera por defecto ################################################################################### + if (g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA != null && + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_ORDEN_DIRECCION_PORDEFECTO != null && + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_ORDEN_DIRECCION_PORDEFECTO.Trim().Length > 0) + { + //Descendente + if (g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_ORDEN_DIRECCION_PORDEFECTO.Equals("1")) + { + Funciones.Cambiar_Imagen_Boton_Orden(0, ex_btn_P_ImportacionFacturaE_actualizaListado); + ex_btn_P_ImportacionFacturaE_actualizaListado.Tag = "1"; + } + //Ascendente + else + { + Funciones.Cambiar_Imagen_Boton_Orden(1, ex_btn_P_ImportacionFacturaE_actualizaListado); + ex_btn_P_ImportacionFacturaE_actualizaListado.Tag = "0"; + } + } + else + { + if (g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.ORDENACION_TIPO_PORDEFECTO().Trim().Length > 0) + { + //Descendente + if (g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.ORDENACION_TIPO_PORDEFECTO().Equals("1")) + { + Funciones.Cambiar_Imagen_Boton_Orden(0, ex_btn_P_ImportacionFacturaE_actualizaListado); + ex_btn_P_ImportacionFacturaE_actualizaListado.Tag = "1"; + } + //Ascendente + else + { + Funciones.Cambiar_Imagen_Boton_Orden(1, ex_btn_P_ImportacionFacturaE_actualizaListado); + ex_btn_P_ImportacionFacturaE_actualizaListado.Tag = "0"; + + } + } + } + + //Seleccionar Orden por Defecto en Combo ########################################################################################################### + if (g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA != null && + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_ORDEN_COLUMNA_PORDEFECTO != null && + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_ORDEN_COLUMNA_PORDEFECTO.Trim().Length > 0) + { + ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.SelectedItem = ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.Items.Cast().Where(m => m.Descripcion.Equals(g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_ORDEN_COLUMNA_PORDEFECTO)).FirstOrDefault(); + } + else + { + if (g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.ORDENACION_NOMBRECOLUMNA_PORDEFECTO().Trim().Length > 0) + { + ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.SelectedItem = ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.Items.Cast().Where(m => m.Identificador.Equals(g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.ORDENACION_NOMBRECOLUMNA_PORDEFECTO())).FirstOrDefault(); + } + else + { + ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.SelectedItem = ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.Items.Cast().FirstOrDefault(); + } + + } + #endregion + } + catch (Exception ex) + { + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa) + "/" + nameof(P_DevolucionPago_Bolsa_Load)); + + g_bol_ConstructorPantalla_Terminado_Correctamente = false; + } + } + + private void P_DevolucionPago_Bolsa_Shown(object sender, EventArgs e) + { + try + { + if (g_bol_ConstructorPantalla_Terminado_Correctamente) + { + //Rellenar el Listado + g_obj_Controladora.Recargar_Listado(true); + } + else + { + Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA()); + Salir_P_Base(); + } + } + catch (Control_Errores) + { + Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA()); + Salir_P_Base(); + } + catch (Exception ex) + { + //No se muestra mensaje pero se guarda en el log + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa) + "/" + nameof(P_DevolucionPago_Bolsa_Shown)); + + Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA()); + Salir_P_Base(); + } + } + #endregion + + #region Listado + private void CrearColumnas_Listado() + { + ex_dgv_P_ImportacionFacturaE_Listado.AutoGenerateColumns = false; + + foreach (INTERNO_ABS_Listado_ColumnasDatos_Modelo mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo in g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.LISTADO_COLUMNAS().Values.ToList()) + { + DataGridViewTextBoxColumn dgv_Columna = new DataGridViewTextBoxColumn(); + dgv_Columna.DataPropertyName = mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna; + dgv_Columna.Name = mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna; + dgv_Columna.HeaderText = mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_AMostrar; + + //Poner visible o no ......................................................................... + bool bol_Visible = true; + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.NoOcultable == false) + { + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Oculto) + { + bol_Visible = false; + } + else if (g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA != null && + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNASAMOSTRAR != null && + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNASAMOSTRAR.Count > 0) + { + if (!g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNASAMOSTRAR.Contains(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna)) + { + bol_Visible = false; + } + } + else if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Mostrado_PorDefecto == false) + { + bol_Visible = false; + } + } + dgv_Columna.Visible = bol_Visible; + + + if (bol_Visible) + { + g_obj_Controladora.g_lst_ColumnasAMostrar_BOLSA.Add(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna); + } + //..................................................................................................... + + //Tipo de Formateo si fuera Fecha + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.DATETIME)) + { + dgv_Columna.DefaultCellStyle.Format = "d"; + } + + //Poner Ancho Columna ................................................................................ + if (g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA != null && + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNAS_ANCHO != null && + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNAS_ANCHO.Count > 0 && + g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNAS_ANCHO.ContainsKey(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna)) + { + dgv_Columna.Width = g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNAS_ANCHO[mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna]; + } + else + { + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Ancho > 0) + { + dgv_Columna.Width = mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Ancho; + } + } + //................................................................................................................ + + dgv_Columna.ReadOnly = true; + + //Poner alineado segun tipo de datos ...................................................................................... + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.DECIMAL) || + mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.LONG) || + mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.LONG_TEXT) || + mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.INT)) + { + dgv_Columna.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; + } + else + { + dgv_Columna.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; + } + //.............................................................................................................................. + + ex_dgv_P_ImportacionFacturaE_Listado.Columns.Add(dgv_Columna); + + //RELLENAR EL ORDEN EN COMBO + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Oculto == false) + { + ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.Items.Add(new INTERNO_ComboBox_Modelo(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna, mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_AMostrar, null)); + } + } + + //Cambiar el orden de las columnas ........ + if (g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA != null && g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNAS_ORDEN != null && g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNAS_ORDEN.Count > 0) + { + foreach (KeyValuePair kvp_Valores in g_mdl_INTERNO_ConfiguracionPantalla_Modelo_BOLSA.LISTADO_COLUMNAS_ORDEN) + { + ex_dgv_P_ImportacionFacturaE_Listado.Columns[kvp_Valores.Key].DisplayIndex = kvp_Valores.Value; + } + } + //......................................... + } + + #region Orden + private void ex_btn_P_ImportacionFacturaE__ActualizaListado_Click(object sender, EventArgs e) + { + //Esta Descedente + if (ex_btn_P_ImportacionFacturaE_actualizaListado.Tag.ToString().Equals("1")) + { + Funciones.Cambiar_Imagen_Boton_Orden(1, ex_btn_P_ImportacionFacturaE_actualizaListado); + } + //Esta Ascendente + else + { + Funciones.Cambiar_Imagen_Boton_Orden(0, ex_btn_P_ImportacionFacturaE_actualizaListado); + } + + //Ordena el Listado + Ordenar_DataGridView(); + } + + private void ex_cbo_P_DevolucionPago_Bolsa_OrdenListado_SelectedIndexChanged(object sender, EventArgs e) + { + //Ordena el Listado + Ordenar_DataGridView(); + } + private void Ordenar_DataGridView() + { + try + { + if (ex_dgv_P_ImportacionFacturaE_Listado.Rows.Count > 0) + { + //Saber el Tipo de Ordenacion ................................. + ListSortDirection obj_ListSortDirection = ListSortDirection.Ascending; + if (ex_btn_P_ImportacionFacturaE_actualizaListado.Tag.ToString().Equals("1")) + { + obj_ListSortDirection = ListSortDirection.Descending; + } + //.............................................................. + + if (ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.SelectedItem != null && ((INTERNO_ComboBox_Modelo)ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.SelectedItem).Identificador.Trim().Length > 0) + { + ex_dgv_P_ImportacionFacturaE_Listado.Sort(ex_dgv_P_ImportacionFacturaE_Listado.Columns[((INTERNO_ComboBox_Modelo)ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.SelectedItem).Identificador], obj_ListSortDirection); + + + //Ordenar el Listado ################## + + //Descendente + if (ex_btn_P_ImportacionFacturaE_actualizaListado.Tag.ToString().Equals("1")) + { + g_obj_Controladora.g_lst_Valores = g_obj_Controladora.g_lst_Valores.OrderByDescending(m => m.GetType().GetProperty(((INTERNO_ComboBox_Modelo)ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.SelectedItem).Identificador).GetValue(m, null)).ToList(); + } + //Ascendente + else + { + g_obj_Controladora.g_lst_Valores = g_obj_Controladora.g_lst_Valores.OrderBy(m => m.GetType().GetProperty(((INTERNO_ComboBox_Modelo)ex_cbo_P_DevolucionPago_Bolsa_OrdenListado.SelectedItem).Identificador).GetValue(m, null)).ToList(); + } + } + else + { + ex_dgv_P_ImportacionFacturaE_Listado.Sort(ex_dgv_P_ImportacionFacturaE_Listado.Columns[g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.ORDENACION_NOMBRECOLUMNA_PORDEFECTO()], obj_ListSortDirection); + + //Descendente + if (ex_btn_P_ImportacionFacturaE_actualizaListado.Tag.ToString().Equals("1")) + { + g_obj_Controladora.g_lst_Valores = g_obj_Controladora.g_lst_Valores.OrderByDescending(m => m.GetType().GetProperty(g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.ORDENACION_NOMBRECOLUMNA_PORDEFECTO()).GetValue(m, null)).ToList(); + } + //Ascendente + else + { + g_obj_Controladora.g_lst_Valores = g_obj_Controladora.g_lst_Valores.OrderBy(m => m.GetType().GetProperty(g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.ORDENACION_NOMBRECOLUMNA_PORDEFECTO()).GetValue(m, null)).ToList(); + } + } + + string str_NombreCampoClave = "id"; + INTERNO_ABS_Listado_ColumnasDatos_Modelo mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo = g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.LISTADO_COLUMNAS().Values.Where(m => m.ColumnaClave).FirstOrDefault(); + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo != null) + { + str_NombreCampoClave = mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna; + } + + ///m.GetType().GetProperty(str_NombreCampoClave).GetValue(m, null) + P_Base_Objetos_Filtrados = g_obj_Controladora.g_lst_Valores.Select(m => new INTERNO_Listado_CamposClave_Modelo { ID = m.GetType().GetProperty(str_NombreCampoClave).GetValue(m) }).ToList(); + //........................................................................................................... + + //Seleccionar la primera + ex_dgv_P_ImportacionFacturaE_Listado.ClearSelection(); + ex_dgv_P_ImportacionFacturaE_Listado.Rows[0].Selected = true; + } + } + catch (Exception) + { } + } + #endregion + + + #endregion + + #region Eventos y Procedimientos Publicos + public override void P_Base_ActualizarRegistros_Campo(List _lst_CamposActualizar, G_ENUM_TIPOACCION _enum_TipoAccion) + { + if (_lst_CamposActualizar != null && _lst_CamposActualizar.Count > 0) + { + //Actualizar el Listado Principal + if (P_Base_PantallaOrigen != null) + { + P_Base_PantallaOrigen.P_Base_ActualizarRegistros_Campo(_lst_CamposActualizar, _enum_TipoAccion); + } + + //Cargar los Datos desde Base de datos + g_obj_Controladora.Recargar_Listado(true); + } + } + + #endregion + + #region Botones + //Exportar a Excel + private void ex_btn_P_ImportacionFacturaE_importar_Click(object sender, EventArgs e) + { + //Exportar_Excel(); + } + private void Exportar_Excel() + { + if (Datos_Generales.Permisos_Comprobar(g_mdl_INTERNO_OpcionesDetalle_Modelo.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.ExportarAExcel, true)) + { + XLWorkbook obj_XLWorkbook = new XLWorkbook(); + + try + { + //Crea la hoja del Excell + var obj_worksheet = obj_XLWorkbook.Worksheets.Add("Hoja 1"); + + //Cabecera + int int_Contador = 1; + + List lst_ColumnasVisibles = ex_dgv_P_ImportacionFacturaE_Listado.Columns + .Cast() + .Where(r => r.Visible) + .OrderBy(r => r.DisplayIndex) + .ToList(); + + foreach (DataGridViewColumn dgvc_Columna in lst_ColumnasVisibles) + { + obj_worksheet.Cell(1, int_Contador).Value = dgvc_Columna.HeaderText; + + //Formato de color al texto y al fondo + obj_worksheet.Cell(1, int_Contador).Style.Fill.BackgroundColor = XLColor.FromHtml(Funciones.Convertir_Color_Hexadecimal(Colores.G_COLOR_PRINCIPAL_BASE)); + obj_worksheet.Cell(1, int_Contador).Style.Font.FontColor = XLColor.FromHtml(Funciones.Convertir_Color_Hexadecimal(Colores.G_COLOR_LISTADO_CABECERA_LETRA)); + int_Contador++; + } + + //Lineas + int int_Contador_Fila = 0; + int int_Contador_Columna = 0; + if (g_obj_Controladora.g_lst_Valores != null) + { + //Recorrer las Filas + foreach (dynamic dnm_Registro in g_obj_Controladora.g_lst_Valores) + { + //Recorrer Columnas Visibles + foreach (DataGridViewColumn dgvc_Columna in lst_ColumnasVisibles) + { + string str_NombreColumna = dgvc_Columna.Name; + + //Buscar el modelo para poder saber que tipo de columna es + INTERNO_ABS_Listado_ColumnasDatos_Modelo mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo = g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.LISTADO_COLUMNAS()[str_NombreColumna]; + + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo != null) + { + //Tipo fecha + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.DATETIME)) + { + DateTime? dtt_Valor = dnm_Registro.GetType().GetProperty(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna).GetValue(dnm_Registro, null); + + if (dtt_Valor != null) + { + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).SetValue(dtt_Valor.Value.ToString("dd/MM/yyyy")).Style.DateFormat.SetFormat("dd/mm/yyyy"); + } + else + { + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).Value = ""; + } + } + //Tipo booleano + else if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.BOOLEAN)) + { + bool? bol_Valor = dnm_Registro.GetType().GetProperty(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna).GetValue(dnm_Registro, null); + string str_Valor = bol_Valor != null && bol_Valor.Value ? "X" : ""; + + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).SetValue(str_Valor).SetDataType(XLCellValues.Text); + } + //Tipo decimal + else if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.DECIMAL)) + { + decimal? dcm_valor = dnm_Registro.GetType().GetProperty(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna).GetValue(dnm_Registro, null); + string str_Valor = (dcm_valor != null ? dcm_valor.ToString() : "").Replace(",", "."); + + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).SetValue(str_Valor).SetDataType(XLCellValues.Number); + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).Style.NumberFormat.Format = "0.0#?"; + + //Alinear los numeros a la derecha + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; + + } + //Tipo long + else if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.LONG)) + { + long? lng_valor = dnm_Registro.GetType().GetProperty(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna).GetValue(dnm_Registro, null); + string str_Valor = lng_valor != null ? lng_valor.ToString() : ""; + + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).SetValue(str_Valor).SetDataType(XLCellValues.Number); + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).Style.NumberFormat.Format = "0"; + + //Alinear los numeros a la derecha + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; + } + //Tipo int + else if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.TipoDato.Equals(G_ENUM_TIPOSDATOS.INT)) + { + int? int_valor = dnm_Registro.GetType().GetProperty(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna).GetValue(dnm_Registro, null); + string str_Valor = int_valor != null ? int_valor.ToString() : ""; + + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).SetValue(str_Valor).SetDataType(XLCellValues.Number); + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).Style.NumberFormat.Format = "0"; + + //Alinear los numeros a la derecha + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; + } + //Tipo texto + else + { + string str_valor = dnm_Registro.GetType().GetProperty(mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna).GetValue(dnm_Registro, null); + + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).SetValue(str_valor).SetDataType(XLCellValues.Text); + + //Alinear los texto a la derecha + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + } + } + else + { + obj_worksheet.Cell(int_Contador_Fila + 2, int_Contador_Columna + 1).Value = ""; + } + + //Sumo 1 a la columna + int_Contador_Columna += 1; + } + + //Sumo 1 a la fila + int_Contador_Fila += 1; + + //las Columnas se reinician a 0 + int_Contador_Columna = 0; + } + } + + //Ajusto el Excell al contenido + obj_worksheet.Columns().AdjustToContents(); + + //Abro un dialog para Guardar + SaveFileDialog save = new SaveFileDialog(); + save.Filter = "Excel (*.xlsx)|*.xlsx"; + save.Title = "Excel"; + + if (save.ShowDialog() == DialogResult.OK) + { + //Guardo el Excell + obj_XLWorkbook.SaveAs(save.FileName); + + Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_EXPORTAREXCEL_CORRECTO()); + } + } + catch (Exception ex) + { + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa) + "/" + nameof(Exportar_Excel)); + Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_EXPORTAREXCEL()); + } + finally + { + obj_XLWorkbook.Dispose(); + } + } + } + + //Borrar Lineas + private void ex_btn_P_DevolucionPago_Bolsa_Borrar_Click(object sender, EventArgs e) + { + Borrar(); + } + private void Borrar() + { + try + { + if (Datos_Generales.Permisos_Comprobar(g_mdl_INTERNO_OpcionesDetalle_Modelo.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Borrar, true)) + { + //Registro Seleccionados ........................................ + List lst_ids = new List(); + + if (ex_dgv_P_ImportacionFacturaE_Listado.Rows.Count > 0) + { + //Buscar el Campo Clave + string str_NombreCampoClave = "id"; + INTERNO_ABS_Listado_ColumnasDatos_Modelo mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo = g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa.LISTADO_COLUMNAS().Values.Where(m => m.ColumnaClave).FirstOrDefault(); + if (mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo != null) + { + str_NombreCampoClave = mdl_INTERNO_ABS_Listado_ColumnasDatos_Modelo.Descripcion_Interna; + } + + if (ex_dgv_P_ImportacionFacturaE_Listado.SelectedRows != null && ex_dgv_P_ImportacionFacturaE_Listado.SelectedRows.Count > 0) + { + foreach (DataGridViewRow dgvr in ex_dgv_P_ImportacionFacturaE_Listado.SelectedRows) + { + lst_ids.Add(long.Parse(dgvr.Cells[str_NombreCampoClave].Value.ToString())); + } + } + } + //................................................................ + + //Cargamos el ensamblado + Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_COMPRAS + ".dll"); + //Obtenemos el tipo de la clase + Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_COMPRAS + "." + Variables.G_STR_LIBRERIA_OPCIONES); + //creamos la instancia + var obj_Clase = Activator.CreateInstance(m_type); + //Cargamos el metodo solicitado + MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_OPCIONES_PROCEDIMIENTO_BORRAR_BOLSA, BindingFlags.Instance | BindingFlags.NonPublic); + + object[] arr_Parametros = { g_mdl_INTERNO_OpcionesDetalle_Modelo.opcion, + this, + Variables.G_MDL_INTERNO_VALORESGENERALES_MODELO, + this.P_Base_FechaTrabajo, + lst_ids + }; + + //Pasamos los parametros al metodo y lo ejecutamos + obj_MethodInfo.Invoke(obj_Clase, arr_Parametros); + } + } + catch (Control_Errores) + { } + catch (Exception ex) + { + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa) + "/" + nameof(Borrar)); + } + } + + //Añadir segun filtros + private void ex_btn_P_DevolucionPago_Bolsa_FiltroAdd_Click(object sender, EventArgs e) + { + FiltroAdd(); + } + private void FiltroAdd() + { + try + { + if (Datos_Generales.Permisos_Comprobar(Variables.G_STR_OPCION_COM_DEVOLUCIONPAGO_BOLSA, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Anadir, true)) + { + Dictionary dct_ListadoFiltros_Agregados = new Dictionary(); + + PE_Listados_Filtros frm_PE_Listados_Filtros = new PE_Listados_Filtros(g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa, ex_dgv_P_ImportacionFacturaE_Listado.Columns, dct_ListadoFiltros_Agregados); + frm_PE_Listados_Filtros.ShowDialog(); + + if (frm_PE_Listados_Filtros.g_bol_BotonAceptar) + { + //Mostrar/Ocultar las Columnas que no esten en el Listado ############################################ + g_obj_Controladora.g_lst_ColumnasAMostrar_BOLSA = frm_PE_Listados_Filtros.g_lst_ColumnasAMostrar; + + bool bol_Cambio_MostraroOcultar_Columnas = false; + + foreach (DataGridViewColumn dgvc_ColumnasActuales in ex_dgv_P_ImportacionFacturaE_Listado.Columns) + { + //Mostrar + if (g_obj_Controladora.g_lst_ColumnasAMostrar_BOLSA.Contains(dgvc_ColumnasActuales.Name)) + { + if (!dgvc_ColumnasActuales.Visible) + { + bol_Cambio_MostraroOcultar_Columnas = true; + } + + dgvc_ColumnasActuales.Visible = true; + } + //Ocultar + else + { + if (dgvc_ColumnasActuales.Visible) + { + bol_Cambio_MostraroOcultar_Columnas = true; + } + + dgvc_ColumnasActuales.Visible = false; + } + } + //###################################################################################################### + + //Rellenar los bolsa con los filtros hechos ############################################################################################################################# + dct_ListadoFiltros_Agregados = frm_PE_Listados_Filtros.g_dct_ListadoFiltros.ToDictionary(entry => entry.Key, entry => entry.Value); + + //Si no cambio ninguna columna (mostrar/Ocultar) y no hay filtros, se cargar los filtros avanzados + //Si no cambio ninguna columna (mostrar/Ocultar) y hay filtros, se cargar los filtros avanzados + //Si cambio alguna columna (mostrar/Ocultar) y no hay filtros, no se cargar los filtros avanzados + //Si cambio alguna columna (mostrar/Ocultar) y hay filtros, se cargar los filtros avanzados + + if (bol_Cambio_MostraroOcultar_Columnas && (dct_ListadoFiltros_Agregados == null || dct_ListadoFiltros_Agregados.Count == 0)) + { + if (frm_PE_Listados_Filtros.g_bol_RecargarListado) + { + //Cargar los Datos desde Base de datos + g_obj_Controladora.Recargar_Listado(true); + } + } + else if (dct_ListadoFiltros_Agregados != null && dct_ListadoFiltros_Agregados.Count > 0) + { + //Cargamos el ensamblado + Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_COMPRAS + ".dll"); + //Obtenemos el tipo de la clase + Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_COMPRAS + "." + Variables.G_STR_LIBRERIA_OPCIONES); + //creamos la instancia + var obj_Clase = Activator.CreateInstance(m_type); + //Cargamos el metodo solicitado + MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_OPCIONES_PROCEDIMIENTO_FILTRAR_REGISTROS_PARA_BOLSA, BindingFlags.Instance | BindingFlags.NonPublic); + + object[] arr_Parametros = { g_mdl_INTERNO_OpcionesDetalle_Modelo.opcion, + Variables.G_STR_OPCION_COM_DEVOLUCIONPAGO, + P_Base_ValoresGenerales.lng_idEmpresa, + P_Base_ValoresGenerales.EjercicioActivo.id, + g_obj_Controladora.g_lst_ColumnasAMostrar_BOLSA, + dct_ListadoFiltros_Agregados + }; + + //Pasamos los parametros al metodo y lo ejecutamos + List lst_id_Agregar = (List)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros); + //######################################################################################################################################################################## + + if (lst_id_Agregar != null && lst_id_Agregar.Count > 0) + { + List lst_id_AgregarFInal = lst_id_Agregar.Cast().ToList(); + + + //creamos la instancia + var obj_Clase2 = Activator.CreateInstance(m_type); + //Cargamos el metodo solicitado + MethodInfo obj_MethodInfo2 = obj_Clase2.GetType().GetMethod(Variables.G_STR_LIBRERIA_OPCIONES_PROCEDIMIENTO_AGREGAR_BOLSA, BindingFlags.Instance | BindingFlags.NonPublic); + + object[] arr_Parametros2 = { g_mdl_INTERNO_OpcionesDetalle_Modelo.opcion, + this, + Variables.G_MDL_INTERNO_VALORESGENERALES_MODELO, + this.P_Base_FechaTrabajo, + lst_id_AgregarFInal + }; + + //Pasamos los parametros al metodo y lo ejecutamos + obj_MethodInfo2.Invoke(obj_Clase2, arr_Parametros2); + } + else if (frm_PE_Listados_Filtros.g_bol_RecargarListado) + { + //Cargar los Datos desde Base de datos + g_obj_Controladora.Recargar_Listado(true); + } + } + } + } + } + catch (Control_Errores) + { } + catch (Exception ex) + { + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa) + "/" + nameof(FiltroAdd)); + } + } + + + //Quitar segun Filtros + private void ex_btn_P_DevolucionPago_Bolsa_FiltroBorrar_Click(object sender, EventArgs e) + { + FiltroBorrar(); + } + private void FiltroBorrar() + { + try + { + if (Datos_Generales.Permisos_Comprobar(Variables.G_STR_OPCION_COM_DEVOLUCIONPAGO_BOLSA, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Borrar, true)) + { + Dictionary dct_ListadoFiltros_Agregados = new Dictionary(); + + PE_Listados_Filtros frm_PE_Listados_Filtros = new PE_Listados_Filtros(g_obj_Controladora.g_obj_ABS_Listado_COM_DevolucionesPagos_Bolsa, ex_dgv_P_ImportacionFacturaE_Listado.Columns, dct_ListadoFiltros_Agregados); + frm_PE_Listados_Filtros.ShowDialog(); + + if (frm_PE_Listados_Filtros.g_bol_BotonAceptar) + { + //Mostrar/Ocultar las Columnas que no esten en el Listado ############################################ + g_obj_Controladora.g_lst_ColumnasAMostrar_BOLSA = frm_PE_Listados_Filtros.g_lst_ColumnasAMostrar; + + bool bol_Cambio_MostraroOcultar_Columnas = false; + + foreach (DataGridViewColumn dgvc_ColumnasActuales in ex_dgv_P_ImportacionFacturaE_Listado.Columns) + { + //Mostrar + if (g_obj_Controladora.g_lst_ColumnasAMostrar_BOLSA.Contains(dgvc_ColumnasActuales.Name)) + { + if (!dgvc_ColumnasActuales.Visible) + { + bol_Cambio_MostraroOcultar_Columnas = true; + } + + dgvc_ColumnasActuales.Visible = true; + } + //Ocultar + else + { + if (dgvc_ColumnasActuales.Visible) + { + bol_Cambio_MostraroOcultar_Columnas = true; + } + + dgvc_ColumnasActuales.Visible = false; + } + } + //###################################################################################################### + + //Rellenar los bolsa con los filtros hechos ############################################################################################################################# + dct_ListadoFiltros_Agregados = frm_PE_Listados_Filtros.g_dct_ListadoFiltros.ToDictionary(entry => entry.Key, entry => entry.Value); + + //Si no cambio ninguna columna (mostrar/Ocultar) y no hay filtros, se cargar los filtros avanzados + //Si no cambio ninguna columna (mostrar/Ocultar) y hay filtros, se cargar los filtros avanzados + //Si cambio alguna columna (mostrar/Ocultar) y no hay filtros, no se cargar los filtros avanzados + //Si cambio alguna columna (mostrar/Ocultar) y hay filtros, se cargar los filtros avanzados + + if (bol_Cambio_MostraroOcultar_Columnas && (dct_ListadoFiltros_Agregados == null || dct_ListadoFiltros_Agregados.Count == 0)) + { + if (frm_PE_Listados_Filtros.g_bol_RecargarListado) + { + //Cargar los Datos desde Base de datos + g_obj_Controladora.Recargar_Listado(true); + } + } + else if (dct_ListadoFiltros_Agregados != null && dct_ListadoFiltros_Agregados.Count > 0) + { + //Cargamos el ensamblado + Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_COMPRAS + ".dll"); + //Obtenemos el tipo de la clase + Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_COMPRAS + "." + Variables.G_STR_LIBRERIA_OPCIONES); + //creamos la instancia + var obj_Clase = Activator.CreateInstance(m_type); + //Cargamos el metodo solicitado + MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_OPCIONES_PROCEDIMIENTO_FILTRAR_REGISTROS_PARA_BOLSA, BindingFlags.Instance | BindingFlags.NonPublic); + + object[] arr_Parametros = { g_mdl_INTERNO_OpcionesDetalle_Modelo.opcion, + Variables.G_STR_OPCION_COM_DEVOLUCIONPAGO, + P_Base_ValoresGenerales.lng_idEmpresa, + P_Base_ValoresGenerales.EjercicioActivo.id, + g_obj_Controladora.g_lst_ColumnasAMostrar_BOLSA, + dct_ListadoFiltros_Agregados + }; + + //Pasamos los parametros al metodo y lo ejecutamos + List lst_id_Agregar = (List)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros); + //######################################################################################################################################################################## + + + if (lst_id_Agregar != null && lst_id_Agregar.Count > 0) + { + List lst_id_AgregarFInal = lst_id_Agregar.Cast().ToList(); + + //creamos la instancia + var obj_Clase2 = Activator.CreateInstance(m_type); + //Cargamos el metodo solicitado + MethodInfo obj_MethodInfo2 = obj_Clase2.GetType().GetMethod(Variables.G_STR_LIBRERIA_OPCIONES_PROCEDIMIENTO_BORRAR_BOLSA, BindingFlags.Instance | BindingFlags.NonPublic); + + object[] arr_Parametros2 = { g_mdl_INTERNO_OpcionesDetalle_Modelo.opcion, + this, + Variables.G_MDL_INTERNO_VALORESGENERALES_MODELO, + this.P_Base_FechaTrabajo, + lst_id_AgregarFInal + }; + + //Pasamos los parametros al metodo y lo ejecutamos + obj_MethodInfo2.Invoke(obj_Clase2, arr_Parametros2); + } + else if (frm_PE_Listados_Filtros.g_bol_RecargarListado) + { + //Cargar los Datos desde Base de datos + g_obj_Controladora.Recargar_Listado(true); + } + } + } + } + } + catch (Control_Errores) + { } + catch (Exception ex) + { + Control_Errores.Errores_Log("", ex, nameof(P_DevolucionPago_Bolsa) + "/" + nameof(FiltroBorrar)); + } + } + + #endregion + + private void ex_btn_P_DevolucionPago_Bolsa_Actualizar_Click(object sender, EventArgs e) + { + if (g_obj_Controladora != null) + { + g_obj_Controladora.Recargar_Listado(true); + } + } + + private void exferia_TextBox1_Paint(object sender, PaintEventArgs e) + { + + } + } +} diff --git a/Exferia_Compras/Exferia_Compras/3_Vistas/P_ImportacionFacturaE.resx b/Exferia_Compras/Exferia_Compras/3_Vistas/P_ImportacionFacturaE.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Exferia_Compras/Exferia_Compras/3_Vistas/P_ImportacionFacturaE.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Exferia_Compras/Exferia_Compras/Exferia_Compras.csproj b/Exferia_Compras/Exferia_Compras/Exferia_Compras.csproj index d9ce813..3958c03 100644 --- a/Exferia_Compras/Exferia_Compras/Exferia_Compras.csproj +++ b/Exferia_Compras/Exferia_Compras/Exferia_Compras.csproj @@ -147,6 +147,7 @@ + @@ -256,6 +257,12 @@ P_DevolucionPago.cs + + Form + + + P_ImportacionFacturaE.cs + Form @@ -464,6 +471,9 @@ P_DevolucionPago_Procesos.cs + + P_ImportacionFacturaE.cs + P_Pago_Procesos.cs