Esempio n. 1
0
        protected void btnEnviar_Click2(object sender, EventArgs e)
        {
            //lblSolicitud.Text = "Procesando...";
            global.sesion = false;
            string guardado;
            char sexo;
            bool becado;
            var gd = new GestorDeportista();
            var documento = int.Parse(txtDocumento.Text);
            var apellido = txtApellido.Text;
            var nombres = txtNombres.Text;
            var email = txtEmail.Text;
            var id_localidad = int.Parse(cmbLocalidades.SelectedValue);

            var id_barrio = int.Parse(cmbBarrios.SelectedValue);
            var id_condicion = int.Parse(cmbCondiciones.SelectedValue);
            var id_deporte = int.Parse(cmbDeportes.SelectedValue);
            var id_escuela = 0;
            var id_unidad = 0;

            if (particular == false)
            {
            id_unidad = int.Parse(cmbUnidad.SelectedValue);
            if (cmbEscuela.SelectedValue != "")
            {
                id_escuela = int.Parse(cmbEscuela.SelectedValue);
            }
            }

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

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

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

            if (txtCaractFijo.Text == "")
            txtCaractFijo.Text = "0";
            if (txtCaractCel.Text == "")
            txtCaractCel.Text = "0";
            if (txtCel.Text == "")
            txtCel.Text = "0";
            if (txtFijo.Text == "")
            txtFijo.Text = "0";

            /*if (bt == null)
            {
            pbFoto.ImageUrl = "~/Imagenes" + FileUpload1.PostedFile.FileName;
            Stream fs =FileUpload1.PostedFile.InputStream;
            BinaryReader br = new BinaryReader(fs);
            byte[] image = br.ReadBytes((Int32)fs.Length);
            }*/

            try
            {
            if (bt == null)
            {
                imagenABytes(Server.MapPath("~/Imagenes/perfil.png"));
            }
            }
            catch (Exception ex)
            {
            bt.SetValue(null, 0);
            }

            try
            {
            caract_fijo = int.Parse(txtCaractFijo.Text);
            tel_fijo = int.Parse(txtFijo.Text);

            caract_cel = int.Parse(txtCaractCel.Text);
            tel_cel = int.Parse(txtCel.Text);
            }
            catch (Exception ex)
            {

            }

            //para hosting somee, porque cambia el idioma ingles sino pongo este europe de deutch aleman
            //formato dd/mm/yyyy

            IFormatProvider culture = new CultureInfo("de-DE", true);

            var fecha_Nac = DateTime.Parse(txtFecNac.Text, culture);

            var direccion = txtDireccion.Text;

            //int id_localidad = int.Parse(cmbLocalidades.SelectedValue.ToString());
            guardado = gd.Registrar(documento, fecha_Nac, apellido, nombres, sexo, caract_fijo, tel_fijo, caract_cel,
            tel_cel, email, becado, direccion, id_localidad, id_barrio, id_condicion, id_deporte, id_unidad, id_escuela,
            bt);

            if (guardado == "Guardado")
            {
            lblSolicitud.Visible = true;
            lblSolicitud.Text = "Guardado Correctamente Documento: " + txtDocumento.Text;
            Global.documento = int.Parse(txtDocumento.Text);
            borrarTodo();

            return;
            }

            if (guardado == "Existe")
            {
            lblSolicitud.Visible = true;
            lblSolicitud.Text = "No Guardado, ya existe Documento o Email registrado";
            btnEnviar.Focus();
            return;
            }

            if (guardado == "Error al Guardar")
            {
            lblSolicitud.Visible = true;
            lblSolicitud.Text = "No Guardado, error de escritura";
            btnEnviar.Focus();
            //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "asd", "alert('asd');", true);
            return;
            }

            //lblSolicitud.Text = "Su solicitud ha sido enviada";

            borrarTodo();
        }
Esempio n. 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;
            }
        }