|
Mostrar Mensajes
|
Páginas: [1] 2 3
|
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 / Re: Ayuda con sql server
|
en: 25 Febrero 2012, 17:35 pm
|
Con esta onsulta si me da solo que me esta mostrando las compañias con cada uno de los valores registrados no un total
SELECT C.NOMBRES, ROUND(SUM(V.VALOR_TOTAL),0), CASE Month(v.fecha) when '1' THEN v.valor_total end enero, CASE Month(v.fecha) when '2' THEN v.valor_total end febrero, CASE Month(v.fecha) when '3' THEN v.valor_total end marzo, CASE Month(v.fecha) when '4' THEN v.valor_total end abril, CASE Month(v.fecha) when '5' THEN v.valor_total end mayo, CASE Month(v.fecha) when '6' THEN v.valor_total end junio FROM CLIENTES C INNER JOIN VENTAS V ON C.NIT=V.NIT GROUP BY C.NOMBRES,V.FECHA,V.valor_total ORDER BY 1
|
|
|
4
|
Programación / Programación General / Re: Ayuda con sql server
|
en: 25 Febrero 2012, 17:21 pm
|
SELECT C.NOMBRES, ROUND(SUM(V.VALOR_TOTAL),0), CASE Month(v.fecha) when '1' THEN v.valor_total end enero, CASE Month(v.fecha) when '2' THEN v.valor_total end febrero, CASE Month(v.fecha) when '3' THEN v.valor_total end marzo, CASE Month(v.fecha) when '4' THEN v.valor_total end abril, CASE Month(v.fecha) when '5' THEN v.valor_total end mayo, CASE Month(v.fecha) when '6' THEN v.valor_total end junio FROM CLIENTES C INNER JOIN VENTAS V ON C.NIT=V.NIT GROUP BY C.NOMBRES,V.FECHA,V.valor_total ORDER BY 1
|
|
|
5
|
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 |
|
|
|
8
|
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
|
|
|
10
|
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; }
|
|
|
|
|
|
|