예제 #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewClients.SelectedItems.Count == 1)
                {
                    ClientsSet clientsSet = listViewClients.SelectedItems[0].Tag as ClientsSet;

                    if (textBoxLastName.Text == "" || textBoxFirstName.Text == "" ||
                        textBoxTelephone.Text == "")
                    {
                        throw new Exception("Обязательные данные не заполнены");
                    }
                    else
                    {
                        clientsSet.LastName  = textBoxLastName.Text;
                        clientsSet.FirstName = textBoxFirstName.Text;
                        clientsSet.Phone     = textBoxTelephone.Text;
                    }

                    Program.varr.SaveChanges();
                    ShowClients();
                }
            }
            catch (Exception ex) { MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); }
        }
예제 #2
0
        private void buttonGo_Click(object sender, EventArgs e)
        {
            try
            {
                ClientsSet clientsSet = new ClientsSet();

                if (textBoxLastName.Text == "" || textBoxFirstName.Text == "" || textBoxTelephone.Text == "")
                {
                    throw new Exception("Обязательные данные не заполнены");
                }
                else
                {
                    clientsSet.LastName  = textBoxLastName.Text;
                    clientsSet.FirstName = textBoxFirstName.Text;
                    clientsSet.Phone     = textBoxTelephone.Text;
                }

                Program.varr.ClientsSet.Add(clientsSet);
                Program.varr.SaveChanges();

                MessageBox.Show("Клиент успешно добавлен!", "Клиент добавлен",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                FormOrderBy formOrderBy = new FormOrderBy();
                formOrderBy.Show();
                this.Hide();
            }
            catch (Exception ex) { MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); }
        }
예제 #3
0
        private void listViewClients_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewClients.SelectedItems.Count == 1)
            {
                ClientsSet clientsSet = listViewClients.SelectedItems[0].Tag as ClientsSet;

                textBoxFirstName.Text = clientsSet.FirstName;
                textBoxLastName.Text  = clientsSet.LastName;
                textBoxTelephone.Text = clientsSet.Phone;
            }
            else
            {
                textBoxFirstName.Text = "";
                textBoxLastName.Text  = "";
                textBoxTelephone.Text = "";
            }
        }
예제 #4
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewClients.SelectedItems.Count == 1)
                {
                    ClientsSet clientsSet = listViewClients.SelectedItems[0].Tag as ClientsSet;

                    Program.varr.ClientsSet.Remove(clientsSet);
                    Program.varr.SaveChanges();
                    ShowClients();
                }
                textBoxFirstName.Text = "";
                textBoxLastName.Text  = "";
                textBoxTelephone.Text = "";
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #5
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                ClientsSet clientsSet = new ClientsSet();

                if (textBoxLastName.Text == "" || textBoxFirstName.Text == "" ||
                    textBoxTelephone.Text == "")
                {
                    throw new Exception("Обязательные данные не заполнены");
                }
                else
                {
                    clientsSet.LastName  = textBoxLastName.Text;
                    clientsSet.FirstName = textBoxFirstName.Text;
                    clientsSet.Phone     = textBoxTelephone.Text;
                }

                Program.varr.ClientsSet.Add(clientsSet);
                Program.varr.SaveChanges();
                ShowClients();
            }
            catch (Exception ex) { MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); }
        }