private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { DialogResult resMessange = MessageBox.Show("Бажаєте додати до документу ключове слово - " + listBox1.SelectedItem.ToString() + "?", "Підтвердження дій", MessageBoxButtons.YesNo); if (resMessange == DialogResult.Yes) { if (checkDocumentSimilarity(listBox1.SelectedItem.ToString()) == false) { MessageBox.Show("Ключове слово успішно додано!"); masOldKeyWords[countOldKeyWords] = new InformationAboutDocumentAll(); masOldKeyWords[countOldKeyWords].id = seekInOneElementInMasKeyWords(listBox1.SelectedItem.ToString()); masOldKeyWords[countOldKeyWords].NewElement = true; masOldKeyWords[countOldKeyWords++].keyword = listBox1.SelectedItem.ToString(); listBox2.Items.Add(listBox1.SelectedItem.ToString()); } else { MessageBox.Show("Дане ключове слово вже є у списку ключових слів, які прив’язані к документу!", "Повідомлення"); } } } }
bool deleteElementFromMasOldkeywords(string tmp) { for (int i = 0; i < countOldKeyWords; i++) { if (masOldKeyWords[i].keyword == tmp) { positionOldKeyWords = i; break; } } if (listBox2.Items.Count > 1) { InformationAboutDocumentAll tmpObForSwapInformation = new InformationAboutDocumentAll(); tmpObForSwapInformation.id = masOldKeyWords[positionOldKeyWords].id; tmpObForSwapInformation.keyword = masOldKeyWords[positionOldKeyWords].keyword; masOldKeyWords[positionOldKeyWords].id = masOldKeyWords[countOldKeyWords - 1].id; masOldKeyWords[positionOldKeyWords].keyword = masOldKeyWords[countOldKeyWords - 1].keyword; masOldKeyWords[countOldKeyWords - 1].id = tmpObForSwapInformation.id; masOldKeyWords[countOldKeyWords - 1].keyword = tmpObForSwapInformation.keyword; masOldKeyWords[countOldKeyWords - 1] = null; countOldKeyWords--; for (int i = 0; i < listBox2.Items.Count; i++) { if (listBox2.Items[i].ToString() == tmp) { listBox2.Items.RemoveAt(i); break; } } return(true); } else { MessageBox.Show("Документ має включати хоча б одне ключове слово!", "Повідомлення"); return(false); } }
void createMasKeyWords() { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); string sql = "SELECT * FROM diploma.tags;"; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { masKeyWords[countKeyWords] = new InformationAboutDocumentAll(); masKeyWords[countKeyWords].id = Convert.ToInt32(reader[0]); masKeyWords[countKeyWords++].keyword = reader[1].ToString(); listBox1.Items.Add(reader[1].ToString()); } reader.Close(); conn.Close(); }
void createMasDiscipline() { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); string sql = "SELECT ID_s_l, ID_discipline, discipline_name FROM studyload, users, disciplines WHERE studyload.ID_user = users.ID_u and studyload.ID_discipline = disciplines.ID_d and fio LIKE ('%" + MainForm.strWay[0] + "%');"; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { masDisciplineDocument[countMasDisciplineDocument] = new InformationAboutDocumentAll(); masDisciplineDocument[countMasDisciplineDocument].id = Convert.ToInt32(reader[0]); masDisciplineDocument[countMasDisciplineDocument++].discipline = reader[2].ToString(); comboBox2.Items.Add(reader[2].ToString()); } reader.Close(); conn.Close(); }
void createMasType() { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); string sql = "SELECT * FROM diploma.document_specification;"; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { masTypeDocument[countMasTypeDocument] = new InformationAboutDocumentAll(); masTypeDocument[countMasTypeDocument].id = Convert.ToInt32(reader[0]); masTypeDocument[countMasTypeDocument++].type = reader[1].ToString(); comboBox1.Items.Add(reader[1].ToString()); } reader.Close(); conn.Close(); }
void createMasOldKeywords() { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); string sql = "SELECT ID_material, tags.ID_tag, Tag_name FROM material_tag, tags WHERE material_tag.ID_tag = tags.ID_tag and ID_material = " + MainForm.strWay[5] + ";"; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { masOldKeyWords[countOldKeyWords] = new InformationAboutDocumentAll(); masOldKeyWords[countOldKeyWords].id = Convert.ToInt32(reader[1]); masOldKeyWords[countOldKeyWords].NewElement = false; masOldKeyWords[countOldKeyWords++].keyword = reader[2].ToString(); listBox2.Items.Add(reader[2].ToString()); } reader.Close(); conn.Close(); }