private void buttonModify_Click(object sender, EventArgs e)
 {
     if (selectedTechnologyId != 0)
     {
         newTechnologyName = textBoxTehnology.Text;
         Confirmation c  = new Confirmation("Confirm modification?");
         DialogResult dr = c.ShowDialog();
         if (dr == DialogResult.Yes)
         {
             try
             {
                 Update_DB.modifyTechnologyInDB(newTechnologyName, selectedTechnologyId);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             MessageBox.Show("Modification successfully performed");
             emptyModifyTechnologyFields();
             fill_ComboBoxTechnology();
         }
         if (dr == DialogResult.No)
         {
             MessageBox.Show("Modification not performed");
             emptyModifyTechnologyFields();
         }
     }
 }
Example #2
0
        private void buttonAddTehnology_Click(object sender, EventArgs e)
        {
            name = textBoxTechnology.Text;
            //Verifica daca campul de <Add new technology> este gol
            if (name == "")
            {
                MessageBox.Show("Add new field cannot be empty");
            }
            else
            {
                // Salvez lungimea listei in variabila listLength;
                int listLength = technologiesDT.Rows.Count;
                //Initializez sirul technologiesList de lungime =listLength;
                String[] technologiesList = new String[listLength];

                //Verifica daca valoarea din name se afla deja in technologiesDT
                //(daca tehnologia tastata exista deja in DB)
                foreach (DataRow dtrw in technologiesDT.Rows)
                {
                    if (dtrw.Field <string>("nume_categorie") == name)
                    {
                        MessageBox.Show("Technology allready in DataBase");
                        emptyAddTechnologyField();
                        return;
                    }
                }

                //Daca numele tehnologiei nu este in DataBase, se continua cu fereastra de confirmare
                Confirmation c  = new Confirmation("Confirm DataBase entry?");
                DialogResult dr = c.ShowDialog();
                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        Update_DB.addTechnologyInDB(name);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    MessageBox.Show("DataBase entry successfully performed");
                    emptyAddTechnologyField();
                    fill_listBoxTechnology();
                }
                if (dr == DialogResult.No)
                {
                    MessageBox.Show("DataBase entry not performed");
                    emptyAddTechnologyField();
                }
            }
        }
Example #3
0
        private void buttonDeleteTechnologies_Click(object sender, EventArgs e)
        {
            if (checkedListBoxDeleteTechnologies.CheckedIndices.Count > 0)
            {
                Confirmation c  = new Confirmation("Confirm deletion?");
                DialogResult dr = c.ShowDialog();
                ArrayList    listDeleteTechnologies = new ArrayList();
                if (dr == DialogResult.Yes)
                {
                    int idTechnology;
                    try
                    {
                        foreach (int i in checkedListBoxDeleteTechnologies.CheckedIndices)
                        {
                            checkedListBoxDeleteTechnologies.SelectedIndex = i;
                            idTechnology = Convert.ToInt32(((DataRowView)checkedListBoxDeleteTechnologies.SelectedValue)["id_categ"]);
                            listDeleteTechnologies.Add(idTechnology);
                        }
                        Update_DB.deleteTechnologyInDB(listDeleteTechnologies);

                        // Reincarc in CheckList cu tehnologiile ramase du modificare DB
                        // Pentru asta "resetez" datele din DataTable technologiesDT (sursa pentru listDeleteTechnologies.DataSource)
                        MessageBox.Show("Deletion was succesfull");
                        technologiesDT.Clear();
                        fill_checkedListBoxDeleteTechnology();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                if (dr == DialogResult.No)
                {
                    MessageBox.Show("Deletion not performed");
                    empty_checkedListBoxDeleteTechnologies();
                }
            }
            else
            {
                MessageBox.Show("You did not select a technology!");
            }
        }