private void MoveItemButton_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { var currentItemID = textBox2.Text; //обнуляется var item = GetConnect_ItemFromListbox(currentItemID); //после FillComboBox, var currentBook = (BookItem)comboBox1.SelectedItem; //поэтому определяем в начале var currentComboBoxIndexBook = comboBox1.SelectedIndex; var selectForm = new frmSelectBook(); selectForm.ShowDialog(); FillComboBox(); var selectBook = selectForm.SELECTEDBOOK; if (currentBook != selectBook) { if (selectBook.BookName != "") { InsertRecordToBook(selectBook, item); DeleteRecordInBook(currentBook, item); ClearItemInfoOnForm(); var findIndex = comboBox1.FindStringExact(selectBook.BookName); comboBox1.SelectedIndex = findIndex != -1 ? findIndex : 0; comboBox1_SelectedIndexChanged(this, e); } else { comboBox1.SelectedIndex = currentComboBoxIndexBook; //возвращаем просматриваемую книгу после обновления списка книг } } } }
private void добавитьТекущийАдресToolStripMenuItem_Click(object sender, EventArgs e) { if (File.Exists(UserConfig.ConfigUserFile)) { var suggestedIDName = System.Net.Dns.GetHostName(); var selectForm = new frmSelectBook(); selectForm.ShowDialog(); FillComboBox(); var selectBook = selectForm.SELECTEDBOOK; if (selectBook.BookName != "") { var thisID = UserConfig.GetThisID(); if (thisID.ID != zeroConnectItem.ID) { var item = new Connect_Item(thisID.adAlias, thisID.ID, suggestedIDName, "Добавлен через \"Текущий адрес\" \r\n" + DateTime.Now.ToLongDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString()); InsertRecordToBook(selectBook, item); } else { MessageBox.Show("Текущий адрес не найден"); } var findIndex = comboBox1.FindStringExact(selectBook.BookName); comboBox1.SelectedIndex = findIndex != -1 ? findIndex : 0; comboBox1_SelectedIndexChanged(this, e); } } else { MessageBox.Show("Текущий адрес не найден"); } }
private void импортИзНедавнихСеансовToolStripMenuItem_Click(object sender, EventArgs e) { if (File.Exists(UserConfig.ConfigUserFile)) { var suggestedBookName = System.Net.Dns.GetHostName() + " (" + Environment.UserName.ToString() + ")"; var selectForm = new frmSelectBook { Owner = this, SUGGESTEDBOOKNAME = suggestedBookName }; selectForm.ShowDialog(); FillComboBox(); var selectBook = selectForm.SELECTEDBOOK; if (selectBook.BookName != "") { var q = UserConfig.GetLastConnections(); foreach (var item in q) { InsertRecordToBook(selectBook, new Connect_Item(item.ID, item.adAlias, item.Name, "Добавлен через \"Импорт недавних сеансов\" \r\n " + DateTime.Now.ToLongDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString())); } var findIndex = comboBox1.FindStringExact(selectBook.BookName); comboBox1.SelectedIndex = findIndex != -1 ? findIndex : 0; comboBox1_SelectedIndexChanged(this, e); } } else { MessageBox.Show("Недавние сеансы не найдены"); } }