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 = "";
                }
            }
        }
Exemple #2
0
        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 = "";
                }
            }
        }
Exemple #3
0
        private void toolStripButtonEdit_Click(object sender, EventArgs e)
        {
            int selectedTab = mainTabControl.SelectedIndex;

            switch (selectedTab)
            {
            //clientTab
            case 0:
                if (clientListBox.SelectedItem != null)
                {
                    Client     client         = (Client)clientListBox.SelectedItem;
                    ClientForm editClientForm = new ClientForm(mainController, true, client);
                    editClientForm.Text = "Изменение клиента";
                    editClientForm.textBoxClientName.Text      = client.name;
                    editClientForm.textBoxClientNumber.Text    = client.number;
                    editClientForm.textBoxClientNumber.Enabled = false;
                    editClientForm.textBoxClientBirth.Text     = client.birth;
                    editClientForm.ShowDialog();
                    updateAllListBox(sender, e);
                }
                break;

            //recordTab
            case 1:
                if (recordListBox.SelectedItem != null)
                {
                    Record record = (Record)recordListBox.SelectedItem;
                    if (!record.status && (DateTime.Today < record.day))
                    {
                        RecordForm editRecordForm = new RecordForm(mainController, true, record);
                        editRecordForm.Text = "Изменение записи";
                        editRecordForm.textBoxClientName.Text      = record.client.name;
                        editRecordForm.textBoxClientNumber.Text    = record.client.number;
                        editRecordForm.textBoxClientName.Enabled   = false;
                        editRecordForm.textBoxClientNumber.Enabled = false;
                        editRecordForm.ShowDialog();
                        updateAllListBox(sender, e);
                    }
                    else
                    {
                        if (record.status)
                        {
                            MessageBox.Show("Нельзя редактировать выполненную запись", "Ошибка", MessageBoxButtons.OK);
                        }
                        else
                        {
                            MessageBox.Show("Нельзя редактировать запись с истекшим сроком", "Ошибка", MessageBoxButtons.OK);
                        }
                        return;
                    }
                }
                break;

            //masterTab
            case 2:
                if (masterListBox.SelectedItem != null)
                {
                    Master     master         = (Master)masterListBox.SelectedItem;
                    MasterForm editMasterForm = new MasterForm(this, true, master);
                    editMasterForm.Text               = "Изменение мастера";
                    editMasterForm.textBoxName.Text   = master.name;
                    editMasterForm.textBoxSalary.Text = master.salary.ToString();
                    foreach (Service service in master.serviceList)
                    {
                        editMasterForm.listBoxService.Items.Add(service);
                    }
                    editMasterForm.ShowDialog();
                    updateAllListBox(sender, e);
                }

                break;

            //serviceTab
            case 3:
                if (serviceListBox.SelectedItem != null)
                {
                    Service     service         = (Service)serviceListBox.SelectedItem;
                    ServiceForm editServiceForm = new ServiceForm(mainController, true, service);
                    editServiceForm.Text = "Изменение услуги";
                    editServiceForm.textBoxServiceName.Text  = service.name;
                    editServiceForm.trackBarDuration.Value   = service.duration;
                    editServiceForm.textBoxServicePrice.Text = service.price.ToString();
                    editServiceForm.ShowDialog();
                    updateAllListBox(sender, e);
                }
                break;
            }
        }
Exemple #4
0
        private void toolStripButtonEdit_Click(object sender, EventArgs e)
        {
            int selectedTab = mainTabControl.SelectedIndex;
            switch (selectedTab)
            {
                //clientTab
                case 0:
                    if (clientListBox.SelectedItem != null)
                    {
                        Client client = (Client)clientListBox.SelectedItem;
                        ClientForm editClientForm = new ClientForm(mainController, true, client);
                        editClientForm.Text = "Изменение клиента";
                        editClientForm.textBoxClientName.Text = client.name;
                        editClientForm.textBoxClientNumber.Text = client.number;
                        editClientForm.textBoxClientNumber.Enabled = false;
                        editClientForm.textBoxClientBirth.Text = client.birth;
                        editClientForm.ShowDialog();
                        updateAllListBox(sender, e);
                    }
                    break;

                //recordTab
                case 1:
                    if (recordListBox.SelectedItem != null)
                    {
                        Record record = (Record)recordListBox.SelectedItem;
                        if (!record.status && (DateTime.Today < record.day))
                        {
                            RecordForm editRecordForm = new RecordForm(mainController, true, record);
                            editRecordForm.Text = "Изменение записи";
                            editRecordForm.textBoxClientName.Text = record.client.name;
                            editRecordForm.textBoxClientNumber.Text = record.client.number;
                            editRecordForm.textBoxClientName.Enabled = false;
                            editRecordForm.textBoxClientNumber.Enabled = false;
                            editRecordForm.ShowDialog();
                            updateAllListBox(sender, e);
                        }
                        else
                        {
                            if (record.status)
                                MessageBox.Show("Нельзя редактировать выполненную запись", "Ошибка", MessageBoxButtons.OK);
                            else
                                MessageBox.Show("Нельзя редактировать запись с истекшим сроком", "Ошибка", MessageBoxButtons.OK);
                            return;
                        }
                    }
                    break;

                //masterTab
                case 2:
                    if (masterListBox.SelectedItem != null)
                    {
                        Master master = (Master)masterListBox.SelectedItem;
                        MasterForm editMasterForm = new MasterForm(this, true, master);
                        editMasterForm.Text = "Изменение мастера";
                        editMasterForm.textBoxName.Text = master.name;
                        editMasterForm.textBoxSalary.Text = master.salary.ToString();
                        foreach (Service service in master.serviceList)
                        {
                            editMasterForm.listBoxService.Items.Add(service);
                        }
                        editMasterForm.ShowDialog();
                        updateAllListBox(sender, e);
                    }

                    break;

                //serviceTab
                case 3:
                    if (serviceListBox.SelectedItem != null)
                    {
                        Service service = (Service)serviceListBox.SelectedItem;
                        ServiceForm editServiceForm = new ServiceForm(mainController, true, service);
                        editServiceForm.Text = "Изменение услуги";
                        editServiceForm.textBoxServiceName.Text = service.name;
                        editServiceForm.trackBarDuration.Value = service.duration;
                        editServiceForm.textBoxServicePrice.Text = service.price.ToString();
                        editServiceForm.ShowDialog();
                        updateAllListBox(sender, e);
                    }
                    break;

            }
        }