Exemplo n.º 1
0
 //BOTON AGREGA LA TARJETA SIEMPRE Y CUANDO SEA VÁLIDA Y SE REPITA
 private void button1_Click(object sender, EventArgs e)
 {
     if (AyudaExtra.esStringNumerico(textBox1.Text) && AyudaExtra.esStringNumerico(textBox2.Text))
     {
         if (textBox1.Text.Contains(textBox2.Text))
         {
             //ES NÚMERO VÁLIDO
             String queryUpdate = "UPDATE SQLEADOS.Cliente SET cliente_datos_tarjeta = " + textBox1.Text + " WHERE cliente_usuario = " + userID;
             DBConsulta.AbrirCerrarModificarDB(queryUpdate);
             MessageBox.Show("El número de tarjeta fue ingresada y actualizada con éxito");
             DBConsulta.conexionAbrir();
             c.cargarDatosDeCompra();
             DBConsulta.conexionCerrar();
             this.Close();
         }
         else
         {
             MessageBox.Show("El número de tarjeta no se repite, vuelva a ingresarla", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Uno de los 2 campos ingresados, o ambos, no son numéricos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            //AGREGAR NUEVA UBICACIÓN
            String fila    = dataGridViewUbicacionesEnLugar.SelectedCells[0].Value.ToString();
            String asiento = dataGridViewUbicacionesEnLugar.SelectedCells[1].Value.ToString();

            //VERIFICAR SI YA FUE INGRESADO
            if (yafueingresado(fila, asiento))
            {
                MessageBox.Show("Esta ubicación ya fue ingresada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                //PROCEDE A INGRESAR NUEVO ASIENTO Y A PONER SU PRECIO Y TAMBIÉN SU TIPO DE UBICACION
                if (comboBox1.SelectedItem == null)
                {
                    MessageBox.Show("No has seleccionado ningún tipo de ubicación aún", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (textBoxPrecio.Text == "")
                {
                    MessageBox.Show("No has ingresado el precio", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!AyudaExtra.esStringNumerico(textBoxPrecio.Text))
                {
                    MessageBox.Show("El precio ingresado no es un número.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                agregarUbicacionConPrecioYTipo(fila, asiento, textBoxPrecio.Text, comboBox1.SelectedItem.ToString());
            }
        }
Exemplo n.º 3
0
        /* BOTON BUSCAR*/
        private void button1_Click(object sender, EventArgs e)
        {
            String error = "";

            if (esVacio(textBoxDNI.Text.Trim()) && esVacio(textBoxEmail.Text.Trim()) && esVacio(textBoxApellido.Text.Trim()) && esVacio(textBoxNombre.Text.Trim()))
            {
                MessageBox.Show("Usted no ha puesto ningún criterio de busquedad. Rellene los campos por favor", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                if (!textBoxNombre.Text.Trim().Equals("") && !AyudaExtra.esStringLetra(textBoxNombre.Text.Trim()) || !textBoxApellido.Text.Trim().Equals("") && !AyudaExtra.esStringLetra(textBoxApellido.Text.Trim()))
                {
                    error += "Los campos Nombre y Apellido no pueden contener numeros\n";
                    //              MessageBox.Show("Los campos Nombre y Apellido no pueden contener numeros", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //              return;
                }
                if (!textBoxDNI.Text.Trim().Equals("") && !AyudaExtra.esStringNumerico(textBoxDNI.Text.Trim()))
                {
                    error += "El campo numero de documento no puede contener letras\n";
                    //          MessageBox.Show("El campo numero de documento no puede contener letras", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //            return;
                }
                if (error != "")
                {
                    MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                dataGridView1.DataSource = null;
                String nombre = "", apellido = "", email = "", numeroDNI = "";
                if (!esVacio(textBoxDNI.Text.Trim()))
                {
                    numeroDNI = textBoxDNI.Text.Trim();
                }
                if (!esVacio(textBoxEmail.Text.Trim()))
                {
                    email = textBoxEmail.Text.Trim();
                }

                if (!esVacio(textBoxNombre.Text.Trim()))
                {
                    nombre = textBoxNombre.Text.Trim();
                }
                if (!esVacio(textBoxApellido.Text.Trim()))
                {
                    apellido = textBoxApellido.Text.Trim();
                }
                DataTable ds = new DataTable();
                DBConsulta.conexionAbrir();
                ds = DBConsulta.buscarClienteSegunCriterios3(nombre, apellido, numeroDNI, email);
                configuracionGrilla(dataGridView1, ds);
                DBConsulta.conexionCerrar();

                //           consultasSQLCliente.llenarDGVCliente(dataGridView1, nombre, apellido, numeroDNI, email);

                /*         DialogResult = DialogResult.OK;  */
                return;
            }
        }
Exemplo n.º 4
0
        private bool elUserTieneTarjeta(int user)
        {
            String    query     = "SELECT cliente_datos_tarjeta AS 'DATOS', cliente_usuario FROM SQLEADOS.Cliente WHERE cliente_usuario = " + user;
            DataTable dt        = DBConsulta.AbrirCerrarObtenerConsulta(query);
            String    cellValue = dt.Rows[0][0].ToString();

            return(!AyudaExtra.esStringVacio(cellValue));
        }
 private void camposConAlgunaModificacion()
 {
     reiniciarBooleanos();
     if (!AyudaExtra.esStringVacio(textBoxApellido.Text.Trim()))
     {
         apellido = true;
     }
     if (!AyudaExtra.esStringVacio(textBoxNombre.Text.Trim()))
     {
         nombre = true;
     }
     if (!AyudaExtra.esStringVacio(textBoxTelefono.Text.Trim()))
     {
         telefono = true;
     }
     if (!AyudaExtra.esStringVacio(textBoxTarjeta.Text.Trim()))
     {
         tarjeta = true;
     }
     if (!AyudaExtra.esStringVacio(textBoxCalle.Text.Trim()))
     {
         calle = true;
     }
     if (!AyudaExtra.esStringVacio(textBoxNroCalle.Text.Trim()))
     {
         nrocalle = true;
     }
     if (!AyudaExtra.esStringVacio(textBoxLocalidad.Text.Trim()))
     {
         localidad = true;
     }
     if (!AyudaExtra.esStringVacio(textBoxPiso.Text.Trim()))
     {
         piso = true;
     }
     if (!AyudaExtra.esStringVacio(textBoxDto.Text.Trim()))
     {
         departamento = true;
     }
     if (!AyudaExtra.esStringVacio(textBoxCodigoPostal.Text.Trim()))
     {
         codigopostal = true;
     }
     if (txtHabilitado.Text.Trim() == "0")
     {
         estado = true;
     }
     if (txtHabilitado.Text.Trim() == "1")
     {
         estado = true;
     }
 }
        //Buscador a partir de criterios
        private void btt_buscar_Click(object sender, EventArgs e)
        {
            //Buscador a partir de criterios
            String error = "";

            if (esVacio(textBoxDNI.Text.Trim()) && esVacio(textBoxEmail.Text.Trim()) && esVacio(textBoxApellido.Text.Trim()) && esVacio(textBoxNombre.Text.Trim()))
            {
                MessageBox.Show("Usted no ha puesto ningún criterio de busquedad. Rellene los campos por favor", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                if (!textBoxNombre.Text.Trim().Equals("") && !AyudaExtra.esStringLetra(textBoxNombre.Text.Trim()) || !textBoxApellido.Text.Trim().Equals("") && !AyudaExtra.esStringLetra(textBoxApellido.Text.Trim()))
                {
                    error += "Los campos Nombre y Apellido no pueden contener numeros\n";
                    MessageBox.Show("Los campos Nombre y Apellido no pueden contener numeros", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!textBoxDNI.Text.Trim().Equals("") && !AyudaExtra.esStringNumerico(textBoxDNI.Text.Trim()))
                {
                    error += "El campo numero de documento no puede contener letras\n";
                    //          MessageBox.Show("El campo numero de documento no puede contener letras", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //            return;
                }
                if (error != "")
                {
                    MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                dataGridView1.DataSource = null;
                if (!esVacio(textBoxDNI.Text.Trim()))
                {
                    numeroDNI = textBoxDNI.Text.Trim();
                }
                if (!esVacio(textBoxEmail.Text.Trim()))
                {
                    email = textBoxEmail.Text.Trim();
                }

                if (!esVacio(textBoxNombre.Text.Trim()))
                {
                    nombre = textBoxNombre.Text.Trim();
                }
                if (!esVacio(textBoxApellido.Text.Trim()))
                {
                    apellido = textBoxApellido.Text.Trim();
                }
                BusquedadYLlenarGrilla();
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     //AGREGAR
     if (!AyudaExtra.esStringNumerico(textBox1.Text))
     {
         MessageBox.Show("El precio no es un número");
         return;
     }
     if (comboBox1.SelectedItem == null)
     {
         MessageBox.Show("No has seleccionado ningún tipo de ubicación aún");
         return;
     }
     editar.agregarUbicacionConPrecioYTipo(fi, ass, textBox1.Text, comboBox1.SelectedItem.ToString());
     this.Close();
 }
Exemplo n.º 8
0
        private void validarCampos()
        {
            String mensaje = "";

            if (!AyudaExtra.esStringLetra(textBox1.Text))
            {
                mensaje += "El campo nombre debe ser alfabético\n";
                String caption = "Error al crear el rol";
                //       MessageBox.Show(mensaje, caption, MessageBoxButtons.OK);
            }

            if (string.IsNullOrEmpty(textBox1.Text) || (int)listBox2.Items.Count == 0)
            {
                mensaje += "Los campos nombre y funcionalidades son obligatorios";
                String caption = "Error al crear el rol";
                MessageBox.Show(mensaje, caption, MessageBoxButtons.OK);
            }
            else
            {
                if (mensaje != "")
                {
                    String caption = "Error al crear el rol";
                    MessageBox.Show(mensaje, caption, MessageBoxButtons.OK);
                }
                coneccion.Open();
                existeRol             = new SqlCommand("SQLeados.existeRol", coneccion);
                existeRol.CommandType = CommandType.StoredProcedure;
                existeRol.Parameters.Add("@nombre", SqlDbType.VarChar).Value = textBox1.Text;
                var resultado = existeRol.Parameters.Add("@Valor", SqlDbType.Int);
                resultado.Direction = ParameterDirection.ReturnValue;
                data = existeRol.ExecuteReader();
                var existeR = resultado.Value;
                data.Close();
                coneccion.Close();

                if ((int)existeR == 1)
                {
                    mensaje += "El rol ya exisste, ingrese otro nombre";
                    String caption = "Error al crear el rol";
                    MessageBox.Show(mensaje, caption, MessageBoxButtons.OK);
                }
                else
                {
                    crearNuevoRol();
                }
            }
        }
Exemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!AyudaExtra.esStringLetra(textBox1.Text))
            {
                MessageBox.Show("El nombre de la categoría debe ser solo alfabética", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (estaRepetidoOParecido(textBox1.Text))
            {
                MessageBox.Show("El nombre de la categoría no debe ser parecido al otro que ya está en la base de datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            String query = "INSERT INTO SQLEADOS.Rubro(rubro_descripcion) VALUES ('" + textBox1.Text + "')";

            DBConsulta.AbrirCerrarModificarDB(query);
            cargar();
        }
        //Buscador a partir de criterios
        private void btt_buscar_Click(object sender, EventArgs e)
        {
            if (esVacio(textBoxDNI.Text.Trim()) && esVacio(textBoxEmail.Text.Trim()) && esVacio(textBoxApellido.Text.Trim()) && esVacio(textBoxNombre.Text.Trim()))
            {
                MessageBox.Show("Usted no ha puesto ningún criterio de busquedad. Rellene los campos por favor");
                return;
            }
            else
            {
                if (!textBoxNombre.Text.Trim().Equals("") && !AyudaExtra.esStringLetra(textBoxNombre.Text.Trim()) || !textBoxApellido.Text.Trim().Equals("") && !AyudaExtra.esStringLetra(textBoxApellido.Text.Trim()))
                {
                    MessageBox.Show("Los campos Nombre y Apellido no pueden contener numeros");
                    return;
                }
                if (!textBoxDNI.Text.Trim().Equals("") && !AyudaExtra.esStringNumerico(textBoxDNI.Text.Trim()))
                {
                    MessageBox.Show("El campo numero de documento no puede contener letras");
                    return;
                }
                dataGridView1.DataSource = null;
                String nombre = "", apellido = "", email = "", numeroDNI = "";
                if (!esVacio(textBoxDNI.Text.Trim()))
                {
                    numeroDNI = textBoxDNI.Text.Trim();
                }
                if (!esVacio(textBoxEmail.Text.Trim()))
                {
                    email = textBoxEmail.Text.Trim();
                }

                if (!esVacio(textBoxNombre.Text.Trim()))
                {
                    nombre = textBoxNombre.Text.Trim();
                }
                if (!esVacio(textBoxApellido.Text.Trim()))
                {
                    apellido = textBoxApellido.Text.Trim();
                }
                DataTable ds = new DataTable();
                ds = DBConsulta.buscarClienteSegunCriterios2(nombre, apellido, numeroDNI, email);
                configuracionGrilla(dataGridView1, ds);
                return;
            }
        }
Exemplo n.º 11
0
        private void buttonAgregar_Click(object sender, EventArgs e)
        {
            if (camposInvalidos()) {
                return;
            }

            // Porque no es campo obligatorio
            bool ingresoPisoYDPT = false;
            if (textBoxPiso.Text.Trim() != "" && textBoxDto.Text.Trim() != "")
            {
                if (!AyudaExtra.esStringNumerico(textBoxPiso.Text.Trim()))
                {
                    MessageBox.Show("Debe ingresar el numero de piso", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else {
                    ingresoPisoYDPT = true;
                }
    //            debeSerTodoNumero(textBoxPiso.Text, "Piso");
            }
            
    //        debeSerTodoNumero(textBoxTelefono.Text, "Telefono");

            String tipo = "Cliente";
            if (consultasSQLCliente.existeCuit(textBoxCuit.Text, tipo))
            {
                MessageBox.Show("Ya se encuentra registrado el numero de CUIT", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
       /*     if (!cuitYNroDocumentoSonCorrectos(textBoxCuit.Text, textBoxDOCNUMERO.Text)) {
                MessageBox.Show("El CUIT y el numero de documento no coindiden", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            */

            String nombre = textBoxNombre.Text.Trim();
            String apellido = textBoxApellido.Text.Trim();
            String tipo_documento = textBoxTIPODOC.Text.Trim();
            String cuit = armarCuit(textBoxCuit.Text);

            String mail = textBoxMail.Text.Trim();
            String fecha_nacimiento = dateFecha.Value.ToString("yyyy-MM-dd");

            String calle = textBoxCalle.Text.Trim();
            String codPostal = textBoxCodigoPostal.Text.Trim();
            String dto = textBoxDto.Text;
            long numero_documento = Convert.ToInt64(textBoxDOCNUMERO.Text);
            String telefono = textBoxTelefono.Text.Trim();
            int nroCalle = Convert.ToInt32(textBoxNroCalle.Text);
            String nro_tarjeta = textBoxTarjeta.Text.Trim();
            int piso;
            if (ingresoPisoYDPT)
            {
                piso = Convert.ToInt32(textBoxPiso.Text);
            }
            else {
                piso = 0;
            }
            String localidad = textBoxLocalidad.Text;
            bool creacionAbortada = false;
            DBConsulta.conexionAbrir();
            if(DBConsulta.repeticion_de_campo_tipoDOC_numero_o_CUIL(cuit, textBoxDOCNUMERO.Text.Trim().ToString(), tipo_documento)) {
                MessageBox.Show("Hay repetición en CUIL, o en Tipo de documento y su número, correspondiente a la DB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DBConsulta.conexionCerrar();
                return;
            }
            if (DBConsulta.repe_mail(mail)) {
                MessageBox.Show("El Email ingresado ya existe en la DB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DBConsulta.conexionCerrar();
                return;
            }

            int usuarioNuevo = ConsultasSQL.crearUser(nombre.Replace(" ", "_") + "_" + apellido.Replace(" ", "_"), creacionAbortada, autogenerarContrasenia.contraGeneradaAString(), "Cliente");
            DBConsulta.conexionCerrar();
            if (creacionAbortada == false)
            {
                consultasSQLCliente.AgregarCliente(nombre, apellido, tipo_documento, numero_documento, mail, nro_tarjeta, cuit, telefono, fecha_nacimiento, DateTime.Today);
                DBConsulta.conexionAbrir();
                consultasSQLCliente.AgregarDomicilio(calle, nroCalle, piso, dto, localidad, codPostal, "Cliente");
                
                
                MessageBox.Show("Usuario creado: " + DBConsulta.obtenerNombreUltimoUserIngresado());
                DBConsulta.conexionCerrar();
            }
            else {
                MessageBox.Show("Error al crear el nuevo usuario al consultar la base de datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DBConsulta.conexionCerrar();
                return;
            }


       //     this.limpiarCuadrosDeTexto();
            return;

        }
        private void button1_Click(object sender, EventArgs e)
        {
            DBConsulta.conexionAbrir();
            camposConAlgunaModificacion();
            bool   clienteTieneSet = false, domicilioTieneSet = false;
            String queryCliente        = "UPDATE SQLEADOS.Cliente ";
            String queryDomicilio      = "UPDATE SQLEADOS.Domicilio ";
            String queryUser           = "";
            String finalQueryDomicilio = " where domicilio_cliente_numero_documento = (SELECT TOP 1 cliente_numero_documento from SQLEADOS.Cliente where cliente_usuario =" + usuarioSeleccionado + ") AND domicilio_cliente_tipo_documento = (SELECT TOP 1 cliente_tipo_documento from SQLEADOS.Cliente where cliente_usuario =" + usuarioSeleccionado + ")";
            String finalQueryCliente   = " where cliente_usuario = " + usuarioSeleccionado;

            String error = "";

            if (apellido == true)
            {
                if (!AyudaExtra.esStringLetra(textBoxApellido.Text.Trim()))
                {
                    error += "El campo Apellido solo admite letras\n";
                }
                else
                {
                    queryCliente   += " SET cliente_apellido = '" + textBoxApellido.Text.Trim() + "'";
                    clienteTieneSet = true;
                }
                queryCliente   += " SET cliente_apellido = '" + textBoxApellido.Text.Trim() + "'";
                clienteTieneSet = true;
            }

            if (nombre == true)
            {
                if (!AyudaExtra.esStringLetra(textBoxNombre.Text.Trim()))
                {
                    error += "El campo Nombre solo admite letras\n";
                }
                else
                {
                    if (clienteTieneSet)
                    {
                        queryCliente += " , cliente_nombre = '" + textBoxNombre.Text.Trim() + "'";
                    }
                    else
                    {
                        queryCliente   += " SET cliente_nombre = '" + textBoxNombre.Text.Trim() + "'";
                        clienteTieneSet = true;
                    }
                }
            }

            if (tarjeta == true)
            {
                if (!AyudaExtra.esStringNumerico(textBoxTarjeta.Text.Trim()))
                {
                    error += "El campo tarjeta solo admite numeros\n";
                }
                else
                {
                    if (clienteTieneSet)
                    {
                        queryCliente += " , cliente_datos_tarjeta = " + textBoxTarjeta.Text.Trim();
                    }
                    else
                    {
                        queryCliente   += " SET cliente_datos_tarjeta = " + textBoxTarjeta.Text.Trim();
                        clienteTieneSet = true;
                    }
                }
            }

            if (telefono == true)
            {
                if (!AyudaExtra.esStringNumerico(textBoxTelefono.Text.Trim()))
                {
                    error += "El campo telefono solo admite numeros\n";
                }
                else
                {
                    if (clienteTieneSet)
                    {
                        queryCliente += " , cliente_telefono = " + textBoxTelefono.Text.Trim();
                    }
                    else
                    {
                        queryCliente   += " SET  cliente_telefono = " + textBoxTelefono.Text.Trim();
                        clienteTieneSet = true;
                    }
                }
            }

            if (calle == true)
            {
                queryDomicilio   += " SET domicilio_calle = '" + textBoxCalle.Text.Trim() + "'";
                domicilioTieneSet = true;
            }

            if (nrocalle == true)
            {
                if (!AyudaExtra.esStringNumerico(textBoxNroCalle.Text.Trim()))
                {
                    error += "El campo número de calle solo admite números\n";
                }
                else
                {
                    if (domicilioTieneSet)
                    {
                        queryDomicilio += " , domicilio_numero = " + textBoxNroCalle.Text.Trim();
                    }
                    else
                    {
                        queryDomicilio   += " SET  domicilio_numero = " + textBoxNroCalle.Text.Trim();
                        domicilioTieneSet = true;
                    }
                }
            }

            if (piso == true)
            {
                if (!AyudaExtra.esStringNumerico(textBoxPiso.Text))
                {
                    error += "El campo piso solo admite números\n";
                }

                if (domicilioTieneSet)
                {
                    queryDomicilio += " , domicilio_piso = " + textBoxPiso.Text.Trim();
                }
                else
                {
                    queryDomicilio   += " SET  domicilio_piso = " + textBoxPiso.Text.Trim();
                    domicilioTieneSet = true;
                }
            }

            if (departamento == true)
            {
                if (!AyudaExtra.esStringLetra(textBoxPiso.Text.Trim()))
                {
                    error += "El campo departamento solo admite letras\n";
                }

                if (domicilioTieneSet)
                {
                    queryDomicilio += " , domicilio_dto = '" + textBoxDto.Text.Trim() + "'";
                }
                else
                {
                    queryDomicilio   += " SET domicilio_dto = '" + textBoxDto.Text.Trim() + "'";
                    domicilioTieneSet = true;
                }
            }

            if (localidad == true)
            {
                if (domicilioTieneSet)
                {
                    queryDomicilio += " , domicilio_localidad = '" + textBoxLocalidad.Text.Trim() + "'";
                }
                else
                {
                    queryDomicilio   += " SET domicilio_localidad = '" + textBoxLocalidad.Text.Trim() + "'";
                    domicilioTieneSet = true;
                }
            }

            if (codigopostal == true)
            {
                if (AyudaExtra.esStringNumerico(textBoxCodigoPostal.Text.Trim()))
                {
                }

                if (domicilioTieneSet)
                {
                    queryDomicilio += " , domicilio_codigo_postal = '" + textBoxCodigoPostal.Text.Trim() + "'";
                }
                else
                {
                    queryDomicilio   += " SET domicilio_codigo_postal = '" + textBoxCodigoPostal.Text.Trim() + "'";
                    domicilioTieneSet = true;
                }
            }
            if (error != "")
            {
                MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (checkBox1.Checked)
            {
                queryUser = "******" + 1 + " where usuario_Id = " + usuarioSeleccionado;
            }
            else
            {
                queryUser = "******" + 0 + " where usuario_Id = " + usuarioSeleccionado;
            }

            queryCliente   += finalQueryCliente;
            queryDomicilio += finalQueryDomicilio;

            if (queryDomicilio.Contains("SET"))
            {
                DBConsulta.ModificarCliente(queryDomicilio);
                //       this.Close();
            }
            if (queryCliente.Contains("SET"))
            {
                DBConsulta.ModificarCliente(queryCliente);
                //         this.Close();
            }
            if (checkBox1.Checked)
            {
                DBConsulta.ModificarCliente(queryUser);
            }
            cargarDatos();
            DBConsulta.conexionCerrar();
        }
        private void botoncrear_Click(object sender, EventArgs e)
        {
            String error = "";

            if (textBoxcontra.Text.Trim() == "")
            {
                error += "El campos contraseña está vacio, debe rellenarlo\n";
            }
            if (textBoxNombre.Text.Trim() == "")
            {
                error += "El campos nombre de usuario está vacio, debe rellenarlo\n";
            }
            if (textBoxrepecontra.Text.Trim() == "")
            {
                error += "El campos repetir la contraseña está vacio, debe rellenarlo\n";
            }
            if (!AyudaExtra.esStringNumerico(textBoxcontra.Text))
            {
                error += "La contraseña debe ser numérica, debe rellenarlo\n";
            }
            if (!AyudaExtra.esStringNumerico(textBoxrepecontra.Text))
            {
                error += "La contraseña debe ser numéricao, debe rellenarlo\n";
            }

            if (textBoxcontra.Text != textBoxrepecontra.Text)
            {
                error += "Las contraseñas ingresadas no coinciden\n";
            }
            if (error != "")
            {
                MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            String comando, comando2;
            String nombreUser = textBoxNombre.Text.Replace(" ", "_");

            if (esParaAdmin)
            {
                comando  = "INSERT INTO SQLEADOS.Usuario(usuario_nombre, usuario_password, usuario_administrador) VALUES ('" + nombreUser + "' , " + textBoxcontra.Text + ", 1);";
                comando2 = "INSERT INTO SQLEADOS.UsuarioXRol (usuarioXRol_usuario, usuarioXRol_rol) SELECT usuario_Id, rol_Id FROM SQLEADOS.Usuario, SQLEADOS.Rol WHERE usuario_Id = (SELECT TOP 1 usuario_Id FROM SQLEADOS.Usuario U ORDER BY U.usuario_Id DESC)";
            }
            else
            {
                String    obtenerIDRol = "SELECT rol_Id FROM SQLEADOS.Rol WHERE rol_nombre LIKE '" + rolUser + "'";
                DataTable dt           = DBConsulta.AbrirCerrarObtenerConsulta(obtenerIDRol);
                //ID DE ROL
                String ID = dt.Rows[0][0].ToString();
                comando  = "INSERT INTO SQLEADOS.Usuario(usuario_nombre, usuario_password) VALUES ('" + nombreUser + "' , " + textBoxcontra.Text + ");";
                comando2 = "INSERT INTO SQLEADOS.UsuarioXRol (usuarioXRol_usuario, usuarioXRol_rol) SELECT S.usuario_Id, " + ID + " FROM SQLEADOS.Usuario S WHERE S.usuario_Id = (SELECT TOP 1 usuario_Id FROM SQLEADOS.Usuario U ORDER BY U.usuario_Id DESC)";
            }

            DBConsulta.AbrirCerrarModificarDB(comando);
            DBConsulta.AbrirCerrarModificarDB(comando2);
            MessageBox.Show("Se añadido el nuevo " + rolUser);

            if (!esParaAdmin)
            {
                //VUELVE, PORQUE SOLO SE HACE UN SOLO INSERT SI NO EL CREADOR NO ES UN ADMIN
                registro.terminar();
                this.Close();
            }
        }
Exemplo n.º 14
0
        private bool camposInvalidos()
        {
            if (textBoxNombre.Text.Trim() == " " | textBoxApellido.Text.Trim() == " " | textBoxCuit.Text.Trim() == " " | textBoxTelefono.Text.Trim() == "" | textBoxMail.Text.Trim() == " "
                | textBoxTIPODOC.Text.Trim() == " " | textBoxDOCNUMERO.Text.Trim() == " " | textBoxTarjeta.Text.Trim() == " "
                | textBoxCodigoPostal.Text.Trim() == " " | textBoxNroCalle.Text.Trim() == " " | textBoxNroCalle.Text.Trim() == " ")
            {
                MessageBox.Show("Faltan completar campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }
            if (!AyudaExtra.fechaMenorQueActual(dateFecha.Value.Date))
            {
                MessageBox.Show("La fecha ingresada es mayor que la actual", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            if (!AyudaExtra.CUILYContraseniaParecenRespetarTamanios(textBoxDOCNUMERO.Text.Trim(), textBoxCuit.Text.Trim()))
            {
                MessageBox.Show("El tamaño del campo CUIL es menor que el numero de documento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            if (!AyudaExtra.CUILYNroDocSeCorresponden(textBoxDOCNUMERO.Text.Trim(), textBoxCuit.Text.Trim()))
            {
                MessageBox.Show("El CUIL no corresponde al documento ingresado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            if (!AyudaExtra.esStringNumerico(textBoxNroCalle.Text.Trim()))
            {
                MessageBox.Show("El numero de calle debe ser numerico", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            if (!AyudaExtra.esUnMail(textBoxMail.Text.Trim()))
            {
                MessageBox.Show("El campo mail está mal ingresado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            if (!AyudaExtra.esStringNumerico(textBoxDOCNUMERO.Text.Trim()))
            {
                MessageBox.Show("El numero de calle debe ser numerico", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            if (AyudaExtra.esStringNumerico(textBoxTIPODOC.Text.Trim()))
            {
                MessageBox.Show("Sólo se permiten letras en el Tipo de documento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            /*
             * if (contieneNumeroTIPODocumento(textBoxTIPODOC.Text))
             * {
             *  MessageBox.Show("Sólo se permiten letras en el Tipo de documento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  return;
             * }
             */

            if (textBoxTIPODOC.TextLength != 3)
            {
                MessageBox.Show("El TIPO DE DOCUMENTO tiene que tener 3 digitos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }
            return(false);
        }
Exemplo n.º 15
0
        private void buttonAgregar_Click(object sender, EventArgs e)
        {
            if (camposInvalidos())
            {
                return;
            }

            // Porque no es campo obligatorio
            bool   ingresoPisoYDPT = false;
            String error           = "";

            if (textBoxPiso.Text.Trim() != "" && textBoxDto.Text.Trim() != "")
            {
                if (!AyudaExtra.esStringNumerico(textBoxPiso.Text.Trim()))
                {
                    error += "Debe ingresar el numero de piso\n";
                    //               MessageBox.Show("Debe ingresar el numero de piso", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //               return;
                }
                else
                {
                    ingresoPisoYDPT = true;
                }
                //            debeSerTodoNumero(textBoxPiso.Text, "Piso");
            }

            //        debeSerTodoNumero(textBoxTelefono.Text, "Telefono");

            String tipo = "Cliente";

            DBConsulta.conexionAbrir();
            if (consultasSQLCliente.existeCuit(textBoxCuit.Text, tipo))
            {
                error += "Ya se encuentra registrado el numero de CUIT\n";
                //              MessageBox.Show("Ya se encuentra registrado el numero de CUIT", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //           return;
            }
            DBConsulta.conexionCerrar();

            if (error != "")
            {
                MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            /*     if (!cuitYNroDocumentoSonCorrectos(textBoxCuit.Text, textBoxDOCNUMERO.Text)) {
             *       MessageBox.Show("El CUIT y el numero de documento no coindiden", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *       return;
             *   }
             */

            String nombre         = textBoxNombre.Text.Trim();
            String apellido       = textBoxApellido.Text.Trim();
            String tipo_documento = textBoxTIPODOC.Text.Trim();
            String cuit           = armarCuit(textBoxCuit.Text);

            String mail             = textBoxMail.Text.Trim();
            String fecha_nacimiento = dateFecha.Value.ToString("yyyy-MM-dd");

            String calle            = textBoxCalle.Text.Trim();
            String codPostal        = textBoxCodigoPostal.Text.Trim();
            String dto              = textBoxDto.Text;
            long   numero_documento = Convert.ToInt64(textBoxDOCNUMERO.Text);
            String telefono         = textBoxTelefono.Text.Trim();
            int    nroCalle         = Convert.ToInt32(textBoxNroCalle.Text);
            String nro_tarjeta      = textBoxTarjeta.Text.Trim();
            int    piso;

            if (ingresoPisoYDPT)
            {
                piso = Convert.ToInt32(textBoxPiso.Text);
            }
            else
            {
                piso = 0;
            }
            String localidad        = textBoxLocalidad.Text;
            bool   creacionAbortada = false;

            DBConsulta.conexionAbrir();
            if (DBConsulta.repeticion_de_campo_tipoDOC_numero_o_CUIL(cuit, textBoxDOCNUMERO.Text.Trim().ToString(), tipo_documento))
            {
                MessageBox.Show("Hay repetición en CUIL, o en Tipo de documento y su número, correspondiente a la DB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DBConsulta.conexionCerrar();
                return;
            }
            DBConsulta.conexionCerrar();
            DBConsulta.conexionAbrir();
            if (mailRepetido(mail))
            {
                MessageBox.Show("El Email ingresado ya existe en la DB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DBConsulta.conexionCerrar();
                return;
            }



            bool   errors             = false;
            bool   autocontra         = false;
            String contraAutogenerada = autogenerarContrasenia.contraGeneradaAString();

            if (textBoxContrasenia.Text.Trim() == "")
            {
                autocontra = true;
                int usuarioNuevo = ConsultasSQL.crearUser(nombre.Replace(" ", "_") + "_" + apellido.Replace(" ", "_"), creacionAbortada, contraAutogenerada, "Cliente");
            }
            else
            {
                if (AyudaExtra.esStringNumerico(textBoxContrasenia.Text.Trim()))
                {
                    int usuarioNuevo = ConsultasSQL.crearUser(nombre.Replace(" ", "_") + "_" + apellido.Replace(" ", "_"), creacionAbortada, textBoxContrasenia.Text.Trim(), "Cliente");
                }
                else
                {
                    MessageBox.Show("La contraseña debe ser numérica", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    errors = true;
                }
            }
            DBConsulta.conexionCerrar();

            if (!errors)
            {
                if (creacionAbortada == false)
                {
                    consultasSQLCliente.AgregarCliente(nombre, apellido, tipo_documento, numero_documento, mail, nro_tarjeta, cuit, telefono, fecha_nacimiento, DateTime.Today);
                    DBConsulta.conexionAbrir();
                    consultasSQLCliente.AgregarDomicilio(calle, nroCalle, piso, dto, localidad, codPostal, "Cliente");
                    string    cmd        = "Select TOP 1 usuario_nombre from SQLEADOS.Usuario order by usuario_Id DESC";
                    DataTable dt         = DBConsulta.obtenerConsultaEspecifica(cmd);
                    String    comentario = "Usuario creado: " + dt.Rows[0][0].ToString();
                    if (autocontra)
                    {
                        comentario += "\n\nContraseña autogenerada: " + contraAutogenerada;
                    }
                    MessageBox.Show(comentario);
                    DBConsulta.conexionCerrar();
                    if (esRegistro)
                    {
                        registro.terminar();
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Error al crear el nuevo usuario al consultar la base de datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    DBConsulta.conexionCerrar();
                    return;
                }
            }

            this.limpiarCuadrosDeTexto();
        }
Exemplo n.º 16
0
        private void buttonAgregar_Click(object sender, EventArgs e)
        {
            String error = validarCamposIniciales();

            if (!AyudaExtra.esUnMail(textBoxMail.Text))
            {
                error += "Ingrese un mail valido\n";
                //       MessageBox.Show("Ingrese un mail valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //       return;
            }
            if (mailRepetido(textBoxMail.Text))
            {
                error += "Mail repetido, ingrese otro\n";
                //       MessageBox.Show("Mail repetido, ingrese otro", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //       return;
            }

            if (!AyudaExtra.esStringNumerico(textBoxCuit.Text))
            {
                error += "Sólo se permiten numeros en el CUIT\n";
                //     MessageBox.Show("Sólo se permiten numeros en el CUIT", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //    return;
            }
            if (!AyudaExtra.esStringNumerico(textBoxNroCalle.Text))
            {
                error += "Sólo se permiten numeros en el Nro de calle\n";
                //        MessageBox.Show("Sólo se permiten numeros en el Nro de calle", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //        return;
            }
            if (textBoxPiso.Text.Trim() != "")
            {
                if (!AyudaExtra.esStringNumerico(textBoxPiso.Text))
                {
                    error += "Sólo se permiten numeros en el Pisoe\n";
                    //         MessageBox.Show("Sólo se permiten numeros en el Piso", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //        return;
                }
            }
            if (!AyudaExtra.esStringLetra(textBoxCiudad.Text))
            {
                error += "Sólo se permiten letras en el campo ciudad\n";
                //    MessageBox.Show("Sólo se permiten letras en el campo ciudad", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //      return;
            }
            if (textBoxDto.Text.Trim() != "")
            {
                if (!AyudaExtra.esStringLetra(textBoxDto.Text))
                {
                    error += "Sólo se permiten letras en el departamento\n";
                    //         MessageBox.Show("Sólo se permiten letras en el departamento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //         return;
                }
            }
            if (!AyudaExtra.esStringNumerico(textBoxTelefono.Text))
            {
                error += "Sólo se permiten numeros en el Telefono\n";
                //      MessageBox.Show("Sólo se permiten numeros en el Telefono", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //       return;
            }

            /*
             * if (textBoxCuit.TextLength != 11)
             * {
             *  MessageBox.Show("El cuit tiene que tener 11 digitos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  return;
             * }
             */

            String razonSocial = textBoxRazonSocial.Text;

            if (existeRazonSocialYa(razonSocial))
            {
                error += "Ya se encuentra registrado esa razon social, ingrese otro\n";
                //       MessageBox.Show("Ya se encuentra registrado esa razon social, ingrese otro", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //       return;
            }

            String cuit   = armarCuit(textBoxCuit.Text);
            String ciudad = textBoxCiudad.Text;

            if (existeCuit(cuit))
            {
                error += "Ya se encuentra registrado el numero de CUIT, ingrese otro\n";
                //            MessageBox.Show("Ya se encuentra registrado el numero de CUIT, ingrese otro", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //           return;
            }

            String mail      = textBoxMail.Text;
            String telefono  = textBoxTelefono.Text;
            int    nroCalle  = Convert.ToInt32(textBoxNroCalle.Text);
            String calle     = textBoxCalle.Text;
            String codPostal = textBoxCodigoPostal.Text;
            String dto       = textBoxDto.Text;
            int    piso      = 0;

            if (textBoxPiso.Text != "")
            {
                piso = Convert.ToInt32(textBoxPiso.Text);
            }

            String localidad = textBoxLocalidad.Text;

            int  usuarioNuevo = 0;
            bool errores      = false;

            DBConsulta.conexionAbrir();
            bool   autocontra         = false;
            String contraautogenerada = autogenerarContrasenia.contraGeneradaAString();

            //SE CREA EL USUARIO
            if (textBoxContrasenia.Text.Trim() != "")
            {
                if (AyudaExtra.esStringNumerico(textBoxContrasenia.Text.Trim()))
                {
                    if (error != "")
                    {
                        error += "La contraseña debe ser numérica\n";
                        MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    usuarioNuevo = ConsultasSQL.crearUser(textBoxRazonSocial.Text.Trim().Replace(" ", "_"), false, textBoxContrasenia.Text.Trim(), "Empresa");
                }
                else
                {
                    error += "La contraseña debe ser numérica\n";
                    MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                    //         MessageBox.Show("La contraseña debe ser numérica", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //       errores = true;
                }
            }
            else
            {
                autocontra   = true;
                usuarioNuevo = ConsultasSQL.crearUser(textBoxRazonSocial.Text.Trim().Replace(" ", "_"), false, contraautogenerada, "Empresa");
            }
            //TERMINA CREA EL USUARIO
            DBConsulta.conexionCerrar();
            //CREA LA EMPRESA
            if (!errores)
            {
                DateTime hoy = DateTime.Today;
                int      ultimoUser;

                String    obtenerUltimoUser = "******";
                DataTable ds = DBConsulta.AbrirCerrarObtenerConsulta(obtenerUltimoUser);
                ultimoUser = Convert.ToInt32(ds.Rows[0][0].ToString());
                DBConsulta.creacionNuevoEmpresa(razonSocial, mail, cuit, hoy.ToString(), ultimoUser, ciudad, telefono);
                ///           crearNuevaEmpresa(razonSocial, cuit, ciudad, mail, telefono, Convert.ToInt32(ds.Rows[0][0].ToString()), hoy);
                //        ConsultasSQLEmpresa.AgregarEmpresa(razonSocial, cuit, ciudad, mail, telefono, Convert.ToInt32(ds.Rows[0][0].ToString()), hoy);
                DBConsulta.crearNuevoDomicilioEmpresa(calle, nroCalle.ToString(), piso.ToString(), dto, codPostal, localidad, razonSocial, cuit);

                //        ConsultasSQLEmpresa.AgregarDomicilio(calle, nroCalle, piso, dto, localidad, codPostal, "Empresa");
                this.limpiarCuadrosDeTexto();
                String    obtenerNombreUser = "******";
                DataTable dt = DBConsulta.AbrirCerrarObtenerConsulta(obtenerNombreUser);

                String mostrarResultado = "Se ha agregado el nuevo Usuario:\n\n" + dt.Rows[0][0].ToString();
                if (autocontra)
                {
                    mostrarResultado += "\n\nSe ha autogenerado una contraseña, es: " + contraautogenerada;
                }
                MessageBox.Show(mostrarResultado);
                if (deEmpresa)
                {
                    ante.Show();
                }
                else
                {
                    reg.terminar();
                }
                this.Close();
            }
            else
            {
                return;
            }
        }
        private void buttonGenerarFactura_Click(object sender, EventArgs e)
        {
            if (!hayDatos)
            {
                MessageBox.Show("No hay nada puesto en la grilla", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //     String buscarIDPublicacion = "SELECT publicacion_codigo FROM SQLEADOS.Publicacion where publicacion_codigo = " + labelNroPublicacion;
            //     String idPubl = DBConsulta.AbrirCerrarObtenerConsulta(buscarIDPublicacion).Rows[0][0].ToString();
            DateTime hoy        = ArchivoDeConfiguracion.fechaReferencia;
            String   montoTotal = cantidadTotal.ToString();

            montoTotal = montoTotal.Replace(",", ".");
            String guardarNuevaFactura = "insert into [SQLEADOS].Factura (factura_publicacion, factura_nro, factura_empresa_cuit, factura_empresa_razon_social, factura_fecha, factura_total, factura_forma_de_pago) Values (" + labelNroPublicacion.Text + ", " + labelNroFactura.Text + ", '" + labelCUIT.Text + "', '" + labelEmpresa.Text + "', '" + AyudaExtra.stringAFormatoFechaSQLDateSinHora(hoy.ToString()) + "', " + montoTotal + ", 'Tarjeta')";

            DBConsulta.AbrirCerrarModificarDB(guardarNuevaFactura);

            int i = 0;

            while (i < dataGridView1.Rows.Count)
            {
                //CREA ITEM FACTURA POR CADA COMISIÓN DE CADA COMPRA

                //     String query = "SELECT DISTINCT (ub.ubiXpubli_precio*gr.grado_comision)/100 FROM SQLEADOS.Publicacion p JOIN SQLEADOS.ubicacionXpublicacion ub ON ub.ubiXpubli_Publicacion = p.publicacion_codigo JOIN SQLEADOS.ubicacionesXPublicidadComprada ubx ON ubxpcom_ubicacionXPublicidad = ub.ubiXpubli_ID JOIN SQLEADOS.Compra c ON c.compra_id = ubx.ubxpcomp_compra JOIN SQLEADOS.GradoPrioridad gr ON gr.grado_id = p.publicacion_grado JOIN SQLEADOS.Ubicacion u ON u.ubicacion_id = ub.ubiXpubli_Ubicacion WHERE p.publicacion_codigo = " + labelNroPublicacion.Text + " AND ub.ubiXpubli_ID NOT IN (SELECT i.item_factura_ubicacion FROM SQLEADOS.ItemFactura i JOIN SQLEADOS.Factura f ON f.factura_nro = i.item_factura_nro AND f.factura_publicacion = p.publicacion_codigo)";

                //     DataTable dt = DBConsulta.AbrirCerrarObtenerConsulta(query);
                String cadena = dataGridView1.Rows[i].Cells[5].Value.ToString().Substring(2, dataGridView1.Rows[i].Cells[5].Value.ToString().Length - 2);
                cadena = cadena.Replace(".", ",");
                double cant = 0;
                cant = Convert.ToDouble(cadena);

                //AQUI EL MONTO TOTAL EN REALIDAD ES EL MONTO PARTICULAR DE CADA COMISION
                montoTotal = (cant.ToString()).Replace(",", ".");

                String ubicacion = dataGridView1.Rows[i].Cells[0].Value.ToString();

                String guardarDatosComisiones = "insert into [SQLEADOS].ItemFactura (item_factura_nro, item_factura_monto, item_factura_descripcion, item_factura_cantidad, item_factura_ubicacion) Values(" + labelNroFactura.Text + ", " + montoTotal + ", 'Precio de comisión', 1, " + ubicacion + ")";
                DBConsulta.AbrirCerrarModificarDB(guardarDatosComisiones);

                i++;
            }

            MessageBox.Show("Se ha generado la factura para la empresa seleccionada");

            //LIMPIO TODO
            entrar();
        }
        //MODIFICAR DATOS
        private void button1_Click(object sender, EventArgs e)
        {
            // O = BORRRADOR = NO HACER NADA , 1 = PUBLICADA o 2 = FINALIZADA = CAMBIAR
//            String update = "UPDATE SQLEADOS.Publicacion SET ";
            String estado = "";

            if (radioButtonBorrador.Checked == true)
            {
                estado = "Borrador";
            }
            else
            if (radioButtonFinalizada.Checked == true)
            {
                estado = "Finalizada";
            }
            else if (radioButtonPublicada.Checked == true)
            {
                estado = "Publicada";
            }

            String fecha_publicacion = "";
            String fecha_estreno     = "";
            String error             = "";

            if (AyudaExtra.fechaMenorQueActual(dateTimePicker1.Value))
            {
                error += "La fecha del espectáculo debe ser mayor que la fecha del sistema\n";
            }
            if (AyudaExtra.fechaIgualQueActual(dateTimePicker1.Value))
            {
                error += "La fecha del espectáculo debe ser mayor que la fecha del sistema\n";
            }
            if (AyudaExtra.fechaMenorQueActual(dateTimePickerFechaFinal.Value))
            {
                error += "La fecha del espectáculo debe ser mayor que la fecha del sistema\n";
            }
            if (AyudaExtra.fechaIgualQueActual(dateTimePickerFechaFinal.Value))
            {
                error += "La fecha del espectáculo debe ser mayor que la fecha del sistema\n";
            }
            if (error != "")
            {
                MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DateTime fechaInicial = dateTimePicker1.Value;

            fechaFinal = dateTimePickerFechaFinal.Value;

            if (todosLosHorariosSonValidos())
            {
                //ARMAR FECHA CON HORA

                //EMPIEZO POR FECHA DE PUBLICACION
                fecha_publicacion = fechaInicial.Year + "-" + fechaInicial.Month + "-" + fechaInicial.Day + " " + textBoxHoraInicial.Text + ":" + textBoxMinutoInicial.Text + ":00.000";
                //PASO POR FECHA DE ESTRENO DE OBRA
                fecha_estreno = fechaFinal.Year + "-" + fechaFinal.Month + "-" + fechaFinal.Day + " " + textBoxHoraFinal.Text + ":" + textBoxMinutoFinal.Text + ":00.000";
            }
            else
            {
                return;
            }
            bool problemaConFechas = false;

            if (Convert.ToInt32(fechaFinal.Year) > Convert.ToInt32(fechaInicial.Year))
            {
                //NO HAY PROBLEMA
            }
            else if (Convert.ToInt32(fechaFinal.Year) == Convert.ToInt32(fechaInicial.Year))
            {
                if (Convert.ToInt32(fechaFinal.Month) > Convert.ToInt32(fechaInicial.Month))
                {
                    //NO HAY PROBLEMA
                }
                else
                {
                    if (Convert.ToInt32(fechaFinal.Month) == Convert.ToInt32(fechaInicial.Month))
                    {
                        if (Convert.ToInt32(fechaFinal.Day) > Convert.ToInt32(fechaInicial.Day))
                        {
                            //NO HAY PROBLEMA ALGUNO
                        }
                        else
                        {
                            //PROBLEMA CON EL DIA
                            problemaConFechas = true;
                        }
                    }
                    else
                    {
                        //PROBLEMA CON EL MES
                        problemaConFechas = true;
                    }
                }
            }
            else
            {
                //PROBLEMA CON EL AÑO
                problemaConFechas = true;
            }

            if (problemaConFechas)
            {
                MessageBox.Show("La fecha de estreno es inferior o\nigual que la fecha de publicación", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            //AGREGAR AHORA CATEGORÍA

            int idCategoria = buscarCategoriaYAgregar();

            if (!AyudaExtra.esStringVacio(textPuntaje.Text))
            {
                if (!AyudaExtra.esStringNumerico(textPuntaje.Text))
                {
                    MessageBox.Show("El puntaje ingresado no es un número", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("El puntaje no fue ingresado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            //   DBConsulta.ConectarConsulta(update);
            if (noHayProblemaConLaFechaYHora(fecha_estreno))
            {
                int idGrado = buscarIDGrado(gradoDePublicacion);
                hacerUpdateDePublicacionEspecifica(publicacionID, estado, idCategoria, idGrado, fecha_estreno, fecha_publicacion, Convert.ToInt32(textPuntaje.Text));

                /*
                 * DBConsulta.conexionAbrir();
                 * DBConsulta.actualizarPublicidad(publicacionID, estado, idCategoria, comboBoxGrados.SelectedIndex + 1, armarFechaYHoraYAgregarAUpdate(), Convert.ToInt32(textPuntaje.Text));
                 * DBConsulta.conexionCerrar();
                 * */
                MessageBox.Show("Se ha actualizado la publicación");
                ed.recargar();
                ed.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("A la fecha que se quiere indicar ya existe otra función,\nSeleccione otra fecha", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        private bool todosLosHorariosSonValidos()
        {
            if (AyudaExtra.esStringVacio(textBoxHoraInicial.Text) == true)
            {
                MessageBox.Show("En la sección HORARIOS, algunos campos están vacíos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (AyudaExtra.esStringVacio(textBoxMinutoInicial.Text) == true)
            {
                MessageBox.Show("En la sección HORARIOS, algunos campos están vacíos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (AyudaExtra.esStringVacio(textBoxHoraFinal.Text) == true)
            {
                MessageBox.Show("En la sección HORARIOS, algunos campos están vacíos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (AyudaExtra.esStringVacio(textBoxMinutoFinal.Text) == true)
            {
                MessageBox.Show("En la sección HORARIOS, algunos campos están vacíos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (!AyudaExtra.esStringNumerico(textBoxHoraInicial.Text))
            {
                MessageBox.Show("El campo hora no es numérico", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (!AyudaExtra.esStringNumerico(textBoxMinutoInicial.Text))
            {
                MessageBox.Show("El campo minuto no es numérico", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (!AyudaExtra.esStringNumerico(textBoxHoraFinal.Text))
            {
                MessageBox.Show("El campo hora no es numérico", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (!AyudaExtra.esStringNumerico(textBoxMinutoFinal.Text))
            {
                MessageBox.Show("El campo minuto no es numérico", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (Convert.ToInt32(textBoxMinutoInicial.Text) >= 60)
            {
                MessageBox.Show("En el campo minuto de publicación, número no es válido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (Convert.ToInt32(textBoxHoraInicial.Text) >= 24)
            {
                MessageBox.Show("En el campo hora de publicación, número no es válido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (Convert.ToInt32(textBoxMinutoFinal.Text) >= 60)
            {
                MessageBox.Show("En el campo minuto de estreno, número no es válido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (Convert.ToInt32(textBoxHoraFinal.Text) >= 24)
            {
                MessageBox.Show("En el campo hora de estreno, número no es válido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
Exemplo n.º 20
0
        private bool camposInvalidos()
        {
            String error = "";

            if (textBoxNombre.Text.Trim() == "" | textBoxApellido.Text.Trim() == "" | textBoxCuit.Text.Trim() == "" | textBoxTelefono.Text.Trim() == "" | textBoxMail.Text.Trim() == ""
                | textBoxTIPODOC.Text.Trim() == "" | textBoxDOCNUMERO.Text.Trim() == "" | textBoxTarjeta.Text.Trim() == ""
                | textBoxCodigoPostal.Text.Trim() == "" | textBoxNroCalle.Text.Trim() == "" | textBoxCalle.Text.Trim() == "")
            {
                error += "Faltan completar campos\n";
                if (textBoxNombre.Text.Trim() == "")
                {
                    error += "Faltan completar el nombre\n";
                }
                if (textBoxApellido.Text.Trim() == "")
                {
                    error += "Faltan completar el apellido\n";
                }
                if (textBoxCuit.Text.Trim() == "")
                {
                    error += "Faltan completar el CUIT\n";
                }
                if (textBoxTIPODOC.Text.Trim() == "")
                {
                    error += "Faltan completar el tipo de documento\n";
                }
                if (textBoxDOCNUMERO.Text.Trim() == "")
                {
                    error += "Faltan completar el número de documento\n";
                }
                if (textBoxTelefono.Text.Trim() == "")
                {
                    error += "Faltan completar el telefono\n";
                }
                if (textBoxMail.Text.Trim() == "")
                {
                    error += "Faltan completar el mail\n";
                }
                if (textBoxTarjeta.Text.Trim() == "")
                {
                    error += "Faltan completar el número de tarjeta\n";
                }
                if (textBoxCodigoPostal.Text.Trim() == "")
                {
                    error += "Faltan completar el código postal\n";
                }
                if (textBoxNroCalle.Text.Trim() == "")
                {
                    error += "Faltan completar el número de calle\n";
                }
                if (textBoxCalle.Text.Trim() == "")
                {
                    error += "Faltan completar la calle del cliente\n";
                }

                //       MessageBox.Show("Faltan completar campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //        return true;
            }
            if (!AyudaExtra.CUILYContraseniaParecenRespetarTamanios(textBoxDOCNUMERO.Text.Trim(), textBoxCuit.Text.Trim()))
            {
                error = "El tamaño del campo CUIL es menor que el numero de documento\n";
                //       MessageBox.Show("El tamaño del campo CUIL es menor que el numero de documento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //       return true;
            }

            if (!AyudaExtra.fechaMenorQueActual(dateFecha.Value.Date))
            {
                error += "La fecha ingresada es mayor o igual que la actual\n";
                //         MessageBox.Show("La fecha ingresada es mayor o igual que la actual", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //        return true;
            }
            if (!AyudaExtra.fechaEsMayorA18Anios(dateFecha.Value.Date))
            {
                error += "La fecha ingresada no cumple los requisitos de que el usuario debe ser mayor a 18 años\n";
                //          MessageBox.Show("La fecha ingresada no cumple los requisitos de que el usuario debe ser mayor a 18 años", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //           return true;
            }
            if (!AyudaExtra.CUILYNroDocSeCorresponden(textBoxDOCNUMERO.Text.Trim(), textBoxCuit.Text.Trim()))
            {
                error += "El CUIL no corresponde al documento ingresado\n";
                //            MessageBox.Show("El CUIL no corresponde al documento ingresado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //           return true;
            }

            if (!AyudaExtra.esStringNumerico(textBoxContrasenia.Text))
            {
                error += "La contraseña debe ser un número\n";
                //       MessageBox.Show("La contraseña debe ser un número", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //       return true;
            }

            if (!AyudaExtra.esStringNumerico(textBoxNroCalle.Text.Trim()))
            {
                error += "El numero de calle debe ser numerico\n";
                //        MessageBox.Show("El numero de calle debe ser numerico", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //         return true;
            }
            if (!AyudaExtra.esStringNumerico(textBoxTarjeta.Text.Trim()))
            {
                error += "El numero de tarjeta debe ser numerico\n";
                //         MessageBox.Show("El numero de tarjeta debe ser numerico", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //         return true;
            }
            if (!AyudaExtra.esStringNumerico(textBoxTelefono.Text.Trim()))
            {
                error += "El numero de telefono debe ser numerico\n";
                //        MessageBox.Show("El numero de telefono debe ser numerico", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //         return true;
            }

            if (!AyudaExtra.esUnMail(textBoxMail.Text.Trim()))
            {
                error += "El campo mail está mal ingresado\n";
                //            MessageBox.Show("El campo mail está mal ingresado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //            return true;
            }

            if (!AyudaExtra.esStringNumerico(textBoxDOCNUMERO.Text.Trim()))
            {
                error += "El numero de documento debe ser numerico\n";
                //         MessageBox.Show("", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //          return true;
            }

            if (!AyudaExtra.esStringLetra(textBoxTIPODOC.Text.Trim()))
            {
                error += "Sólo se permiten letras en el Tipo de documento\n";
                //       MessageBox.Show("", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //      return true;
            }
            if (!AyudaExtra.esStringLetra(textBoxApellido.Text.Trim()) || !AyudaExtra.esStringLetra(textBoxNombre.Text.Trim()))
            {
                error += "Sólo se permiten letras en el campo nombre y apellido\n";
                //         MessageBox.Show("", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //          return true;
            }


            /*
             * if (contieneNumeroTIPODocumento(textBoxTIPODOC.Text))
             * {
             *  MessageBox.Show("Sólo se permiten letras en el Tipo de documento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  return;
             * }
             */

            if (textBoxTIPODOC.TextLength != 3)
            {
                error += "El TIPO DE DOCUMENTO tiene que tener 3 digitos\n";
                //         MessageBox.Show("", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //        return true;
            }
            if (error == "")
            {
                return(false);
            }
            MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return(true);
        }