Exemplo n.º 1
0
        public void agregarCategoriasP(String nombre)
        {
            Conectar con = new Conectar();

            if (nombre != String.Empty)
            {
                dr = con.getSqlQuery("Select * From Categoria_Productos where nombreCategoria ='" + nombre + "'");

                if (dr.Read())
                {
                    MessageBox.Show("El nombre de la categoria ya existe!.");
                }
                else
                {
                    String cadena = "Insert Into Categoria_Productos(nombreCategoria)";
                    cadena += "Values('" + nombre + "')";
                    con.Query(cadena);
                    con.Desconectar();
                }
            }
            else
            {
                MessageBox.Show("Por favor rellene el campo Nombre!.");
            }
        }
Exemplo n.º 2
0
        public void insertarProducto(int Categoria, String nombre, int precio, int stock, PictureBox pic)
        {
            Conectar cn = new Conectar();

            cn.Conectarx();

            if (nombre == String.Empty)
            {
                MessageBox.Show("Debe rellenar el campo nombre");
                return;
            }
            else if (precio.ToString() == String.Empty)
            {
                MessageBox.Show("Debe rellenar el campo precio");
                return;
            }
            else if (stock.ToString() == String.Empty)
            {
                MessageBox.Show("Debe rellenar el campo nombre");
                return;
            }
            else
            {
                String cadena = "INSERT INTO Productos(id_CatProducto,Nombre,Precio,Stock,Imagen)";

                cadena += "VALUES(@id,@nombre,@precio,@stock,@imagen)";

                SqlCommand cmd = new SqlCommand(cadena, cn.conexion);

                cmd.Parameters.Add("@id", SqlDbType.Int);
                cmd.Parameters.Add("@nombre", SqlDbType.VarChar);
                cmd.Parameters.Add("@precio", SqlDbType.Int);
                cmd.Parameters.Add("@stock", SqlDbType.Int);
                cmd.Parameters.Add("@imagen", SqlDbType.Image);
                cmd.Parameters["@id"].Value     = Categoria;
                cmd.Parameters["@nombre"].Value = nombre;
                cmd.Parameters["@precio"].Value = precio;
                cmd.Parameters["@stock"].Value  = stock;

                System.IO.MemoryStream ms = new System.IO.MemoryStream();

                pic.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                cmd.Parameters["@imagen"].Value = ms.GetBuffer();

                int c = cmd.ExecuteNonQuery();

                if (c > 0)
                {
                    MessageBox.Show("Producto insertado correctamente");
                }
                else
                {
                    MessageBox.Show("No se insertaron datos");
                    return;
                }
                cn.Desconectar();
            }
        }
Exemplo n.º 3
0
        public void actualizarDatosUsuarios(DataGridView DataGrid, String query)
        {
            con.Conectarx();

            /** obejeto dataset **/
            System.Data.DataSet d = new System.Data.DataSet();

            /** objeto data **/
            SqlDataAdapter da = new SqlDataAdapter(query, con.conexion);

            da.Fill(d, "Personas");

            DataGrid.DataSource = d;

            DataGrid.DataMember = "Personas";

            con.Desconectar();
        }
        private void btnTerminarVenta_Click(object sender, EventArgs e)
        {
            ValidarDatos vd = new ValidarDatos();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                //recorre las celdas y las va sumando
                total += Convert.ToInt32(row.Cells[3].Value);
                //recorre las seldas y va concatenando los id de los productos
                codigos += String.Concat(row.Cells[0].Value + ",");
            }

            precio_f = Convert.ToString(total);
            cn.Query("INSERT INTO Ventas (id_producto,id_cliente,id_MedioPago,fecha_Venta,PrecioVenta) Values ('" + codigos + "'," + id_cliente + ",1000,'" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + precio_f + "')");
            cn.Desconectar();

            this.GestionarStock();
        }