protected void btnRegistrar_Click(object sender, EventArgs e) { if (validarCampos()) { string valor = Convert.ToString(Request.QueryString["doc"]); string modulo = valor.Split('.')[0]; string unidad = valor.Split('.')[1]; valor = valor.Replace(".", string.Empty); using (RegistroUnicoDataContext db = new RegistroUnicoDataContext(conexion)) { SharePointComportamientoEmprendedor comportamientoEmprendedor = new SharePointComportamientoEmprendedor() { Nombres = txtNombres.Text, Apellidos = txtApellidos.Text, TipoIdentificacion = cmbTipoIdentificacion.SelectedItem.Text, Identificacion = txtIdentificacion.Text, Telefono = Convert.ToInt64(txtTelefono.Text), Email = txtCorreo.Text, codCiudad = Convert.ToInt32(CodCiudadExpedicion.Text), Modulo = modulo, Unidad = unidad, RutaArchivoDescargado = rutaArchivo(valor), emailEnviado = false, archivoDescargado = false, ParticiparCharlasHablemosDe = cmbParticiparCharlas.Value, fechaIngreso = DateTime.Now, ServicioOrientacion = chkOrientacion.Checked, ServicioAsesoriaCreacionEmpresa = chkAsesoriaCreacionEmpresa.Checked, ServicioAsesoriaFormulacionPlan = chkAsesoriaFormulacionPlan.Checked, ServicioFortalecimientoEmpresarial = chkFortalecimientoEmpresarial.Checked }; db.SharePointComportamientoEmprendedor.InsertOnSubmit(comportamientoEmprendedor); db.SubmitChanges(); //Descargar Archivo comportamientoEmprendedor.archivoDescargado = descargarArchivo(comportamientoEmprendedor.RutaArchivoDescargado); //Enviar correo y confirmar envio comportamientoEmprendedor.emailEnviado = enviarCorreo(comportamientoEmprendedor); db.SubmitChanges(); } } else { ClientScript.RegisterStartupScript(this.GetType(), "myScript", "<script>javascript: alert('Por favor diligencie el formulario correctamente.');</script>"); } }
private string rutaArchivo(string parametro) { string ruta = ""; using (RegistroUnicoDataContext db = new RegistroUnicoDataContext(conexion)) { ruta = (from r in db.SharePointArchivosComportEmprendedor where r.RutaArchivo.Contains(parametro) select r.RutaArchivo ).FirstOrDefault(); } return(ruta); }