コード例 #1
0
        //public void LLenarComboEstado2()
        //{
        //    GestorEstado ge = new GestorEstado();
        //    cmbEstadoLab.DataSource = ge.Consultar().Tables[0];
        //    cmbEstadoLab.DisplayMember = "Nombre";
        //    cmbEstadoLab.ValueMember = "id_estado";
        //    cmbEstadoLab.SelectedIndex = 0;
        //}
        private void button5_Click(object sender, EventArgs e)
        {
            var gd = new GestorDeportista();
            string guardado;
            var documento = int.Parse(lblDocumento.Text);
            var id_estado = int.Parse(cmbEstado.SelectedValue.ToString());
            if (id_estado == 4 && fechaLista == false)
            {
                MessageBox.Show("Seleccione fecha de Estudios");
                gbFechas.Enabled = true;
                btnGuardar.Enabled = false;
            }
            else
            {
                gbFechas.Enabled = false;
                guardado = gd.Modificar(documento, id_estado);

                try
                {
                    //usa tabla nueva DeportistaXAptoMedicoXAnio

                    if (id_estado == 6 || id_estado == 7 || id_estado == 11) //6 apto, 7 no apto, 11, apto_solo_recreativos
                    {
                        int anio = DateTime.Now.Year;
                        gd.mantenerEstadoAptoMedico(documento, id_estado, anio);
                    }
                }
                catch (Exception ex) { }

                if (guardado == "Guardado")
                {
                    MessageBox.Show("Guardado Correctamente ");
                    txtEstado.Text = cmbEstado.Text;

                    return;
                }

                if (guardado == "Error")
                {
                    MessageBox.Show("No Guardado, error de escritura");
                }
            }
        }
コード例 #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            var id_deporte = int.Parse(cmbDeportes.SelectedValue.ToString());
            if (!_gestorMensaje.getCupo(id_deporte))
            {
                MessageBox.Show("No hay cupo para el deporte");
                return;
            }

            if (txtDocumento.Text == "")
            {
                MessageBox.Show("Ingrese un Número de Documento", "Advertencia", MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                txtDocumento.Focus();
                return;
            }

            if (txtNombres.Text == "")
            {
                MessageBox.Show("Ingrese un Nombre", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtNombres.Focus();
                return;
            }
            if (txtApellido.Text == "")
            {
                MessageBox.Show("Ingrese un Apellido", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtApellido.Focus();
                return;
            }
            if (txtEmail.Text == "")
            {
                MessageBox.Show("Ingrese un Email", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtEmail.Focus();
                return;
            }

            if (!email_bien_escrito(txtEmail.Text))
            {
                //txtEmail.Select(0, txtEmail.TextLength);
                MessageBox.Show("El formato del email no es correcto, ingreselo nuevamente", "Advertencia",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtEmail.Focus();
                return;
            }
            if (txtEmail.BackColor.Name == "Yellow")
            {
                MessageBox.Show("El email ya existe, debe ingresar otro", "Advertencia", MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                txtEmail.Focus();
                return;
            }
            if ((txtTelFijo.Text != "" && txtCaractFijo.Text == "") ||
                (txtTelFijo.Text == "" && txtCaractFijo.Text != ""))
            {
                MessageBox.Show("Ingrese Número Telefónico completo con característica", "Advertencia",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtCaractFijo.Focus();
                return;
            }
            if ((txtCelular.Text != "" && txtCaractCel.Text == "") || (txtCelular.Text == "" && txtCaractCel.Text != ""))
            {
                MessageBox.Show("Ingrese Número Telefónico completo con característica", "Advertencia",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtCaractCel.Focus();
                return;
            }
            if (cmbDeportes.SelectedItem == null)
            {
                MessageBox.Show("Seleccione un deporte", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cmbDeportes.Focus();
                return;
            }
            gde = new GestorDeportista();

            //radio Sexo
            if (rbMasculino.Checked)
                sexo = 'M';
            else
                sexo = 'F';

            //radio Becado
            if (rbNoBecado.Checked)
                becado = false;
            else
                becado = true;

            //radio Condición
            /*if (rbEstudiante.Checked == true)
                    condicion = "Estudiante";*/

            var documento = int.Parse(txtDocumento.Text);
            int tel_fijo;
            if (txtTelFijo.Text != "")
                tel_fijo = int.Parse(txtTelFijo.Text);
            else
                tel_fijo = 0;
            int tel_cel;
            if (txtCelular.Text != "")
                tel_cel = int.Parse(txtCelular.Text);
            else
                tel_cel = 0;
            int caract_fijo;
            if (txtCaractFijo.Text != "" && tel_fijo != 0)
                caract_fijo = int.Parse(txtCaractFijo.Text);
            else
                caract_fijo = 0;
            int caract_cel;
            if (txtCaractCel.Text != "" && tel_cel != 0)
                caract_cel = int.Parse(txtCaractCel.Text);
            else
                caract_cel = 0;

            var fecha_Nac = dtpFecha.Value;

            if (pbFotoDeportista.Image != null)
            {
                //p.foto = ImgToByte(pbFotoDeportista.Image);
                foto = ImgToByte(pbFotoDeportista.Image);
            }
            //byte[] foto = ImgToByte(pbFoto.Image);

            if (banderaGuardar == 1)
            {
                guardado = gde.Registrar(documento, fecha_Nac, txtApellido.Text, txtNombres.Text, sexo,
                    txtDireccion.Text, (Localidad) cmbLocalidades.SelectedItem, (Barrio) cmbBarrio.SelectedItem,
                    caract_fijo, tel_fijo, caract_cel, tel_cel, txtEmail.Text, (Condicion) cmbCondicion.SelectedItem,
                    becado, (UnidadAcademica) cmbUnidadAcademica.SelectedItem, (Escuela) cmbEscuela.SelectedItem,
                    (TipoDeportista) cmbTipoDeportista.SelectedItem, (Deporte) cmbDeportes.SelectedItem, foto);
                banderaGuardar = 0;
            }
            else
            {
                guardado = gde.Modificar(documento, fecha_Nac, txtApellido.Text, txtNombres.Text, sexo,
                    txtDireccion.Text, (Localidad) cmbLocalidades.SelectedItem, (Barrio) cmbBarrio.SelectedItem,
                    caract_fijo, tel_fijo, caract_cel, tel_cel, txtEmail.Text, (Condicion) cmbCondicion.SelectedItem,
                    becado, (UnidadAcademica) cmbUnidadAcademica.SelectedItem, (Escuela) cmbEscuela.SelectedItem,
                    (TipoDeportista) cmbTipoDeportista.SelectedItem, (Deporte) cmbDeportes.SelectedItem, foto);
                banderaModificar = 0;
            }

            if (guardado == "Guardado")
            {
                MessageBox.Show("Se Registró correctamente al Deportista", "Registro Deportista", MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                limpiar();
                setear();
                ponerNoEnabled();
                btnNuevo.Focus();
                lblDocumento.Enabled = false;
                txtDocumento.Enabled = false;
                btnBuscar.Enabled = false;
                btnGuardar.Enabled = false;
                //poner también no enabled al documento y botón de búsqueda
                /*btnGuardar.Enabled = false;
                        txtDocumento.Enabled = false;
                        lblDocumento.Enabled = false;
                        btnBuscar.Enabled = false;*/
                //btnNuevo.Focus();
                return;
            }
            if (guardado == "Modificado")
            {
                MessageBox.Show("Se Modificó correctamente al Deportista", "Registro Deportista", MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                limpiar();
                setear();
                ponerNoEnabled();
                btnNuevo.Focus();
                lblDocumento.Enabled = false;
                txtDocumento.Enabled = false;
                btnBuscar.Enabled = false;
                btnGuardar.Enabled = false;
                return;
            }

            if (guardado == "Existe")
            {
                MessageBox.Show("No Guardado, ya existe Deportista", "Registro Deportista", MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                limpiar();
                setear();
                ponerNoEnabled();
                btnNuevo.Focus();
                lblDocumento.Enabled = false;
                txtDocumento.Enabled = false;
                btnBuscar.Enabled = false;
                btnGuardar.Enabled = false;

                return;
            }

            if (guardado == "Error al Guardar")
            {
                MessageBox.Show("No Guardado, Error de Escritura", "Registro Deportista", MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                limpiar();
                setear();
                ponerNoEnabled();
                btnNuevo.Focus();
                lblDocumento.Enabled = false;
                txtDocumento.Enabled = false;
                btnBuscar.Enabled = false;
                btnGuardar.Enabled = false;
            }
        }