private void buttonFindClient_Click(object sender, EventArgs e) { String clientNumber = textBoxClientNumber.Text; if (!textBoxClientNumber.MaskCompleted) { MessageBox.Show("Необходимо полностью ввести номер телефона", "Ошибка", MessageBoxButtons.OK); return; } Client client = mainController.getClient(clientNumber); if (client == null) { DialogResult dialogResult = MessageBox.Show("Еще нет клиента с таким номером.\nЗарегистрировать нового клиента?" , "Новый клиент", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { ClientForm newClientForm = new ClientForm(mainController, false, null); newClientForm.textBoxClientNumber.Text = Convert.ToString(clientNumber); newClientForm.textBoxClientNumber.Enabled = false; newClientForm.ShowDialog(); client = mainController.getClient(clientNumber); textBoxClientNumber.Enabled = false; textBoxClientName.Text = client.name; textBoxClientName.Enabled = false; } else if (dialogResult == DialogResult.No) { textBoxClientNumber.Text = ""; } } else { textBoxClientNumber.Enabled = false; textBoxClientName.Text = client.name; textBoxClientName.Enabled = false; } }
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; } }
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; } }
private void newClientToolboxButton_Click(object sender, EventArgs e) { Form newClientForm = new ClientForm(mainController, false, null); newClientForm.Text = "Добавление клиента"; newClientForm.ShowDialog(this); }