Exemplo n.º 1
0
        public List <Sponsorer> GetSponsorer()
        {
            List <Sponsorer> Result      = new List <Sponsorer>();
            string           selectQuery = "SELECT * FROM Sponsorer";

            DataSet resultSet = Execute(selectQuery);

            DataTable dataTable = resultSet.Tables[0];

            foreach (DataRow dataRow in dataTable.Rows)
            {
                Sponsorer tableValue = new Sponsorer();
                int       id         = (int)dataRow["Id"];

                string companyName = (string)dataRow["Company_Name"];
                string branch      = (string)dataRow["Branch"];
                int    playerId    = (int)dataRow["PlayerID"];
                string playerName  = (string)dataRow["PlayerName"];
                double udgift      = (double)dataRow["Udgift"];
                tableValue.Id          = id;
                tableValue.CompanyName = companyName;
                tableValue.Branch      = branch;
                tableValue.PlayerId    = playerId;
                tableValue.PlayerName  = playerName;
                tableValue.Udgift      = udgift;
                Result.Add(tableValue);
            }
            return(Result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Makes it possible to update entry
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void redigerSponsorButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Id = (sponsorDataGrid.SelectedItem as Sponsorer).ID;

            Sponsorer updateSponsor = (from sponsor in _db.Sponsorers
                                       where sponsor.ID == Id
                                       select sponsor).Single();


            registrerButton.Content = "Update";

            // Fills TextBoxes with data from Spillere.ID
            firmanavnText.Text   = updateSponsor.Firmanavn;
            brancheComboBox.Text = updateSponsor.Branche;
            spillerIDText.Text   = updateSponsor.SpillerID.ToString();
            udgiftText.Text      = updateSponsor.Udgift.ToString();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Registering new and updating Spiller
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void registrerSponsorButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var buttonContent = (string)registrerButton.Content;

            // If buttons content is...
            if (buttonContent == "Update")
            {
                // Finds existing Spiller in Database...
                Sponsorer updateSponsor = (from sponsor in _db.Sponsorers
                                           where sponsor.ID == Id
                                           select sponsor).Single();

                // Reassigns values to existing instance of Spiller
                updateSponsor.Firmanavn = firmanavnText.Text;
                updateSponsor.Branche   = brancheComboBox.Text;
                updateSponsor.SpillerID = int.Parse(spillerIDText.Text);
                updateSponsor.Udgift    = int.Parse(udgiftText.Text);
            }
            // Otherwise...
            else
            {
                // Create a new Spiller and populate it with data from the form
                Sponsorer nySponsor = new Sponsorer()
                {
                    Firmanavn = firmanavnText.Text,
                    Branche   = brancheComboBox.Text,
                    SpillerID = int.Parse(spillerIDText.Text),
                    Udgift    = int.Parse(udgiftText.Text)
                };

                //// Adds new Spiller to database
                _db.Sponsorers.Add(nySponsor);
            }

            // Saves changes to satabase
            _db.SaveChanges();
            datagrid.ItemsSource = _db.Sponsorers.ToList();

            // Changes buttons content back
            if (buttonContent == "Update")
            {
                buttonContent = "Registrer";
            }
        }
Exemplo n.º 4
0
 public PlugLoader()
 {
     sponsorer      = new Sponsorer();
     appDomainTable = new Hashtable();
 }