Example #1
0
        private void DGVTramos_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0)
            {
                int       idRecorridoSeleccionado = Int32.Parse(this.DGVRecorridos[0, e.RowIndex].Value.ToString());
                Recorrido recorridoSeleccionado   = recorridos.Where(r => r.Id == idRecorridoSeleccionado).First();
                recorridoSeleccionado.getAll();

                if (e.ColumnIndex == 1)//--Ver detalle
                {
                    new DetalleDeRecorrido(this, recorridoSeleccionado).ShowDialog();
                }
                else if (e.ColumnIndex == 2)//--Inhabilitar/Quitar
                {
                    int rows = inhabilitarRecorrido(recorridoSeleccionado);
                    if (rows == 1)
                    {
                        ventanaInformarExito("El recorrido ha sido inhabilitado");
                        DGVRecorridos.Rows.RemoveAt(e.RowIndex);
                    }
                    else
                    {
                        ventanaInformarError("Ha ocurrido un error");
                    }
                }
            }
        }
        private void DGVRecorridos_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0)
            {
                int       idRecorridoSeleccionado = Int32.Parse(this.DGVRecorridos[0, e.RowIndex].Value.ToString());
                Recorrido recorridoSeleccionado   = recorridos.Where(r => r.Id == idRecorridoSeleccionado).First();
                recorridoSeleccionado.getAll();

                if (e.ColumnIndex == 1)//--Modificar
                {
                    new ModificarTramos(this, recorridoSeleccionado).ShowDialog();
                }
            }
        }