Exemplo n.º 1
0
        private void receiptButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateData())
                {
                    if (RegRecord == null)
                    {
                        RegRecord = new RegRecord()
                        {
                            Resident = new Resident()
                        };
                    }

                    var room = hotel.FindRoom(
                        Convert.ToInt32(floorComboBox.Text),
                        Convert.ToInt32(numberComboBox.Text));

                    // Перевірка, чи був переселений постоялець до іншого номеру.
                    if (originalRoom != null && originalRoom != room)
                    {
                        originalRoom.Occupied        = false;
                        originalRoom.ActualResidents = 0;
                    }

                    RegRecord.ArrivalDate          = arrivalDateTimePicker.Value;
                    RegRecord.DepartureDate        = departureDateTimePicker.Value;
                    RegRecord.Room                 = room;
                    RegRecord.Room.Occupied        = true;
                    RegRecord.Room.ActualResidents = Convert.ToInt32(actualResidentsNumericUpDown.Value);
                    RegRecord.Resident.Surname     = surnameTextBox.Text;
                    RegRecord.Resident.Name        = nameTextBox.Text;
                    RegRecord.Resident.Gender      = genderComboBox.Text;
                    if (genderComboBox.Text == "")
                    {
                        RegRecord.Resident.Gender = "-";
                    }
                    RegRecord.Resident.BirthDate = birthDateTimePicker.Value;
                    RegRecord.Resident.Phone     = phoneTextBox.Text;
                    RegRecord.Resident.Email     = emailTextBox.Text;

                    var toReceipt = RegRecord;
                    var rf        = new ReceiptForm(toReceipt);
                    if (rf.ShowDialog() == DialogResult.OK)
                    {
                        saveButton.Enabled = true;
                        backButton.Enabled = false;
                    }
                }
            }
            catch
            {
                MessageBox.Show("Не все поля заполнены.");
            }
        }
Exemplo n.º 2
0
        private void recalculationButton_Click(object sender, EventArgs e)
        {
            var toReceipt = RegRecord;
            var rf        = new ReceiptForm(toReceipt);

            if (rf.ShowDialog() == DialogResult.OK)
            {
                saveButton.Enabled = true;
                backButton.Enabled = false;
            }
        }