private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (FormIsValid())
            {
                MedicalRecord medicalRecord = new MedicalRecord()
                {
                    IdMedicalRecord   = medicalRecordViewModel.IdMedicalRecord,
                    Name              = FirstNameBox.Text,
                    LastName          = LastNameBox.Text,
                    BirthDate         = BirthDatePicker.SelectedDate.Value,
                    BirthPlace        = BirthPlaceBox.Text,
                    FathersFullName   = FathersNameBox.Text,
                    MothersFullName   = MothersNameBox.Text,
                    FathersProfession = FathersProfessionBox.Text,
                    MothersProfession = MothersProfessionBox.Text,
                    Gender            = (sbyte)(MaleCheckBox.IsChecked.Value ? 0 : 1),
                    MarriageStatus    = (sbyte)(MarriedCheckBox.IsChecked.Value ? 0 : 1),
                    Jmb             = UNBBox.Text,
                    InsuranceNumber = InsuranceNumberBox.Text,
                    IdResidence     = ((PlaceViewModel)ResidancePlaceComboBox.SelectedItem).IdPlace
                };
                DbStatus status = await medicalRecordService.Update(medicalRecord);

                OperationStatus = StatusHandler.Handle(OperationType.Edit, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
Ejemplo n.º 2
0
 private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     if (textBoxName.Text.Length == 0 || textBoxInitialPrice.Text.Length == 0)
     {
         MessageBox.Show("Complete mandatory fields!");
         return;
     }
     if (FieldValidation.IsValidDecimalNumericField(textBoxInitialPrice.Text) == false)
     {
         MessageBox.Show("Invalid value typed for price! Type another!");
         return;
     }
     else
     {
         if (CheckObjectMaterials() == false)
         {
             MessageBox.Show("Some object materials do not exist! Please customize or import!");
             return;
         }
         importedObject.Name         = textBoxName.Text;
         importedObject.Description  = textBoxDescription.Text;
         importedObject.InitialPrice = Convert.ToDecimal(textBoxInitialPrice.Text);
         importedObject.SetInnerObjectMaterials(currentObjectMaterials);
         ClearAllFields();
         if (this.StatusUpdated != null)
         {
             this.StatusUpdated(this, new EventArgs());
         }
     }
 }
Ejemplo n.º 3
0
        public void ConvertNullAPIToAPI()
        {
            apiFieldValidation1 = null;
            FieldValidatorConverter converter = new FieldValidatorConverter(apiFieldValidation1);

            Assert.IsNull(converter.ToAPIFieldValidation());
        }
Ejemplo n.º 4
0
            public override void SetModuleConfiguration()
            {
                //Front end gender code and description
                if (mode == MODE_CREATE)
                {
                    MConfigs.Add(CODE51, DataType.TEXT, DisplayTabs.TabHeaderGeneral, FieldValidation.Add(new List <VG> {
                        VG.Mandatory, VG.MinLength, VG.MaxLength
                    }, minLength: 1, maxLength: 1));
                }
                else
                {
                    MConfigs.Add(CODE51, DataType.LABEL, DisplayTabs.TabHeaderGeneral);
                }


                MConfigs.Add(USER51, DataType.HIDDEN, DisplayTabs.TabHeaderGeneral);
                MConfigs.Add(PGMD51, DataType.HIDDEN, DisplayTabs.TabHeaderGeneral);
                MConfigs.Add(UPDT51, DataType.HIDDEN, DisplayTabs.TabHeaderGeneral);
                MConfigs.Add(ACTR51, DataType.HIDDEN, DisplayTabs.TabHeaderGeneral);
                MConfigs.Add(CONO51, DataType.HIDDEN, DisplayTabs.TabHeaderGeneral);
                MConfigs.Add(TYPE51, DataType.HIDDEN, DisplayTabs.TabHeaderGeneral);
                MConfigs.Add(DECP51, DataType.HIDDEN, DisplayTabs.TabHeaderGeneral);
                MConfigs.Add(DESC51, DataType.TEXT, DisplayTabs.TabHeaderGeneral, FieldValidation.Add(new List <VG> {
                    VG.Mandatory, VG.MinLength, VG.MaxLength
                }, minLength: 1, maxLength: 50));
                MConfigs.Add(VALU51, DataType.HIDDEN, DisplayTabs.TabHeaderGeneral);
                Populate();
            }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (!AreSamePasswords())
            {
                FieldValidation.WriteMessage(ErrorLabel, language.PasswordsDontMatch);
                return;
            }
            if (IsValidForm())
            {
                LocalAccount localAccount = new LocalAccount()
                {
                    IdLocalAccount = localAccountViewModel.IdLocalAccount,
                    FullName       = FullNameBox.Text,
                    Email          = EmailBox.Text,
                    PasswordHash   = PasswordBox.Password,
                };
                ObservableCollection <RoleViewModel> roles = RolesComboBox.SelectedItems as ObservableCollection <RoleViewModel>;
                localAccount.SetRoles(roles.Select(x => Mapping.Mapper.Map <Role>(x)).ToList());
                DbStatus status = await localAccountService.Update(localAccount);

                OperationStatus = StatusHandler.Handle(OperationType.Edit, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
        private bool IsValidForm()
        {
            bool areFilled  = FieldValidation.NotNullOrEmpty(FirstNameBox.Text, LastNameBox.Text, WorkExperienceBox.Text);
            bool isSelected = FieldValidation.IsSelected(AccountComboBox.SelectedIndex);

            return(areFilled && isSelected);
        }
Ejemplo n.º 7
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (FormIsValid())
            {
                Place place = new Place()
                {
                    Name                     = NameBox.Text,
                    CountryName              = CountryNameBox.Text,
                    PostalCode               = PostalCodeBox.Text,
                    FoodQuality              = (int)FoodQualityComboBox.SelectedItem,
                    AirQuality               = (int)AirQualityComboBox.SelectedItem,
                    DrinkingWaterQuality     = (int)DrinkingWaterComboBox.SelectedItem,
                    RecreationalWaterQuality = (int)RecreationalWaterComboBox.SelectedItem,
                    TerrainQuality           = (int)TerrainQualityComboBox.SelectedItem,
                    InlandWaterQuality       = (int)InlandWaterQualityComboBox.SelectedItem,
                    MedicalVasteInformation  = (int)MedicalVasteComboBox.SelectedItem,
                    NoiseInformation         = (int)NoiseInformationComboBox.SelectedItem,
                    Radiation                = (int)RadiationComboBox.SelectedItem
                };
                DbStatus status = await placeService.Add(place);

                OperationStatus = StatusHandler.Handle(OperationType.Create, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
        public bool CheckValidFields()
        {
            if (FieldValidation.IsValidDecimalNumericField(textBoxBudget.Text) == false)
            {
                MessageBox.Show("Invalid value typed for budget! Type another!");
                return(false);
            }
            if (FieldValidation.IsValidFloatNumericField(textBoxWallsHeight.Text) == false)
            {
                MessageBox.Show("Invalid value typed for walls height! Type another!");
                return(false);
            }
            if (FieldValidation.IsValidLongNumericField(textBoxTelephoneNumber.Text) == false)
            {
                MessageBox.Show("Invalid value typed for telephone number! Type another!");
                return(false);
            }
            if (FieldValidation.IsValidEmail(textBoxEmailAddress.Text) == false)
            {
                MessageBox.Show("Invalid value typed for email! Type another!");
                return(false);
            }

            return(true);
        }
 public override void SetModuleConfiguration()
 {
     MConfigs.Add(FLG45, DataType.BOOL_10, DisplayTabs.TabHeaderDefaults);
     MConfigs.Add(SEQ01, DataType.TEXT, DisplayTabs.TabHeaderDefaults, FieldValidation.Add(new List <VG> {
         VG.MaxValue
     }, maxValue: 100));
     MConfigs.Add(XF004B, DataType.BOOL_YN, DisplayTabs.TabHeaderDefaults);
     MConfigs.Add(configID: SeasonTicketExceptionsLinkText, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.Basket);
     MConfigs.Add(configID: TOTAL_ST_EXCEPTIONS_PRICE, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.Basket);
     MConfigs.Add(configID: BackToExceptionsPage, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.SeatSelection);
     MConfigs.Add(configID: ChangeExceptionSeatButton, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.SeatSelection);
     MConfigs.Add(BasketButtonText, DataType.TEXT, DisplayTabs.TabHeaderButtons);
     MConfigs.Add(ChangeSeatText, DataType.TEXT, DisplayTabs.TabHeaderButtons);
     MConfigs.Add(KeepSeatsTogetherButtonText, DataType.TEXT, DisplayTabs.TabHeaderButtons);
     MConfigs.Add(configID: ExceptionsColumnHeading, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageColumnHeadings);
     MConfigs.Add(configID: ExceptionSeatColumnHeading, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageColumnHeadings);
     MConfigs.Add(configID: SeasonTicketSeatColumnHeading, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageColumnHeadings);
     MConfigs.Add(GenericExceptionsProcessingError, DataType.TEXT, DisplayTabs.TabHeaderErrors);
     MConfigs.Add(ProblemKeepingSeatsTogetherText, DataType.TEXT, DisplayTabs.TabHeaderErrors);
     MConfigs.Add(ProblemRemovingSeatText, DataType.TEXT, DisplayTabs.TabHeaderErrors);
     MConfigs.Add(NoAvailabilityMessage, DataType.TEXT, DisplayTabs.TabHeaderErrors);
     MConfigs.Add(configID: ExceptionsOnCurrentSeatText, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageText);
     MConfigs.Add(configID: KeepSeatsTogetherLabelText, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageText);
     MConfigs.Add(configID: NoExceptionSeatsText, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageText);
     MConfigs.Add(configID: PageDetailsText, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageText);
     MConfigs.Add(configID: PickASeatText, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageText);
     MConfigs.Add(configID: RemoveSeatText, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageText);
     MConfigs.Add(configID: SeatDisplayFormatText, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageText);
     MConfigs.Add(configID: UnallocatedSeatText, fieldType: DataType.TEXT, displayTab: DisplayTabs.TabHeaderTexts, accordionGroup: AccordionGroup.ExceptionPageText);
     Populate();
 }
Ejemplo n.º 10
0
        public FieldValidation ToAPIFieldValidation()
        {
            if (fieldValidator == null)
            {
                return(fieldValidation);
            }

            fieldValidation              = new OneSpanSign.API.FieldValidation();
            fieldValidation.MaxLength    = fieldValidator.MaxLength;
            fieldValidation.MinLength    = fieldValidator.MinLength;
            fieldValidation.Required     = fieldValidator.Required;
            fieldValidation.Disabled     = fieldValidator.Disabled;
            fieldValidation.ErrorMessage = fieldValidator.Message;
            fieldValidation.ErrorCode    = fieldValidator.ErrorCode;

            if (!String.IsNullOrEmpty(fieldValidator.Regex))
            {
                fieldValidation.Pattern = fieldValidator.Regex;
            }

            if (fieldValidator.Options != null && fieldValidator.Options.Count != 0)
            {
                foreach (String option in fieldValidator.Options)
                {
                    fieldValidation.AddEnum(option);
                }
            }

            return(fieldValidation);
        }
Ejemplo n.º 11
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (textBoxName.Text.Length == 0 || textBoxPrice.Text.Length == 0)
            {
                MessageBox.Show("Complete mandatory fields!");
                return;
            }

            if (FieldValidation.IsValidDecimalNumericField(textBoxPrice.Text) == false)
            {
                MessageBox.Show("Invalid value typed price! Type another!");
                return;
            }
            else
            {
                importedMaterial.Name        = textBoxName.Text;
                importedMaterial.Description = textBoxDescription.Text;
                importedMaterial.Price       = Convert.ToDecimal(textBoxPrice.Text);
                ClearAllFields();
                if (this.StatusUpdated != null)
                {
                    this.StatusUpdated(this, new EventArgs());
                }
            }
        }
Ejemplo n.º 12
0
        private async Task CreateSupplier()
        {
            List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Name", SupplierName),
                new KeyValuePair <string, string>("Phone", Phone),
                new KeyValuePair <string, string>("Email", Email),
                new KeyValuePair <string, string>("GSTN", GSTN),
                new KeyValuePair <string, string>("WorkDescription", WorkDescription)
            };

            if (FieldValidation.ValidateFields(values))
            {
                CanSaveSupplier = false;
                try
                {
                    SupplierModel supplierData = new SupplierModel()
                    {
                        Name            = SupplierName,
                        Phone           = phone,
                        Email           = Email,
                        GSTN            = GSTN,
                        WorkDescription = WorkDescription,
                    };
                    HttpResponseMessage result = null;
                    if (isUpdate)
                    {
                        supplierData.ID         = ID;
                        supplierData.CreatedBy  = SelectedSupplier.CreatedBy;
                        supplierData.ModifiedOn = DateTime.Now;
                        supplierData.ModifiedBy = ParentLayout.LoggedInUser.Name;
                        result = await apiHelper.PutSupplier(ParentLayout.LoggedInUser.Token, supplierData).ConfigureAwait(false);
                    }
                    else
                    {
                        supplierData.CreatedBy = ParentLayout.LoggedInUser.Name;
                        result = await apiHelper.PostSupplier(ParentLayout.LoggedInUser.Token, supplierData).ConfigureAwait(false);
                    }
                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show($"Supplier Saved Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        await GetSuppliers();

                        IsUpdate = false;
                        ClearFields();
                    }
                    else
                    {
                        MessageBox.Show("Error in saving Supplier", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanSaveSupplier = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    CanSaveSupplier = true;
                }
            }
        }
Ejemplo n.º 13
0
        private async Task CreateSalesEnquiry()
        {
            List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Name", Title),
                new KeyValuePair <string, string>("Phone", Phone),
                new KeyValuePair <string, string>("RelatedTo", RelatedTo),
                new KeyValuePair <string, string>("EnquiryDate", EnquiryDate.ToString()),
                new KeyValuePair <string, string>("FollowUpDate", FollowUpDate.ToString()),
            };

            if (FieldValidation.ValidateFields(values))
            {
                CanSaveEnquiry = false;
                try
                {
                    SalesEnquiryModel salesEnquiryData = new SalesEnquiryModel()
                    {
                        Name         = Title,
                        Phone        = Phone,
                        RelatedTo    = RelatedTo,
                        EnquiryDate  = EnquiryDate,
                        FollowUpDate = FollowUpDate,
                    };
                    HttpResponseMessage result = null;
                    if (isUpdate)
                    {
                        salesEnquiryData.ID         = ID;
                        salesEnquiryData.CreatedBy  = SelectedEnquiry.CreatedBy;
                        salesEnquiryData.ModifiedOn = DateTime.Now;
                        salesEnquiryData.ModifiedBy = ParentLayout.LoggedInUser.Name;
                        result = await apiHelper.PutSalesEnquiry(ParentLayout.LoggedInUser.Token, salesEnquiryData).ConfigureAwait(false);
                    }
                    else
                    {
                        salesEnquiryData.CreatedBy = ParentLayout.LoggedInUser.Name;
                        result = await apiHelper.PostSalesEnquiry(ParentLayout.LoggedInUser.Token, salesEnquiryData).ConfigureAwait(false);
                    }
                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show($"Sales Enquiry Saved Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        await GetEnquiries();

                        ClearFields();
                    }
                    else
                    {
                        MessageBox.Show("Error in saving Sales Enquiry", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanSaveEnquiry = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    CanSaveEnquiry = true;
                }
            }
        }
Ejemplo n.º 14
0
        private async Task CreateProject()
        {
            try
            {
                List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("Title", Title_),
                    new KeyValuePair <string, string>("Project Type", TypeText),
                    new KeyValuePair <string, string>("Project Status", StatusText),
                    new KeyValuePair <string, string>("Address", Address)
                };
                if (FieldValidation.ValidateFields(values))
                {
                    CanSaveProject = false;

                    ProjectModel projectData = new ProjectModel()
                    {
                        Title         = Title_,
                        ProjectTypeID = SelectedType?.ID,
                        Type          = SelectedType == null ? new TypeModel {
                            Title = TypeText, CreatedBy = ProjectSelection.LoggedInUser.Name
                        } : null,
                        ProjectStatusID = SelectedStatus?.ID,
                        Status          = SelectedStatus == null ? new StatusModel {
                            Title = StatusText, CreatedBy = ProjectSelection.LoggedInUser.Name
                        } : null,
                        StartDate = StartDate,
                        DueDate   = DueDate,
                        Address   = Address,
                        CreatedBy = ProjectSelection.LoggedInUser.Name,
                        CreatedOn = DateTime.Now
                    };

                    HttpResponseMessage result = await apiHelper.PostProject(ProjectSelection.LoggedInUser.Token, projectData).ConfigureAwait(false);

                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show($"Project Saved Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            new Action(async() => await ProjectSelection.GetProjects(null))();
                            ClosePopupCommand.Execute(null);
                        });
                    }
                    else
                    {
                        MessageBox.Show("Error in saving Project", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanSaveProject = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                CanSaveProject = true;
            }
        }
Ejemplo n.º 15
0
        private bool FormIsValid()
        {
            bool selectedComboBoxes = FieldValidation.AreSelected(FoodQualityComboBox.SelectedIndex, AirQualityComboBox.SelectedIndex
                                                                  , DrinkingWaterComboBox.SelectedIndex, TerrainQualityComboBox.SelectedIndex
                                                                  , InlandWaterQualityComboBox.SelectedIndex, MedicalVasteComboBox.SelectedIndex, RadiationComboBox.SelectedIndex, RecreationalWaterComboBox.SelectedIndex);
            bool inputedText = FieldValidation.NotNullOrEmpty(NameBox.Text, CountryNameBox.Text, PostalCodeBox.Text);

            return(selectedComboBoxes && inputedText);
        }
        private bool FormIsValid()
        {
            bool areFilled = FieldValidation.NotNullOrEmpty(FirstNameBox.Text, LastNameBox.Text, BirthPlaceBox.Text, UNBBox.Text,
                                                            MothersNameBox.Text, MothersProfessionBox.Text, FathersNameBox.Text, FathersProfessionBox.Text,
                                                            InsuranceNumberBox.Text);
            bool areChecked = (MaleCheckBox.IsChecked.Value || FemaleCheckBox.IsChecked.Value) && (MarriedCheckBox.IsChecked.Value || NotMarriedCheckBox.IsChecked.Value);

            return(areFilled && areChecked && FieldValidation.AreSelected(ResidancePlaceComboBox.SelectedIndex));
        }
Ejemplo n.º 17
0
        public void ConvertAPIToAPI()
        {
            apiFieldValidation1 = CreateTypicalAPIFieldValidation();
            FieldValidatorConverter converter = new FieldValidatorConverter(apiFieldValidation1);

            apiFieldValidation2 = converter.ToAPIFieldValidation();
            Assert.IsNotNull(apiFieldValidation2);
            Assert.AreEqual(apiFieldValidation2, apiFieldValidation1);
        }
        private async Task CreateMaterial()
        {
            try
            {
                List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("Name", Title),
                    new KeyValuePair <string, string>("Unit", UnitText)
                };
                if (FieldValidation.ValidateFields(values))
                {
                    CanSaveMaterial = false;

                    MaterialModel materialData = new MaterialModel()
                    {
                        Name   = Title,
                        UnitID = SelectedUnit?.ID,
                        Unit   = SelectedUnit == null ? new UnitModel {
                            Title = UnitText, CreatedBy = ParentLayout.LoggedInUser.Name, CreatedOn = DateTime.Now
                        } : null,
                    };

                    HttpResponseMessage result = null;
                    if (isUpdate)
                    {
                        materialData.ID        = ID;
                        materialData.CreatedBy = selectedMaterial.CreatedBy;
                        result = await apiHelper.PutMaterial(ParentLayout.LoggedInUser.Token, materialData).ConfigureAwait(false);
                    }
                    else
                    {
                        materialData.CreatedBy = ParentLayout.LoggedInUser.Name;
                        result = await apiHelper.PostMaterial(ParentLayout.LoggedInUser.Token, materialData).ConfigureAwait(false);
                    }
                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show($"Material Saved Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        await GetMaterials();
                        await GetUnits();

                        ClearFields();
                    }
                    else
                    {
                        MessageBox.Show("Error in saving Material", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanSaveMaterial = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                CanSaveMaterial = true;
            }
        }
Ejemplo n.º 19
0
        public void ConvertAPIToSDK()
        {
            apiFieldValidation1 = CreateTypicalAPIFieldValidation();
            sdkFieldValidator1  = new FieldValidatorConverter(apiFieldValidation1).ToSDKFieldValidator();

            Assert.AreEqual(sdkFieldValidator1.Message, apiFieldValidation1.ErrorMessage);
            Assert.AreEqual(sdkFieldValidator1.MaxLength, apiFieldValidation1.MaxLength);
            Assert.AreEqual(sdkFieldValidator1.MinLength, apiFieldValidation1.MinLength);
            Assert.AreEqual(sdkFieldValidator1.Required, apiFieldValidation1.Required);
            Assert.IsEmpty(sdkFieldValidator1.Options);
        }
Ejemplo n.º 20
0
 private bool CheckFields()
 {
     if (AddressStreet.Equals(string.Empty) || AddressCity.Equals(string.Empty) || AddressHouseNo.Equals(string.Empty))
     {
         throw new Exception("Please fill in the fields");
     }
     if (!FieldValidation.ValidateInt(AddressZip))
     {
         throw new Exception("Invalid Zip Code");
     }
     return(true);
 }
 private void AddClinicButton_Click(object sender, RoutedEventArgs e)
 {
     if (SinceDatePicker.SelectedDate.HasValue && FieldValidation.AreSelected(ClinicComboBox.SelectedIndex))
     {
         ErrorLabel.Content = language.WorkPlaceError.Equals(ErrorLabel.Content) ? string.Empty : ErrorLabel.Content;
         doctorUtil.WorkInClinic(SinceDatePicker, UntilDatePicker, DeleteClinicButton_Click);
     }
     else
     {
         FieldValidation.WriteMessage(ErrorLabel, language.WorkPlaceError);
     }
 }
 private void AddTitleButton_Click(object sender, RoutedEventArgs e)
 {
     if (GettingTitleDatePicker.SelectedDate.HasValue && FieldValidation.AreSelected(MedicalTitleComboBox.SelectedIndex))
     {
         ErrorLabel.Content = language.MedicalTitleError.Equals(ErrorLabel.Content) ? string.Empty : ErrorLabel.Content;
         doctorUtil.HasMedicalTitle(GettingTitleDatePicker, DeleteMedicalTitleButton_Click);
     }
     else
     {
         FieldValidation.WriteMessage(ErrorLabel, language.MedicalTitleError);
     }
 }
Ejemplo n.º 23
0
        public void ConvertSDKToAPI()
        {
            sdkFieldValidator1  = CreateTypicalSDKValidator();
            apiFieldValidation1 = new FieldValidatorConverter(sdkFieldValidator1).ToAPIFieldValidation();

            Assert.AreEqual(apiFieldValidation1.ErrorCode, 150);
            Assert.AreEqual(apiFieldValidation1.ErrorMessage, sdkFieldValidator1.Message);
            Assert.AreEqual(apiFieldValidation1.MaxLength, sdkFieldValidator1.MaxLength);
            Assert.AreEqual(apiFieldValidation1.MinLength, sdkFieldValidator1.MinLength);
            Assert.AreEqual(apiFieldValidation1.Required, sdkFieldValidator1.Required);
            Assert.AreEqual(apiFieldValidation1.Pattern, sdkFieldValidator1.Regex);
        }
Ejemplo n.º 24
0
        private FieldValidation CreateTypicalAPIFieldValidation()
        {
            FieldValidation apiFieldValidation = new FieldValidation();

            apiFieldValidation.ErrorCode    = 100;
            apiFieldValidation.ErrorMessage = "Error message.";
            apiFieldValidation.MaxLength    = 30;
            apiFieldValidation.MinLength    = 10;
            apiFieldValidation.Pattern      = "*pattern*";
            apiFieldValidation.Required     = true;

            return(apiFieldValidation);
        }
        private void btnAddToScene_Click(object sender, RoutedEventArgs e)
        {
            if (checkBoxIsSuspendable.IsChecked == true)
            {
                if (textBoxChosenHeight.Text.Length == 0 || Convert.ToSingle(textBoxChosenHeight.Text) == 0)
                {
                    MessageBox.Show("Type a height for the suspended object!");
                    return;
                }
                if (FieldValidation.IsValidFloatNumericField(textBoxChosenHeight.Text) == false)
                {
                    MessageBox.Show("Invalid value typed for walls height! Type another!");
                    return;
                }
                else
                {
                    ChosenHeight = Convert.ToSingle(textBoxChosenHeight.Text);
                    if (SelectedObject.Height + ChosenHeight * scaleFactor > sceneHeight)
                    {
                        MessageBox.Show("The chosen height is invalid! Type another!");
                        return;
                    }
                }
            }

            SelectedObject.Price = Convert.ToDecimal(textBlockTotalPrice.Text);
            if (actualPrice + SelectedObject.Price > projectBudget)
            {
                MessageBox.Show("The object can't be added! You are exceeding the budget!");
                addPermission = false;
                return;
            }

            if (SelectedObject.Height > sceneHeight)
            {
                MessageBox.Show("The object can't be added! Its height is exceeding the walls height!");
                return;
            }
            SelectedObject.Translate = new Point3d(SelectedObject.Translate.X, ChosenHeight * realHeightScaleFactor * 50, SelectedObject.Translate.Z);
            //InitializeSelectedObjectMaterials();
            SelectedObject.SetMaterials(selectedObjectMaterials);
            SelectedObject.MaterialsPrice = Convert.ToDecimal(textBlockMaterialsPrice.Text);

            if (ChosenHeight * realHeightScaleFactor * 50 > 0)
            {
                SelectedObject.IsSuspendable = true;
            }

            this.Close();
        }
Ejemplo n.º 26
0
        private async Task CreateUnit()
        {
            List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Title", Title)
            };

            if (FieldValidation.ValidateFields(values))
            {
                CanSaveUnit = false;
                try
                {
                    UnitModel unitData = new UnitModel()
                    {
                        Title = Title,
                    };
                    HttpResponseMessage result = null;
                    if (isUpdate)
                    {
                        unitData.ID        = ID;
                        unitData.CreatedBy = SelectedUnit.CreatedBy;
                        result             = await apiHelper.PutUnit(ParentLayout.LoggedInUser.Token, unitData).ConfigureAwait(false);
                    }
                    else
                    {
                        unitData.CreatedBy = ParentLayout.LoggedInUser.Name;
                        result             = await apiHelper.PostUnit(ParentLayout.LoggedInUser.Token, unitData).ConfigureAwait(false);
                    }
                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show($"Unit Saved Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        await GetUnits();

                        ClearFields();
                        IsUpdate = false;
                    }
                    else
                    {
                        MessageBox.Show("Error in saving Unit", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanSaveUnit = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    CanSaveUnit = true;
                }
            }
        }
Ejemplo n.º 27
0
        private async Task DoLogin()
        {
            List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("UserName", UserName),
                new KeyValuePair <string, string>("Password", Password)
            };

            if (FieldValidation.ValidateFields(values))
            {
                CanLogin = false;
                try
                {
                    LoginAPIHelper loginAPIHelper = new LoginAPIHelper();
                    var            result         = await loginAPIHelper.Authenticate(UserName, Password).ConfigureAwait(false);

                    if (result.GetType() == typeof(LoginErrorResponse))
                    {
                        LoginErrorResponse response = result as LoginErrorResponse;
                        MessageBox.Show(response.Error_Description, response.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else if (result.GetType() == typeof(AuthenticatedUser))
                    {
                        AuthenticatedUser authenticatedUser = result as AuthenticatedUser;
                        LoggedInUser      loggedInUser      = await loginAPIHelper.GetLoggedInUser(authenticatedUser.Access_Token).ConfigureAwait(false);

                        loggedInUser.Token = authenticatedUser.Access_Token;
                        Application.Current.Properties["LoggedInUser"] = loggedInUser;
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            ProjectSelection projectSelection = new ProjectSelection();
                            projectSelection.Show();
                            this.Close();
                        });
                    }
                    else
                    {
                        MessageBox.Show("OOPS! Unexpected error occured", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanLogin = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    CanLogin = true;
                }
            }
        }
Ejemplo n.º 28
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsValidForm())
            {
                DbStatus status = await roleService.Add(new Role()
                {
                    RoleName = NameBox.Text
                });

                OperationStatus = StatusHandler.Handle(OperationType.Create, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
Ejemplo n.º 29
0
        /*
         * Perform the requested validation against the data entry fields in dataEntryFields.
         * Add any errors to notifications arraylist.
         *
         * Return FALSE if validation errors occur.
         *
         */
        protected bool Validate(FieldValidation validation, Dictionary <string, DataFieldControl> dataEntryFields, ArrayList notifications)
        {
            bool valid = false;

            // trap any errors
            try
            {
                switch (validation)
                {
                case FieldValidation.INSERT_REQUIRED:
                    valid = ValidateInsertRequired(dataEntryFields, notifications);
                    break;

                case FieldValidation.ENTRY_REQUIRED:
                    valid = ValidateEntryRequired(dataEntryFields, notifications);
                    break;

                case FieldValidation.FIELD_TYPE:
                    valid = ValidateFieldType(dataEntryFields, notifications);
                    break;

                case FieldValidation.VALID_LIST:
                    valid = ValidateValidList(dataEntryFields, notifications);
                    break;

                case FieldValidation.MIN_MAX_BETWEEN:
                    valid = ValidateMinMaxBetween(dataEntryFields, notifications);
                    break;

                case FieldValidation.REGEX:
                    valid = ValidateRegEx(dataEntryFields, notifications);
                    break;

                    //case FieldValidation.MISS_VAL:
                    //    valid = ValidateMissVal(dataEntryFields, notifications);
                    //    break;
                }         //switch
            }             // try
            catch (Exception ex)
            {
                notifications.Add(string.Format("Unexpected error in Validate(): {0}", ex.Message));
                valid = false;
            }
            return(valid);
        }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsValidForm())
            {
                DbStatus status = await clinicService.Add(new Clinic()
                {
                    Name    = NameBox.Text,
                    IdPlace = ((PlaceViewModel)PlaceComboBox.SelectedItem).IdPlace
                });

                OperationStatus = StatusHandler.Handle(OperationType.Create, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
        protected void createTabXML()
        {
            
            FieldValidations allFieldsValidations = new FieldValidations();

            DataTable validationDataTable = ValidationDataTable;
            DataTable validationConditionDataTable = ValidationConditionDataTable;

            foreach (DataRow drValidationRow in validationDataTable.Rows)
            {

                string FieldName = drValidationRow[Constants.ValidationField.SPFieldName].ToString();
                Enums.ValidationRule ValidationRule = (Enums.ValidationRule)(Convert.ToInt32(drValidationRow[Constants.ValidationField.ValidationRuleID].ToString()));
                Enums.Operator FieldOperatorID = (Enums.Operator)(Convert.ToInt32(drValidationRow[Constants.ValidationField.SPFieldOperatorID].ToString()));
                string ValidationValue = drValidationRow[Constants.ValidationField.Value].ToString();
                string ErrorMessage = drValidationRow[Constants.ValidationField.ErrorMessage].ToString();
                Enums.Operator BySPPrincipalOperator = (Enums.Operator)(Convert.ToInt32(drValidationRow[Constants.ValidationField.SPPrinciplesOperatorID].ToString()));
                string ForSPPrinciples = drValidationRow[Constants.ValidationField.SPPrinciples].ToString();

                FieldValidation objValidation = new FieldValidation(new Field(FieldName), ValidationRule, FieldOperatorID, ValidationValue, ErrorMessage, ForSPPrinciples, BySPPrincipalOperator);


                int validationID = Convert.ToInt32(drValidationRow[Constants.RowID]);
                DataTable conditionOfSelectedValidation = Helper.GetViewFromDataTable(validationConditionDataTable, validationID, Constants.ConditionField.ValidationRowID).ToTable();

                if (conditionOfSelectedValidation != null && conditionOfSelectedValidation.Rows.Count > 0)
                {
                    foreach (DataRow drCondition in conditionOfSelectedValidation.Rows)
                    {
                        string OnField2 = drCondition[Constants.ConditionField.SPFieldName].ToString();
                        Enums.Operator ByFieldOperator = (Enums.Operator)Convert.ToInt32(drCondition[Constants.ConditionField.SPFieldOperatorID].ToString());
                        object Value = drCondition[Constants.ConditionField.Value].ToString();
                        objValidation.Conditions.Add(new Condition(new Field(OnField2), ByFieldOperator, Value));
                    }

                }

                allFieldsValidations.Add(objValidation);
            }


            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (SPSite objSite = new SPSite(SPContext.Current.Web.Url.ToString()))
                {
                    using (SPWeb objWeb = objSite.OpenWeb())
                    {

                        SPList list = objWeb.Lists[new Guid(Request.QueryString["List"])];
                        objWeb.AllowUnsafeUpdates = true;


                        string xml = allFieldsValidations.ToString();
                        if (allFieldsValidations.Count > 0 && Helper.IsValidXml(xml))
                        {

                            Helper.CreateConfigFile(list, Constants.ConfigFile.FieldValidationFile, xml);
                        }
                        else
                        {
                            Helper.DeleteConfigFile(list, Constants.ConfigFile.FieldValidationFile, xml);
                        }

                        objWeb.AllowUnsafeUpdates = false;
                    }
                }
            });
            
        }