Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            ClientClass selectedClient = (ClientClass)listBox1.SelectedItem;

            if (selectedClient.Status == 0)
            {
                selectedClient.Status = 2;
                MessageBox.Show($"'{selectedClient.FirstName}' with id '{selectedClient.ClientId}' was successfully banned", "Autopark", new MessageBoxButtons(), MessageBoxIcon.Asterisk);
            }
            else if (selectedClient.Status == 1)
            {
                MessageBox.Show("Unable to ban administrator", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                return;
            }
            else if (selectedClient.Status == 2)
            {
                selectedClient.Status = 0;
                MessageBox.Show($"'{selectedClient.FirstName}' with id '{selectedClient.ClientId}' was successfully unbanned", "Autopark", new MessageBoxButtons(), MessageBoxIcon.Asterisk);
            }
            try
            {
                SQLClients.GetInstance().Update(selectedClient);
            }
            catch (Exception excp) { Console.WriteLine(excp.Message); }
            listBox1_SelectedIndexChanged(sender, new EventArgs());
        }
Exemplo n.º 2
0
 public static void InitializeClients()
 {
     foreach (ClientClass i in new List <ClientClass>(SQLClients.GetInstance().GetList()))
     {
         AddNewClient(i);
     }
 }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.ForeColor = Color.Black;
            textBox2.ForeColor = Color.Black;
            if (textBox1.Text.Length < 3 || textBox1.Text.Length > 15)
            {
                textBox1.ForeColor = Color.Red;
                MessageBox.Show("Incorrect login length", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                return;
            }
            else
            {
                if (textBox2.Text.Length < 3 || textBox2.Text.Length > 15)
                {
                    textBox2.ForeColor = Color.Red;
                    MessageBox.Show("Incorrect password length", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                    return;
                }
            }

            ClientClass client = SQLClients.GetInstance().Search(textBox1.Text);

            if (client != null)
            {
                if (textBox2.Text == SQLClients.GetInstance().GetPassword(textBox1.Text))
                {
                    if (client.Status == 2)
                    {
                        MessageBox.Show("Your account was banned!", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                        return;
                    }
                    this.Hide();
                    new WorkForm(client).Show();
                }
                else
                {
                    MessageBox.Show("Incorrect password", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Incorrect login", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            ResetColors();
            if (textBox1.Text == "super")
            {
                textBox1.Text = "";
                if (Status == 0)
                {
                    Status = 1;
                    MessageBox.Show("Status set to admin", "Autopark", new MessageBoxButtons(), MessageBoxIcon.Asterisk);
                }
                else
                {
                    Status = 0;
                    MessageBox.Show("Status set to user", "Autopark", new MessageBoxButtons(), MessageBoxIcon.Asterisk);
                }
                return;
            }

            if (textBox1.Text.Length < 3)
            {
                textBox1.ForeColor = Color.Red;
                label1.ForeColor   = Color.Red;
                MessageBox.Show("First name's length should be > 3", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                return;
            }

            if (textBox2.Text.Length < 3 && textBox2.Text.Length != 0)
            {
                textBox2.ForeColor = Color.Red;
                label2.ForeColor   = Color.Red;
                MessageBox.Show("Second name's length should be > 3", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                return;
            }

            if (textBox3.Text.Length < 3 && textBox3.Text.Length != 0)
            {
                textBox3.ForeColor = Color.Red;
                label3.ForeColor   = Color.Red;
                MessageBox.Show("Patronymic's length should be > 3", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                return;
            }

            if (textBox4.Text.Length < 3 && textBox4.Text.Length != 0)
            {
                textBox4.ForeColor = Color.Red;
                label4.ForeColor   = Color.Red;
                MessageBox.Show("Address's length should be > 3", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                return;
            }

            if (textBox5.Text.Length < 3)
            {
                textBox5.ForeColor = Color.Red;
                label5.ForeColor   = Color.Red;
                MessageBox.Show("Phone number's length should be > 3", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                return;
            }

            if (textBox6.Text.Length < 3)
            {
                textBox6.ForeColor = Color.Red;
                label6.ForeColor   = Color.Red;
                MessageBox.Show("Password's length should be > 3", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                return;
            }

            if (textBox7.Text != textBox6.Text)
            {
                textBox7.ForeColor = Color.Red;
                label7.ForeColor   = Color.Red;
                MessageBox.Show("Passwords do not match", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                return;
            }

            ClientClass client = new ClientClass(Status, textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text);

            try
            {
                SQLClients.GetInstance().AddClient(client, textBox6.Text);
            } catch (MySqlException)
            {
                MessageBox.Show("This name isunavailable", "Error", new MessageBoxButtons(), MessageBoxIcon.Error);
                textBox1.ForeColor = Color.Red;
                label1.ForeColor   = Color.Red;
                return;
            }

            MessageBox.Show("Account has been registered. Log in please.", "Autopark", new MessageBoxButtons(), MessageBoxIcon.Asterisk);
            this.Close();
        }