private void LlenarComboBox()
        {
            var listado = new List <Ubicaciones>();

            listado = UbicacionesClase.getList(p => true);
            UbicacioncomboBox.DataSource    = listado;
            UbicacioncomboBox.DisplayMember = "Descripcion";
            UbicacioncomboBox.ValueMember   = "UbicacionId";
        }
Example #2
0
        private bool Validar()
        {
            bool paso = true;

            if (DescripciontextBox.Text == string.Empty)
            {
                MessageBox.Show("La descripcion no puede estar vacia");
                DescripciontextBox.Focus();
                paso = false;
            }
            if (UbicacionesClase.PalabrasNoIguales(DescripciontextBox.Text))
            {
                MessageBox.Show("Los nombre no pueden ser iguales");
                DescripciontextBox.Focus();
                paso = false;
            }

            return(paso);
        }
Example #3
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            Ubicaciones ubicaciones;
            bool        paso = false;

            if (!Validar())
            {
                return;
            }
            ubicaciones = LlenarClase();
            if (IDnumericUpDown.Value == 0)
            {
                paso = UbicacionesClase.Guardar(ubicaciones);
                MessageBox.Show("Guardado correctamente");
            }
            else
            {
                int id = Convert.ToInt32(IDnumericUpDown.Value);
                ubicaciones = UbicacionesClase.Buscar(id);

                if (ubicaciones != null)
                {
                    paso = UbicacionesClase.Modificar(LlenarClase());
                    MessageBox.Show("Modificado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Id no existe", "Falló", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (paso)
                {
                    Limpiar();
                }
                else
                {
                    MessageBox.Show("No se pudo guardar!!", "Falló", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #4
0
        private void Eliminarbutton_Click(object sender, EventArgs e)
        {
            int id;

            id = (int)IDnumericUpDown.Value;
            try
            {
                if (UbicacionesClase.Eliminar(id))
                {
                    MessageBox.Show("Eliminado correctamente");
                    Limpiar();
                }
                else
                {
                    MessageBox.Show("No se pudo eliminar");
                    Limpiar();
                }
            }catch (Exception)
            {
                MessageBox.Show("Hubo un error");
            }
        }
Example #5
0
        private void Buscarbutton_Click(object sender, EventArgs e)
        {
            int id;

            id = (int)IDnumericUpDown.Value;
            try
            {
                Ubicaciones ubicaciones = UbicacionesClase.Buscar(id);
                if (ubicaciones != null)
                {
                    MessageBox.Show("Producto encontrado");
                    LlenarCampo(ubicaciones);
                }
                else
                {
                    MessageBox.Show("Producto no encontrado");
                    Limpiar();
                }
            }catch (Exception)
            {
                MessageBox.Show("Hubo un error");
            }
        }
Example #6
0
        private bool ExisteEnLaBaseDeDatos()
        {
            Ubicaciones ubicaciones = UbicacionesClase.Buscar((int)IDnumericUpDown.Value);

            return(ubicaciones != null);
        }