Example #1
0
        public AdminSession(AdminForm f1, ISessionService sessionService, IFilmsService filmsService, ValidationField valid)
        {
            _valid = valid;

            _sessionService = sessionService;
            _filmsService   = filmsService;

            _f1 = f1;

            _f1.Load += Form1_Load;

            _dataGridSession            = _f1.DataGridsession;
            _dataGridSession.CellClick += dataGridSession_CellClick;

            _addSession        = _f1.addSession;
            _addSession.Click += AddSession_Click;


            _deleteSession        = _f1.deleteSession;
            _deleteSession.Click += DeleteSession_Click;

            _updateSession        = _f1.updateSession;
            _updateSession.Click += UpdateSession_Click;

            _filmName        = _f1.sessionidfilm;
            _filmName.Click += SessionIDFilm_Click;
        }
        /// <summary>
        /// Обработка события при нажатии на кнопку входа.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_login_system_Click(object sender, EventArgs e)
        {
            bool status;
            Tuple <bool, List <string> > returned;

            try
            {
                if (ValidationField.ValidationFields(fields))
                {
                    TextBoxFiledsBlocked.Add(field_system_login);
                    TextBoxFiledsBlocked.Add(field_system_password);

                    StatusUserUI.StatusFunctionalityPartsOfTheWindow(TextBoxFiledsBlocked);
                    AuthClass userAuth = new AuthClass(field_system_login.Text, field_system_password.Text);
                    returned = userAuth.LogIn();
                    status   = returned.Item1;
                    userData = returned.Item2;
                    if (!status)
                    {
                        StatusUserUI.StatusFunctionalityPartsOfTheWindow(TextBoxFiledsBlocked);
                    }
                    else
                    {
                        this.Hide();
                        StatusUserUI.StatusFunctionalityPartsOfTheWindow(setAllControlsEnabled(controlsInForm));
                    }
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, exp.StackTrace);
            }
        }
Example #3
0
        public AdminStaff(AdminForm f1, IStaffService staffService, ValidationField valid)
        {
            _valid        = valid;
            _staffService = staffService;

            _f1 = f1;

            _f1.Load += Form1_Load;

            _dataGridStaff            = _f1.DataGridstaff;
            _dataGridStaff.CellClick += dataGridStaff_CellClick;

            _addStaff        = _f1.addStaff;
            _addStaff.Click += AddStaff_Click;


            _deleteStaff        = _f1.deleteStaff;
            _deleteStaff.Click += DeleteStaff_Click;

            _updateStaff        = _f1.updateStaff;
            _updateStaff.Click += UpdateStaff_Click;

            _role        = _f1.staffvacant;
            _role.Click += ClickRole;

            _Position        = _f1.staffPosition;
            _Position.Click += ClickPosition;

            _role.DropDownStyle     = ComboBoxStyle.DropDownList;
            _Position.DropDownStyle = ComboBoxStyle.DropDownList;
        }
 public string GetClientValidationJson(Dictionary<string, IList<ModelClientValidationRule>> fields)
 {
     var rules = new Dictionary<string, Dictionary<string, object>>();
     var messages = new Dictionary<string, Dictionary<string, object>>();
     foreach(var field in fields)
     {
         var fieldRules = new Dictionary<string, object>();
         var fieldMessages = new Dictionary<string, object>();
         foreach (var fieldRule in field.Value)
         {
             var c = new ValidationField(fieldRule);
             foreach (var r in c.rules)
             {
                 if (!fieldRules.ContainsKey(r.Key))
                     fieldRules.Add(r.Key, r.Value);
             }
             foreach (var m in c.messages)
             {
                 if (!fieldMessages.ContainsKey(m.Key))
                     fieldMessages.Add(m.Key, m.Value);
             }
         }
         if (!rules.ContainsKey(field.Key))
             rules.Add(field.Key, fieldRules);
         if (!messages.ContainsKey(field.Key))
             messages.Add(field.Key, fieldMessages);
     }
     var serializer = new JavaScriptSerializer();
     return serializer.Serialize(new { rules, messages });
 }
Example #5
0
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="record"></param>
 /// <param name="field"></param>
 /// <param name="message"></param>
 /// <param name="isWarning"></param>
 public ValidationResult(object record, ValidationField field, string message, bool isWarning)
 {
     Record    = record;
     Field     = field;
     Message   = message;
     IsWarning = isWarning;
 }
Example #6
0
        private void SetValueCounts()
        {
            #region ArresteeArmedWith can only have one value when 01 is used

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "arresteeArmedWith");

            ValidationMessage = new ValidationMessage(string.Format("{0} can only have one value when 01 is used", TargetFieldLabel), "arresteeArmedWith");

            TargetField = new ValidationField
            {
                FieldPath   = "arresteeArmedWith",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Multiselect,
            };

            NibrsValidationRules.Add(new Validation(new Guid("CD8D0BD3-F4D4-4728-942A-4131D297D680"), ValidationMessage, TargetField)
                                     .ValueCount("1")
                                     .WithConditions()
                                     .Contains(TargetField, new List <string> {
                "01"
            })
                                     .ThatSelfEvaluates()
                                     .ImplementStateValidationRule());

            #endregion
        }
Example #7
0
        /// <summary>
        /// Removes all error messages.
        /// </summary>
        /// <param name="justForField"></param>
        private void ClearAllMessages(ValidationField justForField = ValidationField.None)
        {
            foreach (var kvp in _ValidationFieldMap)
            {
                if (justForField != ValidationField.None && kvp.Key != justForField)
                {
                    continue;
                }

                var control          = kvp.Value;
                var validateDelegate = control as IValidateDelegate;
                if (validateDelegate != null)
                {
                    if (_WarningProvider != null)
                    {
                        control = validateDelegate.GetValidationDisplayControl(_WarningProvider);
                    }
                    if (_ErrorProvider != null)
                    {
                        control = validateDelegate.GetValidationDisplayControl(_ErrorProvider);
                    }
                }

                if (_ErrorProvider != null)
                {
                    _ErrorProvider.SetError(control, null);
                }
                if (_WarningProvider != null)
                {
                    _WarningProvider.SetError(control, null);
                }
            }
        }
Example #8
0
 private void ValidateWithinBounds(ValidationField field, double value, double lowerInclusive, double upperInclusive, string message, List <ValidationResult> results)
 {
     if (value < lowerInclusive || value > upperInclusive)
     {
         results.Add(new ValidationResult(field, message));
     }
 }
Example #9
0
        private void SetRegularExpressions()
        {
            #region Age2 must be 1-99

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be 1-99", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2")),
                TargetPath = "age2"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "age2",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Text,
                Mask        = Mask.None
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .RegularExpression(ValidationMeta.ZeroToNinetyNineRange)
                             .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);

            #endregion
        }
Example #10
0
        private void SetValueCounts()
        {
            #region Injuries can only have one value when N or M is used

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.VICTIMS, "injuries");

            ValidationMessage = new ValidationMessage(string.Format("{0} can only have one value when N or M is used", TargetFieldLabel), "injuries");

            TargetField = new ValidationField
            {
                FieldPath   = "injuries",
                SectionName = GenericSectionName.VICTIMS,
                ControlType = ControlType.Multiselect,
            };

            ValidationRule = new Validation(ValidationMessage, TargetField).ValueCount("1")
                             .WithConditions()
                             .Contains(TargetField, new List <string> {
                "N", "M"
            })
                             .ThatSelfEvaluates()
                             .SetRuleImplementation(RuleImplementation)
                             .ImplementStateValidationRule();

            ValidationRule.ValidationId = string.Format("{0} can only have one value when N is selected", TargetFieldLabel); // Nibrs override
            NibrsValidationRules.Add(ValidationRule);

            #endregion
        }
Example #11
0
 private void button_save_ftp_settings_Click(object sender, EventArgs e)
 {
     //Сохранение настроек подключения
     if (ValidationField.ValidationFields(fields))
     {
         SaveDataConnection();
     }
 }
        /// <summary>
        /// Tells the helper which fields the view knows about and which control corresponds to which field.
        /// </summary>
        /// <param name="validationField"></param>
        /// <param name="control"></param>
        /// <remarks>
        /// It is not permissable to register the same field or control twice.
        /// </remarks>
        public void RegisterValidationField(ValidationField validationField, Control control)
        {
            if(control == null) throw new ArgumentNullException("control");
            if(_ValidationFieldMap.ContainsKey(validationField)) throw new InvalidOperationException(String.Format("An attempt was made to register the {0} validation field twice", validationField));
            if(_ValidationFieldMap.Where(kvp => kvp.Value == control).Any()) throw new InvalidOperationException(String.Format("An attempt was made to register the {0} control twice", control.Name));

            _ValidationFieldMap.Add(validationField, control);
        }
Example #13
0
        public void RelatedOffenderVictimTest()
        {
            var result = ValidationField.RelatedOffenderVictim();

            result.FieldPath.Should().Be("relationshipToOffender");
            result.SectionName.Should().Be("Victims");
            result.ControlType.Should().Be(ControlType.RelatedOffender);
        }
Example #14
0
        public void RelatedOffensesOrganizationInvolveTest()
        {
            var result = ValidationField.RelatedOffensesOrganizationInvolved();

            result.FieldPath.Should().Be("relatedOffenses");
            result.SectionName.Should().Be("IncidentOrganizations");
            result.ControlType.Should().Be(ControlType.RelatedOffenseMulti);
        }
Example #15
0
        public void RelatedOffenseDrugsTest()
        {
            var result = ValidationField.RelatedOffenseDrugs();

            result.FieldPath.Should().Be("relatedOffense");
            result.SectionName.Should().Be("Drugs");
            result.ControlType.Should().Be(ControlType.RelatedOffense);
        }
 private void button2_Click(object sender, EventArgs e)
 {
     //Если все поля верны - пишем в файл.
     if (ValidationField.ValidationFields(getAllTextBoxFields()))
     {
         this.Close();
     }
 }
Example #17
0
        public void ViolationCodeOffensesTest()
        {
            var result = ValidationField.ViolationCodeOffenses();

            result.FieldPath.Should().Be("violationCodeReference");
            result.SectionName.Should().Be("Offenses");
            result.ControlType.Should().Be(ControlType.Offense);
        }
Example #18
0
        public void RelatedOffensePropertyTest()
        {
            var result = ValidationField.RelatedOffenseProperty();

            result.FieldPath.Should().Be("relatedOffense");
            result.SectionName.Should().Be("Property");
            result.ControlType.Should().Be(ControlType.RelatedOffense);
        }
Example #19
0
 /// <summary>
 /// В зависимости от результатов валидации полей выдаёт ошибку,
 /// или сохраняет данные соединения
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_save_settings_connect_Click(object sender, EventArgs e)
 {
     //Сохранение настроек подключения
     if (ValidationField.ValidationFields(_fields))
     {
         SaveDataConnection();
         Close();
     }
 }
Example #20
0
 /// <summary>
 /// Выполняет проверку соедиения с сервером.
 /// В случае удачи, предлагает сохранить настройки.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_test_connect_Click(object sender, EventArgs e)
 {
     if (ValidationField.ValidationFields(_fields))
     {
         if (TestConnectToDb(_fields))
         {
             SuccessConnection();
         }
     }
 }
Example #21
0
 /// <summary>
 /// Сохраняет данные о конфигурации соединения с сервером баз данных
 /// </summary>
 private void SaveDataConnection()
 {
     if (ValidationField.ValidationFields(_fields))
     {
         foreach (var field in _fields)
         {
             _sdb.WriteDataSettings(field.Name, field.Text);
         }
         Close();
     }
 }
        private void button_save_deviceInfo_Click(object sender, EventArgs e)
        {
            //Если все поля верны - пишем в файл. Сохранять бессмысленно.
            if (ValidationField.ValidationFields(getAllTextBoxFields()))
            {
                ///XmlFileCreatorDeviceInfoPart1 dataPar1 = new XmlFileCreatorDeviceInfoPart1();

                /*currentForm.Close();
                 * FormChecker.ControlOpenedForm(typeof (DeviceStepTwo));
                 */}
        }
Example #23
0
            /// <summary>
            /// Adds a record to the <see cref="Results"/> indicating that a validation test was carried out on the field.
            /// </summary>
            /// <param name="field"></param>
            /// <returns>The result record describing the validation field or null if there was already an entry for this
            /// combination of field and record.</returns>
            public ValidationResult AddPartialValidationField(ValidationField field)
            {
                ValidationResult result = null;

                if (!Results.PartialValidationFields.Any(r => r.Record == Record && r.Field == field))
                {
                    result = new ValidationResult(Record, field, null);
                    Results.PartialValidationFields.Add(result);
                }

                return(result);
            }
Example #24
0
 /// <summary>
 /// Выполняет проверку соедиения с сервером.
 /// В случае удачи, предлагает сохранить настройки.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button_test_ftp_settings_Click(object sender, EventArgs e)
 {
     if (ValidationField.ValidationFields(fields))
     {
         if (TestConnectToDB(fields))
         {
             SuccessConnection(fields);
         }
         else
         {
             failureConnection();
         }
     }
 }
Example #25
0
        public CashireTickets(CashierForm f3, ITicketsServiceC ticketsService, ValidationField valid)
        {
            _valid          = valid;
            _ticketsService = ticketsService;

            _f3 = f3;

            _f3.Load += Form1_Load;

            _dataGridTickets            = _f3.DataGridtickets;
            _dataGridTickets.CellClick += DataGridtickets_CellClick;

            _addTickets        = _f3.addTicket;
            _addTickets.Click += AddTickets_Click;
        }
Example #26
0
        private void SetRange()
        {
            #region Latitude must be in the range 34.85654 to 36.75412

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.latitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be in the range 34.85654 to 36.75412", TargetFieldLabel),
                TargetPath = "address.latitude"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.latitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text,
            };

            NibrsValidationRules.Add(new Validation(ValidationMessage, TargetField)
                                     .Range("34.85654", "36.75412")
                                     .ImplementStateValidationRule());

            #endregion

            #region Longitude must be in the range -81.59809 to -90.49735

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.longitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0}  must be in the range -81.59809 to -90.49735", TargetFieldLabel),
                TargetPath = "address.longitude"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.longitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text,
            };

            NibrsValidationRules.Add(new Validation(ValidationMessage, TargetField)
                                     .Range("-81.59809", "-90.49735")
                                     .ImplementStateValidationRule());

            #endregion
        }
Example #27
0
        private void SetRegularExpressions()
        {
            #region Latitude must be in the format 99.99999 with at least 5 decimal places (Event)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.latitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be in the format 99.99999 with at least 5 decimal places", TargetFieldLabel),
                TargetPath = "address.latitude"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.latitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text,
            };

            NibrsValidationRules.Add(new Validation(ValidationMessage, TargetField)
                                     .RegularExpression(ValidationMeta.Latitude5Places)
                                     .ImplementStateValidationRule());

            #endregion

            #region Longitude must be in the format -99.99999 with at least 5 decimal places (Event)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.longitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be in the format -99.99999 with at least 5 decimal places", TargetFieldLabel),
                TargetPath = "address.longitude"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.longitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text,
            };

            NibrsValidationRules.Add(new Validation(ValidationMessage, TargetField)
                                     .RegularExpression(ValidationMeta.Longitude5Places)
                                     .ImplementStateValidationRule());

            #endregion
        }
Example #28
0
        /// <summary>
        /// Tells the helper which fields the view knows about and which control corresponds to which field.
        /// </summary>
        /// <param name="validationField"></param>
        /// <param name="control"></param>
        /// <remarks>
        /// It is not permissable to register the same field or control twice.
        /// </remarks>
        public void RegisterValidationField(ValidationField validationField, Control control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }
            if (_ValidationFieldMap.ContainsKey(validationField))
            {
                throw new InvalidOperationException(String.Format("An attempt was made to register the {0} validation field twice", validationField));
            }
            if (_ValidationFieldMap.Where(kvp => kvp.Value == control).Any())
            {
                throw new InvalidOperationException(String.Format("An attempt was made to register the {0} control twice", control.Name));
            }

            _ValidationFieldMap.Add(validationField, control);
        }
Example #29
0
        /// <summary>
        /// Returns the control associated with the field passed across. Returns null if the pageObject passed
        /// across does not match the pageObject held by the page.
        /// </summary>
        /// <param name="pageObject"></param>
        /// <param name="validationField"></param>
        /// <param name="isClearMessage"></param>
        /// <returns></returns>
        public Control GetControlForValidationField(object pageObject, ValidationField validationField, bool isClearMessage)
        {
            Control result = null;

            if (pageObject == PageObject)
            {
                _ValidationFieldControlMap.TryGetValue(validationField, out result);

                if (result == null && !isClearMessage && _ValidationFieldControlMap.ContainsKey(validationField))
                {
                    // The page hasn't been created and it has a validation error on it - create the page and try again
                    SettingsView.CreatePage(this);
                    _ValidationFieldControlMap.TryGetValue(validationField, out result);
                }
            }

            return(result);
        }
Example #30
0
        private void SetCustoms()
        {
            #region At least 2 Group A Offenses are required when AggravatedAssaults has a value of 08 (excludes UCR codes 978, 979, 992, and 980)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.VICTIMS, "aggravatedAssaults");

            var groupA = ValidationMeta.NibrsGroupAOffenses;
            groupA.Remove("978");
            groupA.Remove("979");
            groupA.Remove("992");
            groupA.Remove("980");

            ValidationMessage = new ValidationMessage(string.Format("At least 2 Group A Offenses are required when {0} has a value of 08 (excludes UCR codes 978, 979, 992, and 980)", TargetFieldLabel), "aggravatedAssaults");

            TargetField = new ValidationField
            {
                FieldPath   = "aggravatedAssaults",
                SectionName = GenericSectionName.VICTIMS,
                ControlType = ControlType.Multiselect,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField).CustomValidation(
                    "aggravatedAssaults2GroupAOffenses")
                .Contains(new List <string> {
                "08"
            })
                .WithConditions()
                .Contains(ValidationField.ViolationCodeOffenses(), groupA)
                .ThatSelfEvaluates()
                .SetRuleImplementation(RuleImplementation)
                .ImplementStateValidationRule();

            ValidationRule.Operation.Operand       = "aggravatedAssaults2GroupAOffenses";
            ValidationRule.Operation.OperationType = ValidationOperationType.Custom;

            NibrsValidationRules.Add(ValidationRule);

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    ValidationField.ViolationCodeOffenses()).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());

            #endregion
        }
Example #31
0
        public AdminTickets(AdminForm f1, ITicketsService ticketsService, ValidationField valid)
        {
            _valid = valid;

            _ticketsService = ticketsService;

            _f1 = f1;

            _f1.Load += Form1_Load;

            _dataGridTickets            = _f1.DataGridtickets;
            _dataGridTickets.CellClick += DataGridtickets_CellClick;

            _addTickets        = _f1.addTicket;
            _addTickets.Click += AddTickets_Click;

            _deleteTickets        = _f1.deleteTicket;
            _deleteTickets.Click += DeleteTickets_Click;

            _updateTickets        = _f1.updateTicket;
            _updateTickets.Click += UpdateTickets_Click;
        }
Example #32
0
        public AdminHall(AdminForm f1, IHallService hallService, ValidationField valid)
        {
            _valid       = valid;
            _hallService = hallService;

            _f1 = f1;

            _f1.Load += Form1_Load;

            _dataGridHall            = _f1.DataGridhall;
            _dataGridHall.CellClick += dataGridHall_CellClick;

            _addHall        = _f1.addHall;
            _addHall.Click += AddHall_Click;


            _deleteHall        = _f1.deleteHall;
            _deleteHall.Click += DeleteHall_Click;

            _updateHall        = _f1.updateHall;
            _updateHall.Click += UpdateHall_Click;
        }
 private void ValidateFileExists(ValidationField field, string fileName, List<ValidationResult> results)
 {
     ValidateFileSystemEntityExists(field, fileName, results, true);
 }
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="field"></param>
 /// <param name="message"></param>
 public ValidationResult(ValidationField field, string message)
     : this(field, message, false)
 {
 }
 private void ValidateFolderExists(ValidationField field, string folder, List<ValidationResult> results)
 {
     ValidateFileSystemEntityExists(field, folder, results, false);
 }
        private void ValidateFileSystemEntityExists(ValidationField field, string entityName, List<ValidationResult> results, bool isFile)
        {
            ValidationResult result = null;

            if(!String.IsNullOrEmpty(entityName)) {
                var cachedResult = _CachedFileSystemResults.Where(r => r.ValidationField == field).FirstOrDefault();
                if(cachedResult != null && entityName == cachedResult.FileSystemEntityName) result = cachedResult.ValidationResult;
                else {
                    if(cachedResult != null) _CachedFileSystemResults.Remove(cachedResult);
                    cachedResult = new CachedFileSystemResult() { ValidationField = field, FileSystemEntityName = entityName };

                    bool entityExists = isFile ? Provider.FileExists(entityName) : Provider.FolderExists(entityName);
                    if(!entityExists) cachedResult.ValidationResult = result = new ValidationResult(field, String.Format(Strings.SomethingDoesNotExist, entityName), true);

                    _CachedFileSystemResults.Add(cachedResult);
                }

                if(result != null) results.Add(result);
            }
        }
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="field"></param>
 /// <param name="message"></param>
 /// <param name="isWarning"></param>
 public ValidationResult(ValidationField field, string message, bool isWarning)
 {
     Field = field;
     Message = message;
     IsWarning = isWarning;
 }
 private void ValidateWithinBounds(ValidationField field, double value, double lowerInclusive, double upperInclusive, string message, List<ValidationResult> results)
 {
     if(value < lowerInclusive || value > upperInclusive) results.Add(new ValidationResult(field, message));
 }