Пример #1
0
 private void btnVolver_Click(object sender, EventArgs e)
 {
     frmPrincipal frmPrincipal= new frmPrincipal();
     this.Hide();
     frmPrincipal.ShowDialog();
     frmPrincipal = (frmPrincipal)this.ActiveMdiChild;
 }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     frmPrincipal visibilidad = new frmPrincipal();
     this.Hide();
     visibilidad.ShowDialog();
     visibilidad = (frmPrincipal)this.ActiveMdiChild;
 }
Пример #3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            /* insert de monto y fecha */
            if (Convert.ToDouble(txtMontoOferta.Text) > Convert.ToDouble(lblMontoActual.Text))
            {
                string oferta = "insert into JJRD.OFERTAS (COD_PUBLICACION, ID_CLIENTE, MONTO, FECHA) " +
                                "values ( " + cod_Publicacion + ", " + fn.ObtenerIdCliente(Globales.idUsuarioLogueado) + "," + txtMontoOferta.Text + ", '" + Globales.fechaSistema + "')";

                Query qry = new Query(oferta);
                qry.Ejecutar();

                MessageBox.Show("Oferta realizada con éxito!");
                this.Hide();
                frmPrincipal frm = new frmPrincipal();
                frm.ShowDialog();
            }
            else
            {
                MessageBox.Show("El monto ingresado debe ser superior");
            }
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtPregunta.Text.Trim().Length > 0)
            {

                string pregunta = "insert into JJRD.PREGUNTAS (COD_PUBLICACION, ID_CLIENTE, PREGUNTA_DESCRIPCION) " +
                "values ( " + codigo + ", " + fn.ObtenerIdCliente(Globales.idUsuarioLogueado) + ",'" + txtPregunta.Text + "')";

                Query qry = new Query(pregunta);
                qry.Ejecutar();

                MessageBox.Show("Pregunta realizada correctamente!");

                frmPrincipal frm = new frmPrincipal();
                this.Hide();
                frm.ShowDialog();

            }
            else
            {
                MessageBox.Show("Por favor ingrese una pregunta.");
            }
        }
Пример #5
0
        private void bnGuardar_Click(object sender, EventArgs e)
        {
            //Controlar que los datos no sean nulos

            if ((txtCodigo.Text != "")&&
                (txtDescripcion.Text.Trim() != "" ) &&
                (txtStock.Text.Trim() != "" ) &&

                (txtPrecio.Text.Trim() != "" ) &&
                (txtDescripcion.Text.Trim() != "" ) &&
                (comboBoxVisibilidad.Text != "" ) &&

                (comboBoxEstadoPublicacion.Text != "") &&

                (comboBoxPreguntas.Text != ""))

            {
                //Busca codigo de visibilidad y se lo guarda

                string visibilidad = "SELECT COD_VISIBILIDAD FROM JJRD.VISIBILIDAD WHERE DESCRIPCION = '" + comboBoxVisibilidad.Text + "'";
                Query qr = new Query(visibilidad);

                decimal idVisibilidad = (decimal)qr.ObtenerUnicoCampo();

                //Busca codigo de publicacion y se lo guarda

                string codigoPublicacion = "SELECT MAX(COD_PUBLICACION+1) FROM JJRD.PUBLICACION";
                Query qry = new Query(codigoPublicacion);

                decimal idPublicacion = (decimal)qry.ObtenerUnicoCampo();

                 //Busca codigo de estado y se lo guarda

                string consultaEstado = "SELECT ID FROM JJRD.ESTADO_PUBLICACION WHERE DESCRIPCION = '" + comboBoxEstadoPublicacion.Text + "'";

                Query qry3 = new Query(consultaEstado);

                int idEstado = (int)qry3.ObtenerUnicoCampo();

                //inserta publicacion

                if (comboBoxVisibilidad.Text == "Gratis" && comboBoxEstadoPublicacion.Text == "Publicada")
                {

                    //insertar en tabla usuarios contador publicacion gratis

                    string publicacionesGratisUsuario = "SELECT PUBLICACIONES_GRATIS FROM JJRD.USUARIOS WHERE ID_USUARIO =" + idUsuario;
                    Query qry4 = new Query(publicacionesGratisUsuario);
                    int cantidadPublicacionesGratis = (int)qry4.ObtenerUnicoCampo();

                    if (cantidadPublicacionesGratis >= 3)
                    {
                        //Mensaje de Error, usted ya tiene 3 publicaciones gratis

                        MessageBox.Show("Usted ya tiene 3 Publicaciones Gratis", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        //Volver a llenar el formulario

                        FrmPublicacionCompraInmediata volver = new FrmPublicacionCompraInmediata(idUsuario);
                        this.Hide();
                        volver.ShowDialog();
                        volver = (FrmPublicacionCompraInmediata)this.ActiveMdiChild;

                    }
                    else
                    {

                        //Incrementar y generar publicaciones

                        //incrementa publicaciones gratis
                        cantidadPublicacionesGratis = cantidadPublicacionesGratis + 1;

                        string actualizar = "UPDATE JJRD.USUARIOS SET  PUBLICACIONES_GRATIS = " + cantidadPublicacionesGratis + " WHERE ID_USUARIO = " + idUsuario + "";

                        new Query(actualizar).Ejecutar();

                        //inserta publicacion

                        string generar = "INSERT INTO JJRD.PUBLICACION (COD_PUBLICACION,ID_USUARIO,COD_VISIBILIDAD, DESCRIPCION, STOCK, PRECIO,FECHA_VENCIMIENTO,FECHA_INICIO, ID_ESTADO_PUBLICACION, ID_TIPO_PUBLICACION, PREGUNTAS) " +
                                         "  values (" + idPublicacion + "," + idUsuario + "," + idVisibilidad + ",'" + txtDescripcion.Text + "'," + txtStock.Text + "," + txtPrecio.Text + ",'" + txtFechaVencimiento.Text + "','" + Globales.fechaSistema + "'," + idEstado + ",'" + 1 + "','" + comboBoxPreguntas.Text + "')";

                        Query qry2 = new Query(generar);
                        qry2.Ejecutar();

                         }

                }
                else {

                        //inserta comun

                    string generar = "INSERT INTO JJRD.PUBLICACION (COD_PUBLICACION,ID_USUARIO,COD_VISIBILIDAD, DESCRIPCION, STOCK, PRECIO,FECHA_VENCIMIENTO,FECHA_INICIO, ID_ESTADO_PUBLICACION, ID_TIPO_PUBLICACION, PREGUNTAS) " +
                                          "  values (" + idPublicacion + "," + idUsuario + "," + idVisibilidad + ",'" + txtDescripcion.Text + "'," + txtStock.Text + "," + txtPrecio.Text + ",'" + txtFechaVencimiento.Text + "','" + Globales.fechaSistema + "'," + idEstado + ",'" + 1 + "','" + comboBoxPreguntas.Text + "')";

                    Query qry2 = new Query(generar);
                    qry2.Ejecutar();

                        }

                         //Inserta Publicacion_Rubro

                         for (int i = 0; i < listaRubros.Items.Count; i++)
                         {
                             if (listaRubros.GetItemChecked(i))
                             {
                                 string item = listaRubros.Items[i].ToString();
                                 string unRubro = item.Replace(']', ' ').Substring(item.LastIndexOf(',') + 1).TrimEnd();

                                 string publicacionrubro = "INSERT INTO JJRD.Publicacion_Rubro (COD_RUBRO,COD_PUBLICACION) " +
                                                   "  values (" + unRubro + "," + idPublicacion + ")";

                                 Query qry10 = new Query(publicacionrubro);
                                 qry10.Ejecutar();

                             }
                         }

                         //INCREMENTA CONTADOR EN BONIFICACIONES
                         fn.actualizarBonificaciones(idUsuario, idVisibilidad, idPublicacion);

                         MessageBox.Show("Publicacion Realizada Correctamente", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information);

                         //Ir al menu principal

                         frmPrincipal publicacion = new frmPrincipal();
                         this.Hide();
                         publicacion.ShowDialog();
                         publicacion = (frmPrincipal)this.ActiveMdiChild;

            }else

                    {
                        MessageBox.Show("No se pueden Ingresar Campos Vacios", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
        }