Esempio n. 1
0
        public static void Main(string[] args)
        {
            try
            {
                InvoiceDirectory idir = new InvoiceDirectory();

                Gtk.Application.Init();
                MainWindow win = new MainWindow(idir);
                win.Show();
                Gtk.Application.Run();
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Error in " + e.TargetSite + ": " + e.Message);
            }
        }
        public MainWindow(InvoiceDirectory idir_)
            : base(WindowType.Toplevel)
        {
            idir = idir_;

            SetSizeRequest(500, 500);
            Title = "Fakturering 2.6";

            maingroup = new HBox(false, 0);
            buttons = new VButtonBox();
            scrolledhd = new ScrolledWindow();
            create   = Button.NewWithLabel("Skapa ny faktura");
            edit     = Button.NewWithLabel("Redigera faktura");
            delete   = Button.NewWithLabel("Radera faktura");
            showbut  = Button.NewWithLabel("Visa faktura");
            printbut = Button.NewWithLabel("Skriv ut faktura");

            CreateListView();

            Add(maingroup);
            maingroup.PackStart(scrolledhd, true, true, 0);
            maingroup.PackStart(buttons, false, false, 0);
            buttons.Layout = ButtonBoxStyle.Start;
            buttons.PackStart(create,   false, false, 0);
            buttons.PackStart(edit,     false, false, 0);
            buttons.PackStart(showbut,  false, false, 0);
            buttons.PackStart(printbut, false, false, 0);
            buttons.PackStart(delete,   false, false, 0);
            scrolledhd.AddWithViewport(listview);
            scrolledhd.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);

            UpdateHDList();

            create.Clicked   += new EventHandler(Create);
            edit.Clicked     += new EventHandler(Edit);
            delete.Clicked   += new EventHandler(DeleteInvoice);
            showbut.Clicked  += new EventHandler(ShowInvoice);
            printbut.Clicked += new EventHandler(PrintInvoice);

            maingroup.ShowAll();

            //Den här måste vara här då storleken inte är känd innan
            ScrollToEnd(scrolledhd);

            DeleteEvent += new Gtk.DeleteEventHandler(DeleteWindow);
        }
        public EditWindow(Invoice invoice,
		                  string file,
		                  InvoiceDirectory idir_,
                          InvoicesChanged cb)
            : base(WindowType.Toplevel)
        {
            loadedFile = file;
            idir = idir_;
            callback = cb;

            VBox box = new VBox(false, 0);
            table = new Table(7, 3, false);
            Table tablespec = new Table(16, 4, false);
            tablesum = new Table(4, 2, false);

            HButtonBox buttons = new HButtonBox();
            Button save = Button.NewWithLabel("Spara");
            Button abort = Button.NewWithLabel("Avbryt");

            namn = new Entry();
            address = new Entry();
            postnr = new Entry();
            postort = new Entry();
            referens = new Entry();
            datum = new Entry();
            fakturanr = new Entry();
            antaldgr = new Entry();

            ScrolledWindow scrolled = new ScrolledWindow();
            Button GetAddress = Button.NewWithLabel("Slå upp address");

            Add(box);
            scrolled.AddWithViewport(tablespec);
            scrolled.SetPolicy(PolicyType.Never, PolicyType.Automatic);
            box.PackStart(table, false, false, 0);
            box.PackStart(scrolled, true, true, 0);
            scrolled.SetUsize(~1, 250);

            box.PackStart(tablesum, false, false, 0);
            box.PackStart(buttons,  false, false, 0);

            buttons.PackStart(save);
            buttons.PackStart(abort);

            specs = new Spec[15];
            for (uint i=0; i<15; i++) {
                specs[i] = new Spec(invoice.specs[i], tablespec, i + 1);
                specs[i].Changed += RecalcSum;
            }

            tablespec.Attach(new Label("Beskrivning"), 0, 1, 0, 1, 0, 0, 0, 0);
            tablespec.Attach(new Label("Antal"),       1, 2, 0, 1, 0, 0, 0, 0);
            tablespec.Attach(new Label("À pris"),      2, 3, 0, 1, 0, 0, 0, 0);
            tablespec.Attach(new Label("Belopp"),      3, 4, 0, 1, 0, 0, 0, 0);

            SetPosition(WindowPosition.Center);

            namn.Changed += UpdateTitle;
            fakturanr.Changed += UpdateTitle;

            namn.Text = invoice.namn;
            address.Text = invoice.address;
            postnr.Text = invoice.postnr;
            postort.Text = invoice.postort;
            referens.Text = invoice.referens;
            datum.Text = invoice.datum;
            fakturanr.Text = invoice.fakturanr;
            antaldgr.Text = invoice.antaldgr;

            labround = new Label("0");
            labsum   = new Label("0");
            labmoms  = new Label("0");
            labtot   = new Label("0");

            RecalcSum();

            Attach2(0, "Namn", namn);
            table.Attach(GetAddress, 2, 3, 0, 1, 0, 0, 0, 0);
            Attach2(1, "Address", address);
            Attach2(2, "Postnummer", postnr);
            Attach2(3, "Postort", postort);
            Attach2(4, "Er referens", referens);
            Attach2(5, "Datum", datum);
            Attach2(6, "Fakturanummer", fakturanr);
            Attach2(7, "Antal dagar",   antaldgr);

            Attach3(0, "Avrundning", labround);
            Attach3(1, "Summa", labsum);
            Attach3(2, "Moms", labmoms);
            Attach3(3, "Att betala", labtot);

            abort.Clicked += Abort;
            save.Clicked += Save;
            GetAddress.Clicked += FindAddress;

            box.ShowAll();
        }