elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


  Mostrar Mensajes
Páginas: [1] 2 3
1  Programación / Desarrollo Web / Sumar columnas en un gridview en: 26 Febrero 2012, 21:03 pm
Buena tarde

Me gustaria conocer cual es el codigo para sumar cada una de las columnas de un gridview en asp.net.

Muchas Gracias
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
6  Programación / .NET (C#, VB.NET, ASP) / Reportviewer en: 21 Junio 2011, 15:27 pm
Hola Buenos dias me gustarian saber si alguno de ustedes tiene una pagina o un manual para crear Reportviewer, les agradeceria mcuho...
7  Programación / .NET (C#, VB.NET, ASP) / Re: Terminar un evento en c# en: 16 Junio 2011, 22:29 pm
YA LO RESOLVI
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.

Código
  1.   if (lleer.Read())
  2.                    {
  3.                        lineatabla = Convert.ToInt32(lleer[0]);
  4.                        clientelinea = Convert.ToInt32(leer[1]);
  5.                        lleer.Close();
  6.                        SqlDataReader sd;
  7.                        SqlCommand productos = new SqlCommand("SELECT lngIdProducto from tblproductos where lngIdProducto=" + cdgopromarion + " and lngidcliente=" + cliente + "", conexion);
  8.                        sd = productos.ExecuteReader();
  9.  
  10.                        if (sd.Read())
  11.                        {
  12.                            prodcttabla = Convert.ToInt32(sd[0]);
  13.                            if (prodcttabla == cdgopromarion)
  14.                            {
  15.                                MessageBox.Show("El codigo de producto " + cdgopromarion + " " + desproducto + "  ya se encuentra registrado para el cliente " + cliente + "");
  16.  
  17.                            }
  18.                        }
  19.                        else
  20.                        {
  21.                            sd.Close();
  22.                            SqlDataReader insertar;
  23.                            SqlCommand insertproductos = new SqlCommand("insert into dbo.tblProductos  values('" + cdgoprocliente + "'," + cdgopromarion + ",'" + desproducto + "'," + linea + "," + cliente + "," + precio + ",'" + iva2 + "'," + estado + "," + unm + "," + opera + ")", conexion);
  24.                            insertar = insertproductos.ExecuteReader();
  25.                            insertar.Close();
  26.                        }
  27.                    }
  28.                    else
  29.                    {
  30.                        MessageBox.Show("Los datos del codigo de linea " + linea + " asociado al producto " + cdgopromarion + " " + desproducto + " y cliente " + cliente + " no existe ");
  31.  
  32.                    }


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
9  Programación / .NET (C#, VB.NET, ASP) / Paginar un pdf desde c# en: 17 Marzo 2011, 16:34 pm
HOLA,  tengo un datagrid que exporto a pdf y me gustaria poder colocarle el numero de pagina a cada una y no se como estoy trabajando en c#
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.



Código
  1. OdbcDataAdapter dta  =new OdbcDataAdapter (" SELECT a.cdgo_prdcto COD,a.nmbre_prdcto DESCRIPCION, SUM(b.cntdad)PMVTA,a.csto_rpscion CR, " +
  2.                                                   " a.clfccion_prmnnte P, a.clfccion_tmpral T,a.cdgo_brra EAN" +
  3.                                                   " from prdcto a , prmdio_vnta b " +
  4.                                                   " where estdo = 'A' " +
  5.                                                   " and a.cdgo_prdcto = b.cdgo_prdcto " +
  6.                                                   " group by 1,2,4,5,6,7 " +
  7.                                                    " order by 2 ", conn);
  8.  
  9.  
  10.  
  11.            DataSet dsdatos = new DataSet();
  12.            dta.Fill(dsdatos, "Datos");
  13.  
  14.            this.dataGridView1.DataMember = "Datos";
  15.            //this.dataGridView1.Columns(1).Width = 4400;
  16.            this.dataGridView1.DataSource = dsdatos;
  17.  
  18.  
  19.  
  20.        }
  21.  
  22.        private void Form1_Load(object sender, EventArgs e)
  23.        {
  24.  
  25.        }
  26.  
  27.        //private void dataGridView1_DefaultCellStyleChanged(object sender, EventArgs e)
  28.  
  29.        private void btnExportar_Click(object sender, EventArgs e)
  30.        {
  31.  
  32.  
  33.            DateTime hora = DateTime.Now;
  34.            string fcha_ttal = Convert.ToDateTime(hora).Day + "/" + Convert.ToDateTime(hora).Month + "/" + Convert.ToDateTime(hora).Year;
  35.  
  36.  
  37.            Document doc = new Document(PageSize.LETTER, 10, 10, 10, 10);
  38.            string filename = "C:\\Temp\\Listado Total.pdf";
  39.            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;
  40.            Chunk encab = new Chunk(" LISTA DE PRODUCTOS CODIFICADOS EN " + fcha_ttal + "", FontFactory.GetFont("COURIER", 12));
  41.  
  42.  
  43.            try
  44.            {
  45.                FileStream file = new FileStream
  46.               (filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
  47.                PdfWriter.GetInstance(doc, file);
  48.                doc.Open();
  49.  
  50.  
  51.                doc.Add(new Paragraph(encab));
  52.                doc.Add(jpg);
  53.                GenerarDocumento(doc);
  54.  
  55.                Process.Start(filename);
  56.                doc.Close();
  57.            }
  58.  
  59.            catch (Exception ex)
  60.            {
  61.                MessageBox.Show(ex.Message);
  62.            }
  63.  
  64.        }
  65.  
  66.        //Función que genera el documento Pdf
  67.        public void GenerarDocumento(Document document)
  68.        {
  69.  
  70.  
  71.  
  72.            PdfPTable datatable = new PdfPTable(dataGridView1.ColumnCount);
  73.            datatable.DefaultCell.Padding = 1;
  74.            float[] headerwidths = GetTamañoColumnas(dataGridView1);
  75.  
  76.  
  77.            datatable.SetWidths(headerwidths);
  78.            datatable.WidthPercentage = 100;
  79.            datatable.DefaultCell.BorderWidth = 4; // Define el grosor del encabezado
  80.  
  81.            //datatable.DefaultCell.VerticalAlignment = Element.ALIGN_CENTER; // Alinea el encabezado al centro
  82.            //datatable.DefaultCell.Column =
  83.            datatable.DefaultCell.Padding = 3;     //Amplia el tamaño del encabezado
  84.  
  85.  
  86.  
  87.           iTextSharp.text.Font fuente = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.COURIER, 9);
  88.  
  89.           Phrase objP = new Phrase("A", fuente);
  90.  
  91.            for (int i = 0; i < dataGridView1.ColumnCount; i++)
  92.            {
  93.  
  94.                objP = new Phrase(dataGridView1.Columns[i].HeaderText, fuente);
  95.  
  96.                //this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
  97.                datatable.AddCell(objP);
  98.  
  99.  
  100.            }
  101.            datatable.HeaderRows = 1;
  102.            datatable.DefaultCell.BorderWidth = 1;
  103.  
  104.  
  105.            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
  106.            {
  107.                for (int j = 0; j < dataGridView1.ColumnCount; j++)
  108.                {
  109.  
  110.                    objP = new Phrase(dataGridView1[j, i].Value.ToString(), fuente);
  111.                    datatable.AddCell(objP);
  112.                 }
  113.                datatable.CompleteRow();
  114.                }
  115.  
  116.            document.Add(datatable);
  117.  
  118.        }
  119.        public float[] GetTamañoColumnas(DataGridView dg)
  120.        {
  121.            float[] values = new float[dg.ColumnCount];
  122.            for (int i = 0; i < dg.ColumnCount; i++)
  123.            {
  124.                values[i] = (float)dg.Columns[i].Width;
  125.            }
  126.            return values;
  127.        }
Páginas: [1] 2 3
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines