Beispiel #1
0
 private void listViewClients_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewClients.SelectedItems.Count == 1)
     {
         ClientSet clientSet = listViewClients.SelectedItems[0].Tag as ClientSet;
         textBoxName.Text    = clientSet.Name;
         textBoxAddress.Text = clientSet.Address;
         textBoxPhone.Text   = clientSet.Phone;
     }
     else
     {
         textBoxName.Text    = "";
         textBoxAddress.Text = "";
         textBoxPhone.Text   = "";
     }
 }
Beispiel #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (textBoxName.Text != "" && textBoxAddress.Text != "" && textBoxPhone.Text != "")
     {
         if (listViewClients.SelectedItems.Count == 1)
         {
             ClientSet clientSet = listViewClients.SelectedItems[0].Tag as ClientSet;
             clientSet.Name    = textBoxName.Text;
             clientSet.Address = textBoxAddress.Text;
             clientSet.Phone   = textBoxPhone.Text;
             Program.OilerDb.SaveChanges();
             ShowClient();
         }
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewClients.SelectedItems.Count == 1)
         {
             ClientSet clientSet = listViewClients.SelectedItems[0].Tag as ClientSet;
             Program.OilerDb.ClientSet.Remove(clientSet);
             Program.OilerDb.SaveChanges();
             ShowClient();
         }
         textBoxName.Text    = "";
         textBoxAddress.Text = "";
         textBoxPhone.Text   = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }