Beispiel #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            admin ad = new admin();

            ad.Show();
            this.Hide();
        }
Beispiel #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            data.Clear();
            string autoData = @"C:/Users/g580/Documents/Programming/C++, C#/C#/Applications/RentCar/RentCar/RentCar/bin/Debug/Cars/" + textBox1.Text.Trim() + " " + textBox2.Text.Trim() + " " + textBox3.Text.Trim() + "/opis.txt";

            File.WriteAllText(autoData, string.Empty);
            insertNewData();

            try
            {
                using (var writer = new StreamWriter(autoData))
                {
                    for (var i = 0; i < data.Count; i++)
                    {
                        writer.WriteLine(data[i]);
                    }
                }

                MessageBox.Show("Data updated!");
                admin ad = new admin();
                ad.Show();
                this.Hide();
            }
            catch (Exception Ex)
            {
            }
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            deleteCarsFromWypoz(Convert.ToInt16(idSam));
            deleteSpecCar(Convert.ToInt16(idSam));
            checkIfDeleteFolder(marka, model, rok);
            MessageBox.Show("Car deleted");
            admin ad = new admin();

            ad.Show();
            this.Hide();
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Connection       conn    = new Connection();
            DataTable        dt      = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand();
            String           QuesLog = "SELECT * FROM `uzytkownicy` WHERE `LOGIN` = @usn AND `HASLO` = @pass";

            command.CommandText = QuesLog;
            command.Connection  = conn.GetConnection();
            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = textBox1.Text;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = textBox2.Text;

            adapter.SelectCommand = command;
            try
            {
                adapter.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    DataRow row = dt.Rows[0];
                    Id_kli = row["ID_UZYT"].ToString();

                    this.Hide();
                    if (textBox1.Text.Equals("admin"))
                    {
                        admin ad = new admin();
                        this.Hide();
                        ad.Show();
                    }
                    else
                    {
                        Client cl = new Client();
                        this.Hide();
                        cl.Show();
                    }
                }

                else
                {
                    if (textBox1.Text.Trim().Equals("") && !textBox2.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Give your login!", "Empty login", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        textBox2.Text = textBox1.Text = "";
                    }

                    else if (textBox2.Text.Trim().Equals("") && !textBox1.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Give your password!", "Empty password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        textBox2.Text = textBox1.Text = "";
                    }

                    else if (textBox1.Text.Trim().Equals("") && textBox2.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Give your password and login!", "Empty login and password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        textBox2.Text = textBox1.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("Wrong username or password!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        textBox2.Text = textBox1.Text = "";
                    }
                }
            }
            catch
            {
                MessageBox.Show("Unable to connect with database!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }