public bool CheckPassword(string username, string pass) { UserList ul = new UserList(); User x = ul.GetUsers().Where(i => i.GetUsername() == username).FirstOrDefault(); if ((ul.GetUsers().Where(i => i.GetUsername() == username).FirstOrDefault() != null) && (x.GetPassword() == pass)) { return(true); } else { System.Windows.Forms.MessageBox.Show("Klaidingi duomenys"); return(false); } }
private void ConfirmButton_Click(object sender, EventArgs e) { if (CheckFieldsNotEmpty(CurrentPassTextBox.Text, NewPassTextBox.Text, NewPassConfirmTextBox.Text)) { UserList ul = new UserList(); User x = ul.GetUsers().Where(i => i.GetUsername() == StartForm.currentUser).FirstOrDefault(); if (x.GetPassword() == CurrentPassTextBox.Text && NewPassTextBox.Text == NewPassConfirmTextBox.Text) { UserList us = new UserList(); us.ChangePassword(StartForm.currentUser, NewPassTextBox.Text); CurrentPassTextBox.Text = ""; NewPassTextBox.Text = ""; NewPassConfirmTextBox.Text = ""; CurrentPassLabel.Visible = false; NewPassLabel.Visible = false; NewPassConfirmLabel.Visible = false; CurrentPassTextBox.Visible = false; NewPassTextBox.Visible = false; NewPassConfirmTextBox.Visible = false; CancelButton.Visible = false; ConfirmButton.Visible = false; ChangePassButton.Visible = true; ChangePictureButton.Visible = true; } else { MessageBox.Show("Duomenys suvesti klaidingai."); } } }
private void ProfileView_Load(object sender, EventArgs e) { UserList ul = new UserList(); User x = ul.GetUsers().Where(i => i.GetUsername() == StartForm.currentUser).FirstOrDefault(); UsernameLabel.Text = x.GetUsername(); NameLabel.Text = x.GetName(); SurnameLabel.Text = x.GetSurname(); BirthdateLabel.Text = x.GetBirthdate().ToString(); }
public bool CheckUsernameUnique(string un) { UserList ul = new UserList(); if (ul.GetUsers().Where(i => i.GetUsername() == un).FirstOrDefault() == null) { return(true); } else { System.Windows.Forms.MessageBox.Show("Toks naudotojo vardas jau užimtas"); return(false); } }
private void UserListButton_Click(object sender, EventArgs e) { MainFieldPanel.Controls.Clear(); UserList ul = new UserList(); foreach (User x in ul.GetUsers()) { UserListAdminView u = new UserListAdminView(); u.UserIDLabel.Text = x.GetUserID().ToString(); u.UsernameLabel.Text = x.GetUsername(); u.NameLabel.Text = x.GetName(); u.SurnameLabel.Text = x.GetSurname(); u.BirthdateLabel.Text = x.GetBirthdate().ToString(); u.IsAdminLabel.Text = x.GetIsAdmin().ToString(); MainFieldPanel.Controls.Add(u); } }
private void RegisterButton_Click(object sender, EventArgs e) { Registration registration = new Registration(); if (registration.CheckFieldsNotEmpty(nameTextBox.Text, surnameTextBox.Text, usernameTextBox.Text, passwordTextBox.Text, passwordConfirmTextBox.Text) && registration.CheckUsernameUnique(usernameTextBox.Text) && registration.CheckDateFormat(birthDateTextBox.Text) && registration.CheckAge(DateTime.Parse(birthDateTextBox.Text)) && registration.CheckPassword(passwordTextBox.Text, passwordConfirmTextBox.Text)) { UserList u = new UserList(); u.AddUser(nameTextBox.Text, surnameTextBox.Text, DateTime.Parse(birthDateTextBox.Text).ToString(), usernameTextBox.Text, passwordTextBox.Text); StartForm.currentUser = usernameTextBox.Text; foreach (TextBox tb in this.Controls.OfType <TextBox>()) { tb.Text = string.Empty; } MessageBox.Show("Registracija sekminga"); StartForm st = new StartForm(); st.Show(); st.RegistrationLabel.Visible = false; st.LoginLabel.Visible = false; st.LoggedInAsLabel.Visible = true; st.LogoutLabel.Visible = true; st.NameLabel.Visible = true; st.SurnameLabel.Visible = true; st.ProfileLabel.Visible = true; st.WishlistButton.Visible = true; st.CartButton.Visible = true; UserList ul = new UserList(); User x = ul.GetUsers().Where(i => i.GetUsername() == StartForm.currentUser).FirstOrDefault(); st.NameLabel.Text = x.GetName(); st.SurnameLabel.Text = x.GetSurname(); if (x.GetIsAdmin()) { st.UserListButton.Visible = true; } } }
private void CategoryButton_Click(object sender, EventArgs e) { Button button = (Button)sender; Category category = (Category)button.Tag; MainFieldPanel.Controls.Clear(); UserList ul = new UserList(); User x = ul.GetUsers().Where(i => i.GetUsername() == currentUser).FirstOrDefault(); if (currentUser != null && x.GetIsAdmin() == true) { foreach (Item item in category.Items) { ItemAdminView iaw = new ItemAdminView(item); MainFieldPanel.Controls.Add(iaw); } } else if (currentUser != null) { foreach (Item item in category.Items) { ItemRegisteredView irw = new ItemRegisteredView(item); MainFieldPanel.Controls.Add(irw); } } else { foreach (Item item in category.Items) { ItemPublicView ipv = new ItemPublicView(item); MainFieldPanel.Controls.Add(ipv); } } }
private void LoginButton_Click(object sender, EventArgs e) { Login login = new Login(); if (login.CheckFieldsNotEmpty(usernameTextBox.Text, passwordTextBox.Text) && login.CheckPassword(usernameTextBox.Text, passwordTextBox.Text)) { StartForm.currentUser = usernameTextBox.Text; foreach (TextBox tb in this.Controls.OfType <TextBox>()) { tb.Text = string.Empty; } MessageBox.Show("Prisijungimas sekmingas"); StartForm st = new StartForm(); st.Show(); st.RegistrationLabel.Visible = false; st.LoginLabel.Visible = false; st.LoggedInAsLabel.Visible = true; st.LogoutLabel.Visible = true; st.NameLabel.Visible = true; st.SurnameLabel.Visible = true; st.ProfileLabel.Visible = true; st.WishlistButton.Visible = true; st.CartButton.Visible = true; UserList ul = new UserList(); User x = ul.GetUsers().Where(i => i.GetUsername() == StartForm.currentUser).FirstOrDefault(); st.NameLabel.Text = x.GetName(); st.SurnameLabel.Text = x.GetSurname(); if (x.GetIsAdmin()) { st.UserListButton.Visible = true; } } }