Пример #1
0
 private void CopiereFisierToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if ((ListViewDirectoare.SelectedIndices.Count > 0) && (ListViewFisiere.SelectedIndices.Count > 0))
     {
         int      IndexDirector = ListViewDirectoare.SelectedIndices[0];
         int      IndexFisier   = ListViewFisiere.SelectedIndices[0];
         Fisier   fisier        = this[IndexDirector][IndexFisier];
         FileInfo fileInfo      = new FileInfo(fisier.GetNumeComplet());
         if (fileInfo.Exists == true)
         {
             FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
             folderBrowserDialog.Description = "Selectati Directorul Destinatie!";
             if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
             {
                 try
                 {
                     string sursaFisier      = fisier.GetNumeComplet();
                     string destiantieFisier = folderBrowserDialog.SelectedPath + "\\" + fisier.GetNumeFisier();
                     File.Copy(fisier.GetNumeComplet(), destiantieFisier);
                 }
                 catch (UnauthorizedAccessException _ExceptionUnauthorized)
                 {
                     Program.SalvareFisierLoguri(_ExceptionUnauthorized);
                 }
                 catch (IOException _Exception)
                 {
                     Program.SalvareFisierLoguri(_Exception);
                 }
             }
         }
     }
 }
        object ICloneable.Clone()
        {
            Fisier fisier = new Fisier();

            fisier.SetNumeFisier(this.GetNumeFisier());
            fisier.SetNumeComplet(this.GetNumeComplet());
            fisier.SetExtensieFisier(this.GetExtensieFisier());
            fisier.SetDimensiuneFisier(this.GetDimensiuneFisier());
            return(fisier);
        }
Пример #3
0
 private void RedenumireFisierToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if ((ListViewDirectoare.SelectedIndices.Count > 0) && (ListViewFisiere.SelectedIndices.Count > 0))
     {
         int      IndexDirector = ListViewDirectoare.SelectedIndices[0];
         int      IndexFisier   = ListViewFisiere.SelectedIndices[0];
         Fisier   fisier        = this[IndexDirector][IndexFisier];
         FileInfo fileInfo      = new FileInfo(fisier.GetNumeComplet());
         if (fileInfo.Exists == true)
         {
             if ((MessageBox.Show("Redenumiti Fisierul?", "Avertisment", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes))
             {
                 string NumeCompletVechi = fisier.GetNumeComplet();
                 string NumeVechi        = fisier.GetNumeFisier();
                 try
                 {
                     this.Hide();
                     Form RedenumireForm = new RedenumireFisierForm(fisier);
                     RedenumireForm.ShowDialog();
                     string numeNou = fileInfo.DirectoryName + "\\" + fisier.GetNumeFisier();
                     fisier.SetNumeFisier(fisier.GetNumeFisier());
                     fisier.SetNumeComplet(numeNou);
                     File.Move(NumeCompletVechi, fisier.GetNumeComplet());
                     ListViewFisiere.Items[IndexFisier].Text = fisier.GetNumeFisier();
                     TreeView.Nodes[IndexDirector].Nodes[IndexFisier].Text = fisier.GetNumeFisier();
                     DatabaseHelper.ActualizareInregistrare(NumeVechi, fisier);
                 }
                 catch (ArgumentException _ExceptionArgumentException)
                 {
                     Program.SalvareFisierLoguri(_ExceptionArgumentException);
                 }
                 catch (UnauthorizedAccessException _ExceptionUnauthorizedAcces)
                 {
                     Program.SalvareFisierLoguri(_ExceptionUnauthorizedAcces);
                 }
                 finally
                 {
                     fisier.SetNumeComplet(NumeCompletVechi);
                     fisier.SetNumeFisier(NumeVechi);
                 }
             }
         }
         this.Show();
     }
     else
     {
         MessageBox.Show("Nu Ai Selectat Niciun Fisier", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #4
0
 private void StergeFisierToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if ((ListViewDirectoare.SelectedIndices.Count > 0) && (ListViewFisiere.SelectedIndices.Count > 0))
     {
         int      IndexDirector = ListViewDirectoare.SelectedIndices[0];
         int      IndexFisier   = ListViewFisiere.SelectedIndices[0];
         Fisier   fisier        = this[IndexDirector][IndexFisier];
         FileInfo fileInfo      = new FileInfo(fisier.GetNumeComplet());
         if (fileInfo.Exists == true)
         {
             if ((MessageBox.Show("Stergeti Fisierul Definitiv?", "Avertisment", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes))
             {
                 try
                 {
                     string sursa = fisier.GetNumeComplet();
                     File.Delete(sursa);
                     ListViewFisiere.Items[IndexFisier].Remove();
                     TreeView.Nodes[IndexDirector].Nodes[IndexFisier].Remove();
                     DatabaseHelper.StergeInregistrare(fisier);
                     this[IndexDirector].GetListaFisiere().Remove(fisier);
                 }
                 catch (UnauthorizedAccessException _ExceptionUnauthorizedAcces)
                 {
                     Program.SalvareFisierLoguri(_ExceptionUnauthorizedAcces);
                 }
             }
             else
             {
                 ListViewFisiere.Items[IndexFisier].Remove();
                 TreeView.Nodes[IndexDirector].Nodes[IndexFisier].Remove();
                 DatabaseHelper.StergeInregistrare(fisier);
                 this[IndexDirector].GetListaFisiere().Remove(fisier);
             }
         }
         else
         {
             ListViewFisiere.Items[IndexFisier].Remove();
             TreeView.Nodes[IndexDirector].Nodes[IndexFisier].Remove();
             DatabaseHelper.StergeInregistrare(fisier);
             this[IndexDirector].GetListaFisiere().Remove(fisier);
         }
     }
     else
     {
         MessageBox.Show("Nu Ai Selectat Niciun Fisier", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #5
0
 private void MutareFisiereToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if ((ListViewDirectoare.SelectedIndices.Count > 0) && (ListViewFisiere.SelectedIndices.Count > 0))
     {
         int      IndexDirector = ListViewDirectoare.SelectedIndices[0];
         int      IndexFisier   = ListViewFisiere.SelectedIndices[0];
         Fisier   fisier        = this[IndexDirector][IndexFisier];
         FileInfo fileInfo      = new FileInfo(fisier.GetNumeComplet());
         if (fileInfo.Exists == true)
         {
             FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
             folderBrowserDialog.Description = "Selectati Directorul Destinatie!";
             if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
             {
                 try
                 {
                     string sursaFisier      = fisier.GetNumeComplet();
                     string destiantieFisier = folderBrowserDialog.SelectedPath + "\\" + fisier.GetNumeFisier();
                     File.Copy(fisier.GetNumeComplet(), destiantieFisier);
                     File.Delete(sursaFisier);
                     ListViewFisiere.Items[IndexFisier].Remove();
                     TreeView.Nodes[IndexDirector].Nodes[IndexFisier].Remove();
                     this[IndexDirector].GetListaFisiere().Remove(fisier);
                     DatabaseHelper.StergeInregistrare(fisier);
                 }
                 catch (IOException _ExceptionIO)
                 {
                     Program.SalvareFisierLoguri(_ExceptionIO);
                 }
                 catch (UnauthorizedAccessException _ExceptionUnauthorizedAcces)
                 {
                     Program.SalvareFisierLoguri(_ExceptionUnauthorizedAcces);
                 }
                 finally
                 {
                     ListViewFisiere.Items[IndexFisier].Remove();
                     TreeView.Nodes[IndexDirector].Nodes[IndexFisier].Remove();
                     this[IndexDirector].GetListaFisiere().Remove(fisier);
                     DatabaseHelper.StergeInregistrare(fisier);
                 }
             }
         }
     }
 }
Пример #6
0
 public void StergeInregistrare(Fisier _Fisier)
 {
     if (this.conexiune != null)
     {
         try
         {
             this.conexiune.Open();
             SQLiteCommand sQLiteCommand = new SQLiteCommand(this.conexiune);
             sQLiteCommand.CommandText = STERGERE_INREGISTRARE_TABEL;
             sQLiteCommand.Parameters.AddWithValue(COLOANA_NUME, _Fisier.GetNumeFisier());
             sQLiteCommand.ExecuteNonQuery();
             this.conexiune.Close();
         }
         catch (SQLiteException _Exception)
         {
             Program.SalvareFisierLoguri(_Exception);
             this.conexiune.Close();
         }
     }
 }
Пример #7
0
        public List <string> SelectareInregistrare(Fisier _Fisier)
        {
            List <string> rating = new List <string>();

            if (this.conexiune != null)
            {
                try
                {
                    this.conexiune.Open();
                    SQLiteCommand sQLiteCommand = new SQLiteCommand(this.conexiune);
                    sQLiteCommand.CommandText = SELECTARE_INREGISTRARE;
                    sQLiteCommand.Parameters.AddWithValue(COLOANA_NUME, _Fisier.GetNumeFisier());
                    SQLiteDataReader sQLiteDataReader = sQLiteCommand.ExecuteReader();
                    while (sQLiteDataReader.Read())
                    {
                        string Gen      = (string)sQLiteDataReader[COLOANA_GEN];
                        string Recenzie = (string)sQLiteDataReader[COLOANA_RECENZIE];
                        bool   Vizualizat;
                        if ((sQLiteDataReader[COLOANA_VIZUALIZAT].ToString().ToLower()) == "true")
                        {
                            Vizualizat = true;
                        }
                        else
                        {
                            Vizualizat = false;
                        }
                        rating.Add(Gen);
                        rating.Add(Recenzie);
                        rating.Add(Vizualizat.ToString());
                    }
                    sQLiteDataReader.Close();
                    this.conexiune.Close();
                }
                catch (SQLiteException _Exception)
                {
                    Program.SalvareFisierLoguri(_Exception);
                    this.conexiune.Close();
                }
            }
            return(rating);
        }
Пример #8
0
        private List <Fisier> CreareListaFisiere(Director _Director)
        {
            List <Fisier>          listaFisiere           = new List <Fisier>();
            DelegateExtrageFisiere delegateExtrageFisiere = new DelegateExtrageFisiere(ExtrageNumeFisiere);

            string[] fisiere = delegateExtrageFisiere(_Director.GetLocatieDirector(), "*.mp3|*.avi|*.flv|*.mp4|*.xvid|*.divx", SearchOption.AllDirectories);
            for (int Index = 0; Index < fisiere.Length; Index++)
            {
                FileInfo fileInfo = new FileInfo(fisiere[Index]);
                SchimbaAtributeleFisierelor(fileInfo.FullName);
                Fisier fisier = new Fisier();
                fisier.SetNumeFisier(fileInfo.Name);
                fisier.SetNumeComplet(fileInfo.FullName);
                fisier.SetExtensieFisier(fileInfo.Extension);
                fisier.SetDimensiuneFisier((fileInfo.Length) / 1024);
                List <string> rating = DatabaseHelper.SelectareInregistrare(fisier);
                if (rating.Count > 0)
                {
                    fisier.SetGen(rating[0]);
                    fisier.SetRecenzie(rating[1]);
                    if ((rating[2].ToLower()) == "true")
                    {
                        fisier.SetVizualizat(true);
                    }
                    else
                    {
                        fisier.SetVizualizat(false);
                    }
                }
                else
                {
                    fisier.SetGen("");
                    fisier.SetRecenzie("");
                    fisier.SetVizualizat(false);
                    DatabaseHelper.InserareInregistrare(fisier);
                }
                listaFisiere.Add(fisier);
            }
            return(listaFisiere);
        }
Пример #9
0
 public void InserareInregistrare(Fisier _Fisier)
 {
     if (this.conexiune != null)
     {
         try
         {
             this.conexiune.Open();
             SQLiteCommand sQLiteCommand = new SQLiteCommand(this.conexiune);
             sQLiteCommand.CommandText = INSERARE_INREGISTRARE_TABEL;
             sQLiteCommand.Parameters.AddWithValue(COLOANA_NUME, _Fisier.GetNumeFisier());
             sQLiteCommand.Parameters.AddWithValue(COLOANA_GEN, _Fisier.GetGen());
             sQLiteCommand.Parameters.AddWithValue(COLOANA_RECENZIE, _Fisier.GetRecenzie());
             sQLiteCommand.Parameters.AddWithValue(COLOANA_VIZUALIZAT, _Fisier.GetVizualizat().ToString());
             sQLiteCommand.ExecuteNonQuery();
             this.conexiune.Close();
         }
         catch (SQLiteException _Exception)
         {
             Program.SalvareFisierLoguri(_Exception);
             this.conexiune.Close();
         }
     }
 }
Пример #10
0
 public AdaugaRatingForm(Fisier _Fisier)
 {
     InitializeComponent();
     this.fisier          = _Fisier;
     this.NumeVechiFisier = _Fisier.GetNumeFisier();
 }
Пример #11
0
 public RedenumireFisierForm(Fisier _Fisier)
 {
     InitializeComponent();
     this.fisier    = _Fisier;
     this.numeVechi = _Fisier.GetNumeFisier().Remove(_Fisier.GetNumeFisier().Length - _Fisier.GetExtensieFisier().Length);
 }