private void datagridServiceRecords_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e) { lblRowsCount.Text = dgvServiceRecord.Rows.Count.ToString(); if (dgvServiceRecord.Rows.Count == 0 && (TempHolder.searchedEmpID != null)) { btnImport.Visible = true; } if (dgvServiceRecord.Rows.Count == 0) { lblNoServiceRecord.Visible = true; txtFrom.ResetText(); txtTo.ResetText(); txtSchoolName.ResetText(); txtStation.ResetText(); txtBranch.ResetText(); txtDesignation.ResetText(); txtStatus.ResetText(); txtSalary.ResetText(); txtCause.ResetText(); txtLAWOP.ResetText(); TempHolder.clearLastRecord(); } detectLastRow(); }
public void clearDisplay() { TempHolder.clearLastRecord(); if (dgvServiceRecord.Rows.Count > 0) { dgvServiceRecord.Rows.Clear(); } btnDelete.Enabled = false; lblNoServiceRecord.Visible = false; txtSchoolName.ResetText(); txtStation.ResetText(); txtBranch.ResetText(); txtDesignation.ResetText(); txtStatus.ResetText(); txtFrom.ResetText(); txtTo.ResetText(); txtSalary.ResetText(); txtCause.ResetText(); txtLAWOP.ResetText(); btnImport.Visible = false; btnEdit.Enabled = false; btnExport.Enabled = false; btnAddRecord.Enabled = false; }
public void detectLastRow() { int lastIndex = dgvServiceRecord.Rows.Count - 1; if (lastIndex != -1) { TempHolder.lastServiceRecordId = dgvServiceRecord.Rows[lastIndex].Cells[0].Value.ToString(); string school = dgvServiceRecord.Rows[lastIndex].Cells[1].Value.ToString(); string from = dgvServiceRecord.Rows[lastIndex].Cells[2].Value.ToString(); string to = dgvServiceRecord.Rows[lastIndex].Cells[3].Value.ToString(); string designation = dgvServiceRecord.Rows[lastIndex].Cells[4].Value.ToString(); string status = dgvServiceRecord.Rows[lastIndex].Cells[5].Value.ToString(); string salary = dgvServiceRecord.Rows[lastIndex].Cells[6].Value.ToString(); string station = dgvServiceRecord.Rows[lastIndex].Cells[7].Value.ToString(); string branch = dgvServiceRecord.Rows[lastIndex].Cells[8].Value.ToString(); string cause = dgvServiceRecord.Rows[lastIndex].Cells[9].Value.ToString(); string lawop = dgvServiceRecord.Rows[lastIndex].Cells[10].Value.ToString(); DateTime dt; if (DateTime.TryParse(from, out dt)) { TempHolder.lastFrom = dt.ToString("MM/dd/yyyy"); } if (DateTime.TryParse(to, out dt)) { TempHolder.lastTo = dt.ToString("MM/dd/yyyy"); TempHolder.lastIsPresent = false; } else if (to.ToLower().Equals("present")) { TempHolder.lastIsPresent = true; } TempHolder.searchedLastSchool = school; TempHolder.lastDesignation = designation; TempHolder.lastStatus = status; if (salary.Length == 0) { TempHolder.lastSalary = "0.00"; } TempHolder.lastSalary = salary; TempHolder.lastStation = station; TempHolder.lastBranch = branch; TempHolder.lastCause = cause; TempHolder.lastLAWOP = lawop; String searchValue = "original"; int rowIndex = -1; foreach (DataGridViewRow row in dgvServiceRecord.Rows) { if (row.Cells[9].Value.ToString().ToLower().Contains(searchValue)) { rowIndex = row.Index; break; } } if (rowIndex != -1) { TempHolder.searchedOriginalAppointment = dgvServiceRecord.Rows[rowIndex].Cells[2].Value.ToString(); } else { TempHolder.searchedOriginalAppointment = null; } } else { TempHolder.clearLastRecord(); } TempHolder.mainForm.showOtherEmpInfo(); }