Beispiel #1
0
        public void RefreshDgk_DB()
        {
            FilePersonKeywordClient        client = new FilePersonKeywordClient();
            List <MemoriesManager.Keyword> myList;

            myList = client.GetAllKeywords().ToList();
            this.dgk_DB.DataSource = myList;
            client.Close();
        }
Beispiel #2
0
        private void button_fIntoP_Click(object sender, EventArgs e)
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();
            List <int> ids = getPersonIdsFromSelectedRows();

            client.DeletePeopleFromFile(ids.ToArray(), listBox_Files.SelectedItem.ToString());
            RefreshDgp_file();
            client.Close();
        }
Beispiel #3
0
        private void dgp_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();

            Console.WriteLine(e.RowIndex + " " + e.ColumnIndex);
            MemoriesManager.Person person;
            Console.WriteLine(dgp_DB[0, e.RowIndex] + " " + dgp_DB[1, e.RowIndex].ToString() + " " + dgp_DB[2, e.RowIndex].ToString());
            person = client.UpdatePersonNameById(Convert.ToInt32(dgp_DB[2, e.RowIndex].Value), dgp_DB[1, e.RowIndex].Value.ToString(), dgp_DB[3, e.RowIndex].Value.ToString());
            client.Close();
        }
Beispiel #4
0
        private void dgk_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();

            MemoriesManager.Keyword keyword = new MemoriesManager.Keyword();
            // Updating keyword in data grid view
            Console.WriteLine(((dgk_DB[0, e.RowIndex].Value)));
            keyword = client.UpdateKeywordKwordById(Convert.ToInt32(dgk_DB[0, e.RowIndex].Value), dgk_DB[1, e.RowIndex].Value.ToString());
            RefreshDgk_file();
            client.Close();
        }
Beispiel #5
0
        //Get selected persons and bind them with current selected file
        private void AddingPersonsToFile(DataGridView dgp)
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();
            Int32 selectedRowCount         = dgp.Rows.GetRowCount(DataGridViewElementStates.Selected); //getting number of selected rows

            for (int i = 0; i < selectedRowCount; i++)
            {
                Console.WriteLine(dgp[0, dgp.SelectedRows[i].Index].Value.ToString());
                client.InsertPersonIntoFile(Convert.ToInt32(dgp[0, dgp.SelectedRows[i].Index].Value), listBox_Files.SelectedItem.ToString());
            }
            client.Close();
        }
Beispiel #6
0
        // Check keywords of the current file and display them in data grid view
        public void RefreshDgk_file()
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();

            if (listBox_Files.SelectedIndex >= 0)
            {
                if (client.GetFileByPath(listBox_Files.SelectedItem.ToString()) != null)
                {
                    dgk_file.ClearSelection();
                    dgk_file.DataSource = client.GetKeywordsOfFile(listBox_Files.SelectedItem.ToString());
                    client.Close();
                }
            }
        }
        private void button_Add_Click(object sender, EventArgs e)
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();

            if ((client.GetKeywordByKword(textBox_Kword.Text) == null))
            {
                global::MemoriesManager.Keyword newKeyword = new global::MemoriesManager.Keyword
                {
                    Kword = textBox_Kword.Text
                };
                client.CreateKeyword(newKeyword);
            }
            else
            {
                MessageBox.Show("That keyword already exists in DB", "Error");
            }
            memoriesManagerForm.RefreshDgk_DB();
        }
Beispiel #8
0
 private void button_DeletePerson_Click(object sender, EventArgs e)
 {
     if (dgp_DB.SelectedRows.Count != 0)
     {
         for (int i = 0; i < dgp_DB.Rows.Count; i++)
         {
             if (dgp_DB.Rows[i].Selected == true)
             {
                 FilePersonKeywordClient client = new FilePersonKeywordClient();
                 client.DeletePerson(Convert.ToInt32(dgp_DB[0, i].Value));
                 client.Close();
                 Console.WriteLine(Convert.ToInt32(dgp_DB[0, i].Value));
             }
         }
         RefreshDgp_DB();
         RefreshDgp_file();
     }
 }
Beispiel #9
0
        private void button_DeleteFileFromDb_Click(object sender, EventArgs e)
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();

            client.DeleteFileByPath(listBox_Files.SelectedItem.ToString());
            label_dbResponse.Text           = "The file is unregistered in DB";
            label_dbResponse.ForeColor      = Color.Red;
            textBox_locations.Text          = "";
            dateTimePicker_createdAt.Value  = DateTime.Now;
            button_AddFileInDb.Enabled      = true;  //Activam butonul de adaugare fisier in DB
            button_DeleteFileFromDb.Enabled = false; //Dezactivam butonul de stergere fisier din DB
            disableArrowButtons();
            client.Close();
            dgk_DB.ClearSelection();
            dgk_file.DataSource = "";
            dgp_DB.ClearSelection();
            dgp_file.DataSource = "";
        }
        private void button_AddNewPerson_Click(object sender, EventArgs e)
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();

            if ((client.GetPersonByName(textBox_FirstName.Text, textBox_LastName.Text)) == null)
            {
                global::MemoriesManager.Person newPerson = new global::MemoriesManager.Person
                {
                    First_name = textBox_FirstName.Text,
                    Last_name  = textBox_LastName.Text
                };
                client.CreatePerson(newPerson);
            }
            else
            {
                MessageBox.Show("That person already exists in DB", "Error");
            }
            memoriesManagerForm.RefreshDgp_DB();
        }
Beispiel #11
0
        private void listBox_files_SelectedIndexChanged(object sender, EventArgs e)
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();

            MemoriesManager.File fileSelected = new MemoriesManager.File();

            if (listBox_Files.SelectedIndex >= 0)
            {
                ChangeImageInPictureBox(pictureBox_Files, listBox_Files.SelectedItem.ToString());
                if ((fileSelected = client.GetFileByPath(listBox_Files.SelectedItem.ToString())) != null)
                {
                    label_dbResponse.Text           = "The file is registered in DB    >";
                    label_dbResponse.ForeColor      = Color.Green;
                    textBox_locations.Text          = fileSelected.Location;
                    dateTimePicker_createdAt.Value  = fileSelected.Created_at;
                    button_AddFileInDb.Enabled      = false; //Dezactivam butonul de adaugare fisier in DB
                    button_DeleteFileFromDb.Enabled = true;  //Activam butonul de stergere fisier din DB
                    RefreshDgk_file();
                    RefreshDgp_file();
                    dgp_file.ClearSelection();
                    dgk_file.ClearSelection();
                    enableArrowButtons();
                }
                else
                {
                    label_dbResponse.Text           = "The file is unregistered in DB    >";
                    label_dbResponse.ForeColor      = Color.Red;
                    textBox_locations.Text          = "";
                    dateTimePicker_createdAt.Value  = DateTime.Now;
                    button_AddFileInDb.Enabled      = true;  //Activam butonul de adaugare fisier in DB
                    button_DeleteFileFromDb.Enabled = false; //Dezactivam butonul de stergere fisier din DB
                    dgk_DB.ClearSelection();
                    dgp_DB.ClearSelection();
                    //RefreshDgk_file();
                    dgk_file.DataSource = "";
                    //RefreshDgp_file();
                    dgp_file.DataSource = "";
                    disableArrowButtons();
                }
                client.Close();
            }
        }
Beispiel #12
0
        private void button_AddFileInDb_Click(object sender, EventArgs e)
        {
            FilePersonKeywordClient client = new FilePersonKeywordClient();

            MemoriesManager.File file = new MemoriesManager.File
            {
                Path         = listBox_Files.SelectedItem.ToString(),
                Created_at   = dateTimePicker_createdAt.Value.Date,
                Type         = "Image",
                Path_changed = false,
                Location     = textBox_locations.Text
            };
            client.CreateFile(file);
            enableArrowButtons();
            button_AddFileInDb.Enabled      = false; //Dezactivam butonul de adaugare fisier in DB
            label_dbResponse.Text           = "The file is registered in DB";
            label_dbResponse.ForeColor      = Color.Green;
            button_DeleteFileFromDb.Enabled = true; //Activam butonul de stergere fisier din DB
            AddingKeywordsToFile(dgk_DB);
            AddingPersonsToFile(dgp_DB);
            RefreshDgk_file();
            RefreshDgp_file();
            client.Close();
        }