|
Mostrar Temas
|
Páginas: [1] 2
|
2
|
Programación / Desarrollo Web / Inconveniente con agrupacion de datos
|
en: 26 Febrero 2012, 06:19 am
|
Buenas noches
Me gustaria que me ayudaran con el inconveniente que estoy presentando, tengo la siguiente consulta pero me esta trayendo los registros repetidos, necesito que solo me traiga un registro de cada noimbre de compañia
SELECT DISTINCT C.NOMBRES, CASE Month(v.fecha) when '1' THEN ROUND(SUM(v.valor_total),0) end enero, CASE Month(v.fecha) when '2' THEN ROUND(SUM(v.valor_total),0) end Febrero, CASE Month(v.fecha) when '3' THEN ROUND(SUM(v.valor_total),0) end Marzo, CASE Month(v.fecha) when '4' THEN ROUND(SUM(v.valor_total),0) end Abril, CASE Month(v.fecha) when '5' THEN ROUND(SUM(v.valor_total),0) end Mayo, CASE Month(v.fecha) when '6' THEN ROUND(SUM(v.valor_total),0) end Jumio FROM CLIENTES C JOIN VENTAS V on C.NIT=V.NIT WHERE Month(v.fecha) between '2'and '6' GROUP BY C.NOMBRES, Month(v.fecha) ORDER BY C.NOMBRES
Muchas gracias
|
|
|
3
|
Programación / Programación General / Ayuda con sql server
|
en: 25 Febrero 2012, 16:52 pm
|
Buen dia Me gustaria que me ayudaran con esta consulta en sql server, tengo 2 tablas una llamada clientes que tiene nit, nombre,zona y la otra ventas que tiene numero,fecha,nit, valor total. Necesito hacer una consulta que me traiga el nombre de la compañia, total de ventas, y ventas en enero febrero mes a mes etc cliente total enero febrero marzo abril mayo |
|
|
|
5
|
Programación / .NET (C#, VB.NET, ASP) / Terminar un evento en c#
|
en: 16 Junio 2011, 21:39 pm
|
Hola buenas tardes, tengo una pequeña duda estoy creando un programa en c# pero necesito que el evento del boton me finalice al llegar a un else despues de un mensaje y no me siga haciendo el recorrido del siguiente resultado en wile. if (lleer.Read()) { lineatabla = Convert.ToInt32(lleer[0]); clientelinea = Convert.ToInt32(leer[1]); lleer.Close(); SqlDataReader sd; SqlCommand productos = new SqlCommand ("SELECT lngIdProducto from tblproductos where lngIdProducto=" + cdgopromarion + " and lngidcliente=" + cliente + "", conexion ); sd = productos.ExecuteReader(); if (sd.Read()) { prodcttabla = Convert.ToInt32(sd[0]); if (prodcttabla == cdgopromarion) { MessageBox.Show("El codigo de producto " + cdgopromarion + " " + desproducto + " ya se encuentra registrado para el cliente " + cliente + ""); } } else { sd.Close(); SqlDataReader insertar; SqlCommand insertproductos = new SqlCommand ("insert into dbo.tblProductos values('" + cdgoprocliente + "'," + cdgopromarion + ",'" + desproducto + "'," + linea + "," + cliente + "," + precio + ",'" + iva2 + "'," + estado + "," + unm + "," + opera + ")", conexion ); insertar = insertproductos.ExecuteReader(); insertar.Close(); } } else { MessageBox.Show("Los datos del codigo de linea " + linea + " asociado al producto " + cdgopromarion + " " + desproducto + " y cliente " + cliente + " no existe "); }
necesito que cuando llegue a los Messagebox me para todo el proceso hasta el momento pero no me cierre los formularios, no se como hacerlo Necesito ayuda
|
|
|
7
|
Programación / .NET (C#, VB.NET, ASP) / Paginar un pdf y alinear las columnas de un datagridview
|
en: 16 Marzo 2011, 22:38 pm
|
Hola amigos necesito una yuda urgente, estoy generando un datagridview y l oestoy exportando a pdf me gustaria poder alinear las columnas como quiero y poder colocarle el numero de la hoja a cada una si algo aca dejo el codigo . mucahs gracias. OdbcDataAdapter dta =new OdbcDataAdapter (" SELECT a.cdgo_prdcto COD,a.nmbre_prdcto DESCRIPCION, SUM(b.cntdad)PMVTA,a.csto_rpscion CR, " + " a.clfccion_prmnnte P, a.clfccion_tmpral T,a.cdgo_brra EAN" + " from prdcto a , prmdio_vnta b " + " where estdo = 'A' " + " and a.cdgo_prdcto = b.cdgo_prdcto " + " group by 1,2,4,5,6,7 " + " order by 2 ", conn); DataSet dsdatos = new DataSet (); dta.Fill(dsdatos, "Datos"); this.dataGridView1.DataMember = "Datos"; //this.dataGridView1.Columns(1).Width = 4400; this.dataGridView1.DataSource = dsdatos; } private void Form1_Load(object sender, EventArgs e) { } //private void dataGridView1_DefaultCellStyleChanged(object sender, EventArgs e) private void btnExportar_Click(object sender, EventArgs e) { DateTime hora = DateTime.Now; string fcha_ttal = Convert.ToDateTime(hora).Day + "/" + Convert.ToDateTime(hora).Month + "/" + Convert.ToDateTime(hora).Year; Document doc = new Document (PageSize .LETTER, 10, 10, 10, 10); string filename = "C:\\Temp\\Listado Total.pdf"; iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(@"C:\Mis documentos\Biblia_productos\Biblia_productos\Images\marion.JPG"); jpg.Alignment = iTextSharp.text.Image.ALIGN_LEFT; Chunk encab = new Chunk (" LISTA DE PRODUCTOS CODIFICADOS EN " + fcha_ttal + "", FontFactory .GetFont("COURIER", 12)); try { FileStream file = new FileStream (filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); PdfWriter.GetInstance(doc, file); doc.Open(); doc .Add(new Paragraph (encab )); doc.Add(jpg); GenerarDocumento(doc); Process.Start(filename); doc.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } //Función que genera el documento Pdf public void GenerarDocumento(Document document) { PdfPTable datatable = new PdfPTable (dataGridView1 .ColumnCount); datatable.DefaultCell.Padding = 1; float[] headerwidths = GetTamañoColumnas(dataGridView1); datatable.SetWidths(headerwidths); datatable.WidthPercentage = 100; datatable.DefaultCell.BorderWidth = 4; // Define el grosor del encabezado //datatable.DefaultCell.VerticalAlignment = Element.ALIGN_CENTER; // Alinea el encabezado al centro //datatable.DefaultCell.Column = datatable.DefaultCell.Padding = 3; //Amplia el tamaño del encabezado iTextSharp .text.Font fuente = new iTextSharp .text.Font(iTextSharp .text.Font.FontFamily.COURIER, 9); Phrase objP = new Phrase ("A", fuente ); for (int i = 0; i < dataGridView1.ColumnCount; i++) { objP = new Phrase (dataGridView1 .Columns[i ].HeaderText, fuente ); //this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter; datatable.AddCell(objP); } datatable.HeaderRows = 1; datatable.DefaultCell.BorderWidth = 1; for (int i = 0; i < dataGridView1.RowCount - 1; i++) { for (int j = 0; j < dataGridView1.ColumnCount; j++) { objP = new Phrase (dataGridView1 [j, i ].Value.ToString(), fuente ); datatable.AddCell(objP); } datatable.CompleteRow(); } document.Add(datatable); } public float[] GetTamañoColumnas(DataGridView dg) { float[] values = new float[dg .ColumnCount]; for (int i = 0; i < dg.ColumnCount; i++) { values[i] = (float)dg.Columns[i].Width; } return values; }
|
|
|
8
|
Programación / .NET (C#, VB.NET, ASP) / Utilizar un cast en c#
|
en: 16 Marzo 2011, 15:17 pm
|
Utilizar un cast en una consulta de c# IfxDataAdapter dt = new IfxDataAdapter (" SELECT a.cdgo_prdcto COD,a.nmbre_prdcto DESCRIPCION, SUM(b.cntdad)PMVTA, a.csto_rpscion CR, " + " a.clfccion_prmnnte P, a.clfccion_tmpral T,a.cdgo_brra EAN" + " FROM prdcto a , prmdio_vnta b " + " WHERE estdo = 'A' " + " AND a.cdgo_prdcto = b.cdgo_prdcto " + " GROUP BY 1,2,4,5,6,7 " + " ORDER BY 2 ", conexion);
Deseo usarlo en a.csto_rpscion para que me traiga los valores tal y como estan en la bd que es informix ya que en la bd tiene un decimal y aqui no me lo trae como entero
|
|
|
9
|
Programación / .NET (C#, VB.NET, ASP) / Decimales en datagrid y exportar a pdf c#
|
en: 14 Marzo 2011, 02:47 am
|
Hola tengo un inconveniente, lo que pasa es que estoy trayendo informacion d euna base de datos a un datagrid y luego las exporto a pdf pero necesito estrablecerle los decimales por ejemplo tengo este precio de un articulo 638500 y necesito que el decimal se me coloque en la siguiente posicion 6385,00 sin que a este valor traido de la base de datos me coloque ams ceros sino que a los que trae los separe por decimales y que al exportarlos al pdf me generen igual
|
|
|
10
|
Programación / .NET (C#, VB.NET, ASP) / Exportar un Datagridview a PDF con un encabezado personalizado
|
en: 11 Marzo 2011, 02:49 am
|
Hola amigos tengo este codigo que genera un reporte en un datagridview y luego lo exporta a PDF, me gustaria que el encabezado donde dice los nombres de las columnas tuviera una letra en negrilla y que esta fila fuera un poco mas gruesa y con un color de fondo pero no se como hacerle les agredeceria mucho su ayuda. IfxDataAdapter dt = new IfxDataAdapter (" SELECT a.cdgo_prdcto as CODIGO,a.nmbre_prdcto DESCRIPCION, SUM(b.cntdad)PMDIOVTA ,a.csto_rpscion CR, " + " a.clfccion_prmnnte P, a.clfccion_tmpral T,a.cdgo_brra EAN" + " from prdcto a , prmdio_vnta b " + " where estdo = 'A' " + " and a.cdgo_prdcto = b.cdgo_prdcto " + " group by 1,2,4,5,6,7 " + " order by 2 ", conexion); DataGridTableStyle ts1 = new DataGridTableStyle (); DataSet dsdatos = new DataSet (); dt.Fill(dsdatos, "Datos"); this.dataGridView1.DataMember = "Datos"; //this.dataGridView1.Columns(1).Width = 4400; this.dataGridView1.DataSource = dsdatos; } private void Form1_Load(object sender, EventArgs e) { } private void btnExportar_Click(object sender, EventArgs e) { DateTime hora = DateTime.Now; string fcha_ttal = Convert.ToDateTime(hora).Day + "/" + Convert.ToDateTime(hora).Month + "/" + Convert.ToDateTime(hora).Year; Document doc = new Document (PageSize .A4, 9, 9, 10, 10); string filename = "C:\\Temp\\Listado Total.pdf"; iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(@"C:\Mis documentos\Biblia_productos\Biblia_productos\Images\marion.JPG"); jpg.Alignment = iTextSharp.text.Image.ALIGN_LEFT; Chunk encab = new Chunk (" LISTA DE PRODUCTOS CODIFICADOS EN " + fcha_ttal + "", FontFactory .GetFont("COURIER", 12)); try { FileStream file = new FileStream (filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); PdfWriter.GetInstance(doc, file); doc.Open(); doc .Add(new Paragraph (encab )); doc.Add(jpg); GenerarDocumento(doc); Process.Start(filename); doc.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } //Función que genera el documento Pdf public void GenerarDocumento(Document document) { PdfPTable datatable = new PdfPTable (dataGridView1 .ColumnCount); datatable.DefaultCell.Padding = 1; float[] headerwidths = GetTamañoColumnas(dataGridView1); datatable.SetWidths(headerwidths); datatable.WidthPercentage = 100; datatable.DefaultCell.BorderWidth = 2; iTextSharp .text.Font fuente = new iTextSharp .text.Font(iTextSharp .text.Font.FontFamily.COURIER); DataGridViewCellStyle style = this.dataGridView1.ColumnHeadersDefaultCellStyle; Phrase objP = new Phrase ("A", fuente ); datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; for (int i = 0; i < dataGridView1.ColumnCount; i++) { objP = new Phrase (dataGridView1 .Columns[i ].HeaderText, fuente ); datatable.HorizontalAlignment = Element.ALIGN_CENTER; datatable.AddCell(objP); } datatable.HeaderRows =1; datatable.DefaultCell.BorderWidth = 1; for (int i = 0; i < dataGridView1.RowCount - 1; i++) { for (int j = 0; j < dataGridView1.ColumnCount; j++) { objP = new Phrase (dataGridView1 [j, i ].Value.ToString(), fuente ); style.BackColor = Color.WhiteSmoke; style.ForeColor = Color.Gray; datatable.AddCell(objP); } datatable.CompleteRow(); } document.Add(datatable); } public float[] GetTamañoColumnas(DataGridView dg) { float[] values = new float[dg .ColumnCount]; for (int i = 0; i < dg.ColumnCount; i++) { values[i] = (float)dg.Columns[i].Width; } return values; }
|
|
|
|
|
|
|