private void Copiar(DataRow Desde, Entidades.LogDetalle Hasta) { Hasta.Id = Convert.ToInt32(Desde["IdLogDetalle"]); Hasta.IdLog = Convert.ToInt32(Desde["IdLog"]); Hasta.TipoDetalle = Convert.ToString(Desde["TipoDetalle"]); Hasta.Detalle = Convert.ToString(Desde["Detalle"]); }
public List <Entidades.LogDetalle> ListaPorIdLog(int IdLog) { List <Entidades.LogDetalle> lista = new List <Entidades.LogDetalle>(); if (sesion.Cuit.Nro != null) { System.Text.StringBuilder a = new StringBuilder(); a.Append("select "); a.Append("LogDetalle.IdLogDetalle, LogDetalle.IdLog, LogDetalle.TipoDetalle, LogDetalle.Detalle "); a.Append("from LogDetalle "); a.Append("where LogDetalle.IdLog = " + IdLog + " "); a.Append("order by LogDetalle.IdLog asc, IdLogDetalle asc "); DataTable dt = (DataTable)Ejecutar(a.ToString(), TipoRetorno.TB, Transaccion.NoAcepta, sesion.CnnStr); if (dt.Rows.Count != 0) { for (int i = 0; i < dt.Rows.Count; i++) { Entidades.LogDetalle elem = new Entidades.LogDetalle(); Copiar(dt.Rows[i], elem); lista.Add(elem); } } } return(lista); }
protected void LogDetalleGridView_RowCommand(object sender, GridViewCommandEventArgs e) { Entidades.LogDetalle LogDetalle = new Entidades.LogDetalle(); try { int item = Convert.ToInt32(e.CommandArgument); List<Entidades.LogDetalle> lista = (List<Entidades.LogDetalle>)ViewState["lista"]; LogDetalle = lista[item]; } catch { //Selecciono algo del Header. No hago nada con el CommandArgument. } switch (e.CommandName) { case "Detalle": //Session["LogDetalle"] = LogDetalle; string textoXML = LogDetalle.Detalle; textoXML = textoXML.Replace("<", "<"); textoXML = textoXML.Replace(">", ">"); Entidades.Sesion sesion = (Entidades.Sesion)Session["Sesion"]; string filename = sesion.Usuario.Id + ".xml"; string dlDir = @"Temp/"; string path = Server.MapPath(dlDir + filename); //Crear archivo XML en el temporal using (FileStream fs = File.Create(path)) { Encoding enc = Encoding.GetEncoding("utf-16"); Byte[] info = enc.GetBytes(textoXML); // Add some information to the file. fs.Write(info, 0, info.Length); } //Leer y mandar al explorador FileInfo toDownload = new FileInfo(path); if (toDownload.Exists) { Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + toDownload.Name); Response.AddHeader("Content-Length", toDownload.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.WriteFile(dlDir + filename); Response.End(); } else { MensajeLabel.Text = "No se puede obtener la información. "; } break; } }
protected void LogDetalleGridView_RowCommand(object sender, GridViewCommandEventArgs e) { Entidades.LogDetalle LogDetalle = new Entidades.LogDetalle(); try { int item = Convert.ToInt32(e.CommandArgument); List <Entidades.LogDetalle> lista = (List <Entidades.LogDetalle>)ViewState["lista"]; LogDetalle = lista[item]; } catch { //Selecciono algo del Header. No hago nada con el CommandArgument. } switch (e.CommandName) { case "Detalle": //Session["LogDetalle"] = LogDetalle; string textoXML = LogDetalle.Detalle; textoXML = textoXML.Replace("<", "<"); textoXML = textoXML.Replace(">", ">"); Entidades.Sesion sesion = (Entidades.Sesion)Session["Sesion"]; string filename = sesion.Usuario.Id + ".xml"; string dlDir = @"Temp/"; string path = Server.MapPath(dlDir + filename); //Crear archivo XML en el temporal using (FileStream fs = File.Create(path)) { Encoding enc = Encoding.GetEncoding("utf-16"); Byte[] info = enc.GetBytes(textoXML); // Add some information to the file. fs.Write(info, 0, info.Length); } //Leer y mandar al explorador FileInfo toDownload = new FileInfo(path); if (toDownload.Exists) { Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + toDownload.Name); Response.AddHeader("Content-Length", toDownload.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.WriteFile(dlDir + filename); Response.End(); } else { MensajeLabel.Text = "No se puede obtener la información. "; } break; } }
public List<Entidades.LogDetalle> ListaPorIdLog(int IdLog) { List<Entidades.LogDetalle> lista = new List<Entidades.LogDetalle>(); if (sesion.Cuit.Nro != null) { System.Text.StringBuilder a = new StringBuilder(); a.Append("select "); a.Append("LogDetalle.IdLogDetalle, LogDetalle.IdLog, LogDetalle.TipoDetalle, LogDetalle.Detalle "); a.Append("from LogDetalle "); a.Append("where LogDetalle.IdLog = " + IdLog + " "); a.Append("order by LogDetalle.IdLog asc, IdLogDetalle asc "); DataTable dt = (DataTable)Ejecutar(a.ToString(), TipoRetorno.TB, Transaccion.NoAcepta, sesion.CnnStr); if (dt.Rows.Count != 0) { for (int i = 0; i < dt.Rows.Count; i++) { Entidades.LogDetalle elem = new Entidades.LogDetalle(); Copiar(dt.Rows[i], elem); lista.Add(elem); } } } return lista; }