private void ValidateCpr(string cpr) { bool validPersonNr = controller.CheckCpr(cpr); if (validPersonNr == true) { string name = controller.GetNameFromPData(cpr); if (name != string.Empty) { string username_loggedInUser = controller.samaccountnameCurrentUser(); controller.AddLoggingInfoToDB(username_loggedInUser, cpr); lblTemporary_name.Text = name; tableRowDateAndTime.Visible = true; } } else { lblTemporary_name.Text = ""; txtBoxTemporary_socialSecurityNumber.Text = ""; tableRowDateAndTime.Visible = false; tableRowTemporaryCodes.Visible = false; tableRowButton.Visible = false; string alert = "Personnummeret er ikke gyldigt."; RadWindowManager_afloeser.RadAlert(alert, 300, 180, "Ugyldigt CPR", "callBackFn"); ResetInputFields(); } }
protected void BtnCancel_Click(object sender, EventArgs e) { if (grid_temporaryCodesInUse.SelectedItems.Count == 1) { TemporaryUser tempUser = controller.GetTemporaryUserFromGrid(grid_temporaryCodesInUse); int id = tempUser.ID; string username = tempUser.TempCode_username;//tempUser.Kategori; DateTime disablingDateTime = DateTime.Now; string loggedInUser_username = controller.samaccountnameCurrentUser(); bool success = controller.DisableAccountInActiveDirectory(username, disablingDateTime); if (success) { bool success_DB = controller.DeleteInDataBase(id, loggedInUser_username, disablingDateTime); if (success_DB) { RadWindowManager_afloeser.RadAlert("Bestillingen blev annuleret", 300, 180, "Deaktiveret", "alertAndRedirect"); } else { RadWindowManager_afloeser.RadAlert("Der gik noget galt!", 300, 180, "Ikke slettet - DATABASE", "alertAndRedirect"); } } else { RadWindowManager_afloeser.RadAlert("Der gik noget galt!", 300, 180, "Ikke slettet - AD", "alertAndRedirect"); } } }
protected void CheckInputVaribles() { string alertMessage = "Mangler at udfylde: \\n" + "\\n"; if (txtBoxTemporary_socialSecurityNumber.Text == string.Empty) { alertMessage += "Personnummer \\n"; } if (datePickerEndDate.SelectedDate == null) { alertMessage += "Slutdato \\n"; } if (timePickerEndTime.SelectedTime == null) { alertMessage += "Sluttidspunkt \\n"; } RadWindowManager_afloeser.RadAlert(alertMessage, 300, 180, "Ugyldigt CPR", "callBackFn"); }
private void CheckTimeAndDateInput() { if (datePickerEndDate.SelectedDate.ToString() != string.Empty && timePickerEndTime.SelectedTime != null) { if (controller.AddHoursAndMinsToDate((DateTime)datePickerEndDate.SelectedDate, (TimeSpan)timePickerEndTime.SelectedTime) > DateTime.Now) { controller.FillComboTemporaryCodesAvailable(comboTemporaryCodesAvailable); tableRowTemporaryCodes.Visible = true; } else { tableRowTemporaryCodes.Visible = false; string alert; alert = "Sluttidspunkt skal være senere end nuværende dato og tid"; RadWindowManager_afloeser.RadAlert(alert, 300, 180, "Ugyldigt tidspunkt", "callBackFn"); } } else { tableRowTemporaryCodes.Visible = false; } }
protected void btnActivateTemporaryCode_Click(object sender, EventArgs e) { if (CheckForEmptyInputFields() == false) { string samAccountName = comboTemporaryCodesAvailable.SelectedItem.Value; DateTime accountExpirationDate_temporary = controller.AddHoursAndMinsToDate((DateTime)datePickerEndDate.SelectedDate, (TimeSpan)timePickerEndTime.SelectedTime); string fqdn = Properties.Settings.Default.fqdn; string username_admin = Properties.Settings.Default.username_admin; string password_admin = Properties.Settings.Default.password_admin; string socialSecurityNumber_temporary = txtBoxTemporary_socialSecurityNumber.Text; string temporary_name = lblTemporary_name.Text; string temporary_codeName = comboTemporaryCodesAvailable.SelectedItem.Text; string temporary_codeName_prefix = controller.GetCodeNamePrefix(temporary_codeName); string temporaryCode_username = comboTemporaryCodesAvailable.SelectedItem.Value; List <TemporaryUser> list = controller.TemporaryUserIsCreated(socialSecurityNumber_temporary, DateTime.Now, temporary_codeName_prefix); if (list.Count == 0) { //AddToDataBase(); bool success_AD = controller.UpdateUserAccountInActiveDirectory(samAccountName, accountExpirationDate_temporary, socialSecurityNumber_temporary); Tuple <DateTime, bool> userData = Controller_afloeser.GetTemporaryInfo(samAccountName, fqdn, username_admin, password_admin); DateTime expDate = userData.Item1; bool accountEnabled = userData.Item2; if (accountEnabled == true && success_AD) //((accountEnabled == true && expDate == accountExpirationDate_vikar)) { string loggedOnUser_userName = controller.samaccountnameCurrentUser(); bool success_DB = controller.AddToDataBase(socialSecurityNumber_temporary, temporary_name, accountExpirationDate_temporary, temporary_codeName, temporaryCode_username, loggedOnUser_userName); if (success_DB) { string alert; alert = "Brugeren er aktiveret."; RadWindowManager_afloeser.RadAlert(alert, 300, 180, "Bruger aktiveret", "alertAndRedirect"); } else { } ResetInputFields(); } else { string alert; alert = "Brugeren blev IKKE aktiveret."; RadWindowManager_afloeser.RadAlert(alert, 300, 180, "Ikke aktiveret", "alertAndRedirect"); } } else { string message = "Denne bruger har en kode i brug" + "<br/><br/>"; foreach (TemporaryUser item in list) { if (item.Kategori != string.Empty) { message = message + "Kode navn: " + item.Kategori; message = message + "<br/>"; } if (item.StartDato != null) { message = message + "Start dato: " + item.StartDato; message = message + "<br/>"; } if (item.SlutDato != null) { message = message + "S**t dato: " + item.SlutDato; message = message + "<br/>"; } message = message + "<br/> Déaktiver evt denne kode hvis du vil oprette en ny."; } RadWindowManager_afloeser.RadAlert(message, 300, 180, "Bruger allerede oprettet", "alertAndRedirect"); } } else { CheckInputVaribles(); } }