private void btn_save_Click(object sender, EventArgs e) { if (gdv_guards.Rows.Count > 0) { DialogResult dialogResult = MessageBox.Show("This might take a while.Proceed?", " Message Centre", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { for (int i = 0; i < gdv_guards.Rows.Count; i++) { int guard_auto_id = Convert.ToInt32(gdv_guards.Rows[i].Cells[1].Value.ToString()); DateTime pay_month = dt_start_date.Value.Date; string guard_number = gdv_guards.Rows[i].Cells[2].Value.ToString(); int days_worked = gdv_guards.Rows[i].Cells[4].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[4].Value.ToString()) : 0; int over_time_days_worked = gdv_guards.Rows[i].Cells[5].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[5].Value.ToString()) : 0; int days_absent = gdv_guards.Rows[i].Cells[7].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[7].Value.ToString()) : 0; float total_advance_in_month = gdv_guards.Rows[i].Cells[8].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[8].Value.ToString()) : 0; float total_arrears_in_month = gdv_guards.Rows[i].Cells[9].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[9].Value.ToString()) : 0; float special_cash_additions = gdv_guards.Rows[i].Cells[10].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[10].Value.ToString()) : 0; float residential_cost = gdv_guards.Rows[i].Cells[11].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[11].Value.ToString()) : 0; float uniform_costs = gdv_guards.Rows[i].Cells[12].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[12].Value.ToString()) : 0; float local_service_tax_cost = gdv_guards.Rows[i].Cells[13].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[13].Value.ToString()) : 0; float other_penalties_cost = gdv_guards.Rows[i].Cells[14].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[14].Value.ToString()) : 0; float other_refunds = gdv_guards.Rows[i].Cells[15].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[15].Value.ToString()) : 0; //save row records Guard_deployment.Save_update_guard_additional_deployment_data("save_update_guard_additional_deployment_data", guard_number, pay_month, guard_auto_id, days_worked, over_time_days_worked, days_absent, total_advance_in_month, total_arrears_in_month, special_cash_additions, residential_cost, uniform_costs, local_service_tax_cost, other_penalties_cost, other_refunds, Convert.ToInt32(SystemConst._active_deployment_id)); } MessageBox.Show("All records saved successfully", "Message Centre", MessageBoxButtons.OK, MessageBoxIcon.Information); btn_search_Click(btn_search, null); } else if (dialogResult == DialogResult.No) { this.Visible = true; } } else { MessageBox.Show("No records available to save", "Message Centre", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }