private void button1_Click(object sender, EventArgs e) { const string path = @"..\..\Shares\SharesUsers.xml"; try { var share = new Share(); foreach (var control in Controls.OfType<TextBox>().Where(control => control.Text.Length == 0)) { MessageBox.Show(@"Поле должно быть заполнено!"); control.BackColor = Color.Yellow; return; } if (!share.CheckShare(path, textUrl.Text, textName.Text, Login)) { MessageBox.Show(@"Данная закладка существует"); return; } share.Add(path,textUrl.Text,textName.Text,Login); MessageBox.Show(@"Закладка успешно добавлена"); Close(); Log.Info("ShareAdd"); } catch (Exception exception) { Log.Fatal(exception.Message); MessageBox.Show(exception.Message); } }
private void AddSharesInDataGridView() { try { var share = new Share(); var list = share.ReadShares(Path, Login); for (var i = 0; i < list.Count; i++) { dataGridView1.Rows.Add(); dataGridView1.Rows[i].Cells[0].Value = list[i].Url; dataGridView1.Rows[i].Cells[1].Value = list[i].Description; } Log.Info("AddSharesInDataGridView"); } catch (Exception exception) { Log.Fatal(exception.Message); MessageBox.Show(exception.Message); } }
private void button1_Click(object sender, EventArgs e) { try { var share = new Share(); foreach (var control in Controls.OfType<TextBox>().Where(control => control.Text.Length == 0)) { MessageBox.Show(@"Поле должно быть заполнено!"); control.BackColor = Color.Yellow; return; } share.ChangeShare(Path,Url,textBoxURL.Text, Description,textBoxDescription.Text, Login); MessageBox.Show(@"Закладка успешно редактирована"); Close(); Log.Info("ShareChange"); } catch (Exception exception) { Log.Fatal(exception.Message); MessageBox.Show(exception.Message); } }
private void button1_Click(object sender, EventArgs e) { try { var index = dataGridView1.CurrentRow.Index; var url = (string) dataGridView1.Rows[index].Cells[0].Value; var name = (string) dataGridView1.Rows[index].Cells[1].Value; dataGridView1.Rows.RemoveAt(index); IShare share = new Share(); share.RemoveOwnShare(Path, url, name, Login); Log.Info("ShareRemoveAt"); } catch (Exception exception) { Log.Fatal(exception.Message); MessageBox.Show(exception.Message); } }
private void button2_Click(object sender, EventArgs e) { try { dataGridView1.Rows.Clear(); IShare share = new Share(); share.RemoveAllShares(Path); Log.Info("SharesRemoveAll"); } catch (Exception exception) { Log.Fatal(exception.Message); MessageBox.Show(exception.Message); } }