Ejemplo n.º 1
0
 private void CargaGrid() // Funcion encargada de cargar el Grid
 {
     DetalleDataGridView.DataSource = null;
     DetalleDataGridView.DataSource = this.Detalle;
     FormatoDataGridView();
     CalcularTotal();
     DetalleDataGridView.ClearSelection();
 }
Ejemplo n.º 2
0
        private bool SiProductoExiste() //Valida si existe un producto en la factura
        {
            bool Existe   = false;
            int  Posicion = 0;

            foreach (DataGridViewRow Producto in DetalleDataGridView.Rows) //BUsca por el id del producto si este se encuentra en el detalle
            {
                if (ProductoIdNumericUpDown.Value == Convert.ToInt32(Producto.Cells["ProductoId"].Value))
                {
                    Existe   = true;
                    Posicion = Convert.ToInt32(Producto.Index);
                    break;
                }
            }

            if (Existe) //SI estan en el detalle entonces
            {
                var result = MessageBox.Show("Este producto ya se encuentra en la factura, ¿Desea modificarlo?", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (result == DialogResult.Yes)
                {
                    ProductoIdNumericUpDown.Value = Convert.ToInt32(DetalleDataGridView.Rows[Posicion].Cells["ProductoId"].Value);
                    DescripcionTextBox.Text       = DetalleDataGridView.Rows[Posicion].Cells["DescripcionProducto"].Value.ToString();
                    CantidadNumericUpDown.Value   = Convert.ToInt32(DetalleDataGridView.Rows[Posicion].Cells["Cantidad"].Value);
                    PrecioNumericUpDown.Value     = Convert.ToDecimal(DetalleDataGridView.Rows[Posicion].Cells["Precio"].Value);
                    ImporteTextBox.Text           = DetalleDataGridView.Rows[Posicion].Cells["Importe"].Value.ToString();
                    DetalleDataGridView.ClearSelection();

                    List <DetalleFacturas> items = new List <DetalleFacturas>(); //Crea una lista con todos los productos, exepto el que va a modificar
                    foreach (DataGridViewRow dr in DetalleDataGridView.Rows)     //Llena la lista
                    {
                        DetalleFacturas Producto = new DetalleFacturas();
                        Producto.ProductoId = (int)dr.Cells["ProductoId"].Value;
                        if (Producto.ProductoId != (int)ProductoIdNumericUpDown.Value)//Impide que el producto a modificar entre en la lista
                        {
                            Producto.DetalleFacturaId    = (int)dr.Cells["DetalleFacturaId"].Value;
                            Producto.FacturaId           = (int)dr.Cells["FacturaId"].Value;
                            Producto.Cantidad            = (int)dr.Cells["Cantidad"].Value;
                            Producto.DescripcionProducto = dr.Cells["DescripcionProducto"].Value.ToString();
                            Producto.Precio  = Convert.ToInt32(dr.Cells["Precio"].Value);
                            Producto.Importe = Convert.ToInt32(dr.Cells["Importe"].Value);

                            items.Add(Producto);
                        }
                    }

                    this.Detalle = items;//Iguala el detalle a la lista si el producto se va a modificar
                    CargaGrid();
                }
                else
                {
                    LimpiarProductoGroupBox();
                }
            }

            return(Existe);
        }
Ejemplo n.º 3
0
        public bool Actualizar_Fila(DetalleDataGridView DATAGRIDVIEW)
        {
            bool __CAMBIO_FILA = false;

            __CAMBIO_FILA |= DATAGRIDVIEW.Actualizar_Celda(Indice_Nombre, Indice_Fila, Nombre);
            __CAMBIO_FILA |= DATAGRIDVIEW.Actualizar_Celda(Indice_Direccion, Indice_Fila, Direccion);
            __CAMBIO_FILA |= DATAGRIDVIEW.Actualizar_Celda(Indice_Puerto, Indice_Fila, Puerto);
            __CAMBIO_FILA |= DATAGRIDVIEW.Actualizar_Celda(Indice_Estado, Indice_Fila, "");
            return(__CAMBIO_FILA);
        }
Ejemplo n.º 4
0
 public bool Permitir_Modificar(DetalleDataGridView DATAGRIDVIEW)
 {
     //foreach(Modulo_Dispositivo X in DATAGRIDVIEW.Detalle)
     //{
     //    if(X.Direccion == Direccion && X.Indice_Fila != Indice_Fila)
     //    {
     //        return false;
     //    }
     //}
     return(true);
 }
Ejemplo n.º 5
0
        public bool Permitir_Eliminar(DetalleDataGridView DATAGRIDVIEW)
        {
            //foreach (Boton_Relay X in )
            //{
            //    if (X.Direccion == Direccion && X.Indice_Fila == Indice_Fila)
            //    {
            //        return
            //    }
            //}

            return(true);
        }
Ejemplo n.º 6
0
 public bool Permitir_Agregar(DetalleDataGridView DATAGRIDVIEW)
 {
     foreach (Modulo_Dispositivo X in DATAGRIDVIEW.Detalle)
     {
         if (X.Direccion == Direccion || X.Nombre == Nombre)
         {
             Mensajes.Mensaje_Detalle_No_Permitido_Agregar_Ya_Existe(DATAGRIDVIEW, DATAGRIDVIEW.Titulo, Obtener_Elemento());
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 7
0
        private void RemoverButton_Click(object sender, EventArgs e)
        {
            MyErrorProvider.Clear();

            if ((DetalleDataGridView.Rows.Count >= 0) && (DetalleDataGridView.CurrentRow != null))
            {
                Detalle.RemoveAt(DetalleDataGridView.CurrentRow.Index);
                CargarGrid();
            }
            else
            {
                MyErrorProvider.SetError(DetalleDataGridView, "Debes agregar Datos.");
                DetalleDataGridView.Focus();
            }
        }
Ejemplo n.º 8
0
        private bool Validar()
        {
            MyErrorProvider.Clear();
            bool paso = true;

            if (string.IsNullOrWhiteSpace(EstudianteTextBox.Text))
            {
                MyErrorProvider.SetError(EstudianteTextBox, "El campo estudiante no puede estar vacio");
                EstudianteTextBox.Focus();
                paso = false;
            }

            if (this.Detalle.Count == 0)
            {
                MyErrorProvider.SetError(DetalleDataGridView, "Debe de agregar una categoria al detalle");
                DetalleDataGridView.Focus();
                paso = false;
            }

            return(paso);
        }
Ejemplo n.º 9
0
 public static void Cargar_DatagridviewColumns(DetalleDataGridView DATAGRIDVIEW, EventHandler <DetalleDataGridViewEventArgs> METODO_AGREGAR, EventHandler <DetalleDataGridViewEventArgs> METODO_MODIFICAR)
 {
     DATAGRIDVIEW.ReadOnly              = true;
     DATAGRIDVIEW.MultiSelect           = false;
     DATAGRIDVIEW.AllowUserToAddRows    = false;
     DATAGRIDVIEW.RowHeadersVisible     = false;
     DATAGRIDVIEW.SelectionMode         = DataGridViewSelectionMode.FullRowSelect;
     DATAGRIDVIEW.AllowUserToResizeRows = false;
     DATAGRIDVIEW.Modulos = Mensajes.Modulos;
     DATAGRIDVIEW.Estilo  = Configuracion.DataGridView_Default;
     DATAGRIDVIEW.Cargar_Columnas(new DataGridViewColumn[]
     {
         FUNCIONES.Generar_DataGridViewTextBoxColumn("Nombre", new Propiedades_Columnas()
         {
             Ancho = 250
         }, Configuracion.Columna_No_Editable),
         FUNCIONES.Generar_DataGridViewTextBoxColumn("Dirección", new Propiedades_Columnas()
         {
             Ancho = 120
         }, Configuracion.Columna_No_Editable),
         FUNCIONES.Generar_DataGridViewTextBoxColumn("Puerto", new Propiedades_Columnas()
         {
             Ancho = 80
         }, Configuracion.Columna_No_Editable),
         FUNCIONES.Generar_DataGridViewTextBoxColumn("Estado", new Propiedades_Columnas()
         {
             Ancho = 130
         }, Configuracion.Columna_No_Editable)
     });
     DATAGRIDVIEW.Plantilla = new Modulo_Dispositivo("", "192.168.0.0");
     DATAGRIDVIEW.Titulo    = "Lista de Dispositivos";
     DATAGRIDVIEW.Todos     = "Todos los Dispositivos";
     DATAGRIDVIEW.Doble_Click_Celda_ReadOnly += METODO_MODIFICAR;
     DATAGRIDVIEW.Pre_Agregar_Detalle        += METODO_AGREGAR;
     DATAGRIDVIEW.Pre_Modificar_Detalle      += METODO_MODIFICAR;
 }
Ejemplo n.º 10
0
 public void Actualizar_Objeto(DetalleDataGridView DATAGRIDVIEW, int INDICE_COLUMNA)
 {
 }
Ejemplo n.º 11
0
 public int Insertar_Fila(DetalleDataGridView DATAGRIDVIEW)
 {
     return(DATAGRIDVIEW.Rows.Add(Nombre, Direccion, Puerto, ""));
 }