/// <summary> /// Imprimir el listado de documentos de una liquidación /// </summary> public void Imprimir() { try { if (Item.ListCtaCte.Count > 0) { Liquidar(); System.Data.DataTable dtReporte = new System.Data.DataTable(); System.Data.DataTable dtReporteTotales = new System.Data.DataTable(); dtReporte = Item.ListCtaCte.Where(O => O.Seleccionar).ToObservableCollection().ToDataTable(); ObservableCollection <Entities.CtaCte> x_ListGroup = new ObservableCollection <CtaCte>(); x_ListGroup = (from CCCT in Item.ListCtaCte.Where(O => O.Seleccionar).ToObservableCollection() group CCCT by new { CCCT.TIPO_CodMND, CCCT.TIPO_MND } into LCCCT select new CtaCte { CCCT_Pendiente = LCCCT.Sum(x => x.CCCT_Pendiente), CCCT_Pendiente_Cargo = LCCCT.Sum(y => y.CCCT_Pendiente_Cargo), CCCT_Pendiente_Abono = LCCCT.Sum(z => z.CCCT_Pendiente_Abono), TIPO_CodMND = LCCCT.Key.TIPO_CodMND, TIPO_MND = LCCCT.Key.TIPO_MND } ).ToObservableCollection(); dtReporteTotales = x_ListGroup.ToDataTable(); R_Codigo = Item.LIQU_Codigo; R_FechaEmision = Item.LIQU_Fecha.Value.ToString("dd/MM/yyyy"); R_Glosa = Item.LIQU_Glosa; if (dtReporte != null && dtReporte.Rows.Count > 0) { String ReportPath = null; dtReporte.TableName = "CtaCte"; ReportPath = Application.StartupPath + @"\Reportes\CAJ006LiquidacionAgentes.rdlc"; //ReportDataSource RepDetalle = new ReportDataSource("LiquidacionAgentesDS", dtReporte); Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource(); rds.Name = "LiquidacionAgentesDS"; rds.Value = dtReporte; Microsoft.Reporting.WinForms.ReportDataSource rdsDet = new Microsoft.Reporting.WinForms.ReportDataSource(); rdsDet.Name = "DSTotales"; rdsDet.Value = dtReporteTotales; Dictionary <String, Microsoft.Reporting.WinForms.ReportDataSource> x_subreports = new Dictionary <string, Microsoft.Reporting.WinForms.ReportDataSource>(); x_subreports.Add("CAJ006LiquidacionAgentesTotal", rdsDet); Microsoft.Reporting.WinForms.ReportParameter[] Parameters = new Microsoft.Reporting.WinForms.ReportParameter[7]; Fecha = Client.GetFecha(); String _fecha = Fecha.ToString("dd/MM/yyyy HH:mm"); String _agente = F_ENTC_Codigo.ToString(); Parameters[0] = new Microsoft.Reporting.WinForms.ReportParameter("Titulo", "Reporte de " + Title); Parameters[1] = new Microsoft.Reporting.WinForms.ReportParameter("FechaHora", _fecha); Parameters[2] = new Microsoft.Reporting.WinForms.ReportParameter("Agente", R_Agente); Parameters[3] = new Microsoft.Reporting.WinForms.ReportParameter("Codigo", R_Codigo); Parameters[4] = new Microsoft.Reporting.WinForms.ReportParameter("Glosa", R_Glosa); Parameters[5] = new Microsoft.Reporting.WinForms.ReportParameter("FechaEmision", R_FechaEmision); Parameters[6] = new Microsoft.Reporting.WinForms.ReportParameter("Estado", R_Estado); //Visualizador rpt = new Visualizador("Reporte de Liquidación de Agentes", ReportPath, RepDetalle, Parameters); //rpt.StartPosition = FormStartPosition.CenterScreen; //rpt.Imprimir(); //rpt.ShowDialog(); Visualizador _impresion = new Visualizador("", ReportPath, rds, Parameters, x_subreports, null) { StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen }; _impresion.Imprimir(); _impresion.ShowDialog(); } else { Infrastructure.WinForms.Controls.Dialogos.MostrarMensajeInformacion(Title, "No se encontraron registros"); } } } catch (Exception) { throw; } }
/// <summary> /// Realiza la operación de Conciliar, recibiendo el archivo a ser conciliado /// </summary> /// <param name="PathConciliacion">Ruta del archivo que utilizara para realizar la conciliaciónd agentes</param> /// <returns>true: si se proceso el archivo correctamente</returns> public Boolean ProcesarConciliacion(String PathConciliacion, Int32 x_Header, ref System.Windows.Forms.ProgressBar x_PBar) { try { String Archivo = "", MensajeConciliacion = ""; if (System.IO.File.Exists(PathConciliacion)) { Archivo = Path.GetFileName(PathConciliacion); ImportarExcel excel = new ImportarExcel(); String _message = ""; DTImportacion = excel.ReadExcel(PathConciliacion, 1, 5000, x_Header, new Int32[] { 6, 18 }, ref _message, ref x_PBar); DTNoProcesados = DTImportacion.Clone(); MsgError = ""; if (!DTImportacion.Columns.Contains("OV")) { DTImportacion.Columns.Add("OV", typeof(String)); } if (!DTImportacion.Columns.Contains("Documento")) { DTImportacion.Columns.Add("Documento", typeof(String)); } if (!DTImportacion.Columns.Contains("Observaciones")) { DTImportacion.Columns.Add("Observaciones", typeof(String)); } x_PBar.Maximum = x_PBar.Value + DTImportacion.Rows.Count; ObservableCollection <Entities.CtaCte> x_ListGroup = new ObservableCollection <CtaCte>(); x_ListGroup = (from CCCT in Item.ListCtaCte group CCCT by new { CCCT.OV_OP, CCCT.DOOV_HBL } into LCCCT select new CtaCte { CCCT_Pendiente = LCCCT.Sum(x => x.CCCT_Pendiente), OV_OP = LCCCT.Key.OV_OP, DOOV_HBL = LCCCT.Key.DOOV_HBL } ).ToObservableCollection(); Boolean x_IsCorrecto = true; foreach (System.Data.DataRow item in DTImportacion.Rows) { #region Validar Documento String x_HBL = item[5].ToString().Trim(); String x_MontoString = item[17].ToString(); Decimal x_Monto = 0, Monto = 0; if (Decimal.TryParse(x_MontoString, out x_Monto)) { Monto = Math.Abs(x_Monto); } /* Filtrar todos los documentos que coinciden (tipos, serie y numero de documento */ ObservableCollection <Entities.CtaCte> x_listCtaCte = x_ListGroup.Where(Cta => Cta.DOOV_HBL.Equals(x_HBL) && (Cta.CCCT_Pendiente.HasValue ? Math.Abs(Cta.CCCT_Pendiente.Value) : 0) == Monto).ToObservableCollection(); if (x_listCtaCte != null && x_listCtaCte.Count > 0) { ObservableCollection <Entities.CtaCte> x_listCtaCteCMP = Item.ListCtaCte.Where(Cta => Cta.OV_OP.Equals(x_listCtaCte[0].OV_OP)).ToObservableCollection(); x_listCtaCte[0].ConciliadoAgente = true; item["OV"] = x_listCtaCte[0].OV_OP; if (x_listCtaCteCMP != null && x_listCtaCteCMP.Count > 0) { foreach (CtaCte iCtaCte in x_listCtaCteCMP) { iCtaCte.Seleccionar = true; item["Documento"] += String.Format("{0} {1}-{2} {3}", iCtaCte.TIPO_TDO, iCtaCte.CCCT_Serie, iCtaCte.CCCT_Numero, x_listCtaCteCMP.Count > 1 ? "/" : ""); item["Observaciones"] += String.IsNullOrEmpty(iCtaCte.ObservacionesConciliacion) ? "-" : iCtaCte.ObservacionesConciliacion + (x_listCtaCteCMP.Count > 1 ? "/" : ""); } } } else { DTNoProcesados.ImportRow(item); x_IsCorrecto = false; } #endregion x_PBar.Value++; } return(!(MsgError.Length > 0) && x_IsCorrecto); } else { throw new Exception("El archivo no existe"); } return(false); } catch (Exception) { throw; } }