Beispiel #1
0
        /// <summary>
        /// Funktion som skriver ut vilka fordon man har hyrt och vilka datum det gäller
        /// </summary>
        private void fyllHyrningar()
        {
            hyrnings_objekt hyrning = new hyrnings_objekt(new SqlCeDatabase(), this.anvandare);
            SortedList<string, string>[] HyrningsResultat = hyrning.hamtaMinaHyrningar();

            if (HyrningsResultat.Length == 0)
            {
                this.tableLayoutPanelHyrning.Hide();
                this.labelHyrningMeddelande.Text = "Du har inga hyrda fordon";
                this.labelHyrningMeddelande.Show();
            }

            if (this.tableLayoutPanelHyrning.Visible)
            {
                int length = HyrningsResultat.Length;
                for (int i = 0; i < length; i++)
                {
                    SortedList<string, string> hyrningsString = HyrningsResultat[i] as SortedList<string, string>;
                    Label labelHyrningStartDatum = new Label(), labelHyrningSlutDatum = new Label(), labelHyrningFordon = new Label(), labelTabortHyrningar = new Label();
                    Label[] labelHyrning = { labelHyrningStartDatum, labelHyrningSlutDatum, labelHyrningFordon, labelTabortHyrningar };
                    for (int o = 0; o < 4; o++)
                    {
                        switch (o)
                        {
                            case 0:
                                labelHyrning[o].Text = hyrningsString["Startdag"];
                                break;

                            case 1:
                                labelHyrning[o].Text = hyrningsString["Slutdag"];
                                break;

                            case 2:
                                labelHyrning[o].Text = hyrningsString["Fordon"];
                                break;

                            case 3:
                                labelHyrning[o].Text = "Ta bort";
                                labelHyrning[o].Name = "Tabort_" + hyrningsString["Hyrning"];
                                labelHyrning[o].Cursor = Cursors.Hand;
                                labelHyrning[o].Click += new System.EventHandler(this.TaBort);
                                break;
                        }
                        this.tableLayoutPanelHyrning.Controls.Add(labelHyrning[o]);
                    }
                }
            }
        }