Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var name     = txtUserName.Text;
            var email    = txtEmail.Text;
            var phone    = txtPhone.Text;
            var birthDay = dtBirthday.Value;
            var provence = txtProvince.Text;
            var city     = txtCity.Text;
            var county   = txtCounty.Text;
            var street   = txtStreet.Text;

            var userViewModel = new UserViewModel()
            {
                BirthDate = birthDay,
                City      = city,
                Street    = street,
                County    = county,
                Email     = email,
                Name      = name,
                Phone     = phone,
                Province  = provence
            };
            RegisterUserCommand registerStudentCommand = new RegisterUserCommand(userViewModel.Name, userViewModel.Email, userViewModel.BirthDate, userViewModel.Phone, userViewModel.Province, userViewModel.City, userViewModel.County, userViewModel.Street);

            if (!registerStudentCommand.IsValid())
            {
                FrmAlert.Alert(this, registerStudentCommand.ValidationResult, sss);
            }
            UserService userService = new UserService();

            userService.Add(userViewModel);
            #region MyRegion
            ////添加命令验证

            ////如果命令无效,证明有错误
            //if (!registerStudentCommand.IsValid())
            //{
            //    List<string> errorInfo = new List<string>();

            //    //FrmAlert.Alert(this, registerStudentCommand.ValidationResult,(a)=> { this.ActiveControl = (UCTextBox)a; });
            //    //获取到错误,请思考这个Result从哪里来的
            //    foreach (var error in registerStudentCommand.ValidationResult.Errors)
            //    {
            //        //errorInfo.Add(error.ErrorMessage);
            //        //FrmAlert.Alert(this, error.ErrorMessage);
            //    }
            //    //对错误进行记录,还需要抛给前台
            //    var dsd = errorInfo;
            //}
            #endregion
        }
Exemplo n.º 2
0
 public void Open()
 {//Abro la conexión
     try
     {
         Conn.Open();
     }
     catch (Exception ex)
     {
         FrmAlert FrmAlerta = new FrmAlert("No se pudo conectar con la base de datos");
         Form.ActiveForm.Close();
         FrmAlerta.Show();
         Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 3
0
        public void Alert(string msg, FrmAlert.alertTypeEnum type)
        {
            FrmAlert f = new FrmAlert();

            f.setAlert(msg, type);
        }
Exemplo n.º 4
0
        public void Alert(string msg, FrmAlert.enmType type)
        {
            FrmAlert frm = new FrmAlert();

            frm.ShowAlert(msg, type);
        }