Beispiel #1
0
 public void EntityValidation(ValidationResults results)
 {
     //--- Required
     if (string.IsNullOrEmpty(employee_no))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Employee No"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (string.IsNullOrEmpty(first_name))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "First Name"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (string.IsNullOrEmpty(last_name))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Last Name"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (string.IsNullOrEmpty(user_name))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "User Name"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (string.IsNullOrEmpty(user_password))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Password"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
 }
Beispiel #2
0
        public void EntityValidation(ValidationResults results)
        {
            //--- Required
            if (menu_id == null)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Menu"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            if (bill_of_material_head_id == null)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Bill of Material Head"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            if (quantity == null)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Quantity"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }

            //---
            if (quantity <= 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Quantity", 0), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
        }
 public void EntityValidation(ValidationResults results)
 {
     //--- Required
     if (bill_of_material_head_id == null)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Bill Of Material Head"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (IsCheckedMaterial && material_id == null)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     else if (!IsCheckedMaterial && bill_of_material_head_id_sub == null)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "BOM"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (amount == null)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Amount"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (lost_factor == null)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Lost Factor"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
 }
        public void ControlValidationMappingsFailureTest()
        {
            IBugzillaPageView viewMock = MockRepository.StrictMock<IBugzillaPageView>();

            Expect.Call(viewMock.Model).PropertyBehavior();
            viewMock.ValidationRequested += null;
            LastCall.IgnoreArguments();
            viewMock.ControlValidationTriggered += null;
            LastCall.IgnoreArguments();
            IEventRaiser raiser = LastCall.GetEventRaiser();
            Expect.Call(FacadeMock.GetSourceList()).Return(new string[0]);
            Expect.Call(viewMock.SourceList).PropertyBehavior().Return(new string[0]);
            Expect.Call(FacadeMock.GetProjectWrapperList()).Return(null);
            Expect.Call(viewMock.VersionOneProjects).PropertyBehavior();
            Expect.Call(FacadeMock.GetVersionOnePriorities()).Return(null);
            Expect.Call(viewMock.VersionOnePriorities).PropertyBehavior();
            viewMock.DataBind();
            ValidationResults results = new ValidationResults();
            ValidationResult generalResult = new ValidationResult(string.Empty, new BugzillaProjectMapping(), null, null, null);
            results.AddResult(generalResult);
            Expect.Call(FacadeMock.ValidateEntity(viewMock.Model)).IgnoreArguments().Return(results);
            viewMock.SetGeneralTabValid(true);
            viewMock.SetMappingTabValid(false);

            MockRepository.ReplayAll();

            BugzillaController controller = CreateController();
            controller.RegisterView(viewMock);
            controller.PrepareView();
            raiser.Raise(viewMock, EventArgs.Empty);

            MockRepository.VerifyAll();
        }
Beispiel #5
0
 public void EntityValidation(ValidationResults results)
 {
     //--- Required
     if (string.IsNullOrEmpty(material_code))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material Code"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (string.IsNullOrEmpty(material_name))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material Name"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (uom_id_receive == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "UOM Receive"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (uom_id_count == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "UOM Count"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (uom_id_use == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "UOM Use"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (max_stock == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Maximum Stock"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (min_stock == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Minimum Stock"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (shelf_life == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Shelf Life"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (material_cost == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material Cost"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (acceptable_variance == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Acceptable Variance"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (material_group_id == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material Group"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
 }
Beispiel #6
0
 public void ValidationDuplicate(ValidationResults results)
 {
     List<DuplicateItemDTO> listDuplicateItemDTO = ServiceProvider.MenuMappingService.IsDuplicationMenuMapping(this);
     if (listDuplicateItemDTO != null)
     {
         if (listDuplicateItemDTO.Where(item => item.ColumnName == "Key").Select(item => item.isDuplicate).FirstOrDefault())
         {
             ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsDuplicate, "Bill of Material Head"), this, string.Empty, string.Empty, null);
             results.AddResult(result);
         }
     }
 }
 public void CheckDuplicateInsert(ValidationResults results)
 {
     List<DuplicateItemDTO> listDuplicateItemDTO = ServiceProvider.MaterialGroupService.IsDuplicationMaterialGroup(this);
     if (listDuplicateItemDTO != null)
     {
         if (listDuplicateItemDTO.Where(item => item.ColumnName == "Key").Select(item => item.isDuplicate).FirstOrDefault())
         {
             ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsDuplicate, "Material Group Code"), this, string.Empty, string.Empty, null);
             results.AddResult(result);
         }
     }
 }
Beispiel #8
0
 public void EntityValidation(ValidationResults results)
 {
     //--- Required
     if (string.IsNullOrEmpty(menu_code))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Menu Code"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (string.IsNullOrEmpty(menu_name))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Menu Name"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
 }
 public void EntityValidation(ValidationResults results)
 {
     //--- Required
     if (string.IsNullOrEmpty(bill_of_material_group_code))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Bill Of Material Group Code"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (string.IsNullOrEmpty(bill_of_material_group_name))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Bill Of Material Group Name"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
 }
Beispiel #10
0
        public void Validate(ValidationResults results)
        {
            if (string.IsNullOrEmpty(this.control_code) && this.control_parent_id == null)
            {
                ValidationResult result = new ValidationResult(ErrorMessage.ScreenCodeIsRequire, this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }

            List<DuplicateItemDTO> listDuplicateItemDTO = ServiceProvider.ScreenConfigService.IsDuplication(this);
            if (listDuplicateItemDTO.Where(item => item.isDuplicate == true).FirstOrDefault() != null)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsDuplicate, "Screen Code"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
        }
 private void btnSelect_Click(object sender, EventArgs e)
 {
     if (ddlWarehouse.SelectedIndex != 0)
     {
         ComboBoxDTO dto = new ComboBoxDTO();
         dto.Display = this.ddlWarehouse.Text.Substring(this.ddlWarehouse.Text.LastIndexOf(":") + 1); ;
         dto.Value = this.ddlWarehouse.SelectedValue.ToString();                
         this.ClosePopup(dto);
     }
     else
     {
         ValidationResults results = new ValidationResults();
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Warehouse"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
         base.ShowErrorMessage(new ValidationException(results));
     }
 }
Beispiel #12
0
 public void EntityValidation(ValidationResults results)
 {
     //--- Required
     if (period_group_id == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Period Group"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (string.IsNullOrEmpty(period_code))
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Period Code"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (period_date == null)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Period Date"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
 }
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                ValidationResults results = new ValidationResults();

                if (ddlPeriodGroup.SelectedIndex == 0)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Period Group"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }

                if (ddlPeriod.SelectedIndex == 0)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Period"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }

                if (ddlWarehouse.SelectedIndex == 0)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Warehouse"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }

                if (results.Count == 0)
                {
                    this.dsStockDetail = ServiceProvider.StockDetailService.GetStockDetail(ddlPeriodGroup.SelectedValue.ToLong(), ddlWarehouse.SelectedValue.ToLong());
                    baseGridDetail.LoadData();

                    ddlPeriodGroup.Enabled = false;
                    ddlPeriod.Enabled = false;
                    ddlWarehouse.Enabled = false;
                    btnGenerate.Enabled = false;
                }
                else
                {
                    throw new ValidationException(results);
                }
            }
            catch (ValidationException ex)
            {
                base.formBase.ShowErrorMessage(ex);
            }
        }
        private void ValidationDetail(TranDetail entity)
        {
            ValidationResults results = new ValidationResults();
            if (baseGridDetail.FormMode == ObjectState.Add)
            {
                if (entity.material_id == 0)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }
                else
                {
                    if (entity.warehouse_id_dest != 0)
                    {
                        DataRow[] drs = this.GetDataRowDetail(entity.material_id, entity.warehouse_id_dest);
                        if (drs.Count() >= 1)
                        {
                            ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsDuplicate, "Material"), this, string.Empty, string.Empty, null);
                            results.AddResult(result);
                        }
                    }
                }

                if (entity.warehouse_id_dest == 0)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Warehouse"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }
            }

            if (string.IsNullOrEmpty(txtLotNo.Text))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Lot No."), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (Converts.ParseDoubleNullable(txtLotNo.Text) == null)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IncorrectFormatOne, "Lot No."), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (entity.lot_no == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Lot No.", "0"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }

            if (string.IsNullOrEmpty(txtQuantity.Text))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Quantity"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (Converts.ParseDoubleNullable(txtQuantity.Text) == null)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IncorrectFormatOne, "Quantity"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (entity.quantity == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Quantity", "0"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else
            {
                if (entity.warehouse_id_dest != 0 && entity.material_id != 0)
                {
                    if (!ServiceProvider.PhyLotService.CheckLimitMaterial(entity.material_id, entity.warehouse_id_dest, entity.quantity.Value))
                    {
                        ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueLessOrEqual, "Quantity", "Max Stock"), this, string.Empty, string.Empty, null);
                        results.AddResult(result);
                    }
                }
            }

            if (results.Count > 0) { throw new ValidationException(results); }
        }
        private void ValidationHead(TranHead entity)
        {
            ValidationResults results = new ValidationResults();
            if (base.FormMode == ObjectState.Add)
            {
                if (ddlMenu.SelectedIndex == 0)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Menu"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }
                if (entity.warehouse_id == 0)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Warehose"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }
            }
            if (entity.reason_id == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Reason"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }

            if (!(this.dsTranDetail.Tables.Count > 0 && this.dsTranDetail.Tables[0].Rows.Count > 0))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Details"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            if (results.Count > 0) { throw new ValidationException(results); }
        }
Beispiel #16
0
 public void ValidateAddress(ValidationResults results)
 {
     if (!PostalInfoLookupDataSet.Instance.ZipBelongsToState(_zip, _state))
     {
         string errorMessage = string.Format(CultureInfo.CurrentCulture, Resources.InvalidAddressTemplateMessage, _zip, _state);
         ValidationResult result = new ValidationResult(errorMessage, this, "Zip", "Address", null);
         results.AddResult(result);
     }
 }
        private void ValidationDetail(StockDetail entity)
        {
            ValidationResults results = new ValidationResults();

            if (string.IsNullOrEmpty(txtAdjust.Text))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Adjust"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (Converts.ParseDecimalNullable(txtAdjust.Text) == null)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IncorrectFormatOne, "Adjust"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (entity.bal_qty <= 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Adjust", "0"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else
            {
                Material entityMaterial = new Material() { material_id = entity.material_id };
                entityMaterial = ServiceProvider.MaterialService.FindByKeys(entityMaterial, false);
                if (entity.bal_qty > entityMaterial.max_stock)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueLessOrEqual, "Adjust", "Max Stock"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }
            }

            if (results.Count > 0) { throw new ValidationException(results); }
        }
        private void ValidationHead(TranHead entity)
        {
            ValidationResults results = new ValidationResults();
            if (entity.reason_id == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Reason"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            if (rdoWarehouse.Checked && entity.warehouse_id == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Destination Warehouse"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (rdoOther.Checked && string.IsNullOrEmpty(entity.other_source))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Destination other"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }

            if (!(this.dsTranDetail.Tables.Count > 0 && this.dsTranDetail.Tables[0].Rows.Count > 0))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Details"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            if (results.Count > 0) { throw new ValidationException(results); }
        }
        private void ValidationHead(TranHead entity)
        {
            ValidationResults results = new ValidationResults();
            if (base.FormMode == ObjectState.Add)
            {
                if (string.IsNullOrEmpty(entity.reference_no))
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Reference No."), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }
                else
                {
                    TranHead entityTranHead = ServiceProvider.TranHeadService.GetTransactionByReferenceNo(entity.reference_no);
                    if (entityTranHead != null && entityTranHead.tran_head_id != 0)
                    {
                        ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsDuplicate, "Reference No."), this, string.Empty, string.Empty, null);
                        results.AddResult(result);
                    }
                }
            }
            if (entity.reason_id == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Reason"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            if (rdoSupplier.Checked && entity.supplier_id == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Source Supllier"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (rdoWarehouse.Checked && entity.warehouse_id == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Source Warehouse"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (rdoOther.Checked && string.IsNullOrEmpty(entity.other_source))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Source other"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }

            if (!(this.dsTranDetail.Tables.Count > 0 && this.dsTranDetail.Tables[0].Rows.Count > 0))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Details"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else
            {
                //foreach (DataRow dr in this.dsTranDetail.Tables[0].Rows)
                //{
                //    if (!string.IsNullOrEmpty(base.FormKeyCode))
                //    {
                //        dr["tran_head_id"] = base.FormKeyCode.ToLong();
                //    }
                //    TranDetail entityTranDetail = new TranDetail();
                //    entityTranDetail.material_id = dr["material_id"].ToLong();
                //    entityTranDetail.warehouse_id_dest = dr["warehouse_id_dest"].ToLong();
                //    entityTranDetail.quantity = dr["Quantity"].ToDecimal();
                //    entityTranDetail.remark = dr["Remark"].ToString();
                //    entityTranDetail.lot_no = dr["Lot No."].ToDecimal();
                //    this.ValidationDetail(entityTranDetail);
                //}
            }
            if (results.Count > 0) { throw new ValidationException(results); }
        }
Beispiel #20
0
 static void ShowValidatorDetails(ValidationResult item, string indent)
 {
     // Display the values of the properties of this validator.
     Console.WriteLine("{0}- Detected by: {1}", indent, GetTypeNameOnly(item.Validator));
     if (null != item.Tag)
     {
         Console.WriteLine("{0}- Tag value: {1}", indent, item.Tag);
     }
     // Split the value of the Message property into the value and the message.
     // Only required here because we may include the [{0}] token at the start
     // of the Message string so that the validated value can be displayed here.
     string theMessage = item.Message;
     string theValue = String.Empty;
     int endPosition = theMessage.IndexOf(']');
     if (endPosition > 0)
     {
         int startPosition = theMessage.IndexOf('[') + 1;
         theValue = theMessage.Substring(startPosition, endPosition - startPosition);
         theMessage = theMessage.Substring(endPosition + 1);
         // Show the value - it's a good idea to encode it for display.
         Console.WriteLine("{0}- Validated value was: '{1}'", indent, System.Web.HttpUtility.HtmlEncode(theValue));
     }
     Console.WriteLine("{0}- Message: '{1}'", indent, theMessage);
     // See if this is a composite validator - if so, iterate the nested validators.
     // Note that there may be multiple levels of nesting, so use recursion.
     if (item.NestedValidationResults.Count() > 0)
     {
         Console.WriteLine("{0}+ Nested validators:", indent, item.Message);
         foreach (ValidationResult nestedItem in item.NestedValidationResults)
         {
             ShowValidatorDetails(nestedItem, indent + "  ");
         }
     }
 }
 private void ValidationHead(StockHead entity)
 {
     ValidationResults results = new ValidationResults();
     if (ddlPeriodGroup.SelectedIndex == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Period Group"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (entity.period_id == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Period"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (entity.warehouse_id == 0)
     {
         ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Warehouse"), this, string.Empty, string.Empty, null);
         results.AddResult(result);
     }
     if (results.Count > 0) { throw new ValidationException(results); }
 }