public override string ToString() { string result = $"Reg no: {RegNumber}, " + $"Name: {Name}, " + $"DOB: {DOB.ToString("yyyy-MM-dd")}, " + $"\nAddress: {Address.ToString()}, " + $"Tel:{TelephoneNumber}"; return(result); }
public async Task <ClaimsIdentity> GenerateUserIdentityAsync(UserManager <ApplicationUser> manager, string authenticationType) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, authenticationType); // Add custom user claims here userIdentity.AddClaim(new Claim(nameof(FullName), FullName.ToString())); userIdentity.AddClaim(new Claim(nameof(DOB), DOB.ToString())); userIdentity.AddClaim(new Claim(nameof(Age), Age.ToString())); return(userIdentity); }
public virtual string ShowInfo() { StringBuilder textResult = new StringBuilder(); textResult.AppendLine($"*** Client's Id: {ClientId} ***"); textResult.AppendLine($"Name: {Firstname} {Lastname}, born { DOB.ToString("dd/MM/yyyy")}"); textResult.AppendLine($"Adress: {Street}, {City}, {Zip}"); textResult.AppendLine($"Case type: {CaseType} law"); textResult.AppendLine("*** ******** ***"); return(textResult.ToString()); }
public Beneficiary() { FirstName = Name.First(); LastName = Name.Last(); SSN = RandomNumber.Next(111111111, 899999999).ToString(); DOB = Date.Birthday(1, 12); Year = DOB.ToString("yyyy"); Month = DOB.ToString("MMMM"); Day = "13";//DOB.ToString("d"); Address1 = Address.StreetAddress(); City = Address.City(); State = Address.StateAbbreviation(); Zip = Address.ZipCode(); AgeGrade = RandomNumber.Next(1, 1); }
public override string ToString() { string str = $"{Id}\t{FullName}\t\t\t" + $"{Gender}\t\t" + $"{DOB.ToString("dd MMM yyyy")}\t\t" + $"{Age}"; str = $"{str}\n\tName\n\tScore"; foreach (var course in Courses) { str = $"{str}\n\t{course.ToString()}"; } str = $"{str}\n\t\t Arverage {Average}"; return(str); }
private void btnSave_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Are you sure you to do this action?", "Confirming", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { if (Buttons == true) { ClearLabels(); bool Checker = false; Mark = new string[5]; DateTime DOB; long Telephone; int NumberOfMarks = 0; Con.Open(); txtFirstName.Text = txtFirstName.Text.Replace(" ", ""); txtLastName.Text = txtLastName.Text.Replace(" ", ""); txtPassword.Text = txtPassword.Text.Replace(" ", ""); txtTelephone.Text = txtTelephone.Text.Replace(" ", ""); //Removing all spaces, just incase the user puts a space in one of the boxes. //All these if statements detected the kind of errors in each textbox, whether it is because the textbox is empty, or if inappropriate data is entered into the textbox. //Such as a number in a name, or a wrong date. if (comboGender.Text == "") { lblGenderError.Visible = true; lblGenderError.Text = "Fill out this box."; Checker = true; } if (txtAddress.Text.Replace(" ", "") == "") { lblAddressError.Visible = true; lblAddressError.Text = "Fill out this box."; Checker = true; } if (txtPassword.Text == "") { lblPasswordError.Visible = true; lblPasswordError.Text = "Fill out this box."; Checker = true; } if (imgStudent.Image == null) { lblImageError.Visible = true; lblImageError.Text = "Put an image here."; Checker = true; } if (!long.TryParse(txtTelephone.Text, out Telephone) || Telephone.ToString().Length != 10) { Checker = true; lblTelephoneError.Visible = true; lblTelephoneError.Text = "Telephone number\nshould consist of only\nintegers and it should be 10 digits in length."; if (txtTelephone.Text == "") { lblTelephoneError.Visible = true; lblTelephoneError.Text = "Fill out this box."; } } if (txtFirstName.Text == "") { lblFirstNameError.Visible = true; lblFirstNameError.Text = "Fill out this box."; Checker = true; } if (CheckM(txtFirstName.Text) == false) { lblFirstNameError.Visible = true; //If the user entered a string with numbers and letters only, then the program will output that there cannot be numbers in the first name. if (NumberAndLetterOnly(txtFirstName.Text) == true && txtFirstName.Text.Any(char.IsDigit) == true) { lblFirstNameError.Text = "The first name cannot have numbers in it."; } //If there are no numbers detected and the string does not consist of numbers and letters only, then clearly the user put a random symbol like ? ! . @ if (txtFirstName.Text.Any(char.IsDigit) == false && NumberAndLetterOnly(txtFirstName.Text) == false) { lblFirstNameError.Text = "The first name cannot have random symbols in it."; } //If numbers are detected, but there are not only letters and numbers then clearly there are numbers and random symbols. if (txtFirstName.Text.Any(char.IsDigit) == true && NumberAndLetterOnly(txtFirstName.Text) == false) { lblFirstNameError.Text = "The first name cannot have numbers or random symbols in it."; } Checker = true; } FirstName = txtFirstName.Text; if (txtLastName.Text == "") { lblLastNameError.Visible = true; lblLastNameError.Text = "Fill out this box."; Checker = true; } if (CheckM(txtLastName.Text) == false) { lblLastNameError.Visible = true; if (NumberAndLetterOnly(txtLastName.Text) == true && txtLastName.Text.Any(char.IsDigit) == true) { lblLastNameError.Text = "The last name cannot have numbers in it."; } if (txtLastName.Text.Any(char.IsDigit) == false && NumberAndLetterOnly(txtLastName.Text) == false) { lblLastNameError.Text = "The last name cannot have random symbols in it."; } if (txtLastName.Text.Any(char.IsDigit) == true && NumberAndLetterOnly(txtLastName.Text) == false) { lblLastNameError.Text = "The last name cannot have numbers or random symbols in it."; } Checker = true; } LastName = txtLastName.Text; if (!DateTime.TryParse(txtDate.Text, out DOB)) { Checker = true; lblDOBError.Visible = true; lblDOBError.Text = "Error with the date."; if (txtDate.Text.Replace(" ", "") == "") { lblDOBError.Visible = true; lblDOBError.Text = "Fill out this box."; } } int Reptitions = richtxtMarks.Lines.Length; for (int i = 0; i < richtxtMarks.Lines.Length; i++) { //The reason why I declared this for loop is because, let us say the user only put 3 marks in, if there is an empty space on mark4 and mark5, the program will eliminate the space, by reducing the number of repetitions //thus the array will not reach these areas. if (richtxtMarks.Lines[i].Replace(" ", "") == "") { Reptitions--; } } for (int i = 0; i < Reptitions; i++) { try { double Check; if (!double.TryParse(richtxtMarks.Lines[i], out Check)) { Checker = true; lblMarksError.Visible = true; lblMarksError.Text = "Error with the marks."; break; } //Detecting if the marks are within the range of 0 to 100. if (Check > 100 || Check < 0) { lblMarksError.Visible = true; lblMarksError.Text = "Marks can only be from 0 to 100"; Checker = true; break; } Check = Math.Round(Check, 1); Mark[i] = Check.ToString(); } catch { NumberOfMarks = i + 1; } } //Checking if the textbox is empty. //I removed all spaces and enters, since you might try to crash my program by simply just putting a space or enter and then saving it. if (richtxtMarks.Text.Replace(" ", "").Replace("\n", "") == "") { lblMarksError.Visible = true; lblMarksError.Text = "Fill out this box."; Checker = true; } if (NumberOfMarks > 5) { lblMarksError.Visible = true; lblMarksError.Text = "You cannot have more than 5 marks."; Checker = true; } //The program accesses the computer's cloak and checks if the date of birth occured past the current time, if it does, the program outputs an error. if (DOB > DateTime.Now) { lblDOBError.Visible = true; lblDOBError.Text = "You cannot be born in the future."; Checker = true; } OleDbCommand Command = new OleDbCommand(); Command.Connection = Con; if (Checker == false) { //For the StudentID variable, I am using it as a counter and also as the StudentID itself. //I did this to spare myself 4 bytes. int StudentID = 0; Command.CommandText = "select StudentID from tblStudents order by StudentID"; OleDbDataReader Reader = Command.ExecuteReader(); while (Reader.Read()) { StudentID++; } int[] StudentIDArray = new int[StudentID]; StudentID = 0; Reader.Close(); Command.CommandText = "select StudentID from tblStudents order by StudentID"; Reader = Command.ExecuteReader(); while (Reader.Read()) { StudentIDArray[StudentID] = Convert.ToInt32(Reader["StudentID"]); StudentID++; } StudentID = 1; for (int i = 0; i < StudentIDArray.Length; i++) { //This for loop checks if the StudentID exists. //If it does, then the program will add one to the StudentID, and the for loop will start all over again by declaring i to -1. if (StudentID == StudentIDArray[i]) { StudentID++; i = -1; } } Reader.Close(); Command.CommandText = "select UserName from tblStudents"; Reader = Command.ExecuteReader(); int Counter = 0; while (Reader.Read()) { //Counting how many users there are. Counter++; } Reader.Close(); Command.CommandText = "select UserName from tblStudents"; Reader = Command.ExecuteReader(); string[] Users = new string[Counter]; Counter = 0; while (Reader.Read()) { Users[Counter] = Reader["UserName"].ToString(); Users[Counter] = LowerCase(Users[Counter]); Counter++; } Counter = 1; UserName = FirstName[0] + "" + LastName[0]; for (int i = 0; i < Users.Length; i++) { //I change the username and other usernames to lowercase so they could be compared correctly. //For example, without changing them all to lowercase the program will see that Spanky is not the same as spanky. if (LowerCase(UserName) == LowerCase(Users[i])) { //The username consists of the initial of the person, the first letter of the their first name and the first letter of their last name. UserName = FirstName[0] + "" + LastName[0] + Counter.ToString(); //You might be confused of why I declared i to -1 //What I intend to do is to reset the for loop //If I declared it to 0, the for loop ends will start at 1 //And that is not what I want //In order for the program to work, the array must search all values, so it must start at 0. i = -1; Counter++; } } UserName = UserName.ToUpper(); Reader.Close(); FirstName = CapitalizeFirstLetter(FirstName); LastName = CapitalizeFirstLetter(LastName); //Uploading all the values Command.CommandText = "INSERT INTO tblStudents (FirstName, LastName,DOB,Passwords,StudentID,UserName) values ('" + FirstName + "','" + LastName + "','" + DOB.ToString("yyyy-MM-dd") + "','" + txtPassword.Text + "','" + StudentID + "','" + UserName + "')"; Command.ExecuteNonQuery(); Command.CommandText = "INSERT into tblMarks (Mark1,Mark2, Mark3, Mark4, Mark5,StudentID,MarkID) values ('" + Mark[0] + "','" + Mark[1] + "','" + Mark[2] + "','" + Mark[3] + "','" + Mark[4] + "','" + StudentID + "','" + StudentID + "')"; Command.ExecuteNonQuery(); //The image field takes square brackets [], because in order to reference a field such an Ole object, the field must be inclosed by the square brackets. This exception only occurs in access. Command.CommandText = "Insert into tblOtherInformation(Address,Telephone,Gender,StudentID,[Image]) values ('" + txtAddress.Text + "','" + Telephone + "','" + comboGender.Text + "','" + StudentID + "', @Image)"; //Changing the image into binary in order to upload it. Command.Parameters.AddWithValue("@Image", ConvertImagetoBinary()); Command.ExecuteNonQuery(); Con.Close(); this.Hide(); MessageBox.Show("Data saved successfully!"); } if (Checker == true) { MessageBox.Show("Error with the inputed information."); } Con.Close(); } if (Buttons == false) { //Uploading any changes to the program. Mark = new string[5]; bool Checker = false; long Telephone; int NumberOfMarks = 0; DateTime DOB; txtFirstName.Text = txtFirstName.Text.Replace(" ", ""); txtLastName.Text = txtLastName.Text.Replace(" ", ""); txtPassword.Text = txtPassword.Text.Replace(" ", ""); txtTelephone.Text = txtTelephone.Text.Replace(" ", ""); ClearLabels(); if (comboGender.Text == "") { lblGenderError.Visible = true; lblGenderError.Text = "Fill out this box."; Checker = true; } if (txtPassword.Text == "") { lblPasswordError.Visible = true; lblPasswordError.Text = "Fill out this box."; Checker = true; } if (txtAddress.Text.Replace(" ", "") == "") { lblAddressError.Visible = true; lblAddressError.Text = "Fill out this box."; Checker = true; } if (imgStudent.Image == null) { lblImageError.Visible = true; lblImageError.Text = "Put an image here."; Checker = true; } if (!long.TryParse(txtTelephone.Text, out Telephone) || Telephone.ToString().Length != 10) { lblTelephoneError.Visible = true; lblTelephoneError.Text = "Telephone number\nshould consist of only\nintegers and it should be 10 digits in length."; if (txtTelephone.Text == "") { lblTelephoneError.Visible = true; lblTelephoneError.Text = "Fill out this box."; } Checker = true; } if (txtFirstName.Text == "") { lblFirstNameError.Visible = true; lblFirstNameError.Text = "Fill out this box."; Checker = true; } if (CheckM(txtFirstName.Text) == false) { lblFirstNameError.Visible = true; if (NumberAndLetterOnly(txtFirstName.Text) == true && txtFirstName.Text.Any(char.IsDigit) == true) { lblFirstNameError.Text = "The first name cannot have numbers in it."; } if (txtFirstName.Text.Any(char.IsDigit) == false && NumberAndLetterOnly(txtFirstName.Text) == false) { lblFirstNameError.Text = "The first name cannot have random symbols in it."; } if (txtFirstName.Text.Any(char.IsDigit) == true && NumberAndLetterOnly(txtFirstName.Text) == false) { lblFirstNameError.Text = "The first name cannot have numbers or random symbols in it."; } Checker = true; } if (txtLastName.Text == "") { Checker = true; lblLastNameError.Visible = true; lblLastNameError.Text = "Fill out this box."; } if (CheckM(txtLastName.Text) == false) { lblLastNameError.Visible = true; if (NumberAndLetterOnly(txtLastName.Text) == true && txtLastName.Text.Any(char.IsDigit) == true) { lblLastNameError.Text = "The last name cannot have numbers in it."; } if (txtLastName.Text.Any(char.IsDigit) == false && NumberAndLetterOnly(txtLastName.Text) == false) { lblLastNameError.Text = "The last name cannot have random symbols in it."; } if (txtLastName.Text.Any(char.IsDigit) == true && NumberAndLetterOnly(txtLastName.Text) == false) { lblLastNameError.Text = "The last name cannot have numbers or random symbols in it."; } Checker = true; } if (!DateTime.TryParse(txtDate.Text, out DOB)) { lblDOBError.Visible = true; lblDOBError.Text = "Error with the date."; if (txtDate.Text.Replace(" ", "") == "") { lblDOBError.Visible = true; lblDOBError.Text = "Fill out this box."; } Checker = true; } int Repetitions = richtxtMarks.Lines.Length; for (int i = 0; i < richtxtMarks.Lines.Length; i++) { //The reason why I declared this for loop is because, let us say the user only put 3 marks in, if there is an empty space on mark4 and mark5, the program will eliminate the space, by reducing the number of repetitions //thus the array will not reach these areas. if (richtxtMarks.Lines[i].Replace(" ", "") == "") { Repetitions--; } } for (int i = 0; i < Repetitions; i++) { try { double Check; if (!double.TryParse(richtxtMarks.Lines[i], out Check)) { lblMarksError.Visible = true; lblMarksError.Text = "Error with the marks."; Checker = true; break; } if (Check > 100 || Check < 0) { lblMarksError.Visible = true; lblMarksError.Text = "Marks can only be from 0 to 100"; Checker = true; } Check = Math.Round(Check, 1); Mark[i] = Check.ToString(); } catch { NumberOfMarks = i + 1; } } if (richtxtMarks.Text.Replace(" ", "").Replace("\n", "") == "") { lblMarksError.Visible = true; lblMarksError.Text = "Fill out this box."; Checker = true; } if (NumberOfMarks > 5) { lblMarksError.Visible = true; lblMarksError.Text = "You cannot have more than 5 marks."; Checker = true; } if (DOB > DateTime.Now) { lblDOBError.Visible = true; lblDOBError.Text = "You cannot be born in the future."; Checker = true; } if (Checker == false) { Con.Open(); FirstName = CapitalizeFirstLetter(txtFirstName.Text); LastName = CapitalizeFirstLetter(txtLastName.Text); OleDbCommand Command = new OleDbCommand(); Command.Connection = Con; //Same as the insert code except it is update. Command.CommandText = "update tblStudents set FirstName='" + FirstName + "', LastName='" + LastName + "', Passwords='" + txtPassword.Text + "', DOB='" + DOB.ToString("yyyy-MM-dd") + "' where StudentID = " + txtStudentID.Text; Command.ExecuteNonQuery(); Command.CommandText = "Update tblMarks set Mark1='" + Mark[0] + "', Mark2 ='" + Mark[1] + "', Mark3='" + Mark[2] + "', Mark4='" + Mark[3] + "', Mark5='" + Mark[4] + "' where StudentID=" + txtStudentID.Text; Command.ExecuteNonQuery(); Command.CommandText = "Update tblOtherInformation set Address='" + txtAddress.Text + "',Gender='" + comboGender.Text + "', Telephone ='" + Telephone + "', [Image] = @Image where StudentID=" + txtStudentID.Text; Command.Parameters.AddWithValue("@Image", ConvertImagetoBinary()); Command.ExecuteNonQuery(); MessageBox.Show("The changes have been saved."); Con.Close(); this.Hide(); } if (Checker == true) { MessageBox.Show("Error in the inputed information."); } } Con.Close(); } }
/// <summary> /// Validate data controls /// </summary> /// <returns></returns> private bool IsValidData() { bool FirstNameHasValue; bool LastNameHasValue; bool AddressLine1HasValue; bool AddressLine2HasValue; bool AddressLine3HasValue; bool PostCodeHasValue; bool DOBHasValue; bool MobileNoHasValue; bool EmailHasValue; bool EmailConfirmHasValue; bool TCHasValue; bool NHSHasValue; if (string.IsNullOrEmpty(FirstName) || string.IsNullOrWhiteSpace(FirstName)) { IsFirstNameValidatorVisible = Visibility.Visible; FirstnameBorder = new Thickness(1.5); FirstNameMessage = "First name required."; FirstNameHasValue = false; } else { bool isAlphabetsOnly = Regex.IsMatch(FirstName, "^[A-Za-z]*$", RegexOptions.IgnorePatternWhitespace); if (isAlphabetsOnly) { IsFirstNameValidatorVisible = Visibility.Collapsed; FirstnameBorder = new Thickness(0); FirstNameHasValue = true; } else { IsFirstNameValidatorVisible = Visibility.Visible; FirstnameBorder = new Thickness(1.5); FirstNameMessage = "Only alphabets allowed."; FirstNameHasValue = false; } } if (string.IsNullOrEmpty(LastName) || string.IsNullOrWhiteSpace(LastName)) { IsLastNameValidatorVisible = Visibility.Visible; LastnameBorder = new Thickness(1.5); LastNameMessage = "Last name required."; LastNameHasValue = false; } else { bool isAlphabetsOnly = Regex.IsMatch(LastName, "^[A-Za-z]*$", RegexOptions.IgnorePatternWhitespace); if (isAlphabetsOnly) { IsLastNameValidatorVisible = Visibility.Collapsed; LastnameBorder = new Thickness(0); LastNameHasValue = true; } else { IsLastNameValidatorVisible = Visibility.Visible; LastnameBorder = new Thickness(1.5); LastNameMessage = "Only alphabets allowed."; LastNameHasValue = false; } } if (string.IsNullOrEmpty(AddressLine1) || string.IsNullOrWhiteSpace(AddressLine1)) { IsAddressLine1ValidatorVisible = Visibility.Visible; AddresLine1Border = new Thickness(1.5); AddressLine1Message = "Address Line 1 required."; AddressLine1HasValue = false; } else { IsAddressLine1ValidatorVisible = Visibility.Collapsed; AddresLine1Border = new Thickness(0); AddressLine1HasValue = true; } if (string.IsNullOrEmpty(AddressLine2) || string.IsNullOrWhiteSpace(AddressLine2)) { IsAddressLine2ValidatorVisible = Visibility.Visible; AddresLine2Border = new Thickness(1.5); AddressLine2Message = "Address Line 2 required."; AddressLine2HasValue = false; } else { IsAddressLine2ValidatorVisible = Visibility.Collapsed; AddresLine2Border = new Thickness(0); AddressLine2HasValue = true; } if (NHS != null) { if (NHS.Length == 0 || NHS.Length == 10 || (string.IsNullOrEmpty(NHS))) { IsNHSLengthValidatorVisible = Visibility.Collapsed; NHSLengthBorder = new Thickness(0); NHSHasValue = true; } else { IsNHSLengthValidatorVisible = Visibility.Visible; NHSLengthBorder = new Thickness(1.5); NHSLengthMessage = "Should be either zero or ten digits."; NHSHasValue = false; } } else { NHSHasValue = true; } if (PickerSelectedIndex == 0) { IsAddressLine3ValidatorVisible = Visibility.Visible; AddresLine3Border = new Thickness(1.5); AddressLine3Message = "Please select a country."; AddressLine3HasValue = false; } else { IsAddressLine3ValidatorVisible = Visibility.Collapsed; AddresLine3Border = new Thickness(0); AddressLine3HasValue = true; } if (string.IsNullOrEmpty(PostCode) || string.IsNullOrWhiteSpace(PostCode)) { IsPostCodeValidatorVisible = Visibility.Visible; PostCodeBorder = new Thickness(1.5); PostCodeMessage = "Post Code required."; PostCodeHasValue = false; } else { bool isPostCodeValid = Regex.IsMatch(PostCode, @"((([A-PR-UWYZ][0-9][0-9]?)|(([A-PR-UWYZ][A-HK-Y][0-9][0-9]?)|(([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRV-Y])))) ?[0-9][ABD-HJLNP-UW-Z]{2})", RegexOptions.IgnoreCase); if (isPostCodeValid) { IsPostCodeValidatorVisible = Visibility.Collapsed; PostCodeBorder = new Thickness(0); PostCodeHasValue = true; } else { IsPostCodeValidatorVisible = Visibility.Visible; PostCodeBorder = new Thickness(1.5); PostCodeMessage = "Invalid Post Code."; PostCodeHasValue = false; } } if (string.IsNullOrEmpty(DOB.ToString("dd/mm/yy")) || string.IsNullOrWhiteSpace(DOB.ToString("dd/mm/yy"))) { IsDOBValidatorVisible = Visibility.Visible; DOBBorder = new Thickness(1.5); DOBMessage = "Date of birth required."; DOBHasValue = false; } else { if (DateTime.Compare(System.DateTime.Now.Date, DOB.Date) <= 0) { IsDOBValidatorVisible = Visibility.Visible; DOBBorder = new Thickness(1.5); DOBMessage = "Date of birth should be less than the current date."; DOBHasValue = false; } else { IsDOBValidatorVisible = Visibility.Collapsed; DOBBorder = new Thickness(0); DOBHasValue = true; } } if (string.IsNullOrEmpty(MobileNo) || string.IsNullOrWhiteSpace(MobileNo)) { IsMobilePhoneValidatorVisible = Visibility.Visible; MobilePhoneBorder = new Thickness(1.5); MobilePhoneMessage = "Mobile Number required."; MobileNoHasValue = false; } else { bool isDigitsOnly = Regex.IsMatch(MobileNo, "^[0-9]*$", RegexOptions.IgnorePatternWhitespace); if (isDigitsOnly) { IsMobilePhoneValidatorVisible = Visibility.Collapsed; MobilePhoneBorder = new Thickness(0); MobileNoHasValue = true; } else { IsMobilePhoneValidatorVisible = Visibility.Visible; MobilePhoneBorder = new Thickness(1.5); MobilePhoneMessage = "Only digits allowed."; MobileNoHasValue = false; } } if (string.IsNullOrEmpty(EmailId) || string.IsNullOrWhiteSpace(EmailId)) { IsEmailValidatorVisible = Visibility.Visible; EmailBorder = new Thickness(1.5); EmailMessage = "Email ID required."; EmailHasValue = false; } else { bool isEmail = Regex.IsMatch(EmailId, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase); if (!isEmail) { IsEmailValidatorVisible = Visibility.Visible; EmailBorder = new Thickness(1.5); EmailMessage = "Email ID format is incorrect."; EmailHasValue = false; } else { IsEmailValidatorVisible = Visibility.Collapsed; EmailBorder = new Thickness(0); EmailHasValue = true; } } if (string.IsNullOrEmpty(ConfirmEmail) || string.IsNullOrWhiteSpace(ConfirmEmail)) { IsEmailConfirmValidatorVisible = Visibility.Visible; ConfirmEmailBorder = new Thickness(1.5); EmailConfirmMessage = "Confirm Email ID required."; EmailConfirmHasValue = false; } else { bool isEmail = Regex.IsMatch(ConfirmEmail, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase); if (!isEmail) { IsEmailConfirmValidatorVisible = Visibility.Visible; ConfirmEmailBorder = new Thickness(1.5); EmailConfirmMessage = "Confirm Email ID format is incorrect."; EmailConfirmHasValue = false; } else { if (ConfirmEmail != EmailId) { IsEmailConfirmValidatorVisible = Visibility.Visible; ConfirmEmailBorder = new Thickness(1.5); EmailConfirmMessage = "Email IDs do not match."; EmailConfirmHasValue = false; } else { IsEmailConfirmValidatorVisible = Visibility.Collapsed; ConfirmEmailBorder = new Thickness(0); EmailConfirmHasValue = true; } } } if (!CheckedorNot) { IsTCValidatorVisible = Visibility.Visible; TCBorder = new Thickness(1.5); TCMessage = "Please read and accept terms and conditions."; TCHasValue = false; } else { IsTCValidatorVisible = Visibility.Collapsed; TCBorder = new Thickness(0); TCHasValue = true; } if ((FirstNameHasValue) && (LastNameHasValue) && (AddressLine1HasValue) && (NHSHasValue) && (AddressLine2HasValue) && (AddressLine3HasValue) && (PostCodeHasValue) && (DOBHasValue) && (MobileNoHasValue) && (EmailHasValue) && (EmailConfirmHasValue) && (TCHasValue)) { return(true); } else { MessageBox.Show("Please fill all the mandatory fields."); return(false); } }
public string this[string columnName] { get { string result = null; if (columnName == "FIRST_NAME") { if (string.IsNullOrEmpty(FIRST_NAME)) { result = "First Name cannot be empty"; } } if (columnName == "LAST_NAME") { if (String.IsNullOrWhiteSpace(LAST_NAME)) { result = "Last Name cannot be empty"; } } if (columnName == "EMP_ID") { if (String.IsNullOrWhiteSpace(EMP_ID)) { result = "Employee Code cannot be empty"; } } if (columnName == "DOB") { if (String.IsNullOrWhiteSpace(DOB.ToString())) { result = "Date of birth cannot be empty"; } } if (columnName == "GENDER") { if (String.IsNullOrWhiteSpace(GENDER)) { // result = "First Name Cannot be Empty or have White Spaces"; } } if (columnName == "NATIONALITY") { if (String.IsNullOrWhiteSpace(NATIONALITY)) { result = "Nationality cannot be empty"; } } if (columnName == "CIVIL_STATUS") { if (String.IsNullOrWhiteSpace(CIVIL_STATUS)) { result = "Civil Status cannot be empty"; } } if (columnName == "ACCOUNT_TYPE") { if (String.IsNullOrWhiteSpace(ACCOUNT_TYPE)) { result = "Account type cannot be empty"; } } if (columnName == "ADDRESS") { if (String.IsNullOrWhiteSpace(ADDRESS)) { result = "Address cannot be empty"; } } if (columnName == "USERNAME") { if (String.IsNullOrWhiteSpace(USERNAME)) { result = "Username cannot be empty"; } } if (columnName == "PASSWORD") { if (String.IsNullOrWhiteSpace(PASSWORD)) { result = "Password cannot be empty"; } } return(result); } }
public Program() { string conStr1 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + @"C:\Users\sisgks\Desktop\SACHWS.xlsx" + ";Extended Properties=\"Excel 12.0;HDR=YES;\""; string sqlst = @"Select [ChineseSurname], [ChineseGivenName], [EnglishSurname], [EnglishGivenName], [DOBDAY], [DOBMONTH], [DOBYEAR], [Contact], [Apt Blk], [Unit], [Street], [Postal], [Next of Kin], [NoK Contact], [Remarks]" + " from [HWS$] "; BDConnectionDataContext dbConn = new BDConnectionDataContext(); DataSet ds = new DataSet(); using (OleDbConnection connection = new OleDbConnection(conStr1)) using (OleDbCommand command = new OleDbCommand(sqlst, connection)) using (OleDbDataAdapter adapter = new OleDbDataAdapter(command)) { adapter.Fill(ds); } foreach (DataRow Row in ds.Tables[0].Rows) { string query = "INSERT INTO [dbo].[tb_HokkienMember]([EnglishSurname] ,[EnglishGivenName] ,[ChineseSurname] ,[ChineseGivenName] ,[Birthday] ,[Contact] ,[AddressHouseBlock] ,[AddressStreet] ,[AddressUnit] ,[AddressPostalCode] ,[NextOfKinName] ,[NextOfKinContact] ,[Remarks])" + "SELECT ''"; string ChineseSurname = Row[0].ToString(); string ChineseGivenName = Row[1].ToString(); string EnglishSurname = Row[2].ToString(); string EnglishGivenName = Row[3].ToString(); DateTime DOB; bool successful = DateTime.TryParse(Row[5].ToString() + "/" + Row[4].ToString() + "/" + Row[6].ToString(), out DOB); Console.WriteLine(DOB); string Contact = Row[7].ToString(); string AddressHouseBlock = Row[8].ToString(); string AddressStreet = Row[10].ToString(); string AddressUnit = Row[9].ToString(); string AddressPostalCode = Row[11].ToString(); string NextOfKinName = Row[12].ToString();; string NextOfKinContact = Row[13].ToString();; string Remarks = Row[14].ToString();; XElement newXML = new XElement("new"); newXML.Add(new XElement("EnteredBy", "gohks")); newXML.Add(new XElement("EnglishSurname", EnglishSurname)); newXML.Add(new XElement("EnglishGivenName", EnglishGivenName)); newXML.Add(new XElement("ChineseSurname", ChineseSurname)); newXML.Add(new XElement("ChineseGivenName", ChineseGivenName)); if (successful) { newXML.Add(new XElement("DOB", DOB.ToString("dd/MM/yyyy"))); } newXML.Add(new XElement("Contact", Contact)); newXML.Add(new XElement("NOK", NextOfKinName)); newXML.Add(new XElement("NOKContact", NextOfKinContact)); newXML.Add(new XElement("candidate_street_address", AddressStreet)); newXML.Add(new XElement("candidate_postal_code", AddressPostalCode)); newXML.Add(new XElement("candidate_blk_house", AddressHouseBlock)); newXML.Add(new XElement("candidate_unit", AddressUnit)); newXML.Add(new XElement("candidate_photo", "")); newXML.Add(new XElement("remarks", Remarks)); string msg = ""; if (EnglishSurname.Length == 0 && EnglishGivenName.Length == 0 && ChineseSurname.Length == 0 && ChineseGivenName.Length == 0) { } else { dbConn.usp_addNewHWSMember(newXML, ref msg); } } }
private string GetCustCode() { return($"{FirstName}{LastName}{DOB.ToString("yyyyMMdd")}".ToLower()); }
private void UserRoleDropdown_ValueChanged(object sender, ValueChangedEventArgs e) { //i hate firebase if (isDataSent) { return; } //FName, LName, Mname, ContactName, Phone, Address, DOB, State, Zip reference.Child("Patient").Child(MainController.name).Child("address").SetValueAsync(Address.ToString()); reference.Child("Patient").Child(MainController.name).Child("state").SetValueAsync(State.ToString()); reference.Child("Patient").Child(MainController.name).Child("zipCode").SetValueAsync(Zip.ToString()); reference.Child("Patient").Child(MainController.name).Child("dateOfBirth").SetValueAsync(DOB.ToString()); reference.Child("Patient").Child(MainController.name).Child("emergencyContact").SetValueAsync(ContactName.ToString()); reference.Child("Patient").Child(MainController.name).Child("firstName").SetValueAsync(FName.ToString()); reference.Child("Patient").Child(MainController.name).Child("middleName").SetValueAsync(Mname.ToString()); reference.Child("Patient").Child(MainController.name).Child("lastName").SetValueAsync(LName.ToString()); reference.Child("Patient").Child(MainController.name).Child("phoneNumber").SetValueAsync(Phone.ToString()); message.text = "Account successfully updated."; isDataSent = true; /* * reference.Child("Patient").Child(MainController.name).SetValueAsync(UserName.text); * reference.Child("Patient").Child(UserName.text).Child("Username").SetValueAsync(UserName.text); * reference.Child("Patient").Child(UserName.text).Child("Role").SetValueAsync(RoleValue); * reference.Child("Patient").Child(UserName.text).Child("Password").SetValueAsync(Password.text); * reference.Child("Patient").Child(UserName.text).Child("DoB").SetValueAsync(DOB.text); * reference.Child("Patient").Child(UserName.text).Child("EmergencyContact").SetValueAsync("911"); * print("added to db"); * * message.text = "Account successfully updated."; * isDataSent = true; * */ }
public override string ToString() { return(Name + " " + Surname + ", " + DOB.ToString()); }