protected void btnUpdateSysprep_OnClick(object sender, EventArgs e) { RequiresAuthorizationOrManagedImage(Authorizations.UpdateProfile, Image.Id); var deleteResult = BLL.ImageProfileSysprepTag.DeleteImageProfileSysprepTags(ImageProfile.Id); var checkedCount = 0; foreach (GridViewRow row in gvSysprep.Rows) { var enabled = (CheckBox)row.FindControl("chkEnabled"); if (enabled == null ) continue; if (!enabled.Checked) continue; checkedCount++; var dataKey = gvSysprep.DataKeys[row.RowIndex]; if (dataKey == null) continue; var profileSysPrep = new Models.ImageProfileSysprepTag { SysprepId = Convert.ToInt32(dataKey.Value), ProfileId = ImageProfile.Id, }; var txtPriority = row.FindControl("txtPriority") as TextBox; if (txtPriority != null) if (!string.IsNullOrEmpty(txtPriority.Text)) profileSysPrep.Priority = Convert.ToInt32(txtPriority.Text); EndUserMessage = BLL.ImageProfileSysprepTag.AddImageProfileSysprepTag(profileSysPrep) ? "Successfully Updated Image Profile" : "Could Not Update Image Profile"; } if (checkedCount == 0) { EndUserMessage = deleteResult ? "Successfully Updated Image Profile" : "Could Not Update Image Profile"; } }
protected void btnUpdateSysprep_OnClick(object sender, EventArgs e) { RequiresAuthorizationOrManagedImage(Authorizations.UpdateProfile, Image.Id); var deleteResult = BLL.ImageProfileSysprepTag.DeleteImageProfileSysprepTags(ImageProfile.Id); var checkedCount = 0; foreach (GridViewRow row in gvSysprep.Rows) { var enabled = (CheckBox)row.FindControl("chkEnabled"); if (enabled == null) { continue; } if (!enabled.Checked) { continue; } checkedCount++; var dataKey = gvSysprep.DataKeys[row.RowIndex]; if (dataKey == null) { continue; } var profileSysPrep = new Models.ImageProfileSysprepTag { SysprepId = Convert.ToInt32(dataKey.Value), ProfileId = ImageProfile.Id, }; var txtPriority = row.FindControl("txtPriority") as TextBox; if (txtPriority != null) { if (!string.IsNullOrEmpty(txtPriority.Text)) { profileSysPrep.Priority = Convert.ToInt32(txtPriority.Text); } } EndUserMessage = BLL.ImageProfileSysprepTag.AddImageProfileSysprepTag(profileSysPrep) ? "Successfully Updated Image Profile" : "Could Not Update Image Profile"; } if (checkedCount == 0) { EndUserMessage = deleteResult ? "Successfully Updated Image Profile" : "Could Not Update Image Profile"; } }