void btnExport_Click(object sender, EventArgs e) { Exporter.DataGridViewToExel(dgvProduct); }
private void DoClick(object sender, EventArgs e) { if (sender == btnAdd) { if (cboRole.Items.Count > 0) { FormInsertEmployee insert = new FormInsertEmployee(); insert.ShowDialog(); } else { MessageError("Please add role before add new Employee!", "Required"); FormRole frm = new FormRole(); frm.Exited += frm_Exited; frm.ShowDialog(); } } else if (sender == btnUpdate) { emp = dgvEmployee.CurrentRow.Tag as Employee; FormInsertEmployee update = new FormInsertEmployee(emp); update.ShowDialog(); } else if (sender == btnDelete) { DialogResult dr = this.MessageVerify("Do you want to delete?", "Delete"); if (dr == DialogResult.Yes) { foreach (DataGridViewRow row in dgvEmployee.SelectedRows) { int index = employeeList.IndexOf(row.Tag as Employee); int id = employeeList[index].ID; if (Delete(id)) { MessageSuccess("Deleted successfully", "Delete"); employeeList.RemoveAt(index); dgvEmployee.Rows.Remove(row); RefreshBottomInformation(); } else { MessageError("Deleted Unsuccessfully", "Delete"); } } if (employeeList.Count == 0) { btnRefresh.Enabled = false; } if (dgvEmployee.Rows.Count == 0) { SetEnableButton(false); } } } else if (sender == btnExport) { Exporter.DataGridViewToExel(dgvEmployee); } else if (sender == btnRefresh) { LoadData(); /* * femaleNumber = 0; * AccoutNumber = 0; * cboRole.SelectedIndex = -1; * cboSearch.SelectedIndex = 0; * txtSearch.Text = searchBy[0]; * * if (employeeList.Count == 0 || employeeList.Count == dgvEmployee.Rows.Count) return; * dgvEmployee.Rows.Clear(); * foreach (Employee emp in employeeList) * { * if (emp.Gender == "Female") femaleNumber ++; * if (emp.UserName != "") AccoutNumber ++; * AddDataRowToDataGridView(emp); * } * SetBottomInformationToTextBox(); * SetEnableButton(true); */ } else if (sender == btnRoleDetails) { FormRole frm = new FormRole(); frm.Exited += frm_Exited; frm.ShowDialog(); } }