private void btn_modificar_Click(object sender, EventArgs e)
        {
            if (direccionValida && nombreValido && descripcionValida)
            {
                GestionadorUnidad.ResultadoGestionUnidad resultado = gestionador.ModificarUnidad(unidad);
                //Recibe el resultado de la transaccion y muestra un mensaje al usuario
                switch (resultado)
                {
                case GestionadorUnidad.ResultadoGestionUnidad.DescripcionVacia:
                    MessageBox.Show("No se pudo modificar la unidad: La descripcion esta vacia.");
                    break;

                case GestionadorUnidad.ResultadoGestionUnidad.DireccionVacia:
                    MessageBox.Show("No se pudo modificar la unidad: La direccion esta vacia.");
                    break;

                case GestionadorUnidad.ResultadoGestionUnidad.NombreVacio:
                    MessageBox.Show("No se pudo modificar la unidad: El nombre esta vacio.");
                    break;

                case GestionadorUnidad.ResultadoGestionUnidad.Invalido:
                    MessageBox.Show("Ocurrio un error no controlado al modificar.");
                    break;

                case GestionadorUnidad.ResultadoGestionUnidad.Valido:
                    padreTemp.loadUnidades();
                    MessageBox.Show("La unidad se modifico correctamente.");
                    break;
                }
            }
            else
            {
                MessageBox.Show("No se pudo modificar la unidad: Existen datos inválidos.");
            }
        }
Exemple #2
0
        private void btn_modificar_Click(object sender, EventArgs e)
        {
            string nombre      = this.txt_nombre.Text;
            string descripcion = this.txt_descripcion.Text;
            string direccion   = this.txt_direccion.Text;
            bool   habilitado  = this.chk_habilitado.Checked;
            int    salida_temp = -1;
            int?   padre;

            if (this.ddl_padre.SelectedValue == null)
            {
                padre = null;
            }
            else
            {
                padre = int.Parse(this.ddl_padre.SelectedValue.ToString());
            }
            salida_temp = -1;
            int?jefe;

            if (this.ddl_jefe.SelectedValue == null)
            {
                jefe = null;
            }
            else
            {
                jefe = int.Parse(this.ddl_jefe.SelectedValue.ToString());
            }
            using (ServiceWSUnidades.WSUnidadesClient serviceUnidades = new ServiceWSUnidades.WSUnidadesClient())
            {
                int salida = serviceUnidades.modifyUnidad(this.id_unidad, nombre, descripcion,
                                                          direccion, habilitado, padre, jefe);
                if (salida == 0)
                {
                    padreTemp.loadUnidades();
                    MessageBox.Show("Datos modificados con exito!");
                }
                else
                {
                    MessageBox.Show("ERROR NRO: " + salida);
                }
            }
        }
        private void btn_agregar_Click(object sender, EventArgs e)
        {
            string nombre      = this.txt_nombre.Text;
            string descripcion = this.txt_descripcion.Text;
            string direccion   = this.txt_direccion.Text;
            int?   padre;

            if (this.ddl_padre.SelectedValue == null)
            {
                padre = null;
            }
            else
            {
                padre = int.Parse(this.ddl_padre.SelectedValue.ToString());
            }
            int?jefe;

            if (this.ddl_jefe.SelectedValue == null)
            {
                jefe = null;
            }
            else
            {
                jefe = int.Parse(this.ddl_jefe.SelectedValue.ToString());
            }
            using (ServiceWSUnidades.WSUnidadesClient serviceUnidades = new ServiceWSUnidades.WSUnidadesClient())
            {
                int salida = serviceUnidades.addUnidad(nombre, descripcion, direccion, padre, jefe);
                if (salida == 0)
                {
                    padreTemp.loadUnidades();
                    MessageBox.Show("Datos agregados con exito!");
                }
                else
                {
                    MessageBox.Show("ERROR NRO: " + salida);
                }
            }
        }