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; } }
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(); } }
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); } }
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; }
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)); }
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"); } }
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); }
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)); }
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"); } }
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"); } }
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); } }
public virtual void SetEllection(Ellection ellection) { throw new System.NotImplementedException(); }
public bool UpdateEllection(Ellection ellection) { return context.EditEllection(ellection); }
public bool EditEllection(Ellection ellection) { return(ellectionrepo.UpdateEllection(ellection)); }
public bool CreateEllection(Ellection ellection) { return(ellectionrepo.CreateEllection(ellection) != -1); }
public void SetEllection(Ellection ellection) { this.ellection = ellection; }
public int CreateEllection(Ellection ellection) { return context.AddEllection(ellection); }