示例#1
0
        private void Agregar_Producto_Load(object sender, EventArgs e)
        {
            
            n_genero gen = new n_genero();
            dataGenero.DataSource = gen.getTabla();
            //int cantFilasGeneros = dataGenero.Rows.Count-1;


            n_marca marc = new n_marca();
            dataMarca.DataSource = marc.getTabla();
            //int cantFilasMarcas = dataMarca.Rows.Count-1;

            n_pegi peg = new n_pegi();
            dataPEGI.DataSource = peg.getTabla();
            //int cantFilasPegis = dataPEGI.Rows.Count - 1;

            n_producto reg = new n_producto();
            int resu;
            resu = reg.obtenercantidadderegistros();
            resu = resu + 1;
            tbx_id.Text = resu.ToString();





            //for (int i = 1; i <= cantFilasMarcas; i++)
            //{
            //    clx_marca.Items.Add(marc.get(i).getnombre());

            //}
            //for (int i = 1; i <= cantFilasGeneros; i++)
            //{
            //    clx_genero.Items.Add(gen.get(i).getnombre());

            //}
            //for (int i = 1; i <= cantFilasPegis; i++)
            //{
            //    clx_pegi.Items.Add(peg.get(i).getnombre());

            //}

        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            
            
            int cont = 0;
            if (string.IsNullOrEmpty(tbx_nombre.Text))
            {
                tbx_nombre.BackColor = Color.Red;
                cont++;
            }

            if (string.IsNullOrEmpty(tbx_precio.Text))
            {
                tbx_precio.BackColor = Color.Red;
                cont++;
            }

            if (string.IsNullOrEmpty(tbx_desc.Text))
            {
                tbx_desc.BackColor = Color.Red;
                cont++;
            }
            ///------------------------------------------------------
            if (string.IsNullOrEmpty(tbx_Marca.Text))
            {
                tbx_Marca.BackColor = Color.Red;
                cont++;
            }

            if (string.IsNullOrEmpty(tbx_Pegi.Text))
            {
                tbx_Pegi.BackColor = Color.Red;
                cont++;
            }

            if (string.IsNullOrEmpty(tbx_Genero.Text))
            {
                tbx_Genero.BackColor = Color.Red;
                cont++;
            }

            if (string.IsNullOrEmpty(tbx_Cant.Text))
            {
                tbx_Cant.BackColor = Color.Red;
                cont++;
            }

            if (pictureBox1.Image == null)
            {
                error_portada.Visible = true;
            }

            ///---------------------------------------------------------
            if (cont > 0)
            {
                MessageBox.Show("Falta ingresar campos");
            }
            else
            {
                n_producto reg = new n_producto();

                
                direccion = pictureBox1.ToString();

                reg.AgregarProducto(tbx_id.Text, tbx_nombre.Text, tbx_Marca.Text, tbx_Genero.Text, tbx_Pegi.Text,tbx_Cant.Text, tbx_desc.Text, tbx_desc.Text, tbx_precio.Text);


                ///MessageBox.Show(direccion);


                File.Copy(nombre, Path.Combine(@"" + directory + "\\Portadas\\", Path.GetFileName(tbx_nombre.Text + ".jpg")), true);

                MessageBox.Show("Producto Agregado correctamente");
                tbx_id.Text = "";tbx_nombre.Text = "";tbx_Marca.Text = "";tbx_Genero.Text = "";tbx_Pegi.Text = "";tbx_Cant.Text = "";tbx_desc.Text = "";tbx_desc.Text = "";tbx_precio.Text = "";
                pictureBox1.Image = null;


                int resu;
                resu = reg.obtenercantidadderegistros();
                resu = resu + 1;
                tbx_id.Text = resu.ToString();
            }



        }