public UManage(Guid currentUser, List <User> GetUsers) { InitializeComponent(); CultureInfo culture = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = culture.TextInfo; List <string> stateList = new List <string>(); users = GetUsers; CCErrorProvider.Clear(); UserLoginErrorProv.Clear(); UserMaintErrorProv.Clear(); if (currentUser != Guid.Empty) { UserIndexNo = users.FindIndex(a => a.guid == currentUser); LoggedInUser = users[UserIndexNo]; } stateList.Add(string.Empty); stateList.AddRange(Enum.GetNames(typeof(User.StateEnum))); for (int counter = 0; counter < stateList.Count(); counter++) { stateList[counter] = textInfo.ToTitleCase(stateList[counter].Replace("_", " ")); } StateBox.Items.AddRange(stateList.ToArray()); StateBox.SelectedIndex = 0; }
private void ChangePassWdButton_Click(object sender, EventArgs e) { UserMaintErrorProv.Clear(); CCErrorProvider.Clear(); if (string.IsNullOrEmpty(Passwordbox.Text)) { UserMaintErrorProv.SetError(Passwordbox, "You must first enter your old password."); } else if (!LoggedInUser.PassWdMatch(sHA.ComputeHash(ue.GetBytes(Passwordbox.Text)))) { UserMaintErrorProv.SetError(Passwordbox, InvalPass); } else if (string.IsNullOrEmpty(CreatePasswordBox.Text)) { UserMaintErrorProv.SetError(CreatePasswordBox, "You must enter a new password!"); } else { LoggedInUser.ChangePass(sHA.ComputeHash(ue.GetBytes(Passwordbox.Text)), sHA.ComputeHash(ue.GetBytes(CreatePasswordBox.Text))); UserMaintErrorProv.Clear(); users.RemoveAt(UserIndexNo); users.Add(LoggedInUser); UserIndexNo = users.FindIndex(a => a.guid == LoggedInUser.guid); MessageBox.Show("Your password has been successfully changed!", "Password changed", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void Creditcardbox_Validated(object sender, EventArgs e) { if (CheckLuhn(Creditcardbox.Text)) { CCErrorProvider.SetError(Creditcardbox, string.Empty); CCImage.Visible = true; if (Creditcardbox.Text == string.Empty) { CCImage.Visible = false; } else { switch (Creditcardbox.Text.Substring(0, 1)) { case "3": using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Blackjack_CSC470.Images.american_express.gif")) { CCImage.Image = new Bitmap(Image.FromStream(stream), new Size(22, 22)); } break; case "4": using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Blackjack_CSC470.Images.visa.gif")) { CCImage.Image = Image.FromStream(stream); } break; case "5": using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Blackjack_CSC470.Images.mastercard.gif")) { CCImage.Image = new Bitmap(Image.FromStream(stream), new Size(35, 22)); } break; case "6": using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Blackjack_CSC470.Images.discover.jpg")) { CCImage.Image = new Bitmap(Image.FromStream(stream), new Size(35, 22)); } break; default: CCImage.Visible = false; break; } NewUserButton.Enabled = true; EditUserDataButton.Enabled = true; } } else { CCErrorProvider.SetError(Creditcardbox, "Invalid credit card number."); NewUserButton.Enabled = false; EditUserDataButton.Enabled = false; CCImage.Visible = false; } }