コード例 #1
0
        private bool Validera()
        {
            ValidationCheck.checkValidering(tbTravelNamn, "tom", "förnamn");
            ValidationCheck.checkValidering(tbTravelNamn, "innehållerInt", "förnamn");
            ValidationCheck.checkValidering(tbTravelNamn, "längre255", "förnamn");

            ValidationCheck.checkValidering(tbTravelEnamn, "tom", "efternamn");
            ValidationCheck.checkValidering(tbTravelEnamn, "innehållerInt", "efternamn");
            ValidationCheck.checkValidering(tbTravelEnamn, "längre255", "efternamn");

            ValidationCheck.checkValidering(tbTravelEmal, "tom", "email");
            ValidationCheck.checkValidering(tbTravelEmal, "email", "email");

            ValidationCheck.CheckCombox(cmbTravelUppdrag, "uppdrag");

            var felmeddelanden = ValidationCheck.felString;

            if (felmeddelanden.Length > 0)
            {
                MessageBox.Show(string.Format(@"Följande fel har uppstått: {0}", felmeddelanden));
                ValidationCheck.felString = "";
                return(false);
            }
            return(true);
        }
コード例 #2
0
        public static string GetClientErrorData(Type modelType)
        {
            string out_str = "<script language=\"javascript\" type=\"text/javascript\">" + Environment.NewLine;

            out_str += "var errorRules = new Hashtable();" + Environment.NewLine + Environment.NewLine;

            Dictionary <string, List <ValidationRule> > errorRules = ValidationCheck.GetValidationRules(modelType);

            foreach (KeyValuePair <string, List <ValidationRule> > item in errorRules)
            {
                out_str += "var fieldErrorRules = new Hashtable();" + Environment.NewLine;

                foreach (ValidationRule rule in item.Value)
                {
                    string errorMessage = rule.ErrorMessage;

                    //out_str += "fieldErrorRules.put(\"" + rule.Type.ToString().ToLower() + "\", \"" + errorMessage + "\");" + Environment.NewLine;
                    out_str += "fieldErrorRules.put(\"" + rule.Type.ToString().ToLower() + "\", new Array(\"" + errorMessage + "\"" + rule.IFieldValidation.GetAdditionalParams() + "));" + Environment.NewLine;
                }

                out_str += "errorRules.put(\"" + item.Key + "\", fieldErrorRules);" + Environment.NewLine + Environment.NewLine;
            }
            out_str += "SetInputsMaxLength(errorRules);" + Environment.NewLine;
            out_str += "</script>" + Environment.NewLine;
            return(out_str);
        }
コード例 #3
0
        //ValidateWithConfim (Email, Password)
        public void Validate(ModelStateDictionary modelState)
        {
            ValidationCheck.CheckErrors(this, modelState, true);

            //check start and end date
            if (DateStart.CompareTo(DateEnd) >= 0)
            {
                modelState.AddModelError("DateEnd", "End Date must be greater than Start Date.");
            }

            try
            {
                CategoriesList = new List <long>();
                if (!String.IsNullOrEmpty(Categories))
                {
                    CategoriesList.AddRange(Array.ConvertAll(Categories.Split(','), new Converter <string, long>(StringToLong)));
                }
            }
            catch (Exception ex)
            {
                modelState.AddModelError("Categories", ex.Message);
            }

            if (CategoriesList == null || CategoriesList.Count == 0)
            {
                modelState.AddModelError("CategoriesList", "Choose category(s) before updating this event.");
            }
        }
コード例 #4
0
        private bool ValideraVidLaggTillResa()
        {
            ValidationCheck.checkValidering(tbSemesterdagar, "InnehållerBokstav", "semesterdagar");
            ValidationCheck.checkValidering(tbSemesterdagar, "längre255", "semesterdagar");

            ValidationCheck.checkValidering(tbFrukost, "InnehållerBokstav", "frukost");
            ValidationCheck.checkValidering(tbLunch, "InnehållerBokstav", "lunch");
            ValidationCheck.checkValidering(tbMiddag, "InnehållerBokstav", "middag");

            ValidationCheck.CheckCombox(cbUppdrag, "uppdrag");

            ValidationCheck.CheckDates(dtpUtResa.Value, dtpHemResa.Value);

            double avrundaDagar  = Math.Ceiling((dtpHemResa.Value - dtpUtResa.Value).TotalDays);
            double semesterDagar = Convert.ToDouble(tbSemesterdagar.Text);

            ValidationCheck.CheckSemesterDagar(avrundaDagar, semesterDagar);


            var felmeddelanden = ValidationCheck.felString;

            if (felmeddelanden.Length > 0)
            {
                MessageBox.Show(string.Format(@"Följande fel har uppstått: {0}", felmeddelanden));
                ValidationCheck.felString = "";
                return(false);
            }
            return(true);
        }
コード例 #5
0
        private bool ValideraVidSparaUtkast()
        {
            ValidationCheck.checkValidering(tbEfterNamn, "tom", "efternamn");
            ValidationCheck.checkValidering(tbEfterNamn, "längre255", "efternamn");
            ValidationCheck.checkValidering(tbEfterNamn, "innehållerInt", "efternamn");

            ValidationCheck.checkValidering(tbForNamn, "tom", "förnamn");
            ValidationCheck.checkValidering(tbForNamn, "längre255", "förnamn");
            ValidationCheck.checkValidering(tbForNamn, "innehållerInt", "förnamn");

            ValidationCheck.checkValidering(tbEmail, "tom", "email");
            ValidationCheck.checkValidering(tbEmail, "längre255", "email");
            ValidationCheck.checkValidering(tbEmail, "email", "email");

            ValidationCheck.checkValidering(tbMilErsattning, "InnehållerBokstav", "milersättning");
            ValidationCheck.checkValidering(tbMilErsattning, "tom", "milersättning");
            ValidationCheck.checkValidering(tbMilErsattning, "NegativaTal", "milersättning");

            var felmeddelanden = ValidationCheck.felString;

            if (felmeddelanden.Length <= 0)
            {
                return(true);
            }

            MessageBox.Show(string.Format(@"Följande fel har uppstått: {0}", felmeddelanden));
            ValidationCheck.felString = "";
            return(false);
        }
コード例 #6
0
        private string identifierGenerator()
        {
            Random rnd        = new Random();
            int    random     = rnd.Next(1, 5);
            string identifier = "";

            switch (random)
            {
            case 1: identifier = "A"; break;

            case 2: identifier = "B"; break;

            case 3: identifier = "C"; break;

            case 4: identifier = "D"; break;

            case 5: identifier = "E"; break;

            default:
                break;
            }
            for (int i = 0; i < 8; i++)
            {
                identifier = identifier + rnd.Next(0, 9).ToString();
            }

            if (ValidationCheck.getInstance().IsValidClientIdentifier(identifier, allClients) == true)
            {
                return(identifier);
            }
            else
            {
                return(identifierGenerator());
            }
        }
コード例 #7
0
 public static void InputValidation(string s, ValidationCheck ops)
 {
     do
     {
         Console.Write("Please enter an input: ");
     } while (!ops(s));
 }
コード例 #8
0
        //ValidateWithConfim (Email, Password)
        public void ValidateWithConfim(System.Web.Mvc.ModelStateDictionary modelState)
        {
            ValidationCheck.CheckErrors(this, modelState, true);

            //check Login
            if (!ValidationCheck.IsEmpty(this.Login) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateLogin(this.Login, ID))
            {
                modelState.AddModelError("Login", "Login already exists. Please enter a different user name.");
            }

            //check Email
            if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateEmail(this.Email, ID))
            {
                modelState.AddModelError("Email", "A username for that e-mail address already exists. Please enter a different e-mail address.");
            }
            // check Email and Confirm Email
            if (!String.Equals(this.Email, this.ConfirmEmail, StringComparison.Ordinal))
            {
                modelState.AddModelError("Email", "The Email and confirmation Email do not match.");
                modelState.AddModelError("ConfirmEmail", "");
            }
            // check Password and Confirm Password
            if (!String.Equals(this.Password, this.ConfirmPassword, StringComparison.Ordinal))
            {
                modelState.AddModelError("Password", "The password and confirmation password do not match.");
                modelState.AddModelError("ConfirmPassword", "");
            }
        }
コード例 #9
0
        private void btnUtgiter_Click(object sender, EventArgs e)
        {
            double parsedBelopp;

            double.TryParse(tbBelopp.Text, out parsedBelopp);


            ValidationCheck.checkValidering(tbBelopp, "tom", "belopp");
            ValidationCheck.checkValidering(tbBelopp, "bokstäver", "belopp");
            ValidationCheck.checkValidering(tbBelopp, "längre255", "belopp");

            ValidationCheck.checkValidering(tbAndaMal, "tom", "ändamål");
            ValidationCheck.checkValidering(tbAndaMal, "längre255", "ändamål");
            ValidationCheck.checkValidering(tbAndaMal, "siffor", "ändamål");

            var felmeddelanden = ValidationCheck.felString;

            if (felmeddelanden.Length > 0)
            {
                MessageBox.Show(string.Format(@"Följande fel har uppstått: {0}", felmeddelanden));
                ValidationCheck.felString = "";
                return;
            }

            var valtItem           = (ComboboxItem)cbValuta.SelectedItem;
            var valtItemValutaKurs = Convert.ToDouble(valtItem.Value);
            var valtItemValutaNamn = Convert.ToString(valtItem.Text);

            double konverterad = 0;

            if (valtItemValutaNamn == "SEK")
            {
                konverterad = parsedBelopp;
            }
            else if (valtItemValutaNamn == "USD")
            {
                konverterad = parsedBelopp * valtItemValutaKurs;
            }
            else if (valtItemValutaNamn == "EUR")
            {
                konverterad = parsedBelopp * valtItemValutaKurs;
            }

            var nyUtgift = new Utgift
            {
                Belopp      = parsedBelopp,
                AndaMal     = tbAndaMal.Text,
                Valuta      = valtItemValutaNamn,
                ValutaKurs  = valtItemValutaKurs,
                Moms        = 2, // vi vet fortfarande inte varför vi har moms här. Det är en relik från en svunnen tid.
                Konverterad = konverterad
            };


            AllaResor[ValdResa].UtgifterFörResa.Add(nyUtgift);
            UppdateraTotalSumma();
        }
コード例 #10
0
        public void Validate(System.Web.Mvc.ModelStateDictionary modelState)
        {
            ValidationCheck.CheckErrors(this, modelState);

            //check Login
            if (!ValidationCheck.IsEmpty(this.Login) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateLogin(this.Login, ID))
            {
                modelState.AddModelError("Login", "This login already present in system");
            }

            //check Email
            if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateEmail(this.Email, ID))
            {
                modelState.AddModelError("Email", "This email already present in system");
            }

            if (!String.Equals(this.Password, this.ConfirmPassword, StringComparison.Ordinal))
            {
                modelState.AddModelError("Password", "The password and confirmation password do not match.");
                modelState.AddModelError("ConfirmPassword", "");
            }

            if (!String.Equals(this.Email, this.ConfirmEmail, StringComparison.Ordinal))
            {
                modelState.AddModelError("Email", "The email and confirmation email do not match.");
                modelState.AddModelError("ConfirmEmail", "");
            }

            if (this.BillingState == "--" && this.BillingCountry == 1)
            {
                modelState.AddModelError("BillingState", "'State' is required");
            }

            if (this.ShippingState == "--" && this.ShippingCountry == 1 && !this.BillingLikeShipping)
            {
                modelState.AddModelError("ShippingState", "'State' is required");
            }

            if (this.BillingState != "--" && this.BillingCountry > 1)
            {
                modelState.AddModelError("BillingState", "'State' must have value '--'");
            }

            if (this.ShippingState != "--" && this.ShippingCountry > 1 && !this.BillingLikeShipping)
            {
                modelState.AddModelError("ShippingState", "'State' must have value '--'");
            }
            if (this.BillingState == "--" && this.BillingCountry > 1 && String.IsNullOrEmpty(this.BillingInternationalState))
            {
                modelState.AddModelError("BillingInternationalState", "'International State' is required");
            }
            if (this.ShippingState == "--" && this.ShippingCountry > 1 && String.IsNullOrEmpty(this.ShippingInternationalState) && !this.BillingLikeShipping)
            {
                modelState.AddModelError("ShippingInternationalState", "'International State' is required");
            }
        }
コード例 #11
0
        public Address(string line, string city, string zipCode)
        {
            ValidationCheck.ThatIsNotAnEmptyString(line, () => { throw new InvalidAddressException("An address must have a street"); });
            ValidationCheck.ThatIsNotAnEmptyString(city, () => { throw new InvalidAddressException("An address must have a city"); });
            ValidationCheck.ThatIsNotAnEmptyString(zipCode, () => { throw new InvalidAddressException("An address must have a zip code."); });

            AddressLine = line;
            City        = city;
            ZipCode     = zipCode;
        }
コード例 #12
0
        public void Validate(System.Web.Mvc.ModelStateDictionary modelState)
        {
            ValidationCheck.CheckErrors(this, modelState);

            if (!ValidationCheck.IsEmpty(this.Email) && ValidationCheck.IsEmail(this.Email))
            {
                IUser user = ProjectConfig.DataProvider.UserRepository.GetUserByEmail(Email, false);
                if (user == null)
                {
                    modelState.AddModelError("Email", "Sorry, the e-mail address entered was not found.  Please try again.");
                }
            }
        }
コード例 #13
0
        private void ValidateModel(ModelBindingContext bindingContext)
        {
            ValidationCheck.CheckErrors(bindingContext.ModelMetadata.Model, bindingContext.ModelState);

            Type[] interfaces = bindingContext.ModelType.GetInterfaces();
            foreach (Type type in interfaces)
            {
                if (type == typeof(IValidateModel))
                {
                    ((IValidateModel)bindingContext.Model).Validate(bindingContext.ModelState);
                    break;
                }
            }
        }
コード例 #14
0
        private bool ErsattningValidera()
        {
            ValidationCheck.checkValidering(tbMilErsattning, "InnehållerBokstav", "milersättning");
            ValidationCheck.checkValidering(tbMilErsattning, "NegativaTal", "milersättning");
            var felmeddelanden = ValidationCheck.felString;

            if (felmeddelanden.Length <= 0)
            {
                return(true);
            }

            MessageBox.Show(string.Format(@"Följande fel har uppstått: {0}", felmeddelanden));
            ValidationCheck.felString = "";
            return(false);
        }
コード例 #15
0
        // GET: Customers/Create
        public ActionResult Create()
        {
            var validationCheck = new ValidationCheck();
            var currentUserId   = User.Identity.GetUserId();

            if (currentUserId != null)
            {
                if (validationCheck.HasCustomerInfo(currentUserId) == false)
                {
                    ViewBag.stateID = new SelectList(db.state, "stateID", "stateCode");
                    return(View());
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #16
0
        //ValidateWithoutConfim
        public void ValidateWithoutConfim(System.Web.Mvc.ModelStateDictionary modelState)
        {
            ValidationCheck.CheckErrors(this, modelState, true);

            //check Login
            if (!ValidationCheck.IsEmpty(this.Login) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateLogin(this.Login, ID))
            {
                modelState.AddModelError("Login", "Login already exists. Please enter a different user name.");
            }

            //check Email
            if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateEmail(this.Email, ID))
            {
                modelState.AddModelError("Email", "A username for that e-mail address already exists. Please enter a different e-mail address.");
            }
        }
コード例 #17
0
        public void Validate(System.Web.Mvc.ModelStateDictionary modelState)
        {
            ValidationCheck.CheckErrors(this, modelState);

            if (!String.Equals(this.NewPassword, this.ConfirmPassword, StringComparison.Ordinal))
            {
                modelState.AddModelError("NewPassword", "The new password and confirmation password do not match");
                modelState.AddModelError("ConfirmPassword", "");
            }

            SessionUser cuser = AppHelper.CurrentUser;

            if (!ProjectConfig.DataProvider.UserRepository.ValidatePasswordForUser(this.CurrentPassword, cuser != null ? cuser.ID : 0))
            {
                modelState.AddModelError("CurrentPassword", "Current password is invalid");
            }
        }
コード例 #18
0
        public void Validate(System.Web.Mvc.ModelStateDictionary modelState)
        {
            ValidationCheck.CheckErrors(this, modelState);
            if (String.IsNullOrEmpty(Email))
            {
                modelState.AddModelError("Email", "<br /><br /><br /><br />Please enter your email address");
            }

            if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.DataProvider.UserRepository.ValidateOuterSubscriptionEmail(this.Email, ID))
            {
                modelState.AddModelError("Email", "<br /><br /><br /><br />This email already present in system");
            }

            if (this.Email != this.EmailConfirm)
            {
                modelState.AddModelError("Email", "<br /><br /><br /><br />Email and confirmation email should be match.");
            }
        }
コード例 #19
0
 private void usernamTextBox_Leave(object sender, EventArgs e)
 {
     usernamTextBox.Enabled = false;
     if (String.Equals(usernamTextBox.Text, usrname) == false)
     {
         datachange = true;
         if (ValidationCheck.CheckUserName(usernamTextBox.Text))
         {
             usernameExist.Visible = true;
             button1.Enabled       = false;
         }
         else
         {
             usernameExist.Visible = false;
             button1.Enabled       = true;
         }
     }
 }
コード例 #20
0
 private void emailTextBox_Leave(object sender, EventArgs e)
 {
     emailTextBox.Enabled = false;
     if (String.Equals(emailTextBox.Text, email) == false)
     {
         datachange = true;
         if (ValidationCheck.CheckEmail(emailTextBox.Text))
         {
             emailExist.Visible = true;
             button1.Enabled    = false;
         }
         else
         {
             emailExist.Visible = false;
             button1.Enabled    = true;
         }
     }
 }
コード例 #21
0
        public void Validate(System.Web.Mvc.ModelStateDictionary modelState)
        {
            ValidationCheck.CheckErrors(this, modelState);

            //check Email
            if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.DataProvider.DifferentRepository.ValidateOuterSubscriptionEmail(this.Email, ID))
            {
                modelState.AddModelError("Email", "This email already present in system");
            }

            if (!(this.Email == this.EmailConfirm))
            {
                modelState.AddModelError("Email", "Email and confirmation email should be match.");
            }

            if (!IsRecievingWeeklySpecials && !IsRecievingUpdates)
            {
                modelState.AddModelError("IsRecievingUpdates", "Select to recieve news and updates or/and weekly specials.");
            }
        }
コード例 #22
0
        // GET: FeedBackForms/Create
        public ActionResult Create()
        {
            var validationCheck = new ValidationCheck();
            var currentUserId   = User.Identity.GetUserId();

            if (currentUserId != null)
            {
                if (validationCheck.HasCustomerInfo(currentUserId))
                {
                    var feedBackCreateViewModel = new FeedBackCreateViewModel();
                    ViewBag.BatchID    = new SelectList(db.Batch, "BatchID", "TrackingNo");
                    ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName");
                    feedBackCreateViewModel.customers = (from a in db.Customers where a.Id == currentUserId select a).ToList()[0];
                    feedBackCreateViewModel.state     = (from z in db.state where feedBackCreateViewModel.customers.stateID == z.stateID select z.stateName).ToList()[0];

                    return(View(feedBackCreateViewModel));
                }
                return(RedirectToAction("Create", "Customers"));
            }
            return(RedirectToAction("Register", "Account"));
        }
コード例 #23
0
        public ActionResult LogOn(string login, string password, bool?rememberMe, string returnUrl)
        {
            if (ValidationCheck.IsEmpty(login))
            {
                ModelState.AddModelError("login", ErrorMessages.GetRequired("UserID"));
                return(View());
            }
            if (String.IsNullOrEmpty(password))
            {
                ModelState.AddModelError("password", ErrorMessages.GetRequired("Password"));
                return(View());
            }
            User user = UserRepository.ValidateUser(login, password);

            if (user == null)
            {
                ModelState.AddModelError("login", "Incorrect UserID or password.");
                ViewData["rememberMe"] = rememberMe.HasValue && rememberMe.Value;
                ViewData["wrongPass"]  = true;
                return(View());
            }

            UserRepository.TryToUpdateNormalAttempts(user);
            FormsService.SignIn(login, rememberMe.HasValue && rememberMe.Value, user);

            if (!user.IsModifyed)
            {
                Session.Remove("redirectUrl");
                Session.Add("redirectUrl", returnUrl);
                return(RedirectToAction("Profile", "Account"));
            }

            //if (!String.IsNullOrEmpty(returnUrl)) return Redirect(returnUrl);
            if (HttpContext.Request.IsUrlLocalToHost(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #24
0
ファイル: Util.cs プロジェクト: gahenderson85/TARG2
            public static void ReadHostInfo(TargInfo t)
            {
                string filePath = string.Format(
                    @"\\{0}\c$\windows\system32\targinfo.txt", t.host.connection.HostIP);

                //Read targinfo.txt from host
                //Contains: Current User, Host Name, Time
                if (ValidationCheck.FileExists(filePath))
                {
                    StreamReader reader = new StreamReader(filePath);
                    t.host.user.CurrentUser     = reader.ReadLine();
                    t.host.connection.HostName  = reader.ReadLine();
                    t.host.removalTask.HostTime = reader.ReadLine();

                    //Match local time with host time
                    //Used later to calculate time difference
                    //between connection and granting rights.
                    //see Tools.FormatDateTime()
                    t.local.LocalTime = DateTime.Now;
                    reader.Close();
                }
            }
コード例 #25
0
        private bool Validering()
        {
            ValidationCheck.checkValidering(tbSum, "InnehållerBokstav", "summa");
            ValidationCheck.checkValidering(tbSum, "tom", "summa");
            ValidationCheck.checkValidering(tbSum, "NegativaTal", "summa");

            ValidationCheck.checkValidering(tbMotivation, "tom", "motivering");
            ValidationCheck.checkValidering(tbMotivation, "längre255", "motivering");

            ValidationCheck.CheckCombox(cbBoss, "chef");
            ValidationCheck.CheckCombox(cbChooseUppdrag, "uppdrag");

            var felmeddelanden = ValidationCheck.felString;

            if (felmeddelanden.Length <= 0)
            {
                return(true);
            }

            MessageBox.Show(string.Format(@"Följande fel har uppstått: {0}", felmeddelanden));
            ValidationCheck.felString = "";
            return(false);
        }
コード例 #26
0
        public ValidationCheck Validate()
        {
            var vc = new ValidationCheck()
                     .Assert(ValidationCheck.BasicStringCheck(this.lobbyId, "lobbyID"))
                     .Assert(host == null, "no host")
                     .Assert(host.Validate)
                     .Assert(metaData == null ? true : metaData.Count < maxMetaDataCount, "too many items in metadata (" + metaData.Count + "/" + maxMetaDataCount + ")")
                     .Assert(creationTime < DateTime.UtcNow.AddDays(1), "creation time is in the future");

            if (metaData != null)
            {
                foreach (var kv in metaData)
                {
                    if (!vc.result)
                    {
                        break;
                    }
                    vc.Assert(ValidationCheck.BasicStringCheck(kv.Key, "metaData key"));
                    vc.Assert(ValidationCheck.BasicStringCheck(kv.Value, "metaData value"));
                }
            }

            return(vc);
        }
コード例 #27
0
        private void InsertNew(object sender, RoutedEventArgs e)
        {
            bool valid = true;

            resetBorders();
            if (ValidationCheck.getInstance().IsValidEmail(txtEmail.Text, allClients) == false)
            {
                txtEmail.BorderBrush = red;
                valid = false;
            }
            if (ValidationCheck.getInstance().IsPopulatedString(txtName.Text) == false)
            {
                txtName.BorderBrush = red;
                valid = false;
            }
            if (ValidationCheck.getInstance().IsPopulatedString(txtSurname.Text) == false)
            {
                txtSurname.BorderBrush = red;
                valid = false;
            }
            if (ValidationCheck.getInstance().IsValidID(txtID.Text, allClients) == false)
            {
                txtID.BorderBrush = red;
                valid             = false;
            }
            if (ValidationCheck.getInstance().IsValidCell(txtCell.Text) == false)
            {
                txtCell.BorderBrush = red;
                valid = false;
            }
            if (ValidationCheck.getInstance().IsPopulatedString(txtCountry.Text) == false)
            {
                txtCountry.BorderBrush = red;
                valid = false;
            }
            if (ValidationCheck.getInstance().IsPopulatedString(txtCity.Text) == false)
            {
                txtCity.BorderBrush = red;
                valid = false;
            }
            if ((ValidationCheck.getInstance().IsStringInt(txtPostalCode.Text) == false) || (txtPostalCode.Text.Length != 4))
            {
                txtPostalCode.BorderBrush = red;
                valid = false;
            }
            if (ValidationCheck.getInstance().IsPopulatedString(txtLine1.Text) == false)
            {
                txtLine1.BorderBrush = red;
                valid = false;
            }

            if (valid == true)
            {
                Guid           a                 = Guid.NewGuid();
                Guid           cd                = Guid.NewGuid();
                Guid           c                 = Guid.NewGuid();
                Guid           p                 = Guid.NewGuid();
                Address        newAddress        = new Address(txtCountry.Text, txtCity.Text, txtPostalCode.Text, txtLine1.Text, txtLine2.Text, a);
                ContactDetails newContactDetails = new ContactDetails(txtEmail.Text, txtCell.Text, txtTell.Text, cd);
                Client         newClient         = new Client(txtName.Text, txtSurname.Text, txtID.Text, newAddress, newContactDetails, p, identifierGenerator(), c);

                insertNewClient(newClient);

                allClients.Add(newClient);
                lstClients.Items.Refresh();
                resetBorders();
            }
        }
コード例 #28
0
 //ValidateWithConfim (Email, Password)
 public void Validate(System.Web.Mvc.ModelStateDictionary modelState)
 {
     ValidationCheck.CheckErrors(this, modelState, true);
 }
コード例 #29
0
        public void Validate(System.Web.Mvc.ModelStateDictionary modelState)
        {
            ValidationCheck.CheckErrors(this, modelState);

            //check Login
            if (!ValidationCheck.IsEmpty(this.Login) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateLogin(this.Login, ID))
            {
                modelState.AddModelError("Login", "This login already present in system");
            }

            //check Email
            if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateEmail(this.Email, ID))
            {
                modelState.AddModelError("Email", "This email already present in system");
            }

            if (!String.Equals(this.Email, this.ConfirmEmail, StringComparison.Ordinal))
            {
                modelState.AddModelError("Email", "The Email and confirmation Email do not match.");
                modelState.AddModelError("ConfirmEmail", "");
            }

            if (!String.Equals(this.Password, this.ConfirmPassword, StringComparison.Ordinal))
            {
                modelState.AddModelError("Password", "The password and confirmation password do not match.");
                modelState.AddModelError("ConfirmPassword", "");
            }

            if (!ProjectConfig.Config.DataProvider.GetInstance().UserRepository.CheckChangePassword(this.ID, this.Password))
            {
                modelState.AddModelError("Password", "Need to change and confirmation the password.");
                modelState.AddModelError("ConfirmPassword", "");
            }

            if (!Agree)
            {
                modelState.AddModelError("Agree", "YOU MUST CHECK THE BOX BELOW");
            }

            StringBuilder sb = new StringBuilder(BillingPhone);

            sb.Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "").Replace(" ", "").Replace("x", "");
            BillingPhone = sb.ToString();

            sb = new StringBuilder(BillingWorkPhone);
            sb.Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "").Replace(" ", "").Replace("x", "");
            BillingWorkPhone = sb.ToString();

            sb = new StringBuilder(ShippingPhone);
            sb.Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "").Replace(" ", "").Replace("x", "");
            ShippingPhone = sb.ToString();

            sb = new StringBuilder(ShippingWorkPhone);
            sb.Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "").Replace(" ", "").Replace("x", "");
            ShippingWorkPhone = sb.ToString();

            if (String.IsNullOrWhiteSpace(BillingPhone))
            {
                modelState.AddModelError("BillingPhone", "The Phone number is required");
            }

            if (String.IsNullOrWhiteSpace(ShippingPhone) && !BillingLikeShipping)
            {
                modelState.AddModelError("ShippingPhone", "The Phone number is required");
            }

            //if ((modelState.ContainsKey("BillingPhone1") && modelState["BillingPhone1"].Errors.Count > 0) || (modelState.ContainsKey("BillingPhone2") && modelState["BillingPhone2"].Errors.Count > 0))
            //  modelState.AddModelError("BillingPhone", "Phone should contain digits only");
            //if ((modelState.ContainsKey("BillingWorkPhone1") && modelState["BillingWorkPhone1"].Errors.Count > 0) || (modelState.ContainsKey("BillingWorkPhone2") && modelState["BillingWorkPhone2"].Errors.Count > 0))
            //  modelState.AddModelError("BillingWorkPhone", "Work Phone should contain digits only");

            //if ((modelState.ContainsKey("ShippingPhone1") && modelState["ShippingPhone1"].Errors.Count > 0))
            //  modelState.AddModelError("ShippingPhone", "Phone should contain digits only");
            //if ((modelState.ContainsKey("ShippingWorkPhone1") && modelState["ShippingWorkPhone1"].Errors.Count > 0) || (modelState.ContainsKey("ShippingWorkPhone2") && modelState["ShippingWorkPhone2"].Errors.Count > 0))
            //  modelState.AddModelError("ShippingWorkPhone", "Work Phone should contain digits only");
        }
コード例 #30
0
ファイル: Quantity.cs プロジェクト: EhsanGhanbari/Seldino
 public Quantity(int value)
 {
     ValidationCheck.IsGreaterThan(-1, value, () => { throw new ArgumentOutOfRangeException(); });
     Value = value;
 }