Пример #1
0
        public void creaVentanaArticulo()
        {
            titulo="Añadir articulo";
            ventana(titulo);
            Label cat=new Label("Introduce el nombre del nuevo articulo: ");
            text= new Entry();
            ComboBox cb=new ComboBox();
            Label cat2=new Label("Selecciona la categoria: ");
            combot= new ComboBoxHelper(App.Instance.DbConnection,cb,"nombre","id",0,"categoria");
            tabla.Attach(cat,0,1,0,1);
            tabla.Attach(text,1,2,0,1);
            tabla.Attach(cat2,0,1,1,2);
            tabla.Attach(cb,1,2,1,2);
            Label pre=new Label("Introduce el precio del nuevo articulo: ");
            precio=new Entry();
            tabla.Attach(pre,0,1,2,3);
            tabla.Attach(precio,1,2,2,3);
            Button button=new Button("Añadir");
                    button.Clicked +=delegate{
                    añadirArticulo(App.Instance.DbConnection);
                    if(!enBlanco){
                        window.Destroy();
                        refresh();
                }
            };

            tabla.Attach(button,1,2,3,4);
            window.Add(vbox);
            window.ShowAll();
        }
Пример #2
0
    //ListStore listStore;
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        IDbConnection dbConnection= new MySqlConnection("Server=localhost;Database=dbprueba;" +
                "User Id=root;Password=sistemas");
        dbConnection.Open();

        ComboBoxHelper combo= new ComboBoxHelper(dbConnection,Combobox,"nombre","id",1,"categoria");
        //listStore=combo.ListStore;

        //		TreeIter iter;
        //		liststore.GetIterFirst(out iter);
        //		do{
        //			if((int)liststore.GetValue(iter,0)==elementoInicial){
        //				break;
        //			}
        //		}
        //		while(liststore.IterNext(ref iter));

        Combobox.Changed +=delegate{
            Console.WriteLine("El id es {0}",combo.ID);
        };
    }
Пример #3
0
        public void creaVentanaArticulo()
        {
            App.Instance.Tabla=new Table(4,2,false);
            separaFilas(App.Instance.Tabla,10);
            App.Instance.vb.PackStart(App.Instance.Tabla,false,false,0);
            Label cat=new Label("Introduce el nombre del nuevo articulo: ");
            text= new Entry();
            ComboBox cb=new ComboBox();
            Label cat2=new Label("Selecciona la categoria: ");
            combot= new ComboBoxHelper(dbConnection,cb,"nombre","id",0,"categoria");

            App.Instance.Tabla.Attach(cat,0,1,0,1);
            App.Instance.Tabla.Attach(text,1,2,0,1);
            App.Instance.Tabla.Attach(cat2,0,1,1,2);
            App.Instance.Tabla.Attach(cb,1,2,1,2);
            Label pre=new Label("Introduce el precio del nuevo articulo: ");
            precio=new Entry();

            App.Instance.Tabla.Attach(pre,0,1,2,3);
            App.Instance.Tabla.Attach(precio,1,2,2,3);
            Button button=new Button("Añadir");
                    button.Clicked +=delegate{
                    añadirArticulo(dbConnection);
                    if(!enBlanco)
                        App.Instance.Wind.Destroy();
            };

            App.Instance.Tabla.Attach(button,1,2,3,4);
            App.Instance.Wind.ShowAll();
        }
Пример #4
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        IDbConnection dbConnection = new MySqlConnection(
            "Server=localhost;" +
            "Database=dbprueba;" +
            "User Id=root;" +
            "Password=sistemas");
        dbConnection.Open ();

        ComboBoxHelper comboBoxHelper = new ComboBoxHelper(
            comboBox,
            dbConnection,
            "id",
            "nombre",
            "categoria",
            2);

        comboBox.Changed += delegate {
            Console.WriteLine("comboBox.Changed id = {0}", comboBoxHelper.Id);
        };
    }
Пример #5
0
        private void edit()
        {
            titulo="Editar articulo";
            ventana(titulo);

            Label cat=new Label("Introduce el nuevo nombre del articulo: ");
            text= new Entry();

            string nombre="";
            int categoria=0;
            //double sprecio=0;
            decimal sprecio=0;

            IDbCommand dbCommand=App.Instance.DbConnection.CreateCommand();
            dbCommand.CommandText=string.Format ("select * from articulo where id={0}",helper.Id);

            IDataReader dataReader= dbCommand.ExecuteReader();
            while(dataReader.Read()){
                nombre=(string)dataReader.GetValue(1);
                categoria=(int)dataReader.GetValue(2);
                //sprecio=(double)dataReader.GetValue(3);
                sprecio=(decimal)dataReader.GetValue(3);
            }
            dataReader.Close();

            text.Text=nombre;

            ComboBox cb=new ComboBox();
            Label cat2=new Label("Selecciona la categoria: ");
            int id= categoria;
            combot= new ComboBoxHelper(App.Instance.DbConnection,cb,"nombre","id",id,"categoria");

            tabla.Attach(cat,0,1,0,1);
            tabla.Attach(text,1,2,0,1);
            tabla.Attach(cat2,0,1,1,2);
            tabla.Attach(cb,1,2,1,2);

            Label pre=new Label("Introduce el nuevo precio del articulo: ");
            precio=new Entry();
            precio.Text=sprecio.ToString();

            tabla.Attach(pre,0,1,2,3);
            tabla.Attach(precio,1,2,2,3);

            Button button=new Button();

                    button.Image= Image.LoadFromResource("PVenta2.g.png");

                    button.Clicked +=delegate{

                    string precioNuevo=precio.Text;
                    string nombreNuevo=text.Text;
                    int categoriaNueva=combot.ID;

                    if(nombreNuevo.Equals("") ||nombreNuevo.Equals(" ")){
                        string alert="El nombre no puede estar vacio";
                         crearAlerta(alert);
                        enBlanco=true;
                    }else if(categoriaNueva==0){
                        string alert="Elige una categoria";
                         crearAlerta(alert);
                        enBlanco=true;
                    }
                    else if(precioNuevo.Equals("") || precioNuevo.Equals(" ")){
                        string alert="El precio no puede estar vacio";
                         crearAlerta(alert);
                        enBlanco=true;
                    }
                    else{
                        if(!precioNuevo.Equals(sprecio)){
                            double precio2=double.Parse(precio.Text);
                            executeNonQuery(string.Format("update articulo set precio={0} where id={1}",precio2,helper.Id));
                        }
                        if(!nombreNuevo.Equals(nombre)){
                            executeNonQuery(string.Format("update articulo set nombre='{0}' where id={1}",nombreNuevo,helper.Id));
                        }
                        if(categoriaNueva!=id){
                            executeNonQuery(string.Format("update articulo set categoria={0} where id={1}",categoriaNueva,helper.Id));
                        }
                        enBlanco=false;
                        }

                    if(!enBlanco){
                        window.Destroy();
                        refresh();
                }
            };

            tabla.Attach(button,1,2,3,4);

            window.Add(vbox);
            window.ShowAll();
        }
Пример #6
0
 private void rellenaVentana()
 {
     tabla = new Tablas ();
     combohelper = new ComboBoxHelper (App.Instance.DbConnection,this.miCombo,"articulo","id",0,"televisor");
     inf = new Informacion ();
     helper = new TreeViewHelper (inf.getTreviewTelevisor(), "select * from televisor");
     helper2 = new TreeViewHelper (inf.getTreviewComprador(), "select saldo from comprador");
     Show ();
 }