public AddRecordForm(DashboardForm dashboardForm, taskToPerform task, int voterID) { InitializeComponent(); this.dashboardForm = dashboardForm; this.Show(); dashboardForm.Hide(); db = new VoterRecordsEntities(); db.Logins.FirstOrDefault(); this.task = task; this.voterID = voterID; if (voterID != -1) { FillFormFromDatabase(); } using (VoterRecordsEntities db = new VoterRecordsEntities()) { AutoCompleteStringCollection source = new AutoCompleteStringCollection(); var listNames = db.Voters.Select(x => x.address).ToList(); foreach (string name in listNames) { source.Add(name); } txtAddress.AutoCompleteCustomSource = source; } }
private void PerformSearchOn(string keyword) { try { using (VoterRecordsEntities db = new VoterRecordsEntities()) { if (rbName.Checked) { var dgvDataSource = db.Voters.Where(x => x.name.Contains(keyword)).ToList(); dgvVoters.DataSource = dgvDataSource; } else if (rbCNIC.Checked) { var dgvDataSource = db.Voters.Where(x => x.CNIC.Contains(keyword)).ToList(); dgvVoters.DataSource = dgvDataSource; } SetDgvColumnNames(); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
public ChangePasswordForm(DashboardForm dashboardForm) { InitializeComponent(); this.dashboardForm = dashboardForm; this.Show(); dashboardForm.Hide(); db = new VoterRecordsEntities(); }
private void refreshVoterList() { try { using (VoterRecordsEntities db = new VoterRecordsEntities()) { dgvVoters.DataSource = null; dgvVoters.DataSource = db.Voters.ToList(); SetDgvColumnNames(); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
private void RefreshDGV() { try { using (VoterRecordsEntities db = new VoterRecordsEntities()) { dgvVoters.DataSource = null; dgvVoters.DataSource = db.Voters.ToList(); SetDgvColumnNames(); txtSearch.Clear(); } //dgvVoters.DataSource = null; //db.Entry(db.Voters).Reload(); //dgvVoters.DataSource = db.Voters.ToList(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); MessageBox.Show(ex.StackTrace); } }
private void LoginForm_Load(object sender, EventArgs e) { db = new VoterRecordsEntities(); db.Logins.FirstOrDefault(); }