예제 #1
0
        private void newRecordToolboxButton_Click(object sender, EventArgs e)
        {
            Form newRecordForm = new RecordForm(mainController, false, null);

            newRecordForm.Text = "Добавление записи";
            newRecordForm.ShowDialog(this);
            textBoxRecordSearch.Text = "";
            textBoxClientSearch.Text = "";
            textBoxRecordSearch_TextChanged(sender, e);
            textBoxClientSearch_TextChanged(sender, e);
            statusStripLabel.Text = "Добавление записи завершено";
        }
예제 #2
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;

            }
        }
예제 #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;
            }
        }
예제 #4
0
 private void newRecordToolboxButton_Click(object sender, EventArgs e)
 {
     Form newRecordForm = new RecordForm(mainController, false, null);
     newRecordForm.Text = "Добавление записи";
     newRecordForm.ShowDialog(this);
     textBoxRecordSearch.Text = "";
     textBoxClientSearch.Text = "";
     textBoxRecordSearch_TextChanged(sender, e);
     textBoxClientSearch_TextChanged(sender, e);
     statusStripLabel.Text = "Добавление записи завершено";
 }