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

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


  Mostrar Temas
Páginas: [1] 2
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 / 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
4  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...
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.

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
6  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#
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.



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.        }
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#


 
Código
  1. IfxDataAdapter dt = new IfxDataAdapter(" 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.  
  4.                                                   " FROM prdcto a , prmdio_vnta b " +
  5.                                                   " WHERE estdo = 'A' " +
  6.                                                   " AND a.cdgo_prdcto = b.cdgo_prdcto " +
  7.                                                   " GROUP BY 1,2,4,5,6,7 " +
  8.                                                   " ORDER BY 2 ", conexion);
  9.  

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.




Código
  1.            IfxDataAdapter dt = new IfxDataAdapter(" SELECT a.cdgo_prdcto as CODIGO,a.nmbre_prdcto DESCRIPCION, SUM(b.cntdad)PMDIOVTA ,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 ", conexion);
  8.            DataGridTableStyle ts1 = new DataGridTableStyle();
  9.  
  10.  
  11.  
  12.             DataSet dsdatos = new DataSet();
  13.             dt.Fill(dsdatos, "Datos");                        
  14.  
  15.            this.dataGridView1.DataMember = "Datos";
  16.            //this.dataGridView1.Columns(1).Width = 4400;
  17.            this.dataGridView1.DataSource = dsdatos;
  18.  
  19.  
  20.  
  21.  
  22.        }
  23.  
  24.        private void Form1_Load(object sender, EventArgs e)
  25.        {
  26.  
  27.        }
  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.A4, 9, 9, 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.            PdfPTable datatable = new PdfPTable(dataGridView1.ColumnCount);
  70.            datatable.DefaultCell.Padding = 1;
  71.            float[] headerwidths = GetTamañoColumnas(dataGridView1);
  72.  
  73.            datatable.SetWidths(headerwidths);
  74.            datatable.WidthPercentage = 100;
  75.            datatable.DefaultCell.BorderWidth = 2;
  76.  
  77.            iTextSharp.text.Font fuente = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.COURIER);
  78.  
  79.            DataGridViewCellStyle style = this.dataGridView1.ColumnHeadersDefaultCellStyle;
  80.  
  81.            Phrase objP = new Phrase("A", fuente);
  82.  
  83.            datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
  84.            for (int i = 0; i < dataGridView1.ColumnCount; i++)
  85.            {
  86.  
  87.                objP = new Phrase(dataGridView1.Columns[i].HeaderText, fuente);
  88.                 datatable.HorizontalAlignment = Element.ALIGN_CENTER;
  89.  
  90.                datatable.AddCell(objP);
  91.  
  92.  
  93.            }
  94.            datatable.HeaderRows =1;
  95.  
  96.            datatable.DefaultCell.BorderWidth = 1;
  97.  
  98.  
  99.  
  100.  
  101.            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
  102.            {
  103.                for (int j = 0; j < dataGridView1.ColumnCount; j++)
  104.                {
  105.                    objP = new Phrase(dataGridView1[j, i].Value.ToString(), fuente);
  106.  
  107.                    style.BackColor = Color.WhiteSmoke;
  108.                    style.ForeColor = Color.Gray;
  109.  
  110.                    datatable.AddCell(objP);
  111.  
  112.  
  113.  
  114.                }
  115.                datatable.CompleteRow();
  116.            }
  117.            document.Add(datatable);
  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
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines