private void Btndetail1_Click(object sender, EventArgs e) { var mess = MessageBox.Show("Pilih " + labelNama.Text, "Yakin?", MessageBoxButtons.YesNo); if (mess == DialogResult.Yes) { kandidat kandidat = new kandidat(); kandidat = db.kandidats.Single(x => x.id == frmPilihan.id); kandidat.Suara += 1; db.SubmitChanges(); Pemilih pemil = new Pemilih(); pemil = db.Pemilihs.Single(x => x.id == loginPemilih.id_pemilih); if (pemil.status == "belum") { pemil.status = lblkelas.Text; db.SubmitChanges(); frmPilihan piliha = new frmPilihan(); piliha.Show(); this.Close(); } else if (pemil.status == "10" || pemil.status == "11") { pemil.status = "sudah"; db.SubmitChanges(); loginPemilih login = new loginPemilih(); login.Show(); this.Close(); } } }
private void Btnhapus_Click(object sender, EventArgs e) { var mess = MessageBox.Show("Yakin hapus", "", MessageBoxButtons.YesNo); if (mess == DialogResult.Yes) { kandidat kand = new kandidat(); kand = db.kandidats.Single(x => x.id == id); db.kandidats.DeleteOnSubmit(kand); db.SubmitChanges(); loadAll(); } }
private void Btnedit_Click(object sender, EventArgs e) { if (txtNama.Text != "" && txtvisi.Text != "" && txtMisi.Text != "" && foto.Image != null && comboBox1.Text != "") { kandidat kand = new kandidat(); kand = db.kandidats.Single(x => x.id == id); kand.Kelas = comboBox1.Text; kand.Nama = txtNama.Text; kand.Visi = txtvisi.Text; kand.Misi = txtMisi.Text; MemoryStream ms = new MemoryStream(); foto.Image.Save(ms, foto.Image.RawFormat); byte[] img = ms.ToArray(); kand.Foto = img; db.SubmitChanges(); loadAll(); } }
private void HasilPemilihan_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'pilketosDataSet1.kandidat' table. You can move, or remove it, as needed. this.kandidatTableAdapter.Fill(this.pilketosDataSet1.kandidat); kandidat kand = new kandidat(); PanelMenu.Visible = false; PanelMenu.BringToFront(); for (int i = 0; i < dataGridView1.RowCount; i++) { if (dataGridView1.Rows[i].Cells[6].Value.ToString() == "10") { this.chart1.Series["Suara"].Points.AddXY(dataGridView1.Rows[i].Cells[1].Value.ToString(), Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value)); } else if (dataGridView1.Rows[i].Cells[6].Value.ToString() == "11") { this.chart2.Series["Suara"].Points.AddXY(dataGridView1.Rows[i].Cells[1].Value.ToString(), Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value)); } } }
private void FrmPilihan_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'pilketosDataSet1.kandidat' table. You can move, or remove it, as needed. this.kandidatTableAdapter.Fill(this.pilketosDataSet1.kandidat); kandidat kand = new kandidat(); panel4.Enabled = true; panel5.Enabled = true; Pemilih pemil = new Pemilih(); pemil = db.Pemilihs.Single(x => x.id == loginPemilih.id_pemilih); if (pemil.status == "10") { panel5.Enabled = false; } else if (pemil.status == "11") { panel4.Enabled = false; } int j = 0, k = 0; for (int i = 0; i < dataGridView1.RowCount; i++) { if (dataGridView1.Rows[i].Cells[6].Value.ToString() == "10") { id_kandidat_10[j] = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value); j++; } else if (dataGridView1.Rows[i].Cells[6].Value.ToString() == "11") { id_kandidat_11[k] = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value); k++; } } if (id_kandidat_10[0] != 0) { kand = db.kandidats.Single(x => x.id == id_kandidat_10[0]); labelNama1.Text = kand.Nama; byte[] img = new byte[0]; img = kand.Foto.ToArray(); MemoryStream ms = new MemoryStream(img); foto1.Image = Image.FromStream(ms); } if (id_kandidat_10[1] != 0) { kand = db.kandidats.Single(x => x.id == id_kandidat_10[id10_2 - 1]); LabelNama2.Text = kand.Nama; byte[] img = new byte[0]; img = kand.Foto.ToArray(); MemoryStream ms = new MemoryStream(img); foto2.Image = Image.FromStream(ms); } if (id_kandidat_10[2] != 0) { kand = db.kandidats.Single(x => x.id == id_kandidat_10[id10_3 - 1]); labelnama3.Text = kand.Nama; byte[] img = new byte[0]; img = kand.Foto.ToArray(); MemoryStream ms = new MemoryStream(img); Foto3.Image = Image.FromStream(ms); } if (id_kandidat_10[id10_4 - 1] != 0) { kand = db.kandidats.Single(x => x.id == id_kandidat_10[id10_4 - 1]); labelnama4.Text = kand.Nama; byte[] img = new byte[0]; img = kand.Foto.ToArray(); MemoryStream ms = new MemoryStream(img); foto4.Image = Image.FromStream(ms); } if (id_kandidat_11[id11_1 - 1] != 0) { kand = db.kandidats.Single(x => x.id == id_kandidat_11[id11_1 - 1]); labelnama5.Text = kand.Nama; byte[] img = new byte[0]; img = kand.Foto.ToArray(); MemoryStream ms = new MemoryStream(img); foto5.Image = Image.FromStream(ms); } if (id_kandidat_11[id11_2 - 1] != 0) { kand = db.kandidats.Single(x => x.id == id_kandidat_11[id11_2 - 1]); labelnama6.Text = kand.Nama; byte[] img = new byte[0]; img = kand.Foto.ToArray(); MemoryStream ms = new MemoryStream(img); foto6.Image = Image.FromStream(ms); } if (id_kandidat_11[id11_3 - 1] != 0) { kand = db.kandidats.Single(x => x.id == id_kandidat_11[id11_3 - 1]); labelnama7.Text = kand.Nama; byte[] img = new byte[0]; img = kand.Foto.ToArray(); MemoryStream ms = new MemoryStream(img); foto7.Image = Image.FromStream(ms); } if (id_kandidat_11[id11_4 - 1] != 0) { kand = db.kandidats.Single(x => x.id == id_kandidat_11[id11_4 - 1]); labelnama8.Text = kand.Nama; byte[] img = new byte[0]; img = kand.Foto.ToArray(); MemoryStream ms = new MemoryStream(img); foto8.Image = Image.FromStream(ms); } }
partial void Deletekandidat(kandidat instance);
partial void Updatekandidat(kandidat instance);
partial void Insertkandidat(kandidat instance);