예제 #1
0
        private void bCreateEvent_Click(object sender, EventArgs e)
        {
            /*Cursor.Current = Cursors.WaitCursor;
             * try
             * {
             *  string eventName = tTitle.Text;
             *  string eventDescription = tDescription.Text;
             *  DateTime date = tDatePicker.Value;
             *
             *  string[] aux = date.ToString().Split(' ');
             *  string eventDate = aux[0];
             *  string eventOrganiser = tOrganizer.Text;
             *  string eventCreator = usuario.Username;
             *  string image = tImage.Text;
             *  Event evento = new Event(eventName, eventDate, image, eventDescription, eventOrganiser, eventCreator);
             *  MessageBox.Show("Evento creado con exito");
             *  MisEventos misEventos = new MisEventos(usuario);
             *  misEventos.Show();
             *  this.Close();
             *
             * }
             * catch(Exception ex)
             * {
             *  MessageBox.Show(ex.Message);
             * }*/
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                string   eventName        = tTitle.Text;
                string   eventDescription = tDescription.Text;
                DateTime date             = tDatePicker.Value;

                string[] aux            = date.ToString().Split(' ');
                string   eventDate      = aux[0];
                string   eventOrganiser = tOrganizer.Text;
                string   eventCreator   = usuario.Username;
                string   image          = "comida.jpg";
                Event    evento         = new Event(eventName, eventDate, image, eventDescription, eventOrganiser, eventCreator);
                new Forum(evento);
                if (FTPClient.ftpOn)
                {
                    FTPClient ftp = new FTPClient("ftp://25.35.182.85:12975/", "Prueba", "");
                    try
                    {
                        ftp.MakeFtpDirectory("eventos/" + evento.ID);
                        ftp.MakeFtpDirectory("eventos/" + evento.ID + "/files");
                    }
                    catch (Exception ex) { }
                    ftp.UploadFile(imagen, "/eventos/" + evento.ID + "/image.png");
                }
                // imagePath.Substring(0, imagePath.LastIndexOf("/")

                MessageBox.Show("Evento creado con exito");
                MisEventos misEventos = new MisEventos(usuario);
                misEventos.Show();
                this.Owner.Close();
                this.Close();
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        public void mostrarEventos()
        {
            panelEventos.Controls.Clear();
            List <Event> listaEventos = Event.listaEventos();
            int          nEventos     = listaEventos.Count;
            int          separacion   = 50;

            for (int i = 0; i < nEventos; i++)
            {
                string eventName        = listaEventos.ElementAt(i).EventName;
                string eventDate        = listaEventos.ElementAt(i).Date;
                string eventDescription = listaEventos.ElementAt(i).EventDescription;
                string imagen           = listaEventos.ElementAt(i).Image;
                int    id = listaEventos.ElementAt(i).ID;

                Panel panel = new Panel();
                panel.Name = "pEvento" + id;

                //------------------

                LinkLabel ltitulo = new LinkLabel();
                ltitulo.Text      = eventName;
                ltitulo.Size      = new Size(292, 38);
                ltitulo.AutoSize  = true;
                ltitulo.Font      = new Font("Microsoft Sans Serif", 19.8F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
                ltitulo.LinkColor = Color.Black;
                ltitulo.Location  = new Point(230, 18);
                ltitulo.Name      = id.ToString();
                ltitulo.TabIndex  = 31;
                ltitulo.TabStop   = true;
                ltitulo.Visible   = true;
                ltitulo.Click    += new EventHandler(ltitulo_click);

                //------------------


                PictureBox pImagen = new PictureBox();
                pImagen.BackColor = SystemColors.ActiveCaption;
                pImagen.Location  = new Point(59, 28);
                pImagen.Name      = "pImagen";

                string path      = Path.GetDirectoryName(Application.StartupPath);
                string pathBueno = path.Substring(0, path.Length - 3);
                string imagePath = pathBueno + "images\\" + imagen;

                Image image;
                if (FTPClient.ftpOn)
                {
                    try
                    {
                        FTPClient ftpClient   = new FTPClient("ftp://25.35.182.85:12975/eventos/" + listaEventos.ElementAt(i).ID + "/", "Prueba", "");
                        byte[]    byteArrayIn = ftpClient.DownloadFileBytesInArray("image.png");
                        using (var ms = new MemoryStream(byteArrayIn))
                        {
                            image = Image.FromStream(ms);
                        }
                    }
                    catch (Exception ex)
                    {
                        image = null;
                    }
                }
                else if (FTPClient.ftpBackupOn)
                {
                    FTPClient ftp = new FTPClient("ftp://25.35.182.85:12975/", "Prueba", "");
                    try
                    {
                        ftp.MakeFtpDirectory("eventos/" + listaEventos.ElementAt(i).ID);
                    }
                    catch (Exception ex) { }
                    ftp.UploadFile(imagePath, "eventos/" + listaEventos.ElementAt(i).ID + "/image.png");
                    image = Image.FromFile(imagePath);
                }
                else
                {
                    image = Image.FromFile(imagePath);
                }

                pImagen.Image       = image;
                pImagen.SizeMode    = PictureBoxSizeMode.StretchImage;
                pImagen.Size        = new Size(115, 127);
                pImagen.TabIndex    = 0;
                pImagen.TabStop     = false;
                pImagen.Visible     = true;
                pImagen.BorderStyle = BorderStyle.FixedSingle;


                TextBox tFecha = new TextBox();
                tFecha.Text        = "Fecha del evento: " + eventDate;
                tFecha.BorderStyle = BorderStyle.None;
                tFecha.Font        = new Font("Microsoft Sans Serif", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
                tFecha.Location    = new Point(900, 145);
                tFecha.Multiline   = true;
                tFecha.Name        = "tFecha";
                tFecha.ReadOnly    = true;
                tFecha.Size        = new Size(216, 24);
                tFecha.TabIndex    = 32;
                tFecha.Visible     = true;



                panel.Size = new Size(1142, 186); //1142 186

                panel.Location    = new Point(50, separacion);
                panel.Visible     = true;
                panel.BorderStyle = BorderStyle.FixedSingle;


                TextBox descripcion = new TextBox();
                descripcion.Text        = eventDescription;
                descripcion.BorderStyle = BorderStyle.None;
                descripcion.Font        = new Font("Microsoft Sans Serif", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
                descripcion.Location    = new Point(233, 68);
                descripcion.Multiline   = true;
                descripcion.Name        = "tDescripcion";
                descripcion.ReadOnly    = true;
                descripcion.Size        = new Size(panel.Width / 2, panel.Height / 2); //685,59
                descripcion.TabIndex    = 2;
                descripcion.Visible     = true;



                panel.Controls.Add(ltitulo);
                panel.Controls.Add(pImagen);
                panel.Controls.Add(tFecha);
                panel.Controls.Add(descripcion);
                panelEventos.Controls.Add(panel);
                separacion += 180;
            }
            panelEventos.BorderStyle = BorderStyle.FixedSingle;
            panelEventos.Size        = new Size(1265, 640);
        }
예제 #3
0
        public InfoEvento(Event e, User u)
        {
            this.ev = e;
            InitializeComponent();
            string imagen    = "asuma2.ico";
            string path      = Path.GetDirectoryName(Application.StartupPath);
            string pathBueno = path.Substring(0, path.Length - 3);
            string imagePath = pathBueno + "images\\" + imagen;
            Icon   icon      = new Icon(imagePath, 100, 100);

            this.Icon = icon;

            imagen    = e.Image;
            path      = Path.GetDirectoryName(Application.StartupPath);
            pathBueno = path.Substring(0, path.Length - 3);
            imagePath = pathBueno + "images\\" + imagen;
            Image image;

            if (FTPClient.ftpOn)
            {
                try
                {
                    FTPClient ftpClient   = new FTPClient("ftp://25.35.182.85:12975/eventos/" + ev.ID + "/", "Prueba", "");
                    byte[]    byteArrayIn = ftpClient.DownloadFileBytesInArray("image.png");
                    using (var ms = new MemoryStream(byteArrayIn))
                    {
                        image = Image.FromStream(ms);
                    }
                }
                catch (Exception ex)
                {
                    image = null;
                }
            }
            else
            {
                image = Image.FromFile(imagePath);
            }
            pEvento.Image = image;


            lTitulo.Text        = e.EventName;
            tDes.Text           = e.EventDescription;
            lOrganizadores.Text = e.Organizer;
            lFecha.Text         = e.Date;

            this.usuario = u;

            if (usuario == null)
            {
                lUsername.Visible    = false;
                pUser.Visible        = false;
                linitSesion.Visible  = true;
                lSignOut.Visible     = false;
                bInscription.Visible = false;
            }
            else
            {
                pUser.Visible        = true;
                lUsername.Text       = "Bienvenido " + usuario.Username;
                linitSesion.Visible  = false;
                lSignOut.Visible     = true;
                bInscription.Visible = true;
            }
        }