예제 #1
0
        private void insertData()
        {
            string       check    = "SELECT * FROM UserTable WHERE username = @username";
            OleDbCommand checkcmd = new OleDbCommand(check, con);

            checkcmd.Parameters.AddWithValue("@username", usernameTextBox.Text);

            con.Open();

            OleDbDataReader dr = checkcmd.ExecuteReader();

            if (dr.Read())
            {
                MessageBox.Show("το username χρησιμοποιειται ηδη,παρακαλω επιλεξτε διαφορετικο username");
            }
            else
            {
                string       sql = "INSERT INTO UserTable (username, [password], firstName, lastName, city, address, email, is_admin) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
                OleDbCommand cmd = new OleDbCommand(sql, con);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@username", usernameTextBox.Text);
                cmd.Parameters.AddWithValue("@password", hash.encrypt(passwordTextBox.Text));
                cmd.Parameters.AddWithValue("@firstName", fnameTextBox.Text);
                cmd.Parameters.AddWithValue("@lastName", lnameTextBox.Text);
                cmd.Parameters.AddWithValue("@city", cityTextBox.Text);
                cmd.Parameters.AddWithValue("@address", addressTextBox.Text);
                cmd.Parameters.AddWithValue("@email", mailTextBox.Text);
                cmd.Parameters.AddWithValue("@is_admin", 0);

                try
                {
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Succesfully Registered.Please Login");
                    login log = new login();
                    this.Hide();
                    log.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            con.Close();
        }
예제 #2
0
        private void showData(int index)
        {
            login        log = new login();
            int          id  = log.identity();
            string       sql = "SELECT * FROM InterestTable WHERE [user]=" + id + "";
            OleDbCommand cmd = new OleDbCommand(sql, con);

            adapter = new OleDbDataAdapter(cmd);
            adapter.Fill(table);

            con.Open();
            try
            {
                title.Text        = table.Rows[index]["title"].ToString();
                richTextBox1.Text = table.Rows[index]["description"].ToString();
                cat.Text          = table.Rows[index]["category"].ToString();
                placeLabel.Text   = table.Rows[index]["place"].ToString();
                addressLabel.Text = table.Rows[index]["placeAddress"].ToString();
                townLabel.Text    = table.Rows[index]["town"].ToString();
                date1.Text        = table.Rows[index]["sDate"].ToString();
                date2.Text        = table.Rows[index]["eDate"].ToString();

                /*byte[] fetchedImgBytes = (byte[])table.Rows[index]["image"];
                 * MemoryStream stream = new MemoryStream(fetchedImgBytes);
                 * Image fetchImg = Image.FromStream(stream);
                 * pictureBox1.Image = fetchImg;*/

                //To neo kommati kwdika gia tis fwtografies
                var imgUrl  = table.Rows[index]["image"].ToString();
                var request = WebRequest.Create(imgUrl);

                using (var response = request.GetResponse())
                    using (var stream = response.GetResponseStream())
                    {
                        pictureBox1.Image = Bitmap.FromStream(stream);
                    }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Hide();
            }
            con.Close();
        }
예제 #3
0
        private void linkLabel1_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
        {
            login        log = new login();
            int          id  = log.identity();
            string       sql = "SELECT * FROM InterestTable WHERE [user]=" + id + "";
            OleDbCommand cmd = new OleDbCommand(sql, con);

            adapter1 = new OleDbDataAdapter(cmd);
            adapter1.Fill(table1);
            if (table1.Rows.Count == 0)
            {
                MessageBox.Show("Δεν υπάρχουν αποθηκευμένα event για παρακολούθηση!");
            }
            else
            {
                myEvents my = new myEvents();
                my.Show();
            }
        }
예제 #4
0
 private void loginButton_Click(object sender, EventArgs e)
 {
     if (loginButton.Text == "Login")
     {
         this.Hide();
         login login = new login();
         login.Show();
     }
     else
     {
         usernameLabel.Text = " ";
         myAccount acc = new myAccount();
         acc.logout();
         myAccountLabel.Visible = false;
         loginButton.Text       = "Login";
         adminButton.Visible    = false;
         linkLabel1.Visible     = false;
     }
 }