public override global::System.Data.DataSet Clone() { DsVentasPorMes cln = ((DsVentasPorMes)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { DsVentasPorMes ds = new DsVentasPorMes(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private void Inicializar() { meses = (Hashtable)Session["Meses"]; dsVentasPorMes = (DsVentasPorMes)Session["DsVentasAgenciasPorMes"]; dsVentas = (DsVentas)Session["DsVentas"]; mesesAmostrar = (bool[])Session["MesesAmostrar"]; Title = "Ranking de Ventas de Agencias - " + DateTime.Today.ToString("dd/MM/yyyy"); Datos = dsVentas.Tables[0]; CustomExport(); }
public DsVentasPorMes GetVentasPorMesVendedores(int unidadNegocioID, int categoriaUVentaID, int condicionPagoID) { DsVentasPorMes ds = new DsVentasPorMes(); SqlParameter pFechaDesde = new SqlParameter("@FechaDesde", Utiles.BaseDatos.FechaToSql(this.FechaDesde)); SqlParameter pFechaHasta = new SqlParameter("@FechaHasta", Utiles.BaseDatos.FechaToSql(this.FechaHasta)); SqlParameter pUnidadVentaID = new SqlParameter("@UnidadVentaID", Utiles.BaseDatos.IntToSql(this.UnidadVentaID)); SqlParameter pUnidadNegocioID = new SqlParameter("@UnidadNegocioID", unidadNegocioID); SqlParameter pCategoriaUVentaID = new SqlParameter("@CategoriaUVentaID", Utiles.BaseDatos.IntToSql(categoriaUVentaID)); SqlParameter pCondicionPagoID = new SqlParameter("@CondicionPagoID", Utiles.BaseDatos.IntToSql(condicionPagoID)); SqlParameter pValorDeclarado = new SqlParameter("@ValorDeclarado", Utiles.Validaciones.obtieneEntero(ValorDeclarado)); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "VentasPorMesPorVendedor", pFechaDesde, pFechaHasta, pUnidadVentaID, pUnidadNegocioID, pCategoriaUVentaID, pCondicionPagoID, pValorDeclarado); return(ds); }
private void dtgDetalle_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DsVentasPorMes dsVentasPorMes = (DsVentasPorMes)Session["DsVentasAgenciasPorMes"]; // formateo las columnas //e.Item.Cells[e.Item.Cells.Count-2].Text = Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(e.Item.Cells[e.Item.Cells.Count-2].Text)); // Total Flete Neto //e.Item.Cells[e.Item.Cells.Count-1].Text = Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(e.Item.Cells[e.Item.Cells.Count-1].Text)); // Promedio //DsVentas ds = (DsVentas)((DataGrid)sender).DataSource; DataRow dr = ((DataRowView)e.Item.DataItem).Row; double fleteNeto = 0; for (int i = 1; i <= 12; i++) { if (mesesAmostrar[i]) { System.Data.DataRow[] drImportes = dsVentasDetalleUVenta.Datos.Select("EntidadID = " + dr["EntidadID"] + " AND Mes = " + i + " AND UnidadVentaID=" + dr["UnidadVentaID"]); if (drImportes.Length > 0) { e.Item.Cells[i].Text = "<table class='Texto'><td width='10%'>" + Utiles.Formatos.Importe(Convert.ToDouble(Convert.ToString(drImportes[0]["FleteNeto"]))) + //" " + "</td><td width='10%'>" + Utiles.Formatos.Importe(Convert.ToDouble(Convert.ToString(drImportes[0]["FleteBruto"]))) //+ "</td>" + //"<td width='10%'>" + //Convert.ToString(drImportes[0]["EstadoClienteDescrip"]) + "</td></table>"; e.Item.Cells[i].HorizontalAlign = HorizontalAlign.Right; fleteNeto += Convert.ToDouble(Convert.ToString(drImportes[0]["FleteNeto"])); } } } //fleteNeto = Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasDetalleUVenta.Datos.Compute("SUM(FleteNeto)","EntidadID=" + dr["EntidadID"] + " AND UnidadVentaID=" + dr["UnidadVentaID"]))); e.Item.Cells[e.Item.Cells.Count - 2].Text = Utiles.Formatos.Importe(fleteNeto); // Total Flete Neto e.Item.Cells[e.Item.Cells.Count - 1].Text = Utiles.Formatos.Importe(fleteNeto / cantMeses); // Promedio /*if (bandera) * uventa.Add(strUVenta,strUVenta);*/ } }
private void Inicializar() { meses = (Hashtable)Session["Meses"]; dsVentasPorMes = (DsVentasPorMes)Session["DsVentasAgenciasPorMes"]; dsVentas = (DsVentas)Session["DsVentas"]; mesesAmostrar = (bool[])Session["MesesAmostrar"]; /* * Head = new string[ds.Datos.Columns.Count]; * Col = new string[ds.Datos.Columns.Count]; */ /* Head = new string[17]; //ds.Datos.Columns.Count * Col = new string[17];//ds.Datos.Columns.Count * * bool[] mesesAmostrar = (bool[])Session["MesesAmostrar"]; * * Head[0] = "Numerador"; * Col[0] = "Numerador"; * * Head[1] = "Nombre"; * Col[1] = "Nombre"; * * int j = 2; * for (int i=0; i<mesesAmostrar.Length; i++) * { * if (mesesAmostrar[i]) * { * Head[j] = meses[i].ToString() + "<br>Flete Neto / Flete Bruto"; * Col[j] = meses[i].ToString() + "<br>Flete Neto / Flete Bruto"; * j++; * } * } * //int i = 0; * /*for(int i=1; i < ds.Datos.Columns.Count;i++) * { * Head[i] = ds.Datos.Columns[i].ColumnName; * Col[i] = ds.Datos.Columns[i].ColumnName; * }*/ Title = "Ranking de Ventas de Agencias - " + DateTime.Today.ToString("dd/MM/yyyy"); Datos = dsVentas.Tables[0]; CustomExport(); }
private void dtgVentasAgencias_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //DsVentasPorMes dsVentasPorMes = (DsVentasPorMes) Session["DsVentasAgenciasPorMes"]; // formateo las columnas if (e.Item.Cells.Count > 8) { e.Item.Cells[e.Item.Cells.Count - 2].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "FleteNeto"))); // Total Flete Neto e.Item.Cells[e.Item.Cells.Count - 1].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "Promedio"))); // Promedio e.Item.Cells[e.Item.Cells.Count - 7].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "FleteBruto")) / cantidadMeses); // Promedio Bruto e.Item.Cells[e.Item.Cells.Count - 6].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "CreditoAOtorgar"))); // CreditoAOtorgar e.Item.Cells[e.Item.Cells.Count - 5].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "LimiteCredito"))); // LimiteCredito e.Item.Cells[e.Item.Cells.Count - 4].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "MontoActual"))); // MontoActual e.Item.Cells[e.Item.Cells.Count - 3].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "Porcentaje"))).ToString() + " %"; // MontoActual } else { e.Item.Cells[e.Item.Cells.Count - 2].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "FleteNeto"))); // Total Flete Neto e.Item.Cells[e.Item.Cells.Count - 1].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "Promedio"))); // Promedio } DsVentas.DatosRow dr = ((DsVentas.DatosRow)((DataRowView)e.Item.DataItem).Row); int j; if (Convert.ToInt32(Request.QueryString["AgregarColumnaVendedor"]) == 1) { j = 1; } else { j = 0; } for (int i = 1; i <= 12; i++) { if (mesesAmostrar[i]) { System.Data.DataRow[] drImportes = dsVentasPorMes.Datos.Select("EntidadID = " + dr.EntidadID + " AND Mes = " + i); if (drImportes.Length > 0) { e.Item.Cells[j + 3].Text = "" + Utiles.Formatos.Importe(Convert.ToDouble(Convert.ToString(drImportes[0]["FleteNeto"]))); e.Item.Cells[j + 4].Text = "" + Utiles.Formatos.Importe(Convert.ToDouble(Convert.ToString(drImportes[0]["FleteBruto"]))); e.Item.Cells[j + 3].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[j + 4].HorizontalAlign = HorizontalAlign.Center; } j++; j++; } } } else if (e.Item.ItemType == ListItemType.Footer) { int cantMeses = 0; DsVentasPorMes dsVentasPorMes = (DsVentasPorMes)Session["DsVentasAgenciasPorMes"]; string EntidadSeleccionada = string.Empty; if (Session["EntidadSeleccionada"] != null) { EntidadSeleccionada = Session["EntidadSeleccionada"].ToString(); } int j; if (Convert.ToInt32(Request.QueryString["AgregarColumnaVendedor"]) == 1) { j = 2; } else { j = 1; } for (int i = 1; i <= 12; i++) { if (mesesAmostrar[i]) { e.Item.Cells[2].Text = "Totales"; if (EntidadSeleccionada != string.Empty) { e.Item.Cells[j + 2].Text = "" + //" " + Utiles.Formatos.Importe( Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "Mes = " + i + " and EntidadID=" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada))))); //+ " " + //Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteBruto)", "Mes = " + i + " and EntidadID=" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada))))); e.Item.Cells[j + 3].Text = "" + Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteBruto)", "Mes = " + i + " and EntidadID=" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada))))); } else { e.Item.Cells[j + 2].Text = "" + //" " + Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "Mes = " + i)))); // + " " + //Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteBruto)", "Mes = " + i)))); e.Item.Cells[j + 3].Text = "" + Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteBruto)", "Mes = " + i)))); } e.Item.Cells[j + 2].HorizontalAlign = HorizontalAlign.Center; cantMeses++; j++; j++; } } // Si no se comenta la siguiente sección, lanza una excepción. double fleteNeto; if (EntidadSeleccionada != string.Empty) { try { // fleteNeto = Convert.ToDouble(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "EntidadID=" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada))); fleteNeto = Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "EntidadID =" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada)))); } catch (Exception ex) { fleteNeto = 0; } } else { fleteNeto = Convert.ToDouble(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "")); } if (e.Item.Cells.Count > 8) { e.Item.Cells[e.Item.Cells.Count - 9].Text = Utiles.Formatos.Importe(fleteNeto); // Total Flete Neto e.Item.Cells[e.Item.Cells.Count - 9].HorizontalAlign = HorizontalAlign.Right; e.Item.Cells[e.Item.Cells.Count - 8].Text = Utiles.Formatos.Importe(fleteNeto / cantMeses); // Promedio e.Item.Cells[e.Item.Cells.Count - 8].HorizontalAlign = HorizontalAlign.Right; } else { e.Item.Cells[e.Item.Cells.Count - 2].Text = Utiles.Formatos.Importe(fleteNeto); // Total Flete Neto e.Item.Cells[e.Item.Cells.Count - 2].HorizontalAlign = HorizontalAlign.Right; e.Item.Cells[e.Item.Cells.Count - 1].Text = Utiles.Formatos.Importe(fleteNeto / cantMeses); // Promedio e.Item.Cells[e.Item.Cells.Count - 1].HorizontalAlign = HorizontalAlign.Right; } } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); DsVentasPorMes ds = new DsVentasPorMes(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "DatosDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private void dtgVentasAgencias_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //DsVentasPorMes dsVentasPorMes = (DsVentasPorMes) Session["DsVentasAgenciasPorMes"]; // formateo las columnas if (e.Item.Cells.Count > 8) { e.Item.Cells[e.Item.Cells.Count - 9].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "FleteNeto"))); // Total Flete Neto e.Item.Cells[e.Item.Cells.Count - 8].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "Promedio"))); // Promedio e.Item.Cells[e.Item.Cells.Count - 7].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "FleteBruto")) / cantidadMeses); // Promedio Bruto e.Item.Cells[e.Item.Cells.Count - 6].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "CreditoAOtorgar"))); // CreditoAOtorgar e.Item.Cells[e.Item.Cells.Count - 5].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "LimiteCredito"))); // LimiteCredito e.Item.Cells[e.Item.Cells.Count - 4].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "MontoActual"))); // MontoActual e.Item.Cells[e.Item.Cells.Count - 3].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "Porcentaje"))).ToString() + " %"; // MontoActual } else { e.Item.Cells[e.Item.Cells.Count - 2].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "FleteNeto"))); // Total Flete Neto e.Item.Cells[e.Item.Cells.Count - 1].Text = Utiles.Formatos.Importe(Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "Promedio"))); // Promedio } DsVentas.DatosRow dr = ((DsVentas.DatosRow)((DataRowView)e.Item.DataItem).Row); int j; if (Convert.ToInt32(Request.QueryString["AgregarColumnaVendedor"]) == 1) { j = 1; } else { j = 0; } for (int i = 1; i <= 12; i++) { if (mesesAmostrar[i]) { System.Data.DataRow[] drImportes = dsVentasPorMes.Datos.Select("EntidadID = " + dr.EntidadID + " AND Mes = " + i); if (drImportes.Length > 0) { /* ORIGINAL * e.Item.Cells[j+3].Text = "" + * Utiles.Formatos.Importe(Convert.ToDouble(Convert.ToString(drImportes[0]["FleteNeto"]))) + * " " + * Utiles.Formatos.Importe(Convert.ToDouble(Convert.ToString(drImportes[0]["FleteBruto"]))) + * " " + * Convert.ToString(drImportes[0]["EstadoClienteDescrip"]); * e.Item.Cells[j+3].HorizontalAlign = HorizontalAlign.Center;*/ e.Item.Cells[j + 3].Text = "" + Utiles.Formatos.Importe(Convert.ToDouble(Convert.ToString(drImportes[0]["FleteNeto"]))); e.Item.Cells[j + 4].Text = "" + Utiles.Formatos.Importe(Convert.ToDouble(Convert.ToString(drImportes[0]["FleteBruto"]))); e.Item.Cells[j + 3].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[j + 4].HorizontalAlign = HorizontalAlign.Center; } j++; j++; } } /*for (int i = 2; i<e.Item.Cells.Count-2; i++) * { * string importes = ""; * DsVentas.DatosRow dr = ((DsVentas.DatosRow)((DataRowView)e.Item.DataItem).Row); * foreach (DsVentas.DatosRow drValores in dsVentasPorMes.Datos.Select("EntidadID = " + dr.EntidadID + " AND Mes = " + i)) * { * * } * * * * e.Item.Cells[i] = importes; * }*/ //DsVentas ds = (DsVentas)((DataGrid)sender).DataSource; /*int j = 2; * for (int i=1; i<=12; i++) * { * if (mesesAmostrar[i]) * { * DataGrid grd = (DataGrid)e.Item.Cells[j].FindControl("Mes" + i); * * grd.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.grd_ItemDataBound); * * //SisPackController.AdministrarGrillas.ConfigurarChica(grd, "EntidadID"); * grd.AllowPaging = false; * grd.AllowCustomPaging = false; * grd.AutoGenerateColumns = false; * grd.CellPadding = 1; * grd.CellSpacing = 0; * grd.DataKeyField = "EntidadID"; * grd.GridLines = GridLines.Horizontal; * //grd.BorderStyle = BorderStyle.Solid; * grd.BorderWidth = Unit.Pixel(0); * //grd.BorderColor = System.Drawing.Color.Gray; * grd.HeaderStyle.CssClass = "TituloGrilla"; * grd.ItemStyle.CssClass = "TextoGrilla"; * grd.ShowHeader = false; * grd.ShowFooter = false; * grd.Width = Unit.Pixel(200); * * DsVentas.DatosRow dr = ((DsVentas.DatosRow)((DataRowView)e.Item.DataItem).Row); * grd.DataSource = dsVentasPorMes.Datos.Select("EntidadID = " + dr.EntidadID + " AND Mes = " + i); * grd.DataBind(); * j++; * * } * else * e.Item.Cells[i].Visible = false; * }*/ } else if (e.Item.ItemType == ListItemType.Footer) { int cantMeses = 0; DsVentasPorMes dsVentasPorMes = (DsVentasPorMes)Session["DsVentasAgenciasPorMes"]; string EntidadSeleccionada = string.Empty; if (Session["EntidadSeleccionada"] != null) { EntidadSeleccionada = Session["EntidadSeleccionada"].ToString(); } int j; if (Convert.ToInt32(Request.QueryString["AgregarColumnaVendedor"]) == 1) { j = 2; } else { j = 1; } for (int i = 1; i <= 12; i++) { if (mesesAmostrar[i]) { e.Item.Cells[2].Text = "Totales"; if (EntidadSeleccionada != string.Empty) { e.Item.Cells[j + 2].Text = "" + //" " + Utiles.Formatos.Importe( Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "Mes = " + i + " and EntidadID=" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada))))); //+ " " + //Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteBruto)", "Mes = " + i + " and EntidadID=" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada))))); e.Item.Cells[j + 3].Text = "" + Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteBruto)", "Mes = " + i + " and EntidadID=" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada))))); } else { e.Item.Cells[j + 2].Text = "" + //" " + Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "Mes = " + i)))); // + " " + //Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteBruto)", "Mes = " + i)))); e.Item.Cells[j + 3].Text = "" + Utiles.Formatos.Importe(Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteBruto)", "Mes = " + i)))); } e.Item.Cells[j + 2].HorizontalAlign = HorizontalAlign.Center; cantMeses++; j++; j++; } } // Si no se comenta la siguiente sección, lanza una excepción. double fleteNeto; if (EntidadSeleccionada != string.Empty) { try { // fleteNeto = Convert.ToDouble(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "EntidadID=" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada))); fleteNeto = Utiles.Validaciones.obtieneDouble(Convert.ToString(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "EntidadID =" + Utiles.Validaciones.obtieneEntero(EntidadSeleccionada)))); } catch (Exception ex) { fleteNeto = 0; } } else { fleteNeto = Convert.ToDouble(dsVentasPorMes.Datos.Compute("SUM(FleteNeto)", "")); } if (e.Item.Cells.Count > 8) { e.Item.Cells[e.Item.Cells.Count - 9].Text = Utiles.Formatos.Importe(fleteNeto); // Total Flete Neto e.Item.Cells[e.Item.Cells.Count - 9].HorizontalAlign = HorizontalAlign.Right; e.Item.Cells[e.Item.Cells.Count - 8].Text = Utiles.Formatos.Importe(fleteNeto / cantMeses); // Promedio e.Item.Cells[e.Item.Cells.Count - 8].HorizontalAlign = HorizontalAlign.Right; } else { e.Item.Cells[e.Item.Cells.Count - 2].Text = Utiles.Formatos.Importe(fleteNeto); // Total Flete Neto e.Item.Cells[e.Item.Cells.Count - 2].HorizontalAlign = HorizontalAlign.Right; e.Item.Cells[e.Item.Cells.Count - 1].Text = Utiles.Formatos.Importe(fleteNeto / cantMeses); // Promedio e.Item.Cells[e.Item.Cells.Count - 1].HorizontalAlign = HorizontalAlign.Right; } } }