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

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


  Mostrar Mensajes
Páginas: 1 [2] 3 4 5 6
11  Foros Generales / Foro Libre / rational rose en: 1 Febrero 2016, 04:54 am
Wenas gente del foro....
Verán tengo un problemita....estoy usando la herramienta d modelado del asunto para modelar un sistemita de la facu....en mi trabajo estamos pasando x grandes y extensos momentos de ocio jeje y m quería llevar el trabajo para adelantarlo.....pero no puedo instalar ningún programa por no ser administrador y no tener privilegios.....q m recomiendan para poder "llevar" el rational rose y poder ejecutarlo.....muchas grax y saludos
12  Foros Generales / Foro Libre / Re: examen 98-361 microsoft en: 6 Enero 2016, 03:36 am
Muchas grax x las respuestas....la verdad q si ya estoy en 4to d ing y tengo q ahorrar xa anotarm en una academia d ingles jajaja....slds!
13  Foros Generales / Foro Libre / Re: examen 98-361 microsoft en: 5 Enero 2016, 02:41 am
Me temia esta respuesta.....muchas grax tendré q juntar primero para pagarme los intensivos y luego rendir los exámenes....slds!
14  Foros Generales / Foro Libre / examen 98-361 microsoft en: 5 Enero 2016, 01:20 am
Buenas noches gente del foro... Alguien tiene un link o algo parecido con el material de este examen en español? (no se nada de ingles prácticamente jajaja)
Muchas grax d antemano....slds!
15  Foros Generales / Foro Libre / uso de la red tor en: 6 Noviembre 2015, 04:31 am
Slds gente del foro....veran tngo una duda....mejor dicho un problema...en mi trabajo estamos sufriendo últimamente malos tratos y suspensiones injustificadas...nuestra idea (de mis compañeros y yo) era la d crearnos una cuenta en Facebook y desde ahí denunciar lo q viene pasando a través d un medio publico un programa d tv que es muy popular ya q en el ministerio correspondiente nos vienen pateando la denuncia y para colmo d males nos entregan atados en nuestra empresa con nombre y apellido....queria saber si utilizando la red tor y desd ahí hacer lo d la cuenta d Facebook xa evitar q nos ubicaran o algo parecido.....seria esto posible? Desd ya muchas grax y espero q nos sepan entender....slds!
16  Programación / Programación C/C++ / manual de c en: 29 Octubre 2015, 00:42 am
buenas gente del foro....esta pregunta es en especial al mod/s de la sección....cual es el mejor manual q m recomendarian d C el mas completo....el q mejor consideren recomendarme....slds!
17  Programación / .NET (C#, VB.NET, ASP) / cadena o datos binarios podrían truncarse en: 26 Julio 2015, 06:20 am
buenas noches gente del foro....verán tengo el siguiente código el cual modifica el atributo estado d una tabla sql server a partir de los datos del datagridview...obtengo el error del asunto...investigue un poko y dicen q es x exceder el máximo de caracteres del atributo varchar.....bueno lo cambio a 100 exagerándolo demasiado y obtengo el mismo error...a q se debe? muchas grx d antemano
Código
  1. private void button2_Click(object sender, EventArgs e)
  2.        {
  3.  
  4.            try
  5.            {
  6.                conexion.Open();
  7.                foreach (DataGridViewRow row in dgv1.Rows)
  8.                {
  9.  
  10.                    SqlCommand alta1 = new SqlCommand("insert into Stock values(@ubicacion,@medicamento,@jerarquia,@lote,@vto,@cantidadIngreso,@cantidadFaltante)", conexion);
  11.                    alta1.Parameters.AddWithValue("@ubicacion", row.Cells[6].Value);
  12.                    alta1.Parameters.AddWithValue("@medicamento", row.Cells[0].Value);
  13.                    alta1.Parameters.AddWithValue("@jerarquia", row.Cells[1].Value);
  14.                    alta1.Parameters.AddWithValue("@lote", row.Cells[2].Value);
  15.                    alta1.Parameters.AddWithValue("@vto",
  16.         row.Cells[3].Value);
  17.                    alta1.Parameters.AddWithValue("@cantidadIngreso", row.Cells[4].Value);
  18.                    alta1.Parameters.AddWithValue("@cantidadFaltante", row.Cells[5].Value);
  19.                    alta1.ExecuteNonQuery();
  20.                }
  21.                foreach (DataGridViewRow row2 in dgv1.Rows)
  22.                {
  23.                    string ubicacion = row2.Cells["ubicacion"].Value.ToString();
  24.  
  25.                    string query = "update Ubicaciones set estado= 'ocupado' where ubicacion = @ubicacion";
  26.  
  27.                    SqlCommand cmd = new SqlCommand(query, conexion);
  28.                    cmd.Parameters.AddWithValue("@ubicacion", ubicacion);
  29.  
  30.                    cmd.ExecuteNonQuery();
  31.  
  32.  
  33.                }
  34.            }
  35.            catch(SqlException ex)
  36.            {
  37.                MessageBox.Show(ex.ToString());
  38.            }
  39.            finally
  40.            {
  41.                conexion.Close();
  42.            }
  43.        }
18  Programación / .NET (C#, VB.NET, ASP) / Re: evento cellvalidating datagridview en: 23 Julio 2015, 06:11 am
muchas grax gente....grax elektro lo puse en marcha y funciona d maravilla....x otro lado se que m vas a regañar x no abrir otro hilo pero... :silbar:....veras estoy haciendo mi tesis como he comentado y en mi carrera en todos los lenguajes que vi (java, c#, android, php) lo máximo por asi decirlo q m enseñaron fueron ABM a bases d datos....a mi m gusto mucho .NET por eso decidi programar el sistema en este lenguaje....pero hay muchísimas cosas q no se y tngo q preguntar en foros google etc....en lo académico q consejos m podrias dar para aprender desde lo básico hasta lo mas complejo (además d investigar x mi cuenta) y q se pueda certificar cada paso? o como hiciste tu para saber todo lo que sabes hoy en dia.....disculpa las molestias q t ocasionen mis preguntas pero es q siemp q entro al foro veo tus temas y digo guau sabre algún dia tanto como este chabón (asi lo decimos en argentina jaja) m apasiona esta carrera estoy orgulloso d haberla elegido a pesar d no poder ejercer todavía....bueno espero tus comentarios y no sigo mas para ponerme tan cursi jajajaja slds!
19  Programación / .NET (C#, VB.NET, ASP) / evento cellvalidating datagridview en: 21 Julio 2015, 06:34 am
saludos gente del foro....verán tengo este código de un caso d uso en el cual mi problema es que en el evento de ref.- tengo un problemilla....al validar que se ingrese datos d tipo fecha en una columna del datagrid (el cual lo hace sin problemas) no puedo salir d la celda ni cambiarme a otra ni realizar otra acción hasta completarla con el formato correcto....como podría solucionarlo...perdón x las molestias es algo complejo xa mi con lo básico q he aprendido....muchas grax d antemano
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. using System.Data.SqlClient;
  10. using System.Diagnostics;
  11.  
  12. namespace RegistrarOCspp2
  13. {
  14.    public partial class RegistrarStock : Form
  15.    {
  16.        public RegistrarStock()
  17.        {
  18.            InitializeComponent();
  19.            dgv1.AllowUserToAddRows = false;
  20.  
  21.  
  22.  
  23.        }
  24.        int cant = 0;
  25.        ClaseABM con = new ClaseABM();
  26.        private SqlConnection conexion;
  27.        private SqlCommand consulta;
  28.  
  29.        private void studioButton2_Click(object sender, EventArgs e)
  30.        {
  31.            this.Close();
  32.        }
  33.  
  34.        private void RegistrarStock_Load(object sender, EventArgs e)
  35.        {
  36.            // TODO: esta línea de código carga datos en la tabla 'proyectoSaludDataSet27.ubicacion' Puede moverla o quitarla según sea necesario.
  37.            this.ubicacionTableAdapter.Fill(this.proyectoSaludDataSet27.ubicacion);
  38.            // TODO: esta línea de código carga datos en la tabla 'proyectoSaludDataSet26.jerarquia' Puede moverla o quitarla según sea necesario.
  39.            this.jerarquiaTableAdapter.Fill(this.proyectoSaludDataSet26.jerarquia);
  40.            AutoValidate = AutoValidate.Disable;
  41.  
  42.  
  43.        }
  44.  
  45.  
  46.  
  47.  
  48.        private void CrearColumnaLote()
  49.        {
  50.            DataGridViewTextBoxColumn txtColumna =
  51.                new DataGridViewTextBoxColumn();
  52.            txtColumna.Name = "Lote";
  53.            txtColumna.HeaderText = "LOTE";
  54.            dgv1.Columns.Insert(3, txtColumna);
  55.            dgv1.Columns[3].Width = 150;
  56.            dgv1.Columns[3].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  57.            dgv1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  58.        }
  59.        private void CrearColumnaVto()
  60.        {
  61.            DataGridViewTextBoxColumn txtColumna =
  62.                new DataGridViewTextBoxColumn();
  63.            txtColumna.Name = "Vto";
  64.            txtColumna.HeaderText = "VENCIMIENTO";
  65.            dgv1.Columns.Insert(4, txtColumna);
  66.            dgv1.Columns[4].Width = 20;
  67.            dgv1.Columns[4].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  68.            dgv1.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  69.        }
  70.  
  71.        private void CrearColumnaStock()
  72.        {
  73.            DataGridViewTextBoxColumn txtColumna =
  74.                new DataGridViewTextBoxColumn();
  75.            txtColumna.Name = "Stock";
  76.            txtColumna.HeaderText = "CANTIDAD A INGRESAR";
  77.            dgv1.Columns.Insert(5, txtColumna);
  78.            dgv1.Columns[5].Width = 211;
  79.            dgv1.Columns[5].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  80.            dgv1.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  81.  
  82.        }
  83.        private void CrearColumnaFaltante()
  84.        {
  85.            DataGridViewTextBoxColumn txtColumna =
  86.                new DataGridViewTextBoxColumn();
  87.            txtColumna.Name = "Faltante";
  88.            txtColumna.HeaderText = "FALTANTE";
  89.            dgv1.Columns.Insert(6, txtColumna);
  90.            dgv1.Columns[6].Width = 211;
  91.            dgv1.Columns[6].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  92.            dgv1.Columns[6].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  93.  
  94.        }
  95.        private void CrearColumnaUbicacion()
  96.        {
  97.            DataGridViewTextBoxColumn comboColumna =
  98.                new DataGridViewTextBoxColumn();
  99.            comboColumna.Name = "Ubicacion";
  100.            comboColumna.HeaderText = "UBICACION";
  101.            dgv1.Columns.Insert(7, comboColumna);
  102.            dgv1.Columns[7].Width = 30;
  103.            dgv1.Columns[7].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  104.            dgv1.Columns[7].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  105.  
  106.        }
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.        private void txtNumero_KeyDown_1(object sender, KeyEventArgs e)
  114.        {
  115.            if (e.KeyCode == Keys.Enter)
  116.            {
  117.  
  118.                if (txtNumero.Text == "")
  119.                {
  120.  
  121.                    DialogResult ds = MessageBox.Show("DEBE INGRESAR UN NRO DE ORDEN", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  122.                    this.Text = ds.ToString();
  123.                }
  124.                else
  125.                    if (txtNumero.Text != "")
  126.                    {
  127.                        conexion = new SqlConnection("Data Source=GONZALOCABRERA\\SQLEXPRESS;Initial Catalog=ProyectoSalud;Integrated Security=True");
  128.                        conexion.Open();
  129.                        SqlCommand consulta = new SqlCommand("select count (*) from DetalleOrdenCompra where nro_orden=@nro", conexion);
  130.                        consulta.Parameters.AddWithValue("@nro", Convert.ToInt32(txtNumero.Text));
  131.  
  132.                        int count = Convert.ToInt32(consulta.ExecuteScalar());
  133.  
  134.  
  135.                        if (count > 0)
  136.                        {
  137.  
  138.                            DialogResult result = MessageBox.Show(this, "DESEA REGISTRAR LOS DATOS?", "ORDEN DE COMPRA ENCONTRADA", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
  139.  
  140.  
  141.                            //MessageBox.Show(consulta2.ToString());
  142.                            this.Text = result.ToString();
  143.  
  144.                            if (result == DialogResult.OK)
  145.                            {
  146.  
  147.                                //CARGAR LOS DATAGRIDVIEW
  148.                                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);
  149.                                consulta2.Parameters.AddWithValue("@nro", Convert.ToInt32(txtNumero.Text));
  150.                                SqlDataAdapter da = new SqlDataAdapter(consulta2);
  151.                                DataTable dt = new DataTable();
  152.                                da.Fill(dt);
  153.  
  154.                                dgv1.DataSource = dt;
  155.  
  156.                                dgv1.Columns[0].ReadOnly = true;
  157.                                dgv1.Columns[1].ReadOnly = true;
  158.                                dgv1.Columns[2].ReadOnly = true;
  159.                                int rows = dt.Rows.Count;
  160.                                dgv1.Columns[0].HeaderText = "MEDICAMENTO";
  161.                                dgv1.Columns[0].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  162.                                dgv1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  163.                                dgv1.Columns[0].Width = 211;
  164.                                dgv1.Columns[1].HeaderText = "JERARQUIA";
  165.                                dgv1.Columns[1].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  166.                                dgv1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  167.                                dgv1.Columns[1].Width = 180;
  168.                                dgv1.Columns[2].HeaderText = "CANTIDAD";
  169.                                dgv1.Columns[2].Name = "Cantidad";
  170.                                dgv1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
  171.                                dgv1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
  172.                                dgv1.Columns[2].Width = 80;
  173.                                CrearColumnaLote();
  174.                                CrearColumnaVto();
  175.                                CrearColumnaStock();
  176.                                CrearColumnaFaltante();
  177.                                CrearColumnaUbicacion();
  178.                                dgv1.Columns[6].ReadOnly = true;
  179.                                txtNumero.Enabled = false;
  180.                                dgv1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  181.                                dgv1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  182.                                dgv1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  183.                                dgv1.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  184.                                dgv1.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  185.                                dgv1.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
  186.                                dgv1.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable;
  187.                                dgv1.Columns[7].SortMode = DataGridViewColumnSortMode.NotSortable;
  188.                                btnVerificar.Enabled = true;
  189.  
  190.  
  191.  
  192.                               }
  193.                            else if (result == DialogResult.Cancel)
  194.                            {
  195.                                txtNumero.Text = "";
  196.                            }
  197.  
  198.                            this.Text = result.ToString();
  199.                        }
  200.                        else
  201.                        {
  202.                            DialogResult ds = MessageBox.Show(this, "LA ORDEN INGRESADA NO SE ENCUENTRA REGISTRADA", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  203.                            this.Text = ds.ToString();
  204.                        }
  205.  
  206.                        conexion.Close();
  207.  
  208.                    }
  209.  
  210.            }
  211.        }
  212.  
  213.        private void txtNumero_KeyPress(object sender, KeyPressEventArgs e)
  214.        {
  215.            if (char.IsDigit(e.KeyChar))
  216.                e.Handled = false;
  217.            else if (char.IsControl(e.KeyChar))
  218.                e.Handled = false;
  219.            else if (char.IsSeparator(e.KeyChar))
  220.                e.Handled = false;
  221.            else
  222.                e.Handled = true;
  223.        }
  224.  
  225.        private void validar_Keypress(object sender, System.Windows.Forms.KeyPressEventArgs e)
  226.        {
  227.  
  228.            int columna = dgv1.CurrentCell.ColumnIndex;
  229.  
  230.  
  231.            if (columna == 5)
  232.            {
  233.                TextBox txt = (TextBox)sender;
  234.  
  235.                if (char.IsDigit(e.KeyChar))
  236.                    e.Handled = false;
  237.                else if (char.IsControl(e.KeyChar))
  238.                    e.Handled = false;
  239.                else if (char.IsSeparator(e.KeyChar))
  240.                    e.Handled = false;
  241.                else
  242.                    e.Handled = true;
  243.            }
  244.        }
  245.  
  246.        private void dgv1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
  247.        {
  248.            TextBox validar = (TextBox)e.Control;
  249.            validar.KeyPress += validar_Keypress;
  250.        }
  251.  
  252.  
  253.        private void btnVer_Click(object sender, EventArgs e)
  254.        {
  255.                UbicacionesVacias u = new UbicacionesVacias();
  256.                u.Show();
  257.        }
  258.  
  259.        private void button4_Click(object sender, EventArgs e)
  260.        {
  261.            DialogResult result = MessageBox.Show(this, "SEGURO QUE DESEA SALIR?", "SALIR", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
  262.            this.Text = result.ToString();
  263.  
  264.            if (result == DialogResult.OK)
  265.            {
  266.                this.Close();
  267.            }
  268.            else if (result == DialogResult.Cancel)
  269.            {
  270.  
  271.  
  272.  
  273.            }
  274.        }
  275.        private Boolean EsFecha(String fecha)
  276.        {
  277.            try
  278.            {
  279.                DateTime.Parse(fecha);
  280.                return true;
  281.            }
  282.            catch
  283.            {
  284.                return false;
  285.            }
  286.        }
  287.  
  288.  
  289.        private void button2_Click(object sender, EventArgs e)
  290.        {
  291.  
  292.            try
  293.            {
  294.                conexion.Open();
  295.                foreach (DataGridViewRow row in dgv1.Rows)
  296.                {
  297.  
  298.                    SqlCommand alta1 = new SqlCommand("insert into Stock values(@codigo,@medicamento,@cantidad,@lote,@vto)", conexion);
  299.                    alta1.Parameters.AddWithValue("@codigo", row.Cells["Column1"].Value);
  300.                }
  301.            }
  302.            catch
  303.            {
  304.  
  305.            }
  306.            finally
  307.            {
  308.                conexion.Close();
  309.            }
  310.        }
  311.        private bool Existe()
  312.        {
  313.            foreach (IGrouping<object, DataGridViewRow> grupo in dgv1.Rows.Cast<DataGridViewRow>().GroupBy(dr => dr.Cells["Ubicacion"].Value).Where(g => g.Count() > 1))
  314.            {
  315.                foreach (DataGridViewRow fila in grupo)
  316.                {
  317.                    fila.DefaultCellStyle.ForeColor = Color.Red;
  318.                    return true;
  319.                }
  320.  
  321.  
  322.  
  323.            }
  324.            return false;
  325.        }
  326.  
  327.        private void dgv1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
  328.        {
  329.            dgv1.Rows[e.RowIndex].ErrorText = String.Empty;
  330.            DataGridViewRow row = (DataGridViewRow)dgv1.Rows[e.RowIndex];
  331.  
  332.            int cantidad = Convert.ToInt32(row.Cells["Cantidad"].Value);
  333.            int cantidad2 = Convert.ToInt32(row.Cells["Stock"].Value);
  334.            if (cantidad2 > cantidad)
  335.            {
  336.                MessageBox.Show("LA CANTIDAD A INGRESAR SUPERA LA CANTIDAD DE LA ORDEN DE COMPRA", "ATENCION", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
  337.                row.Cells["Stock"].Value = "";
  338.                row.Cells["Faltante"].Value = "";
  339.            }
  340.            else
  341.            {
  342.                row.Cells["Faltante"].Value = cantidad - cantidad2;
  343.            }
  344.            DataGridViewRow row2 = (DataGridViewRow)dgv1.Rows[e.RowIndex];
  345.            string ubicacion=Convert.ToString(row2.Cells["Ubicacion"].Value);
  346.            string jerarquia = Convert.ToString(row2.Cells[1].Value);
  347.            conexion.Open();
  348.            if (ubicacion != "")
  349.            {
  350.                SqlCommand consulta = new SqlCommand("select count (*) from Ubicaciones where codigo=@codigo and jerarquia=@jerarquia ", conexion);
  351.                consulta.Parameters.AddWithValue("@codigo", ubicacion);
  352.                consulta.Parameters.AddWithValue("@jerarquia", jerarquia);
  353.  
  354.                int count = Convert.ToInt32(consulta.ExecuteScalar());
  355.                if (count > 0)
  356.                {
  357.  
  358.                }
  359.                else
  360.                {
  361.                    MessageBox.Show("NO EXISTE LA UBICACION INGRESADA CONSULTE LAS UBICACIONES DISPONIBLES PARA ESA JERARQUIA CON EL BOTON 'UBICACIONES VACIAS' ", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
  362.                    row2.Cells["Ubicacion"].Value = "";
  363.                }
  364.  
  365.            }
  366.            conexion.Close();
  367.  
  368.  
  369.        }
  370.  
  371.        private void dgv1_CellValidating_1(object sender, DataGridViewCellValidatingEventArgs e)
  372.        {
  373.  
  374.            if (!dgv1.Rows[e.RowIndex].IsNewRow)
  375.            {
  376.  
  377.                if (e.ColumnIndex == 4)
  378.                {
  379.                    if (!this.EsFecha(e.FormattedValue.ToString()))
  380.                    {
  381.                         dgv1.Rows[e.RowIndex].ErrorText = "EL DATO INTRODUCIDO NO ES UNA FECHA";
  382.                        e.Cancel = true;
  383.                    }
  384.                }
  385.            }
  386.        }
  387.  
  388.        private void RegistrarStock_FormClosing(object sender, FormClosingEventArgs e)
  389.        {
  390.            e.Cancel=false;
  391.        }
  392.  
  393.  
  394.        private void button1_Click_1(object sender, EventArgs e)
  395.        {
  396.            int cant = 0;
  397.            if (Existe())
  398.                MessageBox.Show("INGRESO LA UBICACION MAS DE UNA VEZ", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  399.            else
  400.            {
  401.                MessageBox.Show("NO SE ENCONTRARON UBICACIONES REPETIDAS", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  402.                dgv1.DefaultCellStyle.ForeColor = Color.Black;
  403.            }
  404.            bool incompleto = (from row in dgv1.Rows.Cast<DataGridViewRow>()
  405.                               from cell in row.Cells.Cast<DataGridViewCell>()
  406.                               where string.IsNullOrEmpty(cell.Value.ToString())
  407.                               select row).Any();
  408.            if (incompleto)
  409.            {
  410.                MessageBox.Show("FALTAN COMPLETAR DATOS", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  411.            }
  412.            else
  413.            {
  414.                MessageBox.Show("DATOS COMPLETOS", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  415.                cant++;
  416.            }
  417.            if (cant != 0)
  418.                btnGuardar.Enabled = true;
  419.  
  420.  
  421.        }
  422.  
  423.  
  424.  
  425.  
  426.  
  427.    }
  428. }
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
20  Programación / .NET (C#, VB.NET, ASP) / validar dato duplicado en columna de datagridview en: 16 Julio 2015, 06:23 am
buenas noches gente del foro.....verán tengo esta línea de código en el que no m dejaba ingresar a un datagrid un nombre que ya estuviera...ahora debo implementarlo en otro caso de uso....en el cual al presionar un botón m tiene q validar y decir q se esta repitiendo  el dato en una columna(solo en esa columna) esperon m puedan ayudar....grax d antemano
Código
  1. bool existe = dgv.Rows.Cast<DataGridViewRow>().Any(x => Convert.ToInt32(x.Cells["Column1"].Value) == numMedic);
Páginas: 1 [2] 3 4 5 6
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines