コード例 #1
0
ファイル: MasterForm.cs プロジェクト: purseal/project_Salon
        private void buttonAddService_Click(object sender, EventArgs e)
        {
            string serviceName = textBoxServiceName.Text;

            if (serviceName == "")
            {
                MessageBox.Show("Необходимо ввести название услуги", "Ошибка", MessageBoxButtons.OK);
                return;
            }
            Service tmpService = mainController.getService(serviceName);

            if (tmpService != null)
            {
                serviceNames.Add(serviceName);
                listBoxService.Items.Add(serviceName);
                textBoxServiceName.Text = "";
            }
            else
            {
                DialogResult dialogResult = MessageBox.Show("Еще нет ни одного мастера, оказывающего данную услугу.\nДобавить новую услугу?", "Новая услуга", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    ServiceForm newServiceForm = new ServiceForm(mainController, false, null);
                    newServiceForm.textBoxServiceName.Text    = serviceName;
                    newServiceForm.textBoxServiceName.Enabled = false;
                    newServiceForm.ShowDialog();
                    listBoxService.Items.Add(serviceName);
                    serviceNames.Add(serviceName);
                    textBoxServiceName.Text = "";
                }
                else if (dialogResult == DialogResult.No)
                {
                    textBoxServiceName.Text = "";
                }
            }
        }