コード例 #1
0
 public CreateEllection(Ellection ellection)
 {
     InitializeComponent();
     btnCreate.Visible = false;
     btnEdit.Visible   = false;
     if (ellection == null)
     {
         btnCreate.Visible = true;
     }
     else if (ellection != null)
     {
         this.ellection = ellection;
         tbName.Text    = ellection.Name;
         tbKind.Text    = ellection.Kind;
         tbSeats.Text   = ellection.Seats.ToString();
         dtpBegin.Value = ellection.BeginDate;
         dtpEnd.Value   = ellection.EndDate;
         if (ellection.Running)
         {
             rbTrue.Checked = true;
         }
         else if (!ellection.Running)
         {
             rbFalse.Checked = true;
         }
         btnEdit.Visible = true;
     }
 }
コード例 #2
0
 private void btnAddParty_Click(object sender, EventArgs e)
 {
     if (lbEllections.SelectedItem != null)
     {
         Ellection   ellection = (Ellection)lbEllections.SelectedItem;
         CreateParty popup     = new CreateParty(ellection.ID, null);
         popup.Show();
     }
 }
コード例 #3
0
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     lbEllections.DataSource = facade.GetAllEllections();
     if (lbEllections.SelectedItem != null)
     {
         Ellection ellection = lbEllections.SelectedItem as Ellection;
         lbParties.DataSource   = facade.GetPartiesFromEllection(ellection.ID);
         lbCoalition.DataSource = facade.GetAllResultsFromEllection(ellection.ID);
     }
 }
コード例 #4
0
 private void btnCoalition_Click(object sender, EventArgs e)
 {
     if (lbResults.SelectedItem != null && lbEllections.SelectedItem != null)
     {
         Result result = (Result)lbResults.SelectedItem;
         lbCoalition.DataSource = facade.GetCoalitionFromResult(result.ID);
         Ellection ellection = (Ellection)lbEllections.SelectedItem;
         lbEllectionParties.DataSource = facade.GetPartiesFromEllection(ellection.ID);
     }
     tabControl.SelectedIndex = 1;
 }
コード例 #5
0
        public int AddEllection(Ellection ellection)
        {
            string query = @"INSERT INTO [Verkiezing](BeginDatum, EindDatum, Lopend, Zetels, Soort, Naam) VALUES ('@begin', '@end', '@running', @seats, '@kind', '@name')";

            query = query.Replace("@begin", ellection.BeginDate.Date.ToString())
                    .Replace("@end", ellection.EndDate.Date.ToString())
                    .Replace("@running", ellection.Running.ToString())
                    .Replace("@seats", ellection.Seats.ToString())
                    .Replace("@kind", ellection.Kind)
                    .Replace("@name", ellection.Name);
            return(DatabaseConnection.Create(query));
        }
コード例 #6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Ellection ellection = (Ellection)lbEllections.SelectedItem;

            if (facade.DeleteEllection(ellection.ID))
            {
                MessageBox.Show("Verkiezing verwijderd");
            }
            else
            {
                MessageBox.Show("Er is iets fout gegaan");
            }
        }
コード例 #7
0
        public List <Ellection> GetAllEllections()
        {
            string           query      = @"SELECT * FROM [Verkiezing]";
            List <Ellection> ellections = new List <Ellection>();

            foreach (object[] data in DatabaseConnection.Read(query))
            {
                Ellection ellection = new Ellection((DateTime)data[1], (DateTime)data[2], (bool)data[3], (int)data[4], (string)data[5], (string)data[6]);
                ellection.SetID((int)data[0]);
                ellections.Add(ellection);
            }
            return(ellections);
        }
コード例 #8
0
        public bool EditEllection(Ellection ellection)
        {
            string query = @"UPDATE [Verkiezing] SET BeginDatum = '@begin', EindDatum = '@end', Lopend = '@running', Zetels = '@seats', Soort = '@kind', Naam = '@name' WHERE ID = @id ";

            query = query.Replace("@begin", ellection.BeginDate.Date.ToString())
                    .Replace("@end", ellection.EndDate.Date.ToString())
                    .Replace("@running", ellection.Running.ToString())
                    .Replace("@seats", ellection.Seats.ToString())
                    .Replace("@kind", ellection.Kind)
                    .Replace("@name", ellection.Name)
                    .Replace("@id", ellection.ID.ToString());
            return(DatabaseConnection.Update(query));
        }
コード例 #9
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     try
     {
         Ellection ellection = new Ellection(dtpBegin.Value, dtpEnd.Value, rbTrue.Checked, Convert.ToInt32(tbSeats.Text), tbKind.Text, tbName.Text);
         if (facade.CreateEllection(ellection))
         {
             MessageBox.Show("Verkiezing aangemaakt");
             this.Hide();
         }
         else
         {
             MessageBox.Show("Er is iets verkeerd gegaan, probeer opnieuw");
         }
     }
     catch
     {
         MessageBox.Show("Vull valide gegevens in");
     }
 }
コード例 #10
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         Ellection ellection = new Ellection(dtpBegin.Value, dtpEnd.Value, rbTrue.Checked, Convert.ToInt32(tbSeats.Text), tbKind.Text, tbName.Text);
         ellection.SetID(this.ellection.ID);
         if (facade.EditEllection(ellection))
         {
             MessageBox.Show("Verkiezing bijgewerkt");
             this.Close();
         }
         else
         {
             MessageBox.Show("Er is iets fout gegaan, probeer opnieuw");
         }
     }
     catch
     {
         MessageBox.Show("Vul valide gegevens in");
     }
 }
コード例 #11
0
 private void lbEllections_SelectedIndexChanged_1(object sender, EventArgs e)
 {
     if (lbEllections.SelectedItem != null)
     {
         Ellection ellection = (Ellection)lbEllections.SelectedItem;
         tbName.Text  = ellection.Name;
         tbKind.Text  = ellection.Kind;
         tbBegin.Text = ellection.BeginDate.ToString();
         tbEnd.Text   = ellection.EndDate.ToString();
         tbSeats.Text = ellection.Seats.ToString();
         if (ellection.Running)
         {
             tbRunning.Text = "Ja";
         }
         else if (!ellection.Running)
         {
             tbRunning.Text = "Nee";
         }
         lbParties.DataSource = facade.GetPartiesFromEllection(ellection.ID);
         lbResults.DataSource = facade.GetAllResultsFromEllection(ellection.ID);
     }
 }
コード例 #12
0
 public virtual void SetEllection(Ellection ellection)
 {
     throw new System.NotImplementedException();
 }
コード例 #13
0
 public bool UpdateEllection(Ellection ellection)
 {
     return context.EditEllection(ellection);
 }
コード例 #14
0
 public bool EditEllection(Ellection ellection)
 {
     return(ellectionrepo.UpdateEllection(ellection));
 }
コード例 #15
0
 public bool CreateEllection(Ellection ellection)
 {
     return(ellectionrepo.CreateEllection(ellection) != -1);
 }
コード例 #16
0
 public void SetEllection(Ellection ellection)
 {
     this.ellection = ellection;
 }
コード例 #17
0
 public int CreateEllection(Ellection ellection)
 {
     return context.AddEllection(ellection);
 }