Example #1
0
        public async void CreateHistoryControl(long UserID)
        {
            sectionLabel.Text = "Historia transakcji";
            InterfaceToDataBaseUserMethods Methods = new InterfaceToDataBaseUserMethods();

            SwapUserControl(new HistoryUserControl(await Methods.GetUserData(UserID)));
        }
Example #2
0
        private async void button1_Click(object sender, EventArgs e)
        {
            if (userNameBox.Text.Length == 0)
            {
                MessageBox.Show("Wpisz nazwę użytkownika!");
                return;
            }
            if (passwordBox.Text.Length == 0)
            {
                MessageBox.Show("Wpisz hasło!");
                return;
            }

            InterfaceToDataBaseUserMethods Method = new InterfaceToDataBaseUserMethods();

            loggedUserData = await Method.LogIn(userNameBox.Text, passwordBox.Text);

            if (loggedUserData != null)
            {
                ToMain();
            }
            else
            {
                MessageBox.Show("Nieprawidłowe dane logowania!");
                return;
            }
        }
Example #3
0
 private async void deleteButton_Click(object sender, EventArgs e)
 {
     if (MakeSure())
     {
         InterfaceToDataBaseUserMethods Methods = new InterfaceToDataBaseUserMethods();
         if (await Methods.DeleteUser(userData.UserID))
         {
             MessageBox.Show("Bardzo nam przykro.");
             MainWindowForm mainForm = (MainWindowForm)Application.OpenForms["MainWindowForm"];
             mainForm.Logout();
         }
         else
         {
             MessageBox.Show("Jesteś ostatim administratorem, nie możesz usunąć swojego konta.");
         }
     }
 }
Example #4
0
 private async void passwordButton_Click(object sender, EventArgs e)
 {
     if (VerifyPasswords() && MakeSure())
     {
         InterfaceToDataBaseUserMethods Methods = new InterfaceToDataBaseUserMethods();
         if (await Methods.UserModification(userData.UserID, null, null, newPasBox.Text))
         {
             newPasBox.Text  = null;
             newPas2Box.Text = null;
             MessageBox.Show("Pomyślnie ustawiono nowe hasło.");
         }
         else
         {
             MessageBox.Show("Nie można było ukończyć operacji.");
         }
     }
 }
Example #5
0
 public SaleDataUserControl(Sale SaleData, decimal sum, bool showName = false)
 {
     InitializeComponent();
     this.SaleData  = SaleData;
     idLabel.Text   = this.SaleData.SaleID.ToString();
     dateLabel.Text = this.SaleData.Date.ToString();
     sumLabel.Text  = sum + "zł";
     if (showName)
     {
         InterfaceToDataBaseUserMethods Methods = new InterfaceToDataBaseUserMethods();
         UserData       = Methods.GetUserData(SaleData.UserID).Result;
         userLabel.Text = UserData.UserName;
     }
     else
     {
         userLabel.Visible = false;
     }
 }
Example #6
0
        private async Task <bool> VerifyName()
        {
            if (nameBox.Text.Length < 1)
            {
                MessageBox.Show("Nazwa użytkownika nie może być pusta!");
                return(false);
            }

            if (userData.UserName == nameBox.Text)
            {
                return(true);
            }
            InterfaceToDataBaseUserMethods Methods = new InterfaceToDataBaseUserMethods();

            if (await Methods.NameExists(nameBox.Text))
            {
                MessageBox.Show("Nazwa użytkownika jest zajęta.");
                return(false);
            }
            return(true);
        }
Example #7
0
        private async void changeButton_Click(object sender, EventArgs e)
        {
            bool correctData;

            //correctData= await VerifyName();
            correctData = VerifyMail();// && correctData;
            if (correctData && MakeSure())
            {
                InterfaceToDataBaseUserMethods Methods = new InterfaceToDataBaseUserMethods();
                if (adminPrivilege)
                {
                    correctData = await Methods.ChangeType(userData.UserID, ReverseTypeString(typeBox.SelectedItem.ToString()));
                }
                if (correctData)
                {
                    if (await Methods.UserModification(userData.UserID, null, mailBox.Text))
                    {
                        mailLabel.Text = mailBox.Text;
                        userData.Mail  = mailLabel.Text;
                        if (adminPrivilege)
                        {
                            typeLabel.Text = typeBox.SelectedItem.ToString();
                            userData.Type  = ReverseTypeString(typeBox.SelectedItem.ToString());
                        }
                        MessageBox.Show("Pomyślnie dokonano zmian.");
                    }
                    else
                    {
                        MessageBox.Show("Nie można było ukończyć operacji.");
                    }
                }
                else
                {
                    MessageBox.Show("Jesteś ostatim administratorem, nie możesz sobie odebrać uprawnień!");
                }
            }
        }
Example #8
0
File: SignUp.cs Project: Gvyn/SOSM
        private async void signButton_Click(object sender, EventArgs e)
        {
            if (userNameBox.Text.Length == 0)
            {
                MessageBox.Show("Wpisz nazwę użytkownika!");
                return;
            }
            if (mailBox.Text.Length == 0)
            {
                MessageBox.Show("Wpisz adres e-mail!");
            }

            if (passwordBox.Text.Length == 0)
            {
                MessageBox.Show("Wpisz hasło!");
                return;
            }
            if (passwordBox.Text.Length < 6)
            {
                MessageBox.Show("Hasło musi mieć przynajmniej 6 znaków.");
                return;
            }
            if (repeatPasswordBox.Text.Length == 0)
            {
                MessageBox.Show("Powtórz hasło!");
                return;
            }

            if (!passwordBox.Text.Equals(repeatPasswordBox.Text))
            {
                MessageBox.Show("Hasła muszą się zgadzać!");
                return;
            }
            try
            {
                User newUser = new User(userNameBox.Text, mailBox.Text, 0, 0);

                InterfaceToDataBaseUserMethods Method = new InterfaceToDataBaseUserMethods();
                if (await Method.AddUser(newUser, passwordBox.Text))
                {
                    this.Visible = false;
                    MessageBox.Show("Rejestracja przebiegła pomyślnie.");
                    ToLogin();
                }
                else
                {
                    MessageBox.Show("Istnieje już użytkownik o tej nazwie.");
                    return;
                }
            }
            catch (Exception ex) when(ex is ArgumentNullException)
            {
                MessageBox.Show("Wpisz nazwę użytkownika!");
                return;
            }
            catch (Exception ex) when(ex is ArgumentException)
            {
                MessageBox.Show("Wpisz prawidłowy adres email!");
                return;
            }
            catch (Exception ex) when(ex is ArgumentOutOfRangeException)
            {
                MessageBox.Show("Typ lub stan użytkownika nie jest prawidłowy.");
                return;
            }
        }