Exemple #1
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewClient.SelectedItems.Count == 1)
                {
                    ClientsSet clientsSet = listViewClient.SelectedItems[0].Tag as ClientsSet;

                    Program.RPE.ClientsSet.Remove(clientsSet);

                    Program.RPE.SaveChanges();

                    ShowClient();
                }
                textBoxFirstName.Text  = "";
                textBoxMiddleName.Text = "";
                textBoxLastName.Text   = "";
                textBoxPhone.Text      = "";
                textBoxEmail.Text      = "";
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #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.RPE.SaveChanges();

                ShowClient();
            }
            else
            {
                textBoxFirstName.Text  = "";
                textBoxMiddleName.Text = "";
                textBoxLastName.Text   = "";
                textBoxPhone.Text      = "";
                textBoxEmail.Text      = "";
            }
        }
Exemple #3
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.RPE.ClientsSet.Add(clientsSet);
            Program.RPE.SaveChanges();

            ShowClient();
        }
Exemple #4
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;
                textBoxLastName.Text   = clientsSet.LastName;
                textBoxMiddleName.Text = clientsSet.MiddleName;
                textBoxEmail.Text      = clientsSet.Email;
                textBoxPhone.Text      = clientsSet.Phone;
            }
            else
            {
                textBoxFirstName.Text  = "";
                textBoxLastName.Text   = "";
                textBoxMiddleName.Text = "";
                textBoxEmail.Text      = "";
                textBoxPhone.Text      = "";
            }
        }