Пример #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewManager.SelectedItems.Count == 1)
                {
                    ManagerSet managerSet = listViewManager.SelectedItems[0].Tag as ManagerSet;

                    if (textBoxLastName.Text == "" || textBoxFirstName.Text == "" ||
                        textBoxTelephone.Text == "" || comboBoxLogin.Text == "" ||
                        textBoxType.Text == "")
                    {
                        throw new Exception("Обязательные данные не заполнены");
                    }
                    else
                    {
                        managerSet.LastName  = textBoxLastName.Text;
                        managerSet.FirstName = textBoxFirstName.Text;
                        managerSet.Telephone = textBoxTelephone.Text;
                        managerSet.IdUser    = Convert.ToInt32(comboBoxLogin.SelectedItem.ToString().Split('.')[0]);
                        managerSet.Type      = textBoxType.Text;
                    }

                    if (textBoxEmail.Text != null)
                    {
                        managerSet.Email = textBoxEmail.Text;
                    }
                    else
                    {
                        managerSet.Email = "";
                    }

                    Program.varr.SaveChanges();
                    ShowManager();
                }
            }
            catch (Exception ex) { MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); }
        }
Пример #2
0
        private void listViewStaff_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewManager.SelectedItems.Count == 1)
            {
                ManagerSet managerSet = listViewManager.SelectedItems[0].Tag as ManagerSet;

                textBoxFirstName.Text = managerSet.FirstName;
                textBoxLastName.Text  = managerSet.LastName;
                textBoxTelephone.Text = managerSet.Telephone;
                textBoxEmail.Text     = managerSet.Email;
                comboBoxLogin.Text    = managerSet.IdUser.ToString() + ". " + managerSet.Users.Login;
                textBoxType.Text      = managerSet.Type;
            }
            else
            {
                textBoxFirstName.Text = "";
                textBoxLastName.Text  = "";
                textBoxTelephone.Text = "";
                textBoxEmail.Text     = "";
                comboBoxLogin.Text    = null;
                textBoxType.Text      = "";
            }
        }
Пример #3
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewManager.SelectedItems.Count == 1)
                {
                    ManagerSet managerSet = listViewManager.SelectedItems[0].Tag as ManagerSet;

                    Program.varr.ManagerSet.Remove(managerSet);
                    Program.varr.SaveChanges();
                    ShowManager();
                }
                textBoxFirstName.Text = "";
                textBoxLastName.Text  = "";
                textBoxTelephone.Text = "";
                textBoxEmail.Text     = "";
                comboBoxLogin.Text    = null;
                textBoxType.Text      = "";
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }