public frmAddOrUpdateAppLinks(AppLinks appLinks) { InitializeComponent(); GlobalLinkId = appLinks.AppLinkId; #region "Loading Credentials" dtCredentials.Columns.Add("CredentialId", typeof(int)); dtCredentials.Columns.Add("CredentialDescription", typeof(string)); dtCredentials.Columns.Add("Username", typeof(string)); dtCredentials.Columns.Add("Password", typeof(string)); dtCredentials.Columns.Add("StringToSearch", typeof(string)); #endregion countryList = DALHelpers.GetCountries(); appList = DALHelpers.GetApplications(); categoryList = DALHelpers.GetCategories(); StyleApplicationButtons(); this.Size = new Size(536, 466); grpCredential.Location = new Point(12, 12); if (GlobalLinkId > 0) { txtDescription.Text = appLinks.Description; txtURL.Text = appLinks.Link; int counter = 0; foreach (Country country in countryList) { cmbCountry.Items.Add(country.CountryName.ToString()); if (appLinks.CountryId == country.CountryId) { cmbCountry.SelectedIndex = counter; } counter++; } counter = 0; foreach (App app in appList) { cmbApplication.Items.Add(app.ApplicationName.ToString()); if (appLinks.ApplicationId == app.ApplicationId) { cmbApplication.SelectedIndex = counter; } counter++; } counter = 0; foreach (Category category in categoryList) { cmbCategory.Items.Add(category.CategoryName.ToString()); if (appLinks.AppCategoryId == category.CategoryId) { cmbCategory.SelectedIndex = counter; } counter++; } credentialList = loadCredentials(); counter = 0; foreach (Credential credential in credentialList) { if (appLinks.CredentialId == credential.CredentialId) { CredentialId = credential.CredentialId; txtCredentialId.Text = credential.Username; btnRemoveCredential.Text = "Remove Credential"; } } dgvCredentials.ClearSelection(); } else { foreach (Country country in countryList) { cmbCountry.Items.Add(country.CountryName.ToString()); } foreach (App app in appList) { cmbApplication.Items.Add(app.ApplicationName.ToString()); } foreach (Category category in categoryList) { cmbCategory.Items.Add(category.CategoryName.ToString()); } credentialList = loadCredentials(); dgvCredentials.ClearSelection(); } if (btnRemoveCredential.Text == "Select Credential") { pictureBox1.Visible = false; } else { pictureBox1.Visible = true; } }
public frmAddOrUpdateAppLinks(int LinkId, int CountryId, int ApplicationId, int CategoryId, string Description, string Link, int CredentialId) { InitializeComponent(); GlobalLinkId = LinkId; #region "Loading Credentials" dtCredentials.Columns.Add("CredentialId", typeof(int)); dtCredentials.Columns.Add("Username", typeof(string)); dtCredentials.Columns.Add("Password", typeof(string)); dtCredentials.Columns.Add("CredentialDescription", typeof(string)); #endregion countryList = DALHelpers.GetCountries(); appList = DALHelpers.GetApplications(); categoryList = DALHelpers.GetCategories(); if (LinkId > 0) { txtDescription.Text = Description; txtURL.Text = Link; int counter = 0; foreach (Country country in countryList) { cmbCountry.Items.Add(country.CountryName.ToString()); if (CountryId == country.CountryId) { cmbCountry.SelectedIndex = counter; } counter++; } counter = 0; foreach (App app in appList) { cmbApplication.Items.Add(app.ApplicationName.ToString()); if (ApplicationId == app.ApplicationId) { cmbApplication.SelectedIndex = counter; } counter++; } counter = 0; foreach (Category category in categoryList) { cmbCategory.Items.Add(category.CategoryName.ToString()); if (CategoryId == category.CategoryId) { cmbCategory.SelectedIndex = counter; } counter++; } credentialList = loadCredentials(); counter = 0; foreach (Credential credential in credentialList) { if (CredentialId == credential.CredentialId) { txtCredentialUsername.Text = credential.Username; txtCredentialId.Text = credential.CredentialId.ToString(); lblOk.Visible = true; } } dgvCredentials.ClearSelection(); } else { foreach (Country country in countryList) { cmbCountry.Items.Add(country.CountryName.ToString()); } foreach (App app in appList) { cmbApplication.Items.Add(app.ApplicationName.ToString()); } foreach (Category category in categoryList) { cmbCategory.Items.Add(category.CategoryName.ToString()); } credentialList = loadCredentials(); dgvCredentials.ClearSelection(); } }