コード例 #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewClient.SelectedItems.Count == 1)
     {
         ClientSet clientSet = listViewClient.SelectedItems[0].Tag as ClientSet;
         clientSet.LastName   = textBoxLastName.Text;
         clientSet.FirstName  = textBoxFirstName.Text;
         clientSet.MiddleName = textBoxMiddleName.Text;
         clientSet.Address    = textBoxAddress.Text;
         clientSet.Phone      = textBoxPhone.Text;
         Program.wFShop.SaveChanges();
         ShowClient();
     }
 }
コード例 #2
0
 private void listViewClient_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewClient.SelectedItems.Count == 1)
     {
         ClientSet clientSet = listViewClient.SelectedItems[0].Tag as ClientSet;
         textBoxLastName.Text   = clientSet.LastName;
         textBoxFirstName.Text  = clientSet.FirstName;
         textBoxMiddleName.Text = clientSet.MiddleName;
         textBoxAddress.Text    = clientSet.Address;
         textBoxPhone.Text      = clientSet.Phone;
     }
     else
     {
         textBoxLastName.Text   = "";
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxAddress.Text    = "";
         textBoxPhone.Text      = "";
     }
 }
コード例 #3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewClient.SelectedItems.Count == 1)
         {
             ClientSet clientSet = listViewClient.SelectedItems[0].Tag as ClientSet;
             Program.wFShop.ClientSet.Remove(clientSet);
             Program.wFShop.SaveChanges();
             ShowClient();
         }
         textBoxLastName.Text   = "";
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxAddress.Text    = "";
         textBoxPhone.Text      = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }