private void BtnGeneratePassword_Click(object sender, EventArgs e) { try { for (int i = 0; i < dgvList.Rows.Count; i++) { string MK_Value = dgvList.Rows[i].Cells["colMK"].Value == null ? null : dgvList.Rows[i].Cells["colMK"].Value.ToString(); if (MK_Value == "I" || MK_Value == "C" || MK_Value == "M") { frmCompanyCodeListController companyCodeList = new frmCompanyCodeListController(); DataTable dt = companyCodeList.GetPassword(); //update datagrid dgvList.Rows[i].Cells["colPASSWORD_"].Value = dt.Rows[0]["PASSWORD"].ToString(); dgvList.Rows[i].Cells["colPASSWORD_SET_DATE"].Value = dt.Rows[0]["PASSWORD_SET_DATE"].ToString(); dgvList.Rows[i].Cells["colPASSWORD_EXPIRATION_DATE"].Value = dt.Rows[0]["PASSWORD_EXPIRATION_DATE"].ToString(); } } } catch (System.TimeoutException) { MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Net.WebException) { MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { Utility.WriteErrorLog(ex.Message, ex, false); MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }