private void IPOctetValidation(object sender, TextCompositionEventArgs e)
        {
            bool eHandled = true;
            TextBox temp = (TextBox)sender;
            string temp_text;
            Classes.Validation validation = new Classes.Validation();

            if( validation.IsTextNumeric(e.Text) )
            {
                temp_text = temp.Text.ToString() + e.Text;
                eHandled = !validation.IsNumberInRange(0, 255, temp_text);
            }

            e.Handled = eHandled;
        }
Esempio n. 2
0
        private void IPOctetValidation(object sender, TextCompositionEventArgs e)
        {
            bool    eHandled = true;
            TextBox temp     = (TextBox)sender;
            string  temp_text;

            Classes.Validation validation = new Classes.Validation();

            if (validation.IsTextNumeric(e.Text))
            {
                temp_text = temp.Text.ToString() + e.Text;
                eHandled  = !validation.IsNumberInRange(0, 255, temp_text);
            }

            e.Handled = eHandled;
        }
        private bool SetPreferences()
        {
            bool flag = false;

            Classes.Validation valid = new Classes.Validation();
            this.Dispatcher.Invoke(() =>
            {
                if (valid.IsTextNumeric(TB_MinPlotSize.Text) && valid.IsTextNumeric(TB_MaxPlotSize.Text) && valid.IsTextNumeric(TB_MinHouseSize.Text) && valid.IsTextNumeric(TB_MaxHouseSize.Text) && valid.IsTextNumeric(TB_MinPrice.Text) && valid.IsTextNumeric(TB_MaxPrice.Text))
                {
                    try
                    {
                        if (valid.IsNumberInRange(Convert.ToInt32(CB_MinBedrooms.SelectedItem), 50, CB_MaxBedrooms.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(CB_MinBathrooms.SelectedItem), 50, CB_MaxBathrooms.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(CB_MinGarages.SelectedItem), 50, CB_MaxGarages.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(TB_MinPlotSize.Text), 2147483645, TB_MaxPlotSize.Text) && valid.IsNumberInRange(Convert.ToInt32(TB_MinHouseSize.Text), 2147483645, TB_MaxHouseSize.Text) && valid.IsNumberInRange(Convert.ToInt32(TB_MinPrice.Text), 2147483645, TB_MaxPrice.Text))
                        {
                            minBedrooms  = Convert.ToInt32(CB_MinBedrooms.SelectedItem);
                            maxBedrooms  = Convert.ToInt32(CB_MaxBedrooms.SelectedItem);
                            minBathrooms = Convert.ToInt32(CB_MinBathrooms.SelectedItem);
                            maxBathrooms = Convert.ToInt32(CB_MaxBathrooms.SelectedItem);
                            minGarages   = Convert.ToInt32(CB_MinGarages.SelectedItem);
                            maxGarages   = Convert.ToInt32(CB_MaxGarages.SelectedItem);
                            minPlotSize  = Convert.ToInt32(TB_MinPlotSize.Text);
                            maxPlotSize  = Convert.ToInt32(TB_MaxPlotSize.Text);
                            minHouseSize = Convert.ToInt32(TB_MinHouseSize.Text);
                            maxHouseSize = Convert.ToInt32(TB_MaxHouseSize.Text);
                            minPrice     = Convert.ToInt32(TB_MinPrice.Text);
                            maxPrice     = Convert.ToInt32(TB_MaxPrice.Text);
                            hasPool      = Convert.ToInt32(CB_HasPool.SelectedIndex.ToString());
                            flag         = true;
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please ensure that all min values are smaller than their corresponding max values", 10);
                        }
                    }
                    catch
                    {
                        DisplayNotifyBox("ERROR", "Please ensure that all field values are smaller than 2 147 483 645", 10);
                    }
                }
                else
                {
                    DisplayNotifyBox("ERROR", "Please ensure that the plotsize, housesize and price fields are numeric", 10);
                }
            });
            return(flag);
        }
 private void BT_AddOffer_Click(object sender, RoutedEventArgs e)
 {
     Classes.OfferManager offerManager = new Classes.OfferManager();
     Classes.Validation valid = new Classes.Validation();
     if (valid.IsTextNumeric(TB_Price.Text) && valid.IsNumberInRange(0, 2147483645, TB_Price.Text) && valid.DateTest(TB_Price.Text))
     {
         if (offerManager.AddOffer(listID[CB_Listing.SelectedIndex], clientsID[CB_Client.SelectedIndex], Convert.ToInt32(TB_Price.Text), CB_Status.SelectedIndex, DP_Date.Text))
         {
             DisplayNotifyBox("Offer added", "The offer from " + CB_Client.SelectedItem + " has been added", 5);
             ClearAddOfferOverlay();
         }
         else
         {
             DisplayNotifyBox("ERROR", "Offer could not be added", 5);
         }
     }
     else
     {
         DisplayNotifyBox("ERROR", "Please ensure the price is numeric and lower than 2 147 483 645, and that the date is in the valid format", 5);
     }
 }
 private void BT_AddOffer_Click(object sender, RoutedEventArgs e)
 {
     Classes.OfferManager offerManager = new Classes.OfferManager();
     Classes.Validation   valid        = new Classes.Validation();
     if (valid.IsTextNumeric(TB_Price.Text) && valid.IsNumberInRange(0, 2147483645, TB_Price.Text) && valid.DateTest(TB_Price.Text))
     {
         if (offerManager.AddOffer(listID[CB_Listing.SelectedIndex], clientsID[CB_Client.SelectedIndex], Convert.ToInt32(TB_Price.Text), CB_Status.SelectedIndex, DP_Date.Text))
         {
             DisplayNotifyBox("Offer added", "The offer from " + CB_Client.SelectedItem + " has been added", 5);
             ClearAddOfferOverlay();
         }
         else
         {
             DisplayNotifyBox("ERROR", "Offer could not be added", 5);
         }
     }
     else
     {
         DisplayNotifyBox("ERROR", "Please ensure the price is numeric and lower than 2 147 483 645, and that the date is in the valid format", 5);
     }
 }
 private bool SetPreferences()
 {
     bool flag = false;
     Classes.Validation valid = new Classes.Validation();
     this.Dispatcher.Invoke(() =>
     {
         if (valid.IsTextNumeric(TB_MinPlotSize.Text) && valid.IsTextNumeric(TB_MaxPlotSize.Text) && valid.IsTextNumeric(TB_MinHouseSize.Text) && valid.IsTextNumeric(TB_MaxHouseSize.Text) && valid.IsTextNumeric(TB_MinPrice.Text) && valid.IsTextNumeric(TB_MaxPrice.Text))
         {
             try
             {
                 if (valid.IsNumberInRange(Convert.ToInt32(CB_MinBedrooms.SelectedItem), 50, CB_MaxBedrooms.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(CB_MinBathrooms.SelectedItem), 50, CB_MaxBathrooms.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(CB_MinGarages.SelectedItem), 50, CB_MaxGarages.SelectedItem.ToString()) && valid.IsNumberInRange(Convert.ToInt32(TB_MinPlotSize.Text), 2147483645, TB_MaxPlotSize.Text) && valid.IsNumberInRange(Convert.ToInt32(TB_MinHouseSize.Text), 2147483645, TB_MaxHouseSize.Text) && valid.IsNumberInRange(Convert.ToInt32(TB_MinPrice.Text), 2147483645, TB_MaxPrice.Text))
                 {
                     minBedrooms = Convert.ToInt32(CB_MinBedrooms.SelectedItem);
                     maxBedrooms = Convert.ToInt32(CB_MaxBedrooms.SelectedItem);
                     minBathrooms = Convert.ToInt32(CB_MinBathrooms.SelectedItem);
                     maxBathrooms = Convert.ToInt32(CB_MaxBathrooms.SelectedItem);
                     minGarages = Convert.ToInt32(CB_MinGarages.SelectedItem);
                     maxGarages = Convert.ToInt32(CB_MaxGarages.SelectedItem);
                     minPlotSize = Convert.ToInt32(TB_MinPlotSize.Text);
                     maxPlotSize = Convert.ToInt32(TB_MaxPlotSize.Text);
                     minHouseSize = Convert.ToInt32(TB_MinHouseSize.Text);
                     maxHouseSize = Convert.ToInt32(TB_MaxHouseSize.Text);
                     minPrice = Convert.ToInt32(TB_MinPrice.Text);
                     maxPrice = Convert.ToInt32(TB_MaxPrice.Text);
                     hasPool = Convert.ToInt32(CB_HasPool.SelectedIndex.ToString());
                     flag = true;
                 }
                 else
                 {
                     DisplayNotifyBox("ERROR", "Please ensure that all min values are smaller than their corresponding max values", 10);
                 }
             }
             catch
             {
                 DisplayNotifyBox("ERROR", "Please ensure that all field values are smaller than 2 147 483 645", 10);
             }
         }
         else
         {
             DisplayNotifyBox("ERROR", "Please ensure that the plotsize, housesize and price fields are numeric", 10);
         }
     });
     return flag;
 }