コード例 #1
0
 private void buttonSaveData_Click(object sender, EventArgs e)
 {
     if (textBoxName.Text == "" || textBoxCity.Text == "" || textBoxPhone.Text == "")
     {
         MessageBox.Show(@"Вы не заполнили поля");
     }
     else
     {
         var xmlData = new XmlData();
         xmlData.WriteSaveXml(Path, textBoxName.Text, textBoxCity.Text, textBoxPhone.Text);
         textBoxName.Text = "";
         textBoxCity.Text = "";
         textBoxPhone.Text = "";
         LoadDataGridView();
     }
 }
コード例 #2
0
 private void SearchName_Click(object sender, EventArgs e)
 {
     if (textBoxNameSearch.Text == "")
         MessageBox.Show(@"Вы не заполнили поле");
     if (radioButton1.Checked == false && radioButton2.Checked == false && radioButton3.Checked == false)
         MessageBox.Show(@"Выберите критерий поиска");
     else
     {
         dataGridView1.Rows.Clear();
         var xmldaataa = new XmlData();
         if (radioButton1.Checked)
             _variable = radioButton1.Text;
         if (radioButton2.Checked)
             _variable = radioButton2.Text;
         if (radioButton3.Checked)
             _variable = radioButton3.Text;
         var list = xmldaataa.Search(Path, _variable, textBoxNameSearch.Text);
         _variable = "";
         foreach (var t in list)
         {
             dataGridView1.Rows.Add(t.Name, t.City, t.Phone);
         }
     }
 }