Ejemplo n.º 1
0
        /// <summary>
        /// Gets all existing Projekte from the Database and adds them to the existingProjekteComboBox
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The event args</param>
        public static void BindFromExistingProjekteToComboBox(object sender, EventArgs e)
        {
            // check sender for null
            if (sender == null)
            {
                return;
            }

            List<ProjektTable> results;

            // add empty element to make empty choices possible
            List<string> listItems = new List<string>();
            listItems.Add("");

            ProjektManager loader = new ProjektManager();

            // Load all existing Projekte to object result list
            results = loader.Load(-1, new DateTime(1900, 1, 1), new DateTime(2100, 1, 1), null);

            // if there are results, add them to string result list
            if (results.Count != 0)
            {
                foreach (ProjektTable projekt in results)
                {
                    string entry = projekt.ID + ": " + projekt.Projektname;
                    listItems.Add(entry);
                }
            }

            // set data source
            (sender as ComboBox).DataSource = listItems;
        }
Ejemplo n.º 2
0
        private void projektSuchenSearchButton_Click(object sender, EventArgs e)
        {
            logger.Log(Logger.Level.Info, "projekt search button pressed");

            // get selected KundenID
            // force searching for existing Kunden, if Kunde has not dropped down the ComboBox (would throw Exception otherwise)
            if (this.projektSuchenKundeCombobox.SelectedIndex < 0)
            {
                GlobalActions.BindFromExistingKundenToComboBox(this.projektSuchenKundeCombobox, null);
            }

            this.projektSuchenMessageLabel.Hide();

            string kundenID = this.projektSuchenKundeCombobox.SelectedItem.ToString();
            int id = -1;
            try
            {
                id = GlobalActions.GetIdFromCombobox(kundenID, projektSuchenMessageLabel);
                logger.Log(Logger.Level.Info, "kundenid in projekt search: " + id);
            }
            catch(InvalidInputException)
            {
                logger.Log(Logger.Level.Error, "Unknown Exception while getting ID from Projekte from AngeboteTab!");
            }
            //logger.Log(Logger.Level.Info, "KundenID:" +id);

            // get Angebot in SDS format: 6/1/2009
            DateTime from = this.projektSuchenVonDatepicker.Value;
            DateTime until = this.projektSuchenBisDatepicker.Value;

            ProjektManager manager = new ProjektManager();
            List<ProjektTable> results = new List<ProjektTable>();

            try
            {
                results = manager.Load(id, from, until, this.projektSuchenMessageLabel);
                logger.Log(Logger.Level.Info,"resultslength: "+results.Count);
            }
            catch (DataBaseException ex)
            {
                this.logger.Log(Logger.Level.Error, "A serious problem with the database has occured. Program will be exited. " + ex.Message + ex.StackTrace);
                Application.Exit();
            }

            this.projektSearchBindingSource.DataSource = results;
        }