当前位置: 首页>>代码示例>>C#>>正文


C# Validation.ValidateEmail方法代码示例

本文整理汇总了C#中Validation.ValidateEmail方法的典型用法代码示例。如果您正苦于以下问题:C# Validation.ValidateEmail方法的具体用法?C# Validation.ValidateEmail怎么用?C# Validation.ValidateEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validation的用法示例。


在下文中一共展示了Validation.ValidateEmail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: button_Save_Click

        private void button_Save_Click(object sender, RoutedEventArgs e)
        {
            Validation validation = new Validation();
             //validation for emails
            if (validation.ValidateTextField(txtEmail.Text) ? validation.ValidateEmail(txtEmail.Text) : true)
            {

                exporter.Name = txtName.Text;
                exporter.RegNo = txtRegNo.Text;
                exporter.TelNo = txtTelNo.Text;
                exporter.ShortTag = txtShortTag.Text;
                exporter.Email = txtEmail.Text;
                exporter.Description = txtDescription.Text;
                exporter.Address = txtAddress.Text;
                //adding to data model
                model.AddToExporters(exporter);
                //applying changes to the database
                model.SaveChanges();
                ContentPresenter con = (ContentPresenter)this.VisualParent;
                con.Content = new AddDirector(exporter);
            }
            else
            {
                MessageBox.Show("Invalid Email");
            }
        }
开发者ID:dinet,项目名称:PMS,代码行数:26,代码来源:AddExporter.xaml.cs

示例2: Edit

        public ActionResult Edit(string email, string name, string oldPassword = "", string newPassword = "", bool Deactivated = false)
        {
            var response = new AjaxResponse();
            var currentUser = Main.Session.GetCurrentUser();
            var newMd5Password = Md5.CalculateMd5(newPassword);
            var validation = new Validation();
            var player = DbHelper.GetPlayerByEmail(email);

            if (currentUser == null)
            {
                response.Message = "You have to be logged in to change user information";
                return Json(response);
            }

            if (!validation.ValidateEmail(email))
            {
                response.Message = "You must provide a valid email";
                return Json(response);
            }

            currentUser.Email = string.IsNullOrEmpty(email) ? currentUser.Email : email;
            currentUser.Name = string.IsNullOrEmpty(name) ? currentUser.Name : name;
            player.Email = currentUser.Email;
            player.Name = currentUser.Name;

            if (!string.IsNullOrEmpty(newPassword))
            {
                if (Md5.CalculateMd5(oldPassword) == currentUser.Password)
                {
                    currentUser.Password = newMd5Password;
                }
                else
                {
                    response.Message = "The old password is not correct";
                    return Json(response);
                }
            }

            DbHelper.SaveUser(currentUser);
            DbHelper.SavePlayer(player);
            response.Message = "User updated succesfully";

            return Json(response);
        }
开发者ID:j4kobbech,项目名称:FoosBall,代码行数:44,代码来源:AccountController.cs

示例3: btnCAdd_Click_1

        private void btnCAdd_Click_1(object sender, RoutedEventArgs e)
        {
            CompanyBuyer cb = new CompanyBuyer();
            cb.Country = (Country)comBoxCCountry.SelectedItem;

            cb.City = txtCCity.Text;
            cb.Address = txtCAddress.Text;
            cb.ZipCode = txtCZipCode.Text;
            cb.Name = txtCName.Text;
            cb.Fax = txtCFax.Text;
            cb.Email = txtCEmail.Text;
            cb.TelephoneNo = txtCTelephoneNo.Text;
            cb.ShortName = txtCShortTag.Text;
            model.AddToBuyers(cb);
            Validation v = new Validation();

            if (v.ValidateTextField(txtCName.Text))
            {

                if (v.ValidateEmail(txtCEmail.Text))
                {
                    model.AddToBuyers(cb);
                    model.SaveChanges();
                    MessageBox.Show("Successfully added to database", "Added the company");

                }

                else
                    MessageBox.Show("Email is in Invalide formate", "Error");

            }
            else
            {
                MessageBox.Show("Need to enter details in required fields", "Error");

            }
        }
开发者ID:dinet,项目名称:PMS,代码行数:37,代码来源:AddBuyers.xaml.cs

示例4: btnSave_Click

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Validation validation = new Validation();
               //validating emails
            if (validation.ValidateTextField(txtEmail.Text) ? validation.ValidateEmail(txtEmail.Text) : true)
            {
                //validating nic
                if(validation.ValidateTextField(txtNIC.Text) ? validation.ValidateNIC(txtNIC.Text) :true)
                {
                    //checking whether nicor passport field fill
                    if (validation.ValidateTextField(txtNIC.Text) || validation.ValidateTextField(txtPassportId.Text))
                    {
                        //addig data to the model
                        Director director = new Director();
                        director.FirstName = txtFirstName.Text;
                        director.LastName = txtLastName.Text;
                        director.NIC = txtNIC.Text;
                        director.PassportNo = txtPassportId.Text;
                        director.JoinedDate = dtPickerJoinedDate.SelectedDate.Value;
                        director.DateOfBirth = dtPickerBirthDay.SelectedDate.Value;
                        director.Gender = txtGender.SelectedValue.ToString();
                        director.TelNo = txtTelNo.Text;
                        director.Type = txtType.SelectedValue.ToString();
                        director.Email = txtEmail.Text;
                        director.Address = txtAddress.Text;
                        model.AddToDirectors(director);
                        //saving changes to the database
                        model.SaveChanges();
                        Exporter expo = model.Exporters.Where(exp => exp.Id == _exporter.Id).First();
                        director.Exporters.Add(expo);
                        model.SaveChanges();

                        //clearing fields
                        txtFirstName.Clear();
                        txtLastName.Clear();
                        txtNIC.Clear();
                        txtPassportId.Clear();
                        dtPickerBirthDay.ClearValue(DatePicker.SelectedDateProperty);
                        dtPickerJoinedDate.ClearValue(DatePicker.SelectedDateProperty);
                        txtGender.ClearValue(ComboBox.SelectedItemProperty);
                        txtTelNo.Clear();
                        txtPassportId.Clear();
                        txtType.ClearValue(ComboBox.SelectedItemProperty);
                        txtAddress.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Either NIC or Passport number is required");

                    }
                }
                else
                {
                    MessageBox.Show("Invalid NIC");

                }

            }
            else
            {
                MessageBox.Show("Email address is invalid");
            }
        }
开发者ID:dinet,项目名称:PMS,代码行数:63,代码来源:AddDirector.xaml.cs


注:本文中的Validation.ValidateEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。