예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Window UpdateHostingUnitWindow = new UpdateHostingUnitWindow();

            UpdateHostingUnitWindow.Show();
            this.Close();
        }
예제 #2
0
        private void updatehostingunitButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (PoolComboxBox.SelectedItem == null || PublicTransportationComboxBox.SelectedItem == null || JacuzziComboxBox.SelectedItem == null || SmokingComboxBox.SelectedItem == null ||
                    RoomServiceComboxBox.SelectedItem == null || GardenComboxBox.SelectedItem == null || ChildrensAttractionComboxBox.SelectedItem == null || WifiComboxBox.SelectedItem == null ||
                    TvComboxBox.SelectedItem == null || SnackBarComboxBox.SelectedItem == null || sizeTextBox.Text == "" ||
                    floorsTextBox.Text == "" || HostingUnitNameTextBox.Text == "" || collectionclearanceComboBox.SelectedItem == null)
                {
                    throw new NullReferenceException("please fill out all of the fields");
                }
                if (!Regex.IsMatch(this.sizeTextBox.Text.ToString(), @"^\d+$"))
                {
                    throw new InvalidOperationException("invaild size");
                }
                if (!Regex.IsMatch(this.floorsTextBox.Text.ToString(), @"^\d+$"))
                {
                    throw new InvalidOperationException("invaild number of floors");
                }
                unit = (BE.HostingUnit) this.HostingUnitKeyComboBox.SelectedItem;
                var x = (from hostingunit in bl.GetHostingUnitList()
                         where hostingunit.HostingUnitKey == unit.HostingUnitKey
                         select hostingunit).FirstOrDefault();
                unit.HostingUnitName           = this.HostingUnitNameTextBox.Text;
                unit.Owner                     = x.Owner;
                unit.Owner.CollectionClearance = (BE.PaymentClearance)collectionclearanceComboBox.SelectedIndex;
                unit.jacuzzi                   = (BE.Jacuzzi) this.JacuzziComboxBox.SelectedItem;
                unit.pool                 = (BE.Pool) this.PoolComboxBox.SelectedItem;
                unit.snackBar             = (BE.SnackBar) this.SnackBarComboxBox.SelectedItem;
                unit.wifi                 = (BE.Wifi) this.WifiComboxBox.SelectedItem;
                unit.tv                   = (BE.Television) this.TvComboxBox.SelectedItem;
                unit.garden               = (BE.Garden) this.GardenComboxBox.SelectedItem;
                unit.roomService          = (BE.RoomService) this.RoomServiceComboxBox.SelectedItem;
                unit.childrensAttractions = (BE.ChildrensAttractions) this.ChildrensAttractionComboxBox.SelectedItem;
                unit.publicTransportation = (BE.PublicTransportation) this.PublicTransportationComboxBox.SelectedItem;
                unit.smoking              = (BE.Smoking) this.SmokingComboxBox.SelectedItem;
                unit.Size                 = int.Parse(sizeTextBox.Text);
                unit.Floors               = int.Parse(floorsTextBox.Text);
                this.DataContext          = unit;

                bl.UpdateHostingUnit(unit);
                unit = new BE.HostingUnit();
                MessageBoxResult result = MessageBox.Show("Thank You, your unit has been updated. Would you like to update another unit?", "Status", MessageBoxButton.YesNo, MessageBoxImage.Question);
                switch (result)
                {
                case MessageBoxResult.Yes:
                    this.Close();
                    Window UpdateHostingUnitWindow = new UpdateHostingUnitWindow();
                    UpdateHostingUnitWindow.Show();
                    break;

                case MessageBoxResult.No:
                    this.Close();
                    Window window = new PersonnalAreaWindow();
                    window.Show();
                    break;
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }