private static bool ValidateEmail(EmailAddress emailToValidate, ref BrokenRuleCollection brokenRules)
        {
            //Set default return value to true
            bool returnValue = true;

            if (emailToValidate != null)
            {
                if (!string.IsNullOrEmpty(emailToValidate.EmailValue))
                {
                    if (!EmailValidator.IsValid(emailToValidate.EmailValue.Trim()))
                    {
                        brokenRules.Add("Email Address", emailToValidate.EmailValue.Trim() + " is an invalid email format.");
                        returnValue = false;
                    }
                }
                else
                {
                    brokenRules.Add("Email Address", "Email is required.");
                    returnValue = false;
                }
            }
            else
            {
                brokenRules.Add("Email Address", "Email class was not instantiated");
                returnValue = false;
            }
            return(returnValue);
        }
Ejemplo n.º 2
0
        public static int Save(int entityId, EntityType entityTypeToSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (entityId <= 0)
            {
                saveBrokenRules.Add("Entity", "Invalid Id for Entity Relationship");
            }

            //make sure email type is in correct format
            // ValidateEmail(emailToSave, ref saveBrokenRules);

            //email type is required
            if (string.IsNullOrEmpty(entityTypeToSave.EntityTypeName))
            {
                saveBrokenRules.Add("Entity Type Name", "Name is required.");
            }

            if (saveBrokenRules.Count() > 0)
            {
                throw new BLLException("There was an error saving Email", saveBrokenRules);
            }
            else
            {
                // Validation successful - call data access layer to save
                return(EntityTypeDAL.Save(entityId, entityTypeToSave));
            }
        }
        public static int Save(int employeeId, EmailAddress emailToSave)
        {
            //Instantiate a brokenRules collection and check for any validation errors
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (employeeId <= 0)
            {
                saveBrokenRules.Add("Employee", "Invalid Id");
            }

            //Make sure email is in correct format
            ValidateEmail(emailToSave, ref saveBrokenRules);

            //email Type is required
            if (emailToSave.EntityType.EntityTypeId <= 0)
            {
                saveBrokenRules.Add("Email Address Type", "Type is required.");
            }

            //Check for validation errors
            if (emailToSave.EntityType.EntityTypeId <= 0)
            {
                throw new BLLException("There was an error saving email.", saveBrokenRules);
            }
            else
            {
                //Validation a success - call the data access layer to save
                return EmailAddressDAL.Save(employeeId, emailToSave);
            }
        }
        public static int Save(int instructorId, EmailAddress emailToSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (instructorId <= 0)
            {
                saveBrokenRules.Add("Instructor", "Invalid Id");
            }

            //make sure email type is in correct format
            ValidateEmail(emailToSave, ref saveBrokenRules);

            //email type is required
            if (emailToSave.EmailType.EntityTypeId <= 0)
            {
                saveBrokenRules.Add("Email Address Type", "Type is required.");
            }
            if (saveBrokenRules.Count() > 0)
            {
                throw new BLLException("There was an error saving Email", saveBrokenRules);
            }
            else
            {
                // Validation successful - call data access layer to save
                return(EmailAddressDAL.Save(instructorId, emailToSave));
            }
        }
        public static int SAVE(int personId, EmailAddress emailToSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (personId <= 0)
                saveBrokenRules.Add("Person", "Invalid ID.");

            //make sure Email is in the correct format
            ValidateEmail(emailToSave, ref saveBrokenRules);

            //email type is required
            if(emailToSave.EmailType.EntityTypeId <=0)
            {
                saveBrokenRules.Add("Email Address Type", "Type is Required.");
            }

            //check for validation errors
            if(saveBrokenRules.Count() > 0)
            {
                throw new BLLException("There was an error saving Email.", saveBrokenRules);
            }
            else 
            {
                //validation success - call DAL to save
                return EmailAddressDAL.Save(personId, emailToSave);
            }
        }
        private bool ValidateForm()
        {
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            if (drpEntity.SelectedValue.Trim().ToInt() == 0)
            {
                brokenRules.Add("Entity", "Please select a valid Entity from the drop-down list");
                returnValue = false;
            }
            if (string.IsNullOrEmpty(txtEntityName.Text.Trim()))
            {
                brokenRules.Add("Lookup Name", "Required Field");
                returnValue = false;
            }
            if (!returnValue)
            {
                if (brokenRules.Count() == 1)
                {
                    this.DisplayLocalMessage("There is an error with your submission. Please correct and try again", brokenRules);
                }
                else
                {
                    this.DisplayLocalMessage("There were some errors with your submission. Please correct and try again.", brokenRules);
                }
            }
            return(returnValue);
        }
Ejemplo n.º 7
0
        public static int SaveMake(VehicleMake vehicleMaketoSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (vehicleMaketoSave == null)
                saveBrokenRules.Add("Vehicle Make", "Invalid vehicleMake object.");
            else
            {
                if (string.IsNullOrEmpty(vehicleMaketoSave.VehicleMakeName))
                    saveBrokenRules.Add("Vehicle Make Name", "Value is Required.");
            }
            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                //check to make sure name dosent exist
                VehicleMake tempMake = GetMake(vehicleMaketoSave.VehicleMakeName);
                if (tempMake == null)
                    return VehicleMakeDAL.Save(vehicleMaketoSave);
                else
                    return
                        tempMake.VehicleMakeId;
            }

        }
Ejemplo n.º 8
0
        public static int SaveDrawing(int lotteryDrawingId, LotteryDrawing drawingToSave)
        {
            //notes:    instantiate BrokenRules collection and check for any validation errors
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (lotteryDrawingId <= 0)
                saveBrokenRules.Add("Drawing", "Drawing must be associated with a valid Drawing");

            if (drawingToSave == null)
                saveBrokenRules.Add("Drawing", "Invalid Drawing object.");

            else
            {
                if (string.IsNullOrEmpty(drawingToSave.PrizeAmount))
                    saveBrokenRules.Add("PrizeAmount", "Value is required");
            }

            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                drawingToSave.PrizeAmount = new LotteryDrawing { LotteryDrawingId = lotteryDrawingId };
                return LotteryDrawingDAL.Save(drawingToSave);
            }
        }
        private static bool ValidateEmail(EmailAddress emailToValidate, ref BrokenRuleCollection brokenRules)
        {
            //set default return value to true
            bool returnValue = true;

            //Validate email address
            if (emailToValidate != null)
            {
                if (!string.IsNullOrEmpty(emailToValidate.EmailAddressName))
                {
                    if (!EmailValidator.IsValid(emailToValidate.EmailAddressName.Trim()))
                    {
                        //email was not in a valid format
                        brokenRules.Add("Email Address", emailToValidate.EmailAddressName.Trim() + " is an invalid email format.");
                        returnValue = false;
                    }
                }
                else
                {
                    //email is required
                    brokenRules.Add("Email Address", "Email is Required.");
                    returnValue = false;
                }
            }
            else
            {
                brokenRules.Add("Email Address", "Email class was not instantiated");
                returnValue = false;
            }
            return returnValue;
        }
Ejemplo n.º 10
0
        private static bool ValidateDrawingDate(DrawingDateBO drawingDateToValidate, ref BrokenRuleCollection brokenRules)
        {
            //Set default return value to true
            bool returnValue = true;

            //Validate email address
            if (drawingDateToValidate != null)
            {
                if (drawingDateToValidate.DrawingDate == DateTime.MinValue)
                {
                    //Email was not in a valid format
                    brokenRules.Add("Drawing Date", "is an invalid email format.");
                    returnValue = false;
                }
                if (drawingDateToValidate.DrawingDate > DateTime.Now)
                {
                    //Email cannot be a date beyond the current date
                    brokenRules.Add("Drawing Date " + drawingDateToValidate.DrawingDate.ToString(), "cannot be a future date.");

                }
                if(drawingDateToValidate.DrawingDate == DateTime.MinValue)
                {
                    //Emailis required
                    brokenRules.Add("Drawing Date", "Drawing date is required");
                    returnValue = false;
                }
            }
            else
            {
                //Generic error - class not instantiated
                brokenRules.Add("Drawing Date", "Drawing Date was not instantiated.");
                returnValue = false;
            }
            return returnValue;
        }
Ejemplo n.º 11
0
        public static int Save(string entityName, string entityTypeValue)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (string.IsNullOrEmpty(entityName))
                saveBrokenRules.Add("Entity", "Invalid Entity Name.");

            if (string.IsNullOrEmpty(entityTypeValue))
                saveBrokenRules.Add("Entity Type", "Value is required");

            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                Entity tempEntity = EntityManager.GetItem(entityName);
                return EntityTypeDAL.Save(tempEntity.EntityId, new EntityType(entityTypeValue));
            }
        }
Ejemplo n.º 12
0
        public static int Save(int entityId, EntityType entityTypeToSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (entityId <= 0)
                saveBrokenRules.Add("Entity", "Invalid Entity Id.");

            if (entityTypeToSave == null)
                saveBrokenRules.Add("Entity Type", "Invalid EntityType object.");
            else
            {
                if (string.IsNullOrEmpty(entityTypeToSave.EntityTypeValue))
                    saveBrokenRules.Add("Entity Type", "Value is Required.");
            }
            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules Failed", saveBrokenRules);
            else
                return EntityTypeDAL.Save(entityId, entityTypeToSave);
        }
Ejemplo n.º 13
0
 public static void AreCodesSet(YellowstonePathology.Business.Billing.Model.CptBillingCodeItemCollection cptBillingCodes, BrokenRuleCollection brokenRules)
 {
     if (cptBillingCodes.Count == 0)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Codes Not Set";
         item.Severity = "Critical";
         item.Description = "Please Set Codes.";
         brokenRules.Add(item);
     }
 }
Ejemplo n.º 14
0
 public static void IsPatientIdValid(string value, BrokenRuleCollection brokenRules)
 {
     if (value == "0" || value == string.Empty)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Blank Patient Id";
         item.Severity = "Critical";
         item.Description = "Please select a link this case.";
         brokenRules.Add(item);
     }
 }
Ejemplo n.º 15
0
 public static void IsDistributionValid(YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionCollection testOrderReportDistributionCollection, BrokenRuleCollection brokenRules)
 {
     if (testOrderReportDistributionCollection.Count == 0)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Report Distribution not set.";
         item.Severity = "Critical";
         item.Description = "Please set the report distribution.";
         brokenRules.Add(item);
     }
 }
Ejemplo n.º 16
0
 public static void IsClientIdValid(long value, BrokenRuleCollection brokenRules)
 {
     if (value == 0)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Blank Client Id";
         item.Severity = "Critical";
         item.Description = "Please select a Client.";
         brokenRules.Add(item);
     }
 }
Ejemplo n.º 17
0
 public static void IsBirthdateValid(Nullable<DateTime> value, BrokenRuleCollection brokenRules)
 {
     if (value.HasValue == false)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Blank Birthdate";
         item.Severity = "Critical";
         item.Description = "Please enter a birthdate.";
         brokenRules.Add(item);
     }
 }
Ejemplo n.º 18
0
 public static void IsDateValid(string value, BrokenRuleCollection brokenRules)
 {
     DateTime result;
     if (DateTime.TryParse(value, out result) == false)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Date Not Valid";
         item.Severity = "Critical";
         item.Description = "Please enter a valid date.";
         brokenRules.Add(item);
     }
 }
Ejemplo n.º 19
0
        public static int SaveGame(int lotteryId, LotteryGameValue gameToSave)
        {
            //notes:    instantiate BrokenRules collection and check for any validation errors
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (lotteryId <= 0)
                saveBrokenRules.Add("Lottery", "Invalid Lottery Game Id");

            if (gameToSave == null)
                saveBrokenRules.Add("Game Name", "Invalid GameName objects.");

            else
            {
                if (string.IsNullOrEmpty(gameToSave.GameName))
                    saveBrokenRules.Add("Game Name", "Game Name is required");
            }

            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
                return LotteryGameDAL.Save2(lotteryId, gameToSave);
        }
Ejemplo n.º 20
0
        public static Entity GetItem(string entityName)
        {
            BrokenRuleCollection getBrokenRules = new BrokenRuleCollection();

            if (string.IsNullOrEmpty(entityName))
            {
                getBrokenRules.Add("Entity Name", "Name is missing.");
                throw new BLLException("There was and error retriving Entity item.", getBrokenRules);
            }
            else
                return EntityDAL.GetItem(entityName);

        }
Ejemplo n.º 21
0
        public static EntityType GetItem(int EntityTypeId)
        {
            BrokenRuleCollection getBrokenRules = new BrokenRuleCollection();

            if (EntityTypeId < 0)
            {
                getBrokenRules.Add("Entity Type", "EntityType is missing.");
                throw new BLLException("There was and error retriving EntityType item.", getBrokenRules);
            }
            else
                return EntityTypeDAL.GetItem(EntityTypeId);

        }
Ejemplo n.º 22
0
        public static int SaveModel(int vehicleMakeId, VehicleModel vehicleModeltoSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (vehicleMakeId<=0)
                saveBrokenRules.Add("Vehicle Make Id", "Vehicle Model must be associated with a valid VehicleMake Id .");

            if (vehicleModeltoSave == null)
                saveBrokenRules.Add("Vehicle Model", "Invalid VehicleModel Object.");
            else
            {
                if (string.IsNullOrEmpty(vehicleModeltoSave.VehicleModelName))
                    saveBrokenRules.Add("Vehicle Model Name", "Value is Required.");
            }
            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                vehicleModeltoSave.Make = new VehicleMake { VehicleMakeId = vehicleMakeId };
                return VehicleModelDAL.Save(vehicleModeltoSave);
            }

        }
Ejemplo n.º 23
0
        public static EntityType GetItem(int entityTypeId)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (entityTypeId <= 0)
            {
                saveBrokenRules.Add("Entity Type", "Invalid Id" + entityTypeId.ToString());

                throw new BLLException("There was an error saving Email", saveBrokenRules);
            }
            EntityType item = EntityTypeDAL.GetItem(entityTypeId);

            if (item == null)
            {
                saveBrokenRules.Add("EntityType", "Could not retrieve record with ID:" + entityTypeId.ToString());
                // Validation successful - call data access layer to save
                throw new BLLException("Error : No record found ", saveBrokenRules);
            }
            else
            {
                return(item);
            }
        }
Ejemplo n.º 24
0
        public void Validate(Patient.Model.Patient patient, BrokenRuleCollection brokenRules)
        {
            if (patient.PatientId == "0" | patient.PatientId == string.Empty)
            {
                Validation.BrokenRuleItem brokenRule = new BrokenRuleItem();
                brokenRule.RuleName = "Patient Not Linked.";
                brokenRule.Description = "Please link this patient.";
                brokenRule.Severity = "Critical";
                brokenRules.Add(brokenRule);
            }

            if (patient.LastName == string.Empty)
            {
                BrokenRuleItem brokenRule = new BrokenRuleItem();
                brokenRule.RuleName = "No Patient Last Name";
                brokenRule.Description = "Please enter the patients last name.";
                brokenRule.Severity = "Critical";
                brokenRules.Add(brokenRule);
            }
            if (patient.FirstName == string.Empty)
            {
                BrokenRuleItem brokenRule = new BrokenRuleItem();
                brokenRule.RuleName = "No Patient First Name";
                brokenRule.Description = "Please enter the patients first name.";
                brokenRule.Severity = "Critical";
                brokenRules.Add(brokenRule);
            }
            if (patient.Birthdate.ToString() == string.Empty)
            {
                BrokenRuleItem brokenRule = new BrokenRuleItem();
                brokenRule.RuleName = "No Patient Birthdate";
                brokenRule.Description = "Please enter the patients birthdate.";
                brokenRule.Severity = "Critical";
                brokenRules.Add(brokenRule);
            }
        }
        public static Gym GetItem(int gymId)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (gymId <= 0)
            {
                saveBrokenRules.Add("Gym", "Invalid ID: " + gymId.ToString());

                throw new BLLException("There was an error retrieving Gym", saveBrokenRules);
            }

            Gym item = GymDAL.GetItem(gymId);

            if (item == null)
            {
                saveBrokenRules.Add("Gym", "Could not retrieve record with ID: " + gymId.ToString());

                throw new BLLException("Error: No records found", saveBrokenRules);
            }
            else
            {
                return(item);
            }
        }
        public static int Save(Gym gymToSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (string.IsNullOrEmpty(gymToSave.GymName))
            {
                saveBrokenRules.Add("Gym Name", "Name is required.");
            }

            if (saveBrokenRules.Count() > 0)
            {
                throw new BLLException("There was an error saving Gym", saveBrokenRules);
            }
            else
            {
                return(GymDAL.Save(gymToSave));
            }
        }
Ejemplo n.º 27
0
        public static int Save(int drawingDateId, int gameId, DrawingDateBO drawingDateToSave)
        {
            //Instantiates a brokenRules collection and check for any validation errors
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (gameId <= 0)
            {
                saveBrokenRules.Add("Drawing date", "Invalid game id");
            }

            ValidateDrawingDate(drawingDateToSave, ref saveBrokenRules);

            if (saveBrokenRules.Count() > 0)
            {
                throw new BLLException("There was an error saving email.", saveBrokenRules);
            }
            else
            {
                //Call DAL to save
                return DrawingDateDAL.Save(drawingDateId, gameId, drawingDateToSave);
            }
        }
        private bool ValidateForm()
        {
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            if (string.IsNullOrEmpty(txtGymName.Text.Trim()))
            {
                brokenRules.Add("Gym Name", "Required Field");
                returnValue = false;
            }
            if (!returnValue)
            {
                if (brokenRules.Count() == 1)
                {
                    this.DisplayLocalMessage("There is an error with your submission. Please correct and try again", brokenRules);
                }
                else
                {
                    this.DisplayLocalMessage("There were some errors with your submission. Please correct and try again", brokenRules);
                }
            }
            return(returnValue);
        }
Ejemplo n.º 29
0
        private bool ValidateForm()
        {
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //notes: validate form controls
            //notes: required fields
            if (string.IsNullOrEmpty(DrawingDate.Text.Trim()))
                brokenRules.Add("Drawing Date", "Required field.");

            if (string.IsNullOrEmpty(PrizeAmount.Text.Trim()))
                brokenRules.Add("Jackpot Amount", "Required field.");

            //notes:    check if broken rules collection has any items
            if (brokenRules.Count() > 0)
            {
                //notes:    bind the collection to the list control
                MessageList.DataSource = brokenRules;
                MessageList.DataBind();

                //notes:    check to see if there were multiple errors - diplay message
                if (brokenRules.Count() == 1)
                {
                    //notes:    display main error message to user
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again.");
                }
                else
                {
                    //notes:    display main error message to user
                    this.DisplayLocalMessage("There were some errors processing your form. Please correct and try saving again.");
                }
                returnValue = false;
            }

            //notes:    return the value of the variable
            return returnValue;
        }
        private bool ValidateForm()
        {
            //Create bool for our return value and instantiate a new brokenRuleCollection object
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //Validate our form controls required fields
            if (string.IsNullOrEmpty(txtFirstName.Text.Trim()))
            {
                brokenRules.Add("First Name", "Required Field");
            }
            if (string.IsNullOrEmpty(txtLastName.Text.Trim()))
            {
                brokenRules.Add("Last Name", "Required Field");
            }

            //Validate dates if user entered in data
            if (string.IsNullOrEmpty(txtBirthDate.Text.Trim()))
            {
                if (txtBirthDate.Text == "" || Convert.ToDateTime(txtBirthDate.Text.Trim()) == DateTime.MinValue)
                {
                    brokenRules.Add("Date of Birth", "Please enter a valid date.");
                }
            }
            if (string.IsNullOrEmpty(txtDateOfHire.Text.Trim()))
            {
                if (txtBirthDate.Text == "" || Convert.ToDateTime(txtDateOfHire.Text.Trim()) == DateTime.MinValue)
                {
                    brokenRules.Add("Date of Hire", "Please enter a valid date.");
                }
            }
            if (string.IsNullOrEmpty(txtDateOfTermination.Text.Trim()))
            {
                if (txtBirthDate.Text == "" || Convert.ToDateTime(txtDateOfTermination.Text.Trim()) == DateTime.MinValue)
                {
                    brokenRules.Add("Date of Termination", "Please enter a valid date.");
                }
            }

            //Check if broken rules collection has any items
            if (brokenRules.Count() > 0)
            {
                //Bind the collection to the list control
                MessageList.DataSource = brokenRules;
                MessageList.DataBind();

                //Check to see if there were mutliple errors - display appropriate message
                if (brokenRules.Count() == 1)
                {
                    //Display main error message to user
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again");
                }
                else
                {
                    this.DisplayLocalMessage("There was some errors processing your form. Please correct and try saving again");
                }
                returnValue = false;
            }
            return returnValue;
        }
Ejemplo n.º 31
0
        private bool ValidateForm()
        {
            PageMessageArea.Visible = true;

            //Create bool for our return value and instantiate a new brokenRuleCollection object
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //Validate our form controls required fields
            if (string.IsNullOrEmpty(txtMatch.Text.Trim()))
            {
                brokenRules.Add("Match", "Required Field");
            }
            if (string.IsNullOrEmpty(txtWin.Text.Trim()))
            {
                brokenRules.Add("Win", "Required Field");
            }
            if (string.IsNullOrEmpty(txtOdds.Text.Trim()))
            {
                brokenRules.Add("Odds", "Required Field");
            }

            //Check if broken rules collection has any items
            if (brokenRules.Count() > 0)
            {
                //Bind the collection to the list control
                MessageList.DataSource = brokenRules;
                MessageList.DataBind();

                //Check to see if there were mutliple errors - display appropriate message
                if (brokenRules.Count() == 1)
                {
                    //Display main error message to user
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again");
                }
                else
                {
                    this.DisplayLocalMessage("There was some errors processing your form. Please correct and try saving again");
                }
                returnValue = false;
            }
            return returnValue;
        }
Ejemplo n.º 32
0
        private bool ValidateForm()
        {
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //validate our form controls
            //required feilds
            if (string.IsNullOrEmpty(FirstName.Text.Trim()))
                brokenRules.Add("First Name", "Required feild.");

            if (string.IsNullOrEmpty(LastName.Text.Trim()))
                brokenRules.Add("Last Name", "Required feild.");

            //Valid Dates if user entered in data
            if (!string.IsNullOrEmpty(BirthDate.Text.Trim()))
            {
                if (BirthDate.Text.Trim().ToDate() == DateTime.MinValue)//trim?
                    brokenRules.Add("Date of Birth", "Please enter a valid date.");

            }
            if (!string.IsNullOrEmpty(HireDate.Text.Trim()))
            {
                if (HireDate.Text.Trim().ToDate() == DateTime.MinValue)
                    brokenRules.Add("Date of Hire", "Please enter a valid date.");

            }
            if (!string.IsNullOrEmpty(TermDate.Text.Trim()))
            {
                if (TermDate.Text.Trim().ToDate() == DateTime.MinValue)
                    brokenRules.Add("Date of Termination", "Please enter a valid date.");

            }

            //check if broken rulles collection has any items
            if (brokenRules.Count() > 0)
            {
                CustomMessageArea.BrokenRules = brokenRules;

                //execute display() method to render to screen
                CustomMessageArea.Display();

                if (brokenRules.Count() == 1)
                {
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again.");
                }
                else
                {
                    this.DisplayLocalMessage("There were Some errors processing your form. Please correct and try saving again.");
                }
                returnValue = false;
            }
            return returnValue;
        }
        private bool ValidateForm()
        {
            PageMessageArea.Visible = true;

            //Create bool for our return value and instantiate a new brokenRuleCollection object
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //Validate that the game id is greater than zero
            if (_gameId <= 0)
            {
                brokenRules.Add("Game Id", "Please select a game to add drawing information for.");
            }

            //Validate our form controls required fields
            if (string.IsNullOrEmpty(txtDrawingDate.Text.Trim()))
            {
                brokenRules.Add("Drawing Date", "Required Field");
            }
            if (string.IsNullOrEmpty(txtJackpotAmount.Text.Trim()))
            {
                brokenRules.Add("Jackpot", "Required Field");
            }

            //find dynamic textboxes for validating required fields
            int i = 1;
            while (i <= _intForCreatingTextBoxes)
            {
                //Find the textbox control by the ID, which I gave them IDs 1-6
                TextBox txtWinningNumber = (TextBox)Panel1.FindControl("txtBox" + i.ToString());
                HiddenField hdnWinningNumberId = (HiddenField)Panel1.FindControl("id" + i.ToString());
                string txtBoxName = "Textbox" + i.ToString();

                if (string.IsNullOrEmpty(txtWinningNumber.Text))
                {
                    brokenRules.Add(txtBoxName, "Required Field");
                }

                //Validate number value integer inputs and if user entered correct integers format and if integer is greater than zero
                int value;
                if (int.TryParse(txtWinningNumber.Text, out value))
                {
                    if (value < 0)
                    {
                        brokenRules.Add(txtBoxName, "Please enter a valid integer greater than zero.");
                    }
                }

                i++;
            }

            //Validate Drawing date and make sure it is in correct date format
            if (string.IsNullOrEmpty(txtDrawingDate.Text.Trim()))
            {
                if (txtDrawingDate.Text == "" || Convert.ToDateTime(txtDrawingDate.Text.Trim()) == DateTime.MinValue)
                {
                    brokenRules.Add("Drawing Date", "Please enter a valid date.");
                }
            }
            /*
            DateTime dateValue;
            if (DateTime.TryParse(txtDrawingDate.Text, out dateValue))
            {
                if (dateValue > DateTime.Now)
                {
                    brokenRules.Add("Drawing Date " + dateValue.ToShortDateString(), "cannot be greater than current date.");
                }
            }
            */

            //Validate jackpot integer inputs and if user entered correct integers format and if integer is greater than zero
            int value2;
            if (int.TryParse(txtJackpotAmount.Text, out value2))
            {
                if (value2 < 0)
                {
                    brokenRules.Add("Jackpot", "Please enter a valid integer greater than zero.");
                }
            }

            ////Check if broken rules collection has any items////
            if (brokenRules.Count() > 0)
            {
                //Bind the collection to the list control
                MessageList.DataSource = brokenRules;
                MessageList.DataBind();

                //Check to see if there were mutliple errors - display appropriate message
                if (brokenRules.Count() == 1)
                {
                    //Display main error message to user
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again");
                }
                else
                {
                    this.DisplayLocalMessage("There was some errors processing your form. Please correct and try saving again");
                }
                returnValue = false;
            }
            return returnValue;
        }
        private bool ValidateForm()
        {
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            if (string.IsNullOrEmpty(txtFirstName.Text.Trim()))
            {
                brokenRules.Add("First Name", "Required field");
            }

            if (string.IsNullOrEmpty(txtLastName.Text.Trim()))
            {
                brokenRules.Add("Last Name", "Required field");
            }

            if (drpEmployeeType.SelectedValue == "0")
            {
                brokenRules.Add("Employee Type", "Select an Employee Type from the drop down list");
            }

            if (drpGender.SelectedValue == "0")
            {
                brokenRules.Add("Gender", "Select a Gender from the drop down list");
            }

            if (!string.IsNullOrEmpty(txtBirthDate.Text.Trim()))
            {
                if (txtBirthDate.Text.Trim().ToDate() == DateTime.MinValue)
                {
                    brokenRules.Add("Date Of Birth", "Please enter a valid date.");
                }
            }

            if (!string.IsNullOrEmpty(txtHireDate.Text.Trim()))
            {
                if (txtHireDate.Text.Trim().ToDate() == DateTime.MinValue)
                {
                    brokenRules.Add("Date Of Hire", "Please enter a valid date.");
                }
            }
            if (!string.IsNullOrEmpty(txtTermDate.Text.Trim()))
            {
                if (txtTermDate.Text.Trim().ToDate() == DateTime.MinValue)
                {
                    brokenRules.Add("Date Of Term", "Please enter a valid date.");
                }
            }
            if (brokenRules.Count() > 0)
            {
                MessageList.DataSource = brokenRules;
                MessageList.DataBind();

                if (brokenRules.Count() == 1)
                {
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again");
                }
                else
                {
                    this.DisplayLocalMessage("There was some error processing your form. Please correct and try saving again");
                }
                returnValue = false;
            }
            return(returnValue);
        }
Ejemplo n.º 35
0
 public static void IsPhyscianIdValid(int value, BrokenRuleCollection brokenRules)
 {
     if (value == 0)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Blank Physician Id";
         item.Severity = "Critical";
         item.Description = "Please select a Physician.";
         brokenRules.Add(item);
     }
 }
Ejemplo n.º 36
0
        public static int SaveModel(string vehicleMakeName, VehicleModel vehicleModeltoSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (string.IsNullOrEmpty(vehicleMakeName))
                saveBrokenRules.Add("Vehicle Make Name", "Vehicle Model must be associated with a valid Vehicle Make Name.");

            if (vehicleModeltoSave == null)
                saveBrokenRules.Add("Vehicle Model", "Invaild VehicleModel object.");
            else
            {
                if (string.IsNullOrEmpty(vehicleModeltoSave.VehicleModelName))
                    saveBrokenRules.Add("Vehicle Make Name", "Value is Required.");
            }
            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                //check to make sure name dosent exist
                VehicleMake itemMake = GetMake(vehicleMakeName);
                if (itemMake == null)
                {
                    itemMake = new VehicleMake();
                    itemMake.VehicleMakeId = SaveMake(new VehicleMake{VehicleMakeName = vehicleMakeName});
                }
               
                vehicleModeltoSave.Make = itemMake;
                return VehicleModelDAL.Save(vehicleModeltoSave);
               
            }

        }
        private bool ValidateForm()
        {
            PageMessageArea.Visible = true;

            //Create bool for our return value and instantiate a new brokenRuleCollection object
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //Validate our form controls required fields
            if (string.IsNullOrEmpty(txtMovieTitle.Text.Trim()))
            {
                brokenRules.Add("Movie Title", "Required Field");
            }
            if (string.IsNullOrEmpty(txtYearReleased.Text.Trim()))
            {
                brokenRules.Add("Year Released", "Required Field");
            }

            //Validate integer inputs and if user entered correct integers format and if integer is greater than zero
            int value;
            if (int.TryParse(txtYearReleased.Text, out value))
            {
                if (value <= 0)
                {
                    brokenRules.Add("Year Released", "Please enter a valid integer greater than zero.");
                }
            }
            else
            {
                brokenRules.Add("Year Released", "Only numeric values allowed.");
            }

            //Check if broken rules collection has any items
            if (brokenRules.Count() > 0)
            {
                //Bind the collection to the list control
                MessageList.DataSource = brokenRules;
                MessageList.DataBind();

                //Check to see if there were mutliple errors - display appropriate message
                if (brokenRules.Count() == 1)
                {
                    //Display main error message to user
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again");
                }
                else
                {
                    this.DisplayLocalMessage("There was some errors processing your form. Please correct and try saving again");
                }
                returnValue = false;
            }
            return returnValue;
        }
Ejemplo n.º 38
0
        private bool ValidateForm()
        {
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            if (GameList.SelectedValue.Trim().ToInt() == 0)
            {
                brokenRules.Add("Lottery Game", "Please select a valid Lottery Game from the drop-down list.");
                returnValue = false;
            }

            if(string.IsNullOrEmpty(GameValueField.Text.Trim()))
            {
                brokenRules.Add("Lookup Value", "Required field.");
                    returnValue = false;
            }

            if (!returnValue)
            {
                if(brokenRules.Count() == 1)
                    this.DisplayLocalMessage("There is an error with your submission. Please correct and try again.", brokenRules);
                else
                    this.DisplayLocalMessage("There were some errors with your submission. Please correct and try again.", brokenRules);
            }

            return returnValue;
        }