protected void _formview_DataBound(object sender, EventArgs e) { if (_formview.CurrentMode == FormViewMode.Edit) { var accountTypeCtrl = (TextBox)(_formview).FindControl("_accountType"); var requestTypeCtrl = (TextBox)(_formview).FindControl("_requestType"); var deleteRequestDateSection = (Panel)(_formview).FindControl("_deleteRequestPanel"); if (requestTypeCtrl.Text.Contains("Delete")) { deleteRequestDateSection.Visible = true; } else { deleteRequestDateSection.Visible = false; } var siprSection = (Panel)(_formview).FindControl("_siprSection"); if (accountTypeCtrl.Text == "SIPR" && requestTypeCtrl.Text.Contains("Create")) { siprSection.Visible = true; } else { siprSection.Visible = false; } if (accountTypeCtrl.Text != "NIPR") { var saAdInfoSection = (PlaceHolder)(_formview).FindControl("_adInfo"); saAdInfoSection.Visible = true; } if (IsSaCreateRequest || IsEpCreateRequest) { // Set visibility defaults for the NEC sections. var iaApprovalSection = (PlaceHolder)(_formview).FindControl("_iaSection"); iaApprovalSection.Visible = true; var dsdApprovalSection = (PlaceHolder)(_formview).FindControl("_dsdSection"); dsdApprovalSection.Visible = false; var saApprovalSection = (PlaceHolder)(_formview).FindControl("_saSection"); saApprovalSection.Visible = false; var requestStatusCtrl = (TextBox)(_formview).FindControl("_requestStatus"); var dsdCheckBoxCtrl = (CheckBox)(_formview).FindControl("_dsdCheckBox"); var iaCheckBoxCtrl = (CheckBox)(_formview).FindControl("_iaCheckBox"); if (IsSaCreateRequest) { var supervisorNameCtrl = (Literal)(_formview).FindControl("_supervisorName"); var supervisorEdipiCtrl = (TextBox)(_formview).FindControl("_supervisorEdipi"); var supervisorInfo = AdAccount.ReturnActiveDirectoryDisplayName(supervisorEdipiCtrl.Text); supervisorNameCtrl.Text = supervisorInfo; var securityNameCtrl = (Literal)(_formview).FindControl("_securityName"); var securityEdipiCtrl = (TextBox)(_formview).FindControl("_securityEdipi"); var securityInfo = AdAccount.ReturnActiveDirectoryDisplayName(securityEdipiCtrl.Text); securityNameCtrl.Text = securityInfo; // Update visible properties of each section depending on the value of the request status. if ((requestStatusCtrl.Text == "IA Approved" || requestStatusCtrl.Text == "Completed") && iaCheckBoxCtrl.Checked) { dsdApprovalSection.Visible = true; var imoGroupListCtrl = (ListBox)(_formview).FindControl("_imoGroupList"); var imoGroupList = AdAccount.ListImoGroups(); foreach (string group in imoGroupList) { imoGroupListCtrl.Items.Add(new ListItem(group, group)); } } if ((requestStatusCtrl.Text == "DSD Approved" || requestStatusCtrl.Text == "Completed") && dsdCheckBoxCtrl.Checked) { saApprovalSection.Visible = true; } } else { var saRequestInfoSection = (Panel)(_formview).FindControl("_saPanel"); saRequestInfoSection.Visible = false; if ((requestStatusCtrl.Text == "IA Approved" || requestStatusCtrl.Text == "Completed") && iaCheckBoxCtrl.Checked) { saApprovalSection.Visible = true; } } // Set defaults for the individual controls inside the NEC approval sections var dsdSubmitBtn = (Button)(_formview).FindControl("_dsdSubmit"); dsdSubmitBtn.Visible = false; var dsdRemarkCtrl = (TextBox)(_formview).FindControl("_dsdRemark"); dsdRemarkCtrl.Enabled = false; var dsdCheckboxCtrl = (CheckBox)(_formview).FindControl("_dsdCheckBox"); dsdCheckboxCtrl.Enabled = false; var dsdApprovalCtrl = (RadioButtonList)(_formview).FindControl("_dsdApproval"); dsdApprovalCtrl.Enabled = false; var dsdImoList = (ListBox)(_formview).FindControl("_imoGroupList"); dsdImoList.Enabled = false; var iaSubmitBtn = (Button)(_formview).FindControl("_iaSubmit"); iaSubmitBtn.Visible = false; var iaRemarkCtrl = (TextBox)(_formview).FindControl("_iaRemark"); iaRemarkCtrl.Enabled = false; var iaCheckboxCtrl = (CheckBox)(_formview).FindControl("_iaCheckBox"); iaCheckboxCtrl.Enabled = false; var iaApprovalCtrl = (RadioButtonList)(_formview).FindControl("_iaApproval"); iaApprovalCtrl.Enabled = false; var saSubmitBtn = (Button)(_formview).FindControl("_saSubmit"); saSubmitBtn.Visible = false; var saSamAccountCtrl = (TextBox)(_formview).FindControl("_samAccount"); saSamAccountCtrl.Enabled = false; var saHomeFolderCtrl = (TextBox)(_formview).FindControl("_homeFolder"); saHomeFolderCtrl.Enabled = false; var saRemarkCtrl = (TextBox)(_formview).FindControl("_saRemark"); saRemarkCtrl.Enabled = false; var saCheckboxCtrl = (CheckBox)(_formview).FindControl("_saCheckBox"); saCheckboxCtrl.Enabled = false; var saRequestStatusCtrl = (DropDownList)(_formview).FindControl("_editRequestStatus"); saRequestStatusCtrl.Enabled = false; // Update defaults depending on the security group the current NEC employee is a member of. if (User.IsInRole("CARSON NEC SSD SMB SA SG")) { saSubmitBtn.Visible = true; saSamAccountCtrl.Enabled = true; saHomeFolderCtrl.Enabled = true; saRemarkCtrl.Enabled = true; saCheckboxCtrl.Enabled = true; saRequestStatusCtrl.Enabled = true; } if (User.IsInRole("CARSON NEC DSD Account Review")) { dsdSubmitBtn.Visible = true; dsdRemarkCtrl.Enabled = true; dsdCheckboxCtrl.Enabled = true; dsdApprovalCtrl.Enabled = true; dsdImoList.Enabled = true; } if (User.IsInRole("CARSON NEC IA Account Review")) { iaSubmitBtn.Visible = true; iaRemarkCtrl.Enabled = true; iaCheckboxCtrl.Enabled = true; iaApprovalCtrl.Enabled = true; } } else { var saApprovalSection = (PlaceHolder)(_formview).FindControl("_saSection"); if (User.IsInRole("CARSON NEC SSD SMB SA SG")) { saApprovalSection.Visible = true; } else { saApprovalSection.Visible = false; } var iaSection = (PlaceHolder)(_formview).FindControl("_iaSection"); iaSection.Visible = false; var dsdSection = (PlaceHolder)(_formview).FindControl("_dsdSection"); dsdSection.Visible = false; var justificationSectionCtrl = (Panel)(_formview).FindControl("_justificationPanel"); justificationSectionCtrl.Visible = false; var saRequestInfoSection = (Panel)(_formview).FindControl("_saPanel"); saRequestInfoSection.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { string accountType = Session["AccountType"] as string; string requestType = Session["RequestType"] as string; var userAccount = new AdAccount(); //Un-comment next line for testing a specific user //var userAccount = new AdAccount("123"); var currentUser = userAccount.CurrentUser; if (!IsPostBack && accountType != null && requestType != null && currentUser != null) { if (requestType == "Create") { bool accountExist = false; switch (accountType) { case "NIPR": accountExist = userAccount.queryForest(); if (accountExist) { _niprName.Text = userAccount.NiprAccountName; _createNiprFail.Visible = true; _formview.Visible = false; } break; case "VPN": accountExist = userAccount.queryVpn(); if (accountExist) { _vpnGroup.Text = userAccount.VpnGroupName; _createVpnFail.Visible = true; _formview.Visible = false; break; } accountExist = userAccount.queryOurDomain(); if (!accountExist) { _createSpecialAcctFail.Visible = true; _formview.Visible = false; } break; case "SIPR": case "EP": case "SA": accountExist = userAccount.queryOurDomain(); if (!accountExist) { _createSpecialAcctFail.Visible = true; _formview.Visible = false; } break; } } else { bool accountExist = false; switch (accountType) { case "NIPR": accountExist = userAccount.queryOurDomain(); if (!accountExist) { _deleteNiprFail.Visible = true; _formview.Visible = false; } break; case "VPN": accountExist = userAccount.queryVpn(); if (!accountExist) { _deleteVpnFail.Visible = true; _formview.Visible = false; } break; } } } else if (!IsPostBack && accountType == null) { Server.Transfer("~/default.aspx"); } }