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

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


  Mostrar Mensajes
Páginas: 1 2 [3] 4 5 6
21  Programación / .NET (C#, VB.NET, ASP) / Re: agregar columnas al datagrid en tiempo de ejecucion en: 1 Julio 2015, 16:26 pm
lo pude solucionar....agrego a datagrid2 tantas filas como devuelva la consulta al datagrid1.....ahora como puedo hacer para que las filas del datagrid2 se puedan modificar? muchas gracias
Código
  1. private void txtNumero_KeyDown_1(object sender, KeyEventArgs e)
  2.        {
  3.            if (e.KeyCode == Keys.Enter)
  4.            {
  5.  
  6.                if (txtNumero.Text == "")
  7.                {
  8.  
  9.                    DialogResult ds = MessageBox.Show("DEBE INGRESAR UN NRO DE ORDEN", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  10.                    this.Text = ds.ToString();
  11.                }
  12.                else
  13.                    if (txtNumero.Text != "")
  14.                    {
  15.                        conexion = new SqlConnection("Data Source=GONZALOCABRERA\\SQLEXPRESS;Initial Catalog=ProyectoSalud;Integrated Security=True");
  16.                        conexion.Open();
  17.                        SqlCommand consulta = new SqlCommand("select count (*) from DetalleOrdenCompra where nro_orden=@nro", conexion);
  18.                        consulta.Parameters.AddWithValue("@nro", Convert.ToInt32(txtNumero.Text));
  19.  
  20.                        int count = Convert.ToInt32(consulta.ExecuteScalar());
  21.  
  22.  
  23.                        if (count > 0)
  24.                        {
  25.  
  26.                            DialogResult result = MessageBox.Show(this, "DESEA REGISTRAR LOS DATOS?", "ORDEN DE COMPRA ENCONTRADA", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
  27.  
  28.  
  29.                            //MessageBox.Show(consulta2.ToString());
  30.                            this.Text = result.ToString();
  31.  
  32.                            if (result == DialogResult.OK)
  33.                            {
  34.  
  35.                                //CARGAR LOS DATAGRIDVIEW
  36.                                SqlCommand consulta2 = new SqlCommand("SELECT dbo.medicamentos1.nombre_medicamento, dbo.medicamentos1.jerarquia, dbo.DetalleOrdenCompra.cantidad FROM dbo.DetalleOrdenCompra INNER JOIN dbo.medicamentos1 ON dbo.DetalleOrdenCompra.codigoMedicamento = dbo.medicamentos1.id_medicamento WHERE nro_orden=@nro ", conexion);
  37.                                consulta2.Parameters.AddWithValue("@nro", Convert.ToInt32(txtNumero.Text));
  38.                                SqlDataAdapter da = new SqlDataAdapter(consulta2);
  39.                                DataTable dt = new DataTable();
  40.                                da.Fill(dt);
  41.  
  42.                                dgv1.DataSource = dt;
  43.                                int rows = dt.Rows.Count;
  44.  
  45.                                dgv1.Columns[0].HeaderText = "MEDICAMENTO";
  46.                                dgv1.Columns[0].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  47.                                dgv1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  48.                                dgv1.Columns[0].Width = 211;
  49.                                dgv1.Columns[1].HeaderText = "JERARQUIA";
  50.                                dgv1.Columns[1].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  51.                                dgv1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  52.                                dgv1.Columns[1].Width = 180;
  53.                                dgv1.Columns[2].HeaderText = "CANTIDAD";
  54.                                dgv1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  55.                                dgv1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  56.                                dgv1.Columns[2].Width = 80;
  57.  
  58.  
  59.  
  60.                                for (int i = 1; i <= rows; i++)
  61.                                {
  62.                                    DataGridViewRow row = (DataGridViewRow)dgv2.RowTemplate.Clone();
  63.                                    dgv2.Rows.Add(row);
  64.  
  65.  
  66.                                }
  67.                                txtNumero.Enabled = false;
  68.  
  69.                            }
  70.                            else if (result == DialogResult.Cancel)
  71.                            {
  72.  
  73.                                txtNumero.Text = "";
  74.  
  75.                            }
  76.  
  77.                            this.Text = result.ToString();
  78.  
  79.  
  80.                        }
  81.                        else
  82.                        {
  83.  
  84.                            DialogResult ds = MessageBox.Show(this, "LA ORDEN INGRESADA NO SE ENCUENTRA REGISTRADA", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  85.                            this.Text = ds.ToString();
  86.  
  87.                        }
  88.  
  89.                        conexion.Close();
  90.                    }
22  Programación / .NET (C#, VB.NET, ASP) / agregar columnas al datagrid en tiempo de ejecucion en: 1 Julio 2015, 02:17 am
buenas noches verán tengo el sig. código en el cual traigo una consulta de la bd y pongo los resultados en el datagridview....lo q qiero hacer es agregar una o mas columnas d tipo textbox y checkbox y q tngan x filas según la cantidad de renglones q devuelva la consulta en tiempo de ejecución....como lo logro? grax d antemano
Código
  1. private void textBox1_KeyDown(object sender, KeyEventArgs e)
  2.        {
  3.            if (e.KeyCode == Keys.Enter)
  4.            {
  5.  
  6.                if (txtNumero.Text == "")
  7.                {
  8.  
  9.                    DialogResult ds = MessageBox.Show("DEBE INGRESAR UN NRO DE ORDEN", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  10.                    this.Text = ds.ToString();
  11.                }
  12.                else
  13.                    if (txtNumero.Text != "")
  14.                    {
  15.                        conexion = new SqlConnection("Data Source=GONZALOCABRERA\\SQLEXPRESS;Initial Catalog=ProyectoSalud;Integrated Security=True");
  16.                        conexion.Open();
  17.                        SqlCommand consulta = new SqlCommand("select count (*) from DetalleOrdenCompra where codigoOrden=@codigo", conexion);
  18.                        consulta.Parameters.AddWithValue("@codigo", Convert.ToInt32(txtNumero.Text));
  19.  
  20.                        int count = Convert.ToInt32(consulta.ExecuteScalar());
  21.  
  22.  
  23.                        if (count > 0)
  24.                        {
  25.  
  26.                            DialogResult result = MessageBox.Show(this, "DESEA REGISTRAR LOS DATOS?", "ORDEN DE COMPRA ENCONTRADA", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
  27.  
  28.  
  29.  
  30.                            //MessageBox.Show(consulta2.ToString());
  31.                            this.Text = result.ToString();
  32.  
  33.                            if (result == DialogResult.OK)
  34.                            {
  35.  
  36.                                //CARGAR LOS DATAGRIDVIEW
  37.                                SqlCommand consulta2 = new SqlCommand("SELECT dbo.DetalleOrdenCompra.codigoMedicamento,dbo.medicamentos1.nombre_medicamento, dbo.DetalleOrdenCompra.cantidad FROM dbo.DetalleOrdenCompra INNER JOIN dbo.medicamentos1 ON dbo.DetalleOrdenCompra.codigoMedicamento = dbo.medicamentos1.id_medicamento INNER JOIN dbo.DetalleMedicamento ON dbo.medicamentos1.id_medicamento = dbo.DetalleMedicamento.id_medicamento WHERE codigoOrden=@codigo ", conexion);
  38.                                consulta2.Parameters.AddWithValue("@codigo", Convert.ToInt32(txtNumero.Text));
  39.                                SqlDataAdapter da = new SqlDataAdapter(consulta2);
  40.                                DataTable dt = new DataTable();
  41.                                da.Fill(dt);
  42.                                //dgv1.AutoGenerateColumns = false;
  43.                                dgv1.DataSource = dt;
  44.  
  45.                                dgv1.Columns[0].HeaderText = "CODIGO";
  46.                                dgv1.Columns[0].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  47.                                dgv1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  48.                                dgv1.Columns[0].Width = 60;
  49.                                dgv1.Columns[1].HeaderText = "MEDICAMENTO";
  50.                                dgv1.Columns[1].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  51.                                dgv1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  52.                                dgv1.Columns[1].Width = 211;
  53.                                dgv1.Columns[2].HeaderText = "CANTIDAD";
  54.                                dgv1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  55.                                dgv1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  56.                                dgv1.Columns[2].Width = 80;
  57.  
  58.  
  59.  
  60.                                txtNumero.Enabled = false;
  61.                            }
  62.                            else if (result == DialogResult.Cancel)
  63.                            {
  64.  
  65.                                txtNumero.Text = "";
  66.  
  67.                            }
  68.  
  69.                            this.Text = result.ToString();
  70.  
  71.  
  72.                        }
  73.                        else
  74.                        {
  75.  
  76.                            DialogResult ds = MessageBox.Show(this, "LA ORDEN INGRESADA NO SE ENCUENTRA REGISTRADA", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  77.                            this.Text = ds.ToString();
  78.  
  79.                        }
  80.  
  81.                        conexion.Close();
  82.  
  83.                    }
23  Programación / .NET (C#, VB.NET, ASP) / consulta sobre proyecto en c# en: 7 Junio 2015, 05:45 am
buenas noches gente del foro....verán esta vez no pregunto sobre códigos ni demás jejeje.....sino q solicito vuestras opiniones(consejos) sobre un proyecto q estoy llevando a cabo (tesis) sobre administración de un deposito de medicamentos.....al grano: tengo varios forms (c#) en el cual registro en tablas de bd (medicamento por categoría, ordenes de compra, detalle de ordenes de compra, ubicaciones por categoría según medicamento) en detalle de ordenes registro los medicamentos q tiene la orden(con su precio, programa, etc.).....a la hora d registrar el stock de esos medicamentos en las ubicaciones(puede ser el total q pide esa orden o un parcial) se m complica la "funcionalidad"....yo m imagino consultando el detalle d la orden y pudiendo registrar el total o un parcial....en el caso de registrar un parcial realizar un "update".....como podría realizar dicha función? q m aconsejan? perdón x la falta d info...necesito la opinión d expertos(elektro por nombrar alguno, por ser siempre el q m comprendió y sin ofender a nadie) en el tema q siemp m guiaron en el desarrollo d esta aplicación.....muchísimas graxias d antemano....slds!!
24  Programación / .NET (C#, VB.NET, ASP) / barcode en picture en: 3 Junio 2015, 07:09 am
saludos gente del foro....como se asigna el código de barras al picture? grax d antemano
Código
  1. private void GenerateBacode(string _data,string _file)
  2.        {
  3.            _data = "2345";
  4.  
  5.            Linear barcode = new Linear();
  6.            barcode.Type = BarcodeType.CODE128;
  7.            barcode.Data = _data;
  8.            barcode.drawBarcode();
  9.  
  10.        }
25  Programación / .NET (C#, VB.NET, ASP) / Re: validar registro de datagrid en: 1 Junio 2015, 05:14 am
disculpen....lo pude resolver mil grax perdón x las molestias
26  Programación / .NET (C#, VB.NET, ASP) / validar registro de datagrid en: 1 Junio 2015, 05:04 am
buenas noches gente del foro....tengo el siguiente código en el cual a partir de un botón voy agregando registros a un datagridview e intento no dejar agregar otro registro que tenga igual el campo medicamento si ya esta cargado....al final no lo puedo conseguir ya q no m deja agregar uno repetido pero qando cambio el medicamento o sea es distinto...no m lo deja agregar...q tngo q modificar del bool? muchas grax d antemano
Código
  1. private void button1_Click(object sender, EventArgs e)
  2.        {
  3.            if (txtCantidad.Text == "" || txtPrograma.Text == "" || txtPrecio.Text == "")
  4.            {
  5.  
  6.                DialogResult ds = MessageBox.Show(this, "DEBE COMPLETAR TODOS LOS CAMPOS", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  7.                this.Text = ds.ToString();
  8.  
  9.            }
  10.            else
  11.  
  12.                if (txtCantidad.Text != "" || txtPrograma.Text != "" || txtPrecio.Text != "")
  13.                {
  14.  
  15.                    int numero = int.Parse(txtNumero.Text);
  16.                    string medicamento = comboMedicamento.Text;
  17.                    int cantidad = int.Parse(txtCantidad.Text);
  18.                    string programa = txtPrograma.Text;
  19.                    float precio = float.Parse(txtPrecio.Text);
  20.                    int numMedic = int.Parse(comboMedicamento.SelectedValue.ToString());
  21.                    bool existe = dgv.Rows.Cast<DataGridViewRow>().Any(x => Convert.ToInt32(x.Cells["Column7"].Value) == numMedic);
  22.  
  23.                    if (existe)
  24.                    {
  25.  
  26.                        MessageBox.Show(this, "MEDICAMENTO YA CARGADO", "ATENCION", MessageBoxButtons.OK);
  27.  
  28.                    }
  29.                    else
  30.                    {
  31.                        if (!existe)
  32.                        {
  33.                            dgv.Rows.Add(numMedic, medicamento, cantidad, programa, precio, cantidad * precio, numero);
  34.                            button2.Enabled = true;
  35.                            button3.Enabled = true;
  36.                            txtCantidad.Text = "";
  37.                            txtPrecio.Text = "";
  38.                            txtPrograma.Text = "";
  39.                        }
  40.                    }
  41.                }
  42.  
  43.        }
27  Programación / .NET (C#, VB.NET, ASP) / Re: autocomplete en textbox c# en: 27 Mayo 2015, 06:47 am
como siempre....me han servido d gran ayuda vuestros comentarios muchas grax x responder SLDS!!!
28  Programación / .NET (C#, VB.NET, ASP) / autocomplete en textbox c# en: 26 Mayo 2015, 06:06 am
buenas noches gente del foro...verán tengo una duda...estoy haciendo una aplicación de escritorio en la cual ingreso una serie de datos para darlos de alta en una tabla en una bd....verán cuando ingreso el nro d orden en el textbox presionaba un botón consultar para ver si ya se encontraba esa orden registrada si no estaba, habilitaba los controles para cargar los datos y luego registrarlos....al exponer esta parte d la aplicación (mi tesis) la profesora m la rechazo ya q es tedioso para el usuario presionar un botón para consultar sobre un dato si esta registrado o no....x lo q se m ocurrio implementar un autocomplete en el textbox.....m podrían ayudar sobre la implementación es decir ejemplos y demás? creo entender q al ir escribiendo el dato en el textbox hace la consulta y va trayendo los datos q tngan ese valor? y si no esta podría activar los otros controles y demás x ejemplo?
espero no causar muchas molestias y dsd ya muchas grax
expongo el código q fui realizando hst el momento
Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace RegistrarOCspp2
  11. {
  12.    public partial class RegistrarOrden : Form
  13.    {
  14.        public RegistrarOrden()
  15.        {
  16.            InitializeComponent();
  17.  
  18.        }
  19.  
  20.        private void studioButton2_Click(object sender, EventArgs e)
  21.        {
  22.            this.Close();
  23.        }
  24.  
  25.        private void RegistrarOrden_Load(object sender, EventArgs e)
  26.        {
  27.            // TODO: esta línea de código carga datos en la tabla 'proyectoSaludDataSet7.medicamentos1' Puede moverla o quitarla según sea necesario.
  28.            this.medicamentos1TableAdapter.Fill(this.proyectoSaludDataSet7.medicamentos1);
  29.  
  30.        }
  31.  
  32.        private static void OnlyNumber(KeyPressEventArgs e, bool isdecimal)
  33.        {
  34.            String aceptados;
  35.            if (!isdecimal)
  36.            {
  37.                aceptados = "0123456789," + Convert.ToChar(8);
  38.            }
  39.            else
  40.                aceptados = "0123456789." + Convert.ToChar(8);
  41.  
  42.            if (aceptados.Contains("" + e.KeyChar))
  43.            {
  44.                e.Handled = false;
  45.            }
  46.            else
  47.            {
  48.                e.Handled = true;
  49.            }
  50.        }
  51.  
  52.        private void txtUnidad_KeyPress(object sender, KeyPressEventArgs e)
  53.        {
  54.  
  55.            if (!Char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
  56.            {
  57.  
  58.                e.Handled = true;
  59.                OnlyNumber(e, false);
  60.  
  61.            }
  62.        }
  63.  
  64.        private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
  65.        {
  66.  
  67.            if (!Char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
  68.            {
  69.  
  70.                e.Handled = true;
  71.                OnlyNumber(e, false);
  72.  
  73.            }
  74.        }
  75.  
  76.        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  77.        {
  78.            if (char.IsDigit(e.KeyChar))
  79.                e.Handled = false;
  80.            else if (char.IsControl(e.KeyChar))
  81.                e.Handled = false;
  82.            else if (char.IsSeparator(e.KeyChar))
  83.                e.Handled = false;
  84.            else
  85.                e.Handled = true;
  86.        }
  87.  
  88.  
  89.        private void textBox1_Click(object sender, EventArgs e)
  90.        {
  91.            System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
  92.            ToolTip1.SetToolTip(this.txtNumero, "Ejemplo: 2290");
  93.            txtCantidad.Enabled = true;
  94.  
  95.        }
  96.  
  97.        private void button1_Click(object sender, EventArgs e)
  98.        {
  99.            if (txtCantidad.Text == "" || txtPrograma.Text == "" || txtPrecio.Text == "")
  100.            {
  101.  
  102.                DialogResult ds = MessageBox.Show(this, "DEBE COMPLETAR TODOS LOS CAMPOS", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  103.                this.Text = ds.ToString();
  104.  
  105.            }
  106.            else
  107.  
  108.                if (txtCantidad.Text != "" || txtPrograma.Text != "" || txtPrecio.Text != "")
  109.                {
  110.  
  111.  
  112.                    string medicamento = comboMedicamento.Text;
  113.                    int cantidad = int.Parse(txtCantidad.Text);
  114.                    string programa = txtPrograma.Text;
  115.                    float precio = float.Parse(txtPrecio.Text);
  116.                    dgv.Rows.Add(medicamento, cantidad, programa, precio, cantidad * precio);
  117.                    button3.Enabled = true;
  118.  
  119.  
  120.                }
  121.  
  122.        }
  123.  
  124.        private void button4_Click(object sender, EventArgs e)
  125.        {
  126.            this.Close();
  127.        }
  128.  
  129.  
  130.        private void button3_Click(object sender, EventArgs e)
  131.        {
  132.  
  133.  
  134.            int fila = dgv.CurrentRow.Index;
  135.            if (fila == 0)
  136.                button3.Enabled = false;
  137.            dgv.Rows.RemoveAt(fila);
  138.  
  139.  
  140.  
  141.        }
  142.  
  143.  
  144.  
  145.  
  146.  
  147.    }
  148. }
  149.  
29  Programación / .NET (C#, VB.NET, ASP) / Re: problema al eliminar y agregar registros d radGridView en: 6 Mayo 2015, 06:45 am
buenas noches ha funcionado a la perfeccion.........se q me vas a regañar xq va contra las reglas del foro pero MUCHISIMAS GRACIAS ELEKTRO
30  Programación / .NET (C#, VB.NET, ASP) / Re: problema al eliminar y agregar registros d radGridView en: 5 Mayo 2015, 06:03 am
m salio el mismo error d solo lectura.....m falta algo?
Código
  1. private void radButton5_Click(object sender, EventArgs e)
  2.        {
  3.            using (rgv.DeferRefresh())
  4.            {
  5.                foreach (GridViewRowInfo row in rgv.SelectedRows)
  6.                {
  7.                    rgv.Rows.Remove(row);
  8.                }
  9.            }
  10.  
  11.  
  12.        }
Páginas: 1 2 [3] 4 5 6
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines