Пример #1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (dtpCaducidad.Value == null) throw new Exception("Escoja una fecha");
         ILaboratorios bdd = new BusinessLogic();
         IUsuarios userBdd = new BusinessLogic();
         LABORATORIO laboratorioConsultado=bdd.ObtenerLaboratorioPorNombre(ddlLaboratorio.Text);
         USUARIO userToSave = new USUARIO
         {
             IDUSUARIO = Guid.NewGuid(),
             IDLABORATORIO = laboratorioConsultado != null ? laboratorioConsultado.IDLABORATORIO : Guid.Empty,
             NOMBRECOMPLETO = txtNombre.Text,
             USUARIO1 = txtUsuario.Text,
             FechaCreacion=DateTime.Now.Date,
             FechaCaducidad=(DateTime)dtpCaducidad.Value,
             CLAVE=txtClaveRepeat.Text.EncriptarMD5()
         };
         userBdd.CrearUsuario(userToSave);
         lblErrores.Visible = true;
         Response.Redirect("~/ui/MantenimientoUsuarios.aspx");
     }
     catch (Exception ex)
     {
         lblErrores.Visible = true;
         lblErrores.Text = ex.Message;
     }
 }