Esempio n. 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ClientsSet clientSet = new ClientsSet();

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