Пример #1
0
        public static PerfilClassOnline saveProfile(PerfilClassOnline p)
        {
            MySqlConnection conexion = null;

            try {
                conexion = getConnection();
                conexion.Open();

                MySqlTransaction myTrans = conexion.BeginTransaction();

                MySqlCommand comando = new MySqlCommand("SELECT id FROM Perfil WHERE nombre=@nombre and fk_Usuario=@usuario", conexion);
                comando.Parameters.AddWithValue("@nombre", p.nombre);
                comando.Parameters.AddWithValue("@usuario", VIGallery.getUser().id);
                MySqlDataReader reader = comando.ExecuteReader();

                if (!reader.HasRows)
                {
                    reader.Close();

                    comando             = new MySqlCommand("INSERT INTO Perfil VALUES (null, @nombrePerfil, @mode, @numMenus, @fkUsuario)", conexion);
                    comando.Transaction = myTrans;

                    comando.Parameters.AddWithValue("@nombrePerfil", p.nombre);
                    comando.Parameters.AddWithValue("@mode", 0);
                    comando.Parameters.AddWithValue("@numMenus", 0);
                    comando.Parameters.AddWithValue("@fkUsuario", VIGallery.getUser().id);
                    comando.ExecuteNonQuery();
                    myTrans.Commit();

                    comando.Parameters.Clear();
                    reader.Close();
                    comando = new MySqlCommand("SELECT id FROM Perfil WHERE nombre=@nombre and fk_Usuario=@fkUsuario", conexion);
                    comando.Parameters.AddWithValue("@nombre", p.nombre);
                    comando.Parameters.AddWithValue("@fkUsuario", p.idUsuario);
                    reader = comando.ExecuteReader();
                    if (reader.HasRows)
                    {
                        reader.Read();
                        Int32 id = (Int32)reader["id"];
                        p.id = id;
                        return(p);
                    }

                    return(p);
                }
            } catch (MySqlException e) {
                Console.WriteLine("No se ha podido añadir el perfil:\n" + e);
                throw e;
            } finally {
                if (conexion != null)
                {
                    conexion.Close();
                }
            }
            return(null);
        }
Пример #2
0
 public MenuComponent(WrapPanelPrincipal wp, /*SerieComponent s, */ VIGallery vi, Grid gridPrincipal)
 {
     InitializeComponent();
     _defaultCanvas = canvasFolder;
     _wrapSeries    = wp;
     //setSerie(s);
     isVisible      = false;
     _ventanaMain   = vi;
     _gridPrincipal = gridPrincipal;
 }
Пример #3
0
 public Archivo(ArchivoClass archivo, VIGallery vi, WrapPanelPrincipal wrap)
 {
     InitializeComponent();
     this.main      = vi;
     _wrapMenu      = wrap;
     _archivoClass  = archivo;
     _carpetaPadre  = null;
     _defaultCanvas = canvasFile;
     Title.SetText(_archivoClass.nombre);
 }
Пример #4
0
 private void onClick(object sender, RoutedEventArgs e)
 {
     if (_selectedProfile != null)
     {
         Dispatcher.Invoke(new Action(() => {
             VIGallery vi = new VIGallery(_selectedProfile);
             vi.loadDataConexion(_selectedProfile.id);
             vi.Show();
         }));
         //Task task1 = Task.Factory.StartNew(() => loadProfile());
         //Task.WaitAll(task1);
         this.Close();
     }
     else
     {
         MessageBox.Show("No has seleccionado un perfil");
     }
 }
Пример #5
0
 public void setMain(VIGallery vi)
 {
     this.main = vi;
 }
Пример #6
0
 public void setMain(VIGallery vi)
 {
     main = vi;
 }
Пример #7
0
 public VideoElement(VIGallery vi)
 {
     InitializeComponent();
     main = vi;
 }
Пример #8
0
 public void setVIGallery(VIGallery vi)
 {
     main = vi;
 }
Пример #9
0
        public void onAceptar(object sender, RoutedEventArgs e)
        {
            if (newProfileText.Text.CompareTo("") != 0)
            {
                Regex containsABadCharacter = new Regex("[" + Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars())) + "]");
                if (!containsABadCharacter.IsMatch(newProfileText.Text))
                {
                    if (!Lista.checkProfile(newProfileText.Text))
                    {
                        PerfilClassOnline pfOnline = new PerfilClassOnline(newProfileText.Text.ToString(), VIGallery.getUser().id);
                        pfOnline = Conexion.saveProfile(pfOnline);

                        if (pfOnline != null)
                        {
                            addedProfile = true;
                            Lista.addProfile(pfOnline);
                        }
                        name = newProfileText.Text;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("El perfil ya existe");
                    }
                }
                else
                {
                    MessageBox.Show("El nombre contiene caractéres no permitidos: " + new string(System.IO.Path.GetInvalidFileNameChars()));
                }
            }
            else
            {
                MessageBox.Show("No has introducido un nombre");
            }
        }