Пример #1
0
        private void btnagregar_Click(object sender, EventArgs e)
        {
            String nombre      = txtnombrecat.Text;
            String descripcion = txtdesccat.Text;

            try {
                if (nombre.Equals(""))
                {
                    MessageBox.Show("Debe ingresar un nombre a la categoria");
                }
                else
                {
                    String query = "insert into Categoria(nombre,Descripcion) values (@nombre,@descripcion)";

                    MySqlCommand cmd = new MySqlCommand();
                    //MySqlDataReader reader;

                    cmd.CommandText = query;
                    // cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection = conexion;
                    cmd.Parameters.AddWithValue("nombre", nombre);
                    cmd.Parameters.AddWithValue("descripcion", descripcion);
                    operacionesformulario.insertar(cmd, conexion);
                    llenarcategorias();
                }
            }

            catch (Exception es) {
                MessageBox.Show(es.ToString());
            }
        }
Пример #2
0
 private void botonagregar_Click(object sender, EventArgs e)
 {
     if (textonombre.Text == "" || textoid.Text == "" || textodescripcion.Text == "")
     {
         MessageBox.Show("Debe rellenar todos los campos.");
     }
     else
     {
         try {
             if (numero(textoid.Text))
             {
                 String       query = "INSERT into estadopedido(idestadopedido,Nombre,descripcion) values(@id,@name,@descripcion)";
                 MySqlCommand cmd   = new MySqlCommand();
                 cmd.CommandText = query;
                 cmd.Connection  = conexion;
                 cmd.Parameters.AddWithValue("id", textoid.Text);
                 cmd.Parameters.AddWithValue("name", textonombre.Text);
                 cmd.Parameters.AddWithValue("descripcion", textodescripcion.Text);
                 operacionesformulario.insertar(cmd, conexion);
                 llenarestadopedido();
                 textonombre.Text      = "";
                 textoid.Text          = "";
                 textodescripcion.Text = "";
             }
             else
             {
                 MessageBox.Show("El código no es un valor numérico.");
             }
         }
         catch (Exception es)
         {
             MessageBox.Show(es.ToString());
         }
     }
 }
Пример #3
0
        private void botonagregar_Click(object sender, EventArgs e)
        {
            if (textonombre.Text == "" || textocontrasena.Text == "" || textocontrasena2.Text == "" || comboBox1.Text == "")
            {
                MessageBox.Show("Debe rellenar todos los campos.");
            }
            else
            {
                if (textocontrasena.Text != textocontrasena2.Text)
                {
                    MessageBox.Show("Las contraseñas no coinciden.");
                }
                else
                {
                    String nombre = textonombre.Text;
                    String contra = textocontrasena.Text;
                    int    activo = 0;
                    int    rol    = 0;
                    if (checkBox1.Checked)
                    {
                        activo = 1;
                    }
                    if (comboBox1.SelectedIndex == 0)
                    {
                        rol = 1;
                    }
                    else
                    {
                        rol = 2;
                    }


                    try
                    {
                        String       query = "INSERT into usuario(Nombre,FechadeCreacion,Password,Activo,Tipousuario_idTipousuario) values(@user,Now(),md5(@contra),@active,@type)";
                        MySqlCommand cmd   = new MySqlCommand();
                        cmd.CommandText = query;
                        cmd.Connection  = conexion;
                        cmd.Parameters.AddWithValue("user", nombre);
                        cmd.Parameters.AddWithValue("contra", contra);
                        cmd.Parameters.AddWithValue("active", activo);
                        cmd.Parameters.AddWithValue("type", rol);
                        operacionesformulario.insertar(cmd, conexion);
                        llenarusuarios();
                        limpiar();
                    }
                    catch (Exception es)
                    {
                        MessageBox.Show(es.ToString());
                    }
                }
            }
        }
Пример #4
0
        private void btnagregar_Click(object sender, EventArgs e)
        {
            Nombre         = txtnombreprod.Text;
            descripcion    = txtdescripcion.Text;
            preciocompra   = Convert.ToDouble(txtprecompra.Text);
            precioventa    = Convert.ToDouble(txtpreventa.Text);
            cantidadtienda = Convert.ToInt32(txtcanttienda.Text);
            cantidadbodega = Convert.ToInt32(txtcantbodega.Text);

            try
            {
                if (Nombre.Equals("") || txtprecompra.Text.Equals("") || txtpreventa.Text.Equals("") || txtcanttienda.Text.Equals("") || txtcantbodega.Text.Equals(""))
                {
                    MessageBox.Show("Debe ingresar todos los datos requeridos");
                }
                else
                {
                    String query = "insert into Producto(nombre,descripcion,imagen,fechaingreso,Preciocompra,Precioventa,idCategoria,idtipounidad,idestadoproducto) values (@nombre,@descripcion,@imagen,Now(),@Preciocompra,@Precioventa,@idCategoria,@idtipounidad,@idestadoproducto)";

                    MySqlCommand cmd = new MySqlCommand();
                    //MySqlDataReader reader;

                    cmd.CommandText = query;
                    // cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection = conexion;
                    cmd.Parameters.AddWithValue("nombre", Nombre);
                    cmd.Parameters.AddWithValue("descripcion", descripcion);
                    cmd.Parameters.AddWithValue("imagen", rutaimagen);
                    cmd.Parameters.AddWithValue("Preciocompra", preciocompra);
                    cmd.Parameters.AddWithValue("Precioventa", precioventa);
                    cmd.Parameters.AddWithValue("idCategoria", indicecategoria);
                    cmd.Parameters.AddWithValue("idtipounidad", indicetipounidad);
                    cmd.Parameters.AddWithValue("idestadoproducto", indiceestadoprod);

                    operacionesformulario.insertar(cmd, this.conexion);
                    insertarproductolocacion();
                    llenargridProductos();
                    llenargridPrincipal();
                    limpiarvariablesycampos();
                    //  llenarcategorias();
                }
            }

            catch (Exception es)
            {
                MessageBox.Show(es.ToString());
            }
        }