예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime myDate = this.incio.Value.Date; //+

            //dTimePiker_HoraNueva.Value.TimeOfDay;
            if (this.Tdescripcon.TextLength == 0)
            {
                MessageBox.Show("La descripcion no puede ser vacia");
                return;
            }



            if ((DateTime.Compare(myDate, ((DateTime)Properties.Settings.Default.FECHA_HORA_APP).Date)) < 0)
            {
                MessageBox.Show("No se puede settear una fecha de publicacion anterior a la actual.");
                return;
            }

            DateTime myDate2 = this.fin.Value.Date; //+

            //dTimePiker_HoraNueva.Value.TimeOfDay;

            if ((DateTime.Compare(myDate, myDate2)) >= 0)
            {
                MessageBox.Show("La publicacion minima es de 1 dia.");
                return;
            }

            string datos = "";

            datos += @"Estado: " + this.Cestado.SelectedValue.ToString();
            datos += @"Rubro: " + this.Crubro.SelectedValue.ToString();
            if (this.RBCompraInmediata.Checked == true)
            {
                datos += @"Tipo: Compra Inmediata";
            }
            else
            {
                datos += @"Tipo: Subasta";
            }
            if (preguntas.Checked == true)
            {
                datos += @"Preguntas: 1";
            }
            else
            {
                datos += @"Preguntas: 0";
            }
            datos += @"Stock: " + this.NUstock.Value.ToString();
            datos += @"Precio: " + this.NUprecio.Value.ToString();
            datos += @"Inicio: " + this.incio.Value.Date.ToString();
            datos += @"Fin: " + this.fin.Value.Date.ToString();


            publicar_dto dto = new publicar_dto();


            dto.setestado(this.Cestado.SelectedValue.ToString());
            dto.setidrubro(this.Crubro.SelectedValue.ToString());

            if (this.RBCompraInmediata.Checked == true)
            {
                dto.settipo_publicacion("Compra Inmediata");
            }
            else
            {
                dto.settipo_publicacion("Subasta");
            }

            if (preguntas.Checked == true)
            {
                dto.setpermitir_preguntas("1");
            }
            else
            {
                dto.setpermitir_preguntas("0");
            }

            if (CBenvio.Checked == true)
            {
                dto.setenvio("1");
            }
            else
            {
                dto.setenvio("0");
            }

            if (this.Cvisibilidad.Items.Count > 0)
            {
                dto.setidvisibilidad(this.Cvisibilidad.SelectedValue.ToString());
            }
            else
            {
                MessageBox.Show("No hay visibilidades, consulte a su administrador, no se podra publicar");
                return;
            }

            dto.setstock(this.NUstock.Value.ToString());
            dto.setprecio(this.NUprecio.Value.ToString());
            dto.setcosto(this.NUprecio.Value.ToString());

            // MessageBox.Show("Precio "+dto.getprecio());
            dto.setfecha_inicio(this.incio.Value.Date);
            // MessageBox.Show("Fecha I " + dto.getfecha_inicio());
            dto.setfecha_vencimiento(this.fin.Value.Date);
            // MessageBox.Show("Fecha V " + dto.getfecha_vencimiento());

            dto.setdescp(this.Tdescripcon.Text.ToString());
            dto.setidusuario(this.id);
            _conexionSQL conectarBD = _conexionSQL.Instance;
            Boolean      retorno    = conectarBD.publicar(dto);

            if (retorno == true)
            {
                MessageBox.Show("Publicacion exitosa");
                //this.Tdescripcon.Text += datos;
            }
            else
            {
                MessageBox.Show("Problemas con la base de datos");
            }
        }
예제 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                this.display.Enabled = true;
                this.display.Visible = true;
                DataGridViewRow fila = this.DGBuscar.Rows[e.RowIndex];
                if (Convert.ToString(fila.Cells["tipo_publicacion"].Value).Equals("Compra Inmediata"))
                {
                    this.Bcomprar.Enabled       = true;
                    this.Bcomprar.Visible       = true;
                    this.Bcomprar.Text          = "Comprar";
                    this.Cantidad.Enabled       = true;
                    this.Cantidad.Visible       = true;
                    this.Cantidad.Minimum       = 1;
                    this.Cantidad.Value         = 1;
                    this.Cantidad.DecimalPlaces = 0;


                    this.Cantidad.Increment = 1;
                    this.Cantidad.Maximum   = Convert.ToInt32(fila.Cells["DGstock"].Value);
                }
                else
                {
                    this.Bcomprar.Enabled       = true;
                    this.Bcomprar.Visible       = true;
                    this.Bcomprar.Text          = "Ofertar";
                    this.Cantidad.Enabled       = true;
                    this.Cantidad.Visible       = true;
                    this.Cantidad.Minimum       = Convert.ToDecimal(fila.Cells["DGprecio"].Value) + 1;
                    this.Cantidad.Maximum       = 99999999;
                    this.Cantidad.DecimalPlaces = 2;
                    this.Cantidad.Increment     = Convert.ToDecimal(0.5);
                    this.Cantidad.Value         = Convert.ToDecimal(fila.Cells["DGprecio"].Value) + 1;
                }

                String texto = "";
                texto += @"Descripcion: " + Convert.ToString(fila.Cells["DGdescripcion"].Value) + System.Environment.NewLine;
                texto += @"Stock: " + Convert.ToString(fila.Cells["DGstock"].Value) + System.Environment.NewLine;

                texto += @"Precio: " + Convert.ToString(fila.Cells["DGprecio"].Value) + System.Environment.NewLine;
                texto += @"Vencimiento: " + Convert.ToString(fila.Cells["fecha_vencimiento"].Value) + System.Environment.NewLine;
                texto += @"Rubro: " + Convert.ToString(fila.Cells["idrubro"].Value) + System.Environment.NewLine;
                texto += @"Tipo: " + Convert.ToString(fila.Cells["tipo_publicacion"].Value) + System.Environment.NewLine;
                texto += @"Preguntas: " + Convert.ToString(fila.Cells["permitir_preguntas"].Value) + System.Environment.NewLine;
                if (fila.Cells["permitir_preguntas"].Value.Equals(true))
                {
                    //this.pr_buscar_productoTableAdapter.Fill(this.buscar_producto.pr_buscar_producto, 1, 5, id, "", "");
                    this.DGpreguntas.Visible      = true;
                    this.DGpreguntas.Enabled      = true;
                    this.preguntar.Visible        = true;
                    this.preguntar.Enabled        = true;
                    this.textBoxpreguntas.Visible = true;
                    this.textBoxpreguntas.Enabled = true;
                    this.label3.Visible           = true;
                    this.label3.Enabled           = true;
                    this.pr_preguntasTableAdapter.Fill(this.preguntas.pr_preguntas, Convert.ToString(fila.Cells["idpublicacion"].Value));
                }
                else
                {
                    this.DGpreguntas.Visible      = false;
                    this.DGpreguntas.Enabled      = false;
                    this.preguntar.Visible        = false;
                    this.preguntar.Enabled        = false;
                    this.textBoxpreguntas.Visible = false;
                    this.textBoxpreguntas.Enabled = false;
                    this.label3.Visible           = false;
                    this.label3.Enabled           = false;
                }

                texto += @"Envio: " + Convert.ToString(fila.Cells["permitir_envio"].Value) + System.Environment.NewLine;
                if (Convert.ToString(fila.Cells["permitir_envio"].Value).Equals("True"))
                {
                    this.CBEnvio.Visible = true;
                    this.CBEnvio.Enabled = true;
                }
                else
                {
                    this.CBEnvio.Visible = false;
                    this.CBEnvio.Enabled = false;
                }

                texto += @"PublicionId: " + Convert.ToString(fila.Cells["idpublicacion"].Value) + System.Environment.NewLine;
                texto += @"Vendedor: " + Convert.ToString(fila.Cells["idusuario"].Value);
                this.TBdescripcion.Text = texto;


                dto.setidusuario(id);
                dto.setidpublicacion(Convert.ToString(fila.Cells["idpublicacion"].Value));

                dto.setfechasys(this.fechaHoraLocal);

                //
                dto.setprecio(Convert.ToString(fila.Cells["DGprecio"].Value));
            }
        }