public void txt() { int UsuarioId = Convert.ToInt32(Session["UsuarioCoId"]); DataTable dt = new DataTable(); dt = Utilitario.Lista(" AbonoId,Cantidad,Fecha ", " from Abono ", " where PrestamoId = " + tbxPrestamo.Text); MemoryStream ms = new MemoryStream(); TextWriter sw = new StreamWriter(ms); string Empresa = Utilitario.DatosHerramientas("Descripcion", Convert.ToString(Utilitario.ObtenerIdUsuarioAdm(UsuarioId)), "5"); string NumeroEmpresa = Utilitario.Lista(" U.Telefono ", " from Usuario as U inner join UsuarioCo as Uc on Uc.UsuarioId = U.UsuarioId ", " where Uc.UsuarioCoId = " + UsuarioId).Rows[0]["Telefono"].ToString(); ObtenerGridView(); sw.WriteLine("----------" + Empresa + "---------"); sw.WriteLine("-----------Estado Abono------------"); sw.WriteLine("Telefono:" + NumeroEmpresa); sw.WriteLine("------------------------------"); sw.WriteLine("Cod:" + tbxPrestamo.Text); sw.WriteLine("USUARIO: " + Session["UserName"]); sw.WriteLine("FECHA: " + DateTime.Now.ToString("yyy/MM/dd")); sw.WriteLine("CLIENTE: " + tbxNombre.Text); sw.WriteLine("------------------------------"); sw.WriteLine(" CANTIDAD | FECHA "); foreach (DataRow row in dt.Rows) { sw.WriteLine(" --- " + row[1].ToString() + " --- " + Utilitario.FormatoFecha(row[2].ToString()) + "--- "); } sw.WriteLine("------------------------------"); sw.WriteLine("TOTAL: " + tbxMontoTotal.Text); sw.WriteLine("PENDIENTE: " + tbxPendiente.Text); sw.WriteLine("________________|____________"); sw.WriteLine("Despachado Por -- Cliente"); sw.Flush(); byte[] bytes = ms.ToArray(); ms.Close(); Response.Clear(); Response.ContentType = "application/force-download"; Response.AddHeader("content-disposition", "attachment; filename=RepoAbono " + tbxPrestamo.Text + ".txt"); Response.BinaryWrite(bytes); Response.End(); }
public void txt(int PrestamoId) { try { string NombreEmpresa = ""; int UsuarioId = Convert.ToInt32(Session["UsuarioCoId"]); Usuario us = new Usuario(); NombreEmpresa = Utilitario.DatosHerramientas("Descripcion", UsuarioId.ToString(), "5"); MemoryStream ms = new MemoryStream(); TextWriter sw = new StreamWriter(ms); //32 CARACTERES PARA LA OJA TERMICA sw.WriteLine("*******" + NombreEmpresa + "******"); sw.WriteLine("*******REGISTRO DE PRESTAMO*****"); sw.WriteLine("TELEFONO:" + BuscarDatosEmpresa() + ""); sw.WriteLine("********************************"); sw.WriteLine("COD:" + PrestamoId.ToString()); sw.WriteLine("USUARIO: " + Session["UserName"]); sw.WriteLine("FECHA: " + DateTime.Now.ToString("yyy/MM/dd")); sw.WriteLine("CLIENTE: " + tbxNombre.Text); sw.WriteLine("********************************"); sw.WriteLine("$CUOTAS: " + tbxCuotaPrestar.Text); sw.WriteLine("TIEMPO COBRO: " + ConvertirCuotastring()); sw.WriteLine("TOTAL + INTERES: " + tbxtotal.Text); sw.WriteLine("_________________|_______________"); sw.WriteLine(" REGISTRADO POR --- CLIENTE"); sw.Flush(); byte[] bytes = ms.ToArray(); ms.Close(); Response.Clear(); Response.ContentType = "application/force-download"; Response.AddHeader("content-disposition", "attachment; filename=Factura " + tbxNombre.Text + PrestamoId + ".txt"); Response.BinaryWrite(bytes); Limpiar(); Response.End(); } catch (Exception e) { throw e; } }
public bool ValidarActualizacion() { bool Resultado = false; DateTime FechaAux; string Fecha1, Fecha2; Herramienta he = new Herramienta(); int Id = 0; Id = Convert.ToInt32(Session["UsuarioId"]); if (Id == 0 && Convert.ToInt32(Session["UsuarioCoId"]) > 0) { Id = Utilitario.ObtenerIdUsuarioAdm(Convert.ToInt32(Session["UsuarioCoId"])); } if (Id > 0) { btnCerrarSesion.Visible = true; UserName.InnerText = Session["UserName"].ToString(); UserName.Visible = true; } else { btnCerrarSesion.Visible = false; UserName.InnerText = ""; UserName.Visible = false; } try { //4 por el campo valor de la tabla herramienta if ((Utilitario.DatosHerramientas("Fecha", Id.ToString(), "4")) == "0") { //SI EL USUARIO ES NUEVO QUE TIRE 0 PORQUE NO TIENE REGISTRO DE FECHA AUN } else { FechaAux = Convert.ToDateTime(Utilitario.DatosHerramientas("Fecha", Id.ToString(), "4")); Fecha1 = Utilitario.FormatoFecha(FechaAux.ToString()); Fecha2 = Utilitario.FormatoFecha(DateTime.Now.ToString()); if (Fecha2 != Fecha1) { //PONER DE ALGUNA MANERA QUE ESTA CONDICION SOLO ENTRE EL USUARIO ADMINISTRATIVO MEDIANTE OTRO LOGING SOLO PARA ADMINISTRATIVO O COMO SEA CUALQUIERA DE LOS DOS he.UsuarioId = Id; he.Fecha = Utilitario.FormatoFecha(DateTime.Now.ToString()); he.ActualizarFecha(); Resultado = true; } } } catch (Exception e) { throw e; } return(Resultado); }
public void PrestamoAbono() { string Valor = ""; int Aux = 0; string ReportString = ""; string DataSet = ""; Valor = Request.QueryString["Valor"].ToString(); Aux = Convert.ToInt32(Request.QueryString["Aux"].ToString()); string CoUsuarioId = Convert.ToString(Session["UsuarioCoId"]); string Campos = ""; string Entidades = ""; string Condicion = ""; string ConvFechaTermino = "Convert(VARCHAR(10),P.FechaTermino,103) as FechaTermino"; string ConvFechaInicio = "Convert(VARCHAR(10),P.FechaInicio,103) as FechaInicio"; string replace = "replace(replace(P.Estado,2,'Abono'),3,'Mora') as 'Estado' "; if (Aux == 1) { string ConvFechaAbono = "Convert(VARCHAR(10),A.Fecha,103) as Fecha"; Campos = " P.PrestamoId,C.Nombre," + ConvFechaInicio + "," + ConvFechaTermino + ",P.Taza,P.Total,P.Interes," + replace + ",P.CantidadCuota,A.Cantidad," + ConvFechaAbono; Entidades = " from Prestamo as P inner join Cliente as C on C.ClienteId = P.ClienteId inner join UsuarioCo as Uc on Uc.UsuarioCoId = P.UsuarioCoId inner join Usuario as U on U.UsuarioId = Uc.UsuarioId inner join Abono as A on A.PrestamoId = P.PrestamoId"; Condicion = " where P.PrestamoId = " + Valor; H2Reporte.InnerText = "Reporte de prestamo"; ReportString = @"Reportes\ReportePrestamoAbono.rdlc"; DataSet = "DataSetPrestamoAbono"; } else if (Aux == 2) { Campos = " P.PrestamoId,C.Nombre," + ConvFechaInicio + "," + ConvFechaTermino + ",P.Taza,P.Total,P.Interes," + replace + ",P.CantidadCuota"; Entidades = " from Prestamo as P inner join Cliente as C on C.ClienteId = P.ClienteId inner join UsuarioCo as Uc on Uc.UsuarioCoId = P.UsuarioCoId inner join Usuario as U on U.UsuarioId = Uc.UsuarioId"; Condicion = " where P.PrestamoId = " + Valor; H2Reporte.InnerText = "Reporte de Abono"; ReportString = @"Reportes\ReportePrestamoAbono.rdlc"; DataSet = "DataSetPrestamoAbono"; } else if (Aux == 3) { Campos = " C.P1, C.P5,C.P10,C.P25,C.P50,C.P100,C.P200,C.P500,C.P1000,C.P2000,C.Total,C.Fecha,Uc.Nombre,C.CuadreId "; Entidades = " from Cuadre as C inner join UsuarioCo as Uc on Uc.UsuarioCoId = C.UsuarioCoId "; Condicion = " where C.CuadreId = " + Valor; H2Reporte.InnerText = "Reporte de Cuadre"; ReportString = @"Reportes\ReporteCuadre.rdlc"; DataSet = "DataSetCuadre"; } string UsuarioAdmId = ""; if (Convert.ToInt32(Session["UsuarioCoId"]) == 0) { try { UsuarioAdmId = Session["UsuarioId"].ToString(); //CoUsuarioId = Request.QueryString["UsuarioCoId"].ToString(); //UsuarioAdmId = Convert.ToString(Utilitario.ObtenerIdUsuarioAdm(Convert.ToInt32(CoUsuarioId))); } catch (Exception) { UsuarioAdmId = Session["UsuarioId"].ToString(); } } else { UsuarioAdmId = Convert.ToString(Utilitario.ObtenerIdUsuarioAdm(Convert.ToInt32(CoUsuarioId))); } string NombreEmpresa = ""; //5 por que queremos el valor 5 y es el nombre de la empresa //EN CASO DE QUE DE UN ERROR PONERLO DONDE ESTABA ABAJO NombreEmpresa = Utilitario.DatosHerramientas("Descripcion", UsuarioAdmId, "5"); ReportParameter p = new ReportParameter("Parametro1", NombreEmpresa); ReportViewTodo.LocalReport.DataSources.Clear(); ReportViewTodo.ProcessingMode = ProcessingMode.Local; ReportViewTodo.LocalReport.ReportPath = AppDomain.CurrentDomain.BaseDirectory + ReportString; //POR SI DA ERROR DE DIRECCION https://stackoverflow.com/questions/28718036/reportviewer-error-when-dynamically-setting-rdlc-file-on-azure-cloud-services //AQUI DICE QUE HAY QUE DARLE CLICK DERECHO AL ARCHIVO .rdlc y darle a propeties: //1) BUILD ARCTION: Content //2) Copy always: Copy always //3) DESPUES INSTALAR EL PACKAGE EN INSTALAR EN LA CONSOLA: Install-Package Microsoft.SqlServer.Types -Version 14.0.1016.290 ReportDataSource source = new ReportDataSource(DataSet, Utilitario.Lista(Campos, Entidades, Condicion)); ReportViewTodo.LocalReport.DataSources.Add(source); ReportViewTodo.LocalReport.SetParameters(p); ReportViewTodo.LocalReport.Refresh(); }