Пример #1
0
        public void interest()
        {
            string       sql = "INSERT INTO InterestTable (title, town, description, place, placeAddress, [sDate], [eDate], category, [user], [image]) VALUES (?,?,?,?,?,?,?,?,?,?)";
            OleDbCommand cmd = new OleDbCommand(sql, con);

            login log = new login();

            cmd.Parameters.AddWithValue("@title", this.title.Text);
            cmd.Parameters.AddWithValue("@town", town.Text);
            cmd.Parameters.AddWithValue("@description", this.description_Rich.Text);
            cmd.Parameters.AddWithValue("@place", this.place.Text);
            cmd.Parameters.AddWithValue("@placeAddress", this.address.Text);
            cmd.Parameters.AddWithValue("@sDate", this.date.Text);
            cmd.Parameters.AddWithValue("@eDate", this.date2.Text);

            /*OleDbParameter par = cmd.Parameters.AddWithValue("@image", SqlDbType.Binary);
             * par.Value = imgAsBytes;
             * par.Size = imgAsBytes.Length;*/
            cmd.Parameters.AddWithValue("@category", this.category.Text);
            cmd.Parameters.AddWithValue("@user", log.identity());
            cmd.Parameters.AddWithValue("@image", img());
            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                MessageBox.Show("προστεθηκε επιτυχως!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            con.Close();
        }
Пример #2
0
        private void myEventDelete_Click(object sender, EventArgs e)
        {
            login log  = new login();
            int   iden = log.identity();

            string       sql = "DELETE ROW FROM InterestTable WHERE (title = ? AND user = ?)";
            OleDbCommand cmd = new OleDbCommand(sql, con);

            try
            {
                con.Open();

                cmd.Parameters.AddWithValue("@title", title.Text);
                cmd.Parameters.AddWithValue("@user", iden);

                cmd.ExecuteNonQuery();
                MessageBox.Show("Το event διαγράφηκε από τα αποθηκευμένα :(");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            con.Close();
            this.Close();
            myEvents my = new myEvents();

            my.Show();
        }
Пример #3
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();
        }
Пример #4
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();
            }
        }