Ejemplo n.º 1
0
        public bool AgregarProductosBd(Producto registro)
        {
            IDbConnection dbcon = this.ConectarBd();

                IDbCommand dbcmd = dbcon.CreateCommand();
                string sql =
                    "INSERT INTO productos (codigobarra,nombre,precio_venta,nombre_familia,pesable,vigente) " +
                        "VALUES ("+registro.Codigobarra+",'"+registro.Nombre+"','"+registro.Precioventa+"','"+registro.Familia+"','"+registro.Pesable+"','"+registro.Vigente+"');";

                dbcmd.CommandText = sql;
                IDataReader reader = dbcmd.ExecuteReader();

                dbcmd.Dispose();
                dbcmd = null;

                this.DesconectarBd(dbcon);

            return false;
        }
Ejemplo n.º 2
0
        protected void OnBotonAgregarPClicked(object sender, EventArgs e)
        {
            bool existe= this.db.ExisteRegistroProductosBd(entryCodigoBarra.Text.Trim());

            if (existe)	{
                Dialog dialog = new Dialog("PRODUCTO YA EXISTE", this, Gtk.DialogFlags.DestroyWithParent);
                dialog.Modal = true;
                dialog.Resizable = false;
                Gtk.Label etiqueta = new Gtk.Label();
                etiqueta.Markup = "El Producto que intenta agregar ya existe en la Base de Datos";
                dialog.BorderWidth = 8;
                dialog.VBox.BorderWidth = 8;
                dialog.VBox.PackStart(etiqueta, false, false, 0);
                dialog.AddButton ("Cerrar", ResponseType.Close);
                dialog.ShowAll();
             	dialog.Run ();
                dialog.Destroy ();
            }
            else
            {
                Producto prod = new Producto(entryCodigoBarra.Text.Trim(),entryNombre.Text.Trim(),Int32.Parse(entryPrecioVenta.Text.Trim()),comboboxFamiliaProd.ActiveText, checkbox,checkbox2);

                this.db.AgregarProductosBd(prod);

                Console.WriteLine("agrego producto");

                Dialog dialog = new Dialog("PRODUCTO INGRESADO", this, Gtk.DialogFlags.DestroyWithParent);
                dialog.Modal = true;
                dialog.Resizable = false;
                Gtk.Label etiqueta = new Gtk.Label();
                etiqueta.Markup = "El Producto ha sido ingresado a la Base de Datos";
                dialog.BorderWidth = 8;
                dialog.VBox.BorderWidth = 8;
                dialog.VBox.PackStart(etiqueta, false, false, 0);
                dialog.AddButton ("Cerrar", ResponseType.Close);
                dialog.ShowAll();
                dialog.Run ();
                dialog.Destroy ();

                this.CargarProductos();
                }
        }