コード例 #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ClientsSet clientsSet = new ClientsSet();

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