protected void auto_assign_salary_scale_to_guard() { DataTable dt = Salary_scales.return_number_of_years_served_for_each_gaurd("return_number_of_years_served_for_each_gaurd"); if (dt.Rows.Count > 0) { //loop through all rows to map with salary scale id for (int i = 0; i < dt.Rows.Count; i++) { DataRow dtRow = dt.Rows[i]; int guard_auto_id = Convert.ToInt32(dtRow["auto_id"].ToString()); string guard_number = (String)dtRow["guard_number"]; int Duration = Convert.ToInt32(dtRow["Duration"].ToString()); //save or update scale-guard mapping try { Salary_scales.auto_assign_salary_scale_to_guard("auto_assign_salary_scale_to_guard", Duration, guard_auto_id, guard_number); } catch (Exception ex) { throw ex; } } MessageBox.Show("All Guards salary scales successfully updated", "Update salary scales", MessageBoxButtons.OK, MessageBoxIcon.Information); } }