//Main function
        public static void Main(string[] args)
        {
            //Change file path
            var reader = new StreamReader(File.OpenRead(@""));

            reader.ReadLine();
            while (!reader.EndOfStream)
            {
                var          line   = reader.ReadLine();
                var          values = line.Split(',');
                int          i      = 0;
                List <float> listA  = new List <float>();
                while (i < 13)
                {
                    float x = float.Parse(values[i]);
                    listA.Add(x);
                    i++;
                }
                obj = new info(listA);
                l1.Add(obj);

                line   = reader.ReadLine();
                values = line.Split(',');
                i      = 0;
                List <float> listB = new List <float>();
                while (i < 13)
                {
                    float x = float.Parse(values[i]);
                    listB.Add(x);
                    i++;
                }
                info obj2 = new info(listB);
                l2.Add(obj2);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Beispiel #2
0
        private void loginbutton_Click(object sender, EventArgs e)
        {
            pictureBox2.BackgroundImage = Properties.Resources.user1;
            panel1.BackColor            = Color.FromArgb(233, 233, 233);
            usernameinput.ForeColor     = Color.FromArgb(233, 233, 233);
            pictureBox3.BackgroundImage = Properties.Resources.lock1;
            panel2.BackColor            = Color.FromArgb(233, 233, 233);
            passwordinput.ForeColor     = Color.FromArgb(233, 233, 233);
            pictureBox4.BackgroundImage = Properties.Resources.email1;
            panel3.BackColor            = Color.FromArgb(233, 233, 233);
            emailinput.ForeColor        = Color.FromArgb(233, 233, 233);

            bool proced = true;

            if (string.IsNullOrEmpty(usernameinput.Text.ToString()) == true)
            {
                user_click_check   = false;
                usernameinput.Text = "User Name";
            }

            if (string.IsNullOrEmpty(passwordinput.Text.ToString()) == true)
            {
                pass_click_check           = false;
                passwordinput.Text         = "Password";
                passwordinput.PasswordChar = '\0';
            }

            if (string.IsNullOrEmpty(emailinput.Text.ToString()) == true)
            {
                email_click_check = false;
                emailinput.Text   = "Email";
            }


            if (user_click_check == false)
            {
                usernameinput.ForeColor = Color.FromArgb(100, 100, 100);
                panel1.BackColor        = Color.FromArgb(190, 40, 40);
                proced = false;
            }

            if (pass_click_check == false)
            {
                passwordinput.ForeColor = Color.FromArgb(100, 100, 100);
                panel2.BackColor        = Color.FromArgb(190, 40, 40);
                proced = false;
            }

            if (email_click_check == false)
            {
                emailinput.ForeColor = Color.FromArgb(100, 100, 100);
                panel3.BackColor     = Color.FromArgb(190, 40, 40);
                proced = false;
            }

            if (proced == true)
            {
                string connectionString = "datasource=127.0.0.1;port=3306;username=root;password=;database=scorpio;";

                // Select all
                string          query = "SELECT * FROM user";
                MySqlConnection databaseConnection = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);
                commandDatabase.CommandTimeout = 60;
                MySqlDataReader reader;

                try
                {
                    databaseConnection.Open();
                    reader = commandDatabase.ExecuteReader();
                    // Success, now list

                    // If there are available rows
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            string userName = (string)reader["User_name"];
                            string email    = (string)reader["Email"];
                            if (string.Compare(userName, usernameinput.Text.ToString()) == 0 || string.Compare(email, emailinput.Text.ToString()) == 0)
                            {
                                if (string.Compare(userName, usernameinput.Text.ToString()) == 0)
                                {
                                    panel1.BackColor = Color.FromArgb(190, 40, 40);
                                }

                                if (string.Compare(email, emailinput.Text.ToString()) == 0)
                                {
                                    panel3.BackColor    = Color.FromArgb(190, 40, 40);
                                    incorrectpanel.Text = "This email is already in use";
                                }



                                incorrectpanel.Visible = true;
                                databaseConnection.Close();
                                return;
                            }
                        }
                        string sa     = DateTime.Now.ToString("yyyy/M/dd");
                        string insert = "INSERT INTO `user` (`First_name`, `Last_name`, `User_name`, `Email`, `Password`, `Phone_no`, `Birth_date`,`joined`, `info_show`,`other_show`, `dp`) VALUES(NULL, NULL, '" + usernameinput.Text + "','" + emailinput.Text + "', '" + passwordinput.Text + "', NULL, NULL,'" + sa + "' ,'1','1', 'default.png')";

                        // MessageBox.Show(insert);

                        MySqlConnection insertconnection = new MySqlConnection(connectionString);
                        insertconnection.Open();

                        MySqlCommand    insertcommand = new MySqlCommand(insert, insertconnection);
                        MySqlDataReader myinsert      = insertcommand.ExecuteReader();
                        //MessageBox.Show("Done");
                        insertconnection.Close();
                        user_log_in.UserID = usernameinput.Text;

                        this.Hide();
                        var info = new info();
                        info.Closed += (s, args) => this.Close();
                        info.Show();
                        return;
                    }
                    else
                    {
                        Console.WriteLine("No rows found.");
                    }

                    databaseConnection.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }