protected void btnUpdateScripts_OnClick(object sender, EventArgs e) { RequiresAuthorizationOrManagedImage(Authorizations.UpdateProfile, Image.Id); var deleteResult = BLL.ImageProfileScript.DeleteImageProfileScripts((ImageProfile.Id)); var checkedCount = 0; foreach (GridViewRow row in gvScripts.Rows) { var pre = (CheckBox)row.FindControl("chkPre"); var post = (CheckBox)row.FindControl("chkPost"); if (pre == null || post == null) { continue; } if (!pre.Checked && !post.Checked) { continue; } checkedCount++; var dataKey = gvScripts.DataKeys[row.RowIndex]; if (dataKey == null) { continue; } var profileScript = new Models.ImageProfileScript() { ScriptId = Convert.ToInt32(dataKey.Value), ProfileId = ImageProfile.Id, RunPre = Convert.ToInt16(pre.Checked), RunPost = Convert.ToInt16(post.Checked) }; var txtPriority = row.FindControl("txtPriority") as TextBox; if (txtPriority != null) { if (!string.IsNullOrEmpty(txtPriority.Text)) { profileScript.Priority = Convert.ToInt32(txtPriority.Text); } } EndUserMessage = BLL.ImageProfileScript.AddImageProfileScript(profileScript) ? "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 btnUpdateScripts_OnClick(object sender, EventArgs e) { RequiresAuthorizationOrManagedImage(Authorizations.UpdateProfile, Image.Id); var deleteResult = BLL.ImageProfileScript.DeleteImageProfileScripts((ImageProfile.Id)); var checkedCount = 0; foreach (GridViewRow row in gvScripts.Rows) { var pre = (CheckBox)row.FindControl("chkPre"); var post = (CheckBox)row.FindControl("chkPost"); if (pre == null || post == null) continue; if (!pre.Checked && !post.Checked) continue; checkedCount++; var dataKey = gvScripts.DataKeys[row.RowIndex]; if (dataKey == null) continue; var profileScript = new Models.ImageProfileScript() { ScriptId = Convert.ToInt32(dataKey.Value), ProfileId = ImageProfile.Id, RunPre = Convert.ToInt16(pre.Checked), RunPost = Convert.ToInt16(post.Checked) }; var txtPriority = row.FindControl("txtPriority") as TextBox; if(txtPriority != null) if (!string.IsNullOrEmpty(txtPriority.Text)) profileScript.Priority = Convert.ToInt32(txtPriority.Text); EndUserMessage = BLL.ImageProfileScript.AddImageProfileScript(profileScript) ? "Successfully Updated Image Profile" : "Could Not Update Image Profile"; } if (checkedCount == 0) { EndUserMessage = deleteResult ? "Successfully Updated Image Profile" : "Could Not Update Image Profile"; } }