public List <InfEstadoGuias> InformeEstadoGuias(string OT, string NombreOT, DateTime FechaInicio, DateTime FechaTermino, int Procedimiento) { List <InfEstadoGuias> lista = new List <InfEstadoGuias>(); Conexion conexion = new Conexion(); SqlCommand cmd = conexion.AbrirConexionIntranet(); if (cmd != null) { cmd.CommandText = "[Desp_EstadoGuias]"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@OT", OT); cmd.Parameters.AddWithValue("@NombreOT", NombreOT); cmd.Parameters.AddWithValue("@FechaInicio", FechaInicio); cmd.Parameters.AddWithValue("@FechaTermino", FechaTermino); cmd.Parameters.AddWithValue("@Procedimiento", Procedimiento); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { InfEstadoGuias p = new InfEstadoGuias(); p.NroPallet = reader["cod_pallet"].ToString(); p.OT = reader["OT"].ToString(); p.NombreOT = reader["NombreOT"].ToString().ToLower(); p.Terminacion = reader["Terminacion"].ToString(); p.TipoEmbalaje = reader["TipoEmbalaje"].ToString(); p.Cantidad = Convert.ToInt32(reader["Cantidad"].ToString()).ToString("N0").Replace(",", "."); p.Ejemplares = Convert.ToInt32(reader["Ejemplares"].ToString()).ToString("N0").Replace(",", "."); p.Total = Convert.ToInt32(reader["Total"].ToString()).ToString("N0").Replace(",", "."); p.Modelo = reader["Modelo"].ToString(); p.Observacion = reader["Observacion"].ToString().ToLower(); p.FechaCreacion = Convert.ToDateTime(reader["FechaCreacion"].ToString()).ToString("dd/MM/yyyy HH:mm"); if (reader["Estado"].ToString() == "Creado") { p.Estado = "<div style='Color:Blue;'>Creado</div>"; } else if (reader["Estado"].ToString() == "Rechazado") { p.Estado = "<div style='Color:red;'>Rechazado</div>"; } else { p.Estado = "<div style='Color:Green;'>Recepcionado</div>"; } lista.Add(p); } } conexion.CerrarConexion(); return(lista); }
protected void ibExcel_Click(object sender, ImageClickEventArgs e) { List <InfEstadoGuias> lista = new List <InfEstadoGuias>(); for (int i = 0; i < RadGrid1.Items.Count; i++) { InfEstadoGuias p = new InfEstadoGuias(); p.NroPallet = RadGrid1.Items[i]["NroPallet"].Text; p.OT = RadGrid1.Items[i]["OT"].Text; p.NombreOT = RadGrid1.Items[i]["NombreOT"].Text; p.Terminacion = RadGrid1.Items[i]["Terminacion"].Text; p.TipoEmbalaje = RadGrid1.Items[i]["TipoEmbalaje"].Text; p.Cantidad = RadGrid1.Items[i]["Cantidad"].Text.Replace(".", ""); p.Ejemplares = RadGrid1.Items[i]["Ejemplares"].Text.Replace(".", ""); p.Total = RadGrid1.Items[i]["Total"].Text.Replace(".", ""); p.Modelo = RadGrid1.Items[i]["Modelo"].Text; p.Observacion = RadGrid1.Items[i]["Observacion"].Text.Replace(" ", ""); p.FechaCreacion = RadGrid1.Items[i]["FechaCreacion"].Text; if (RadGrid1.Items[i]["Estado"].Text == "<div style='Color:red;'>Rechazado</div>") { p.Estado = "Rechazada"; } else if (RadGrid1.Items[i]["Estado"].Text == "<div style='Color:Blue;'>Creado</div>") { p.Estado = "Creado"; } else { p.Estado = "Recepcionado"; } lista.Add(p); } GridView GridView1 = new GridView(); GridView1.DataSource = lista; GridView1.DataBind(); GridView1.HeaderStyle.BackColor = System.Drawing.Color.Blue; GridView1.HeaderStyle.ForeColor = System.Drawing.Color.White; ExportToExcel("", GridView1); }