public int insertarUsuario(User user) { var transaction = SessionData.Contains("Transaction") ? SessionData.Get <SqlTransaction>("Transaction") : null; var service = new LoginService(); var encryptedPass = service.ComputeHash("w23e", new SHA256Managed()); int result = 0; if (transaction != null)//Si usa la transaccion { result = SqlDataAccess.ExecuteScalarQuery <int>( "[SHARPS].InsertUser", SqlDataAccessArgs .CreateWith("@UserName", user.UserName) .And("@Password", encryptedPass) .Arguments, transaction); return(result); } else//Sin transaccion { result = SqlDataAccess.ExecuteScalarQuery <int>(ConfigurationManager.ConnectionStrings["StringConexion"].ToString(), "[SHARPS].InsertUser", SqlDataAccessArgs .CreateWith("@UserName", user.UserName) .And("@Password", encryptedPass) .Arguments); return(result); } }
public BindingList <Profesional> GetAll() { if (SessionData.Contains("Profesionales")) { return(SessionData.Get <BindingList <Profesional> >("Profesionales")); } var result = SqlDataAccess.ExecuteDataTableQuery(ConfigurationManager.ConnectionStrings["StringConexion"].ToString(), "[SHARPS].GetProfesionales"); //Todos los profesionales activos var profesionales = new BindingList <Profesional>(); EspecialidadesManager espMan = new EspecialidadesManager(); if (result != null && result.Rows != null) { foreach (DataRow row in result.Rows) { Profesional profesional = new Profesional(); profesional.UserID = int.Parse(row["ID"].ToString()); profesional.UserName = row["UserName"].ToString(); profesional.FaltanDatos = bool.Parse(row["FaltanDatos"].ToString()); if (!DBNull.Value.Equals(row["Matricula"])) { profesional.Matricula = row["Matricula"].ToString(); } profesional.DetallesPersona = new DetallesPersona(); profesional.DetallesPersona.Apellido = row["Apellido"].ToString(); profesional.DetallesPersona.Nombre = row["Nombre"].ToString(); profesional.DetallesPersona.FechaNacimiento = Convert.ToDateTime(row["FechaNacimiento"]); profesional.DetallesPersona.DNI = long.Parse(row["DNI"].ToString()); profesional.DetallesPersona.Email = row["Email"].ToString(); profesional.DetallesPersona.Direccion = row["Direccion"].ToString(); profesional.DetallesPersona.Telefono = long.Parse(row["Telefono"].ToString()); if (!DBNull.Value.Equals(row["Sexo"])) { profesional.DetallesPersona.Sexo = (TipoSexo)Enum.Parse(typeof(TipoSexo), row["Sexo"].ToString()); } if (!DBNull.Value.Equals(row["TipoDoc"])) { profesional.DetallesPersona.TipoDNI = (TipoDoc)Enum.Parse(typeof(TipoDoc), row["TipoDoc"].ToString()); } profesional.Especialidades = espMan.GetAllForUser(profesional.UserID); profesionales.Add(profesional); } } SessionData.Set("Profesionales", profesionales); return(profesionales); }
public int AddDetallePersona(User user) { var transaction = SessionData.Contains("Transaction") ? SessionData.Get <SqlTransaction>("Transaction") : null; if (transaction != null) { return(SqlDataAccess.ExecuteScalarQuery <int>( "[SHARPS].InsertDetallePersona", SqlDataAccessArgs .CreateWith( "@Telefono", user.DetallesPersona.Telefono) .And("@Email", user.DetallesPersona.Email) .And("@Nombre", user.DetallesPersona.Nombre) .And("@Apellido", user.DetallesPersona.Apellido) .And("@DNI", user.DetallesPersona.DNI) .And("@TipoDNI", user.DetallesPersona.TipoDNI) .And("@Sexo", user.DetallesPersona.Sexo) .And("@FechaNacimiento", user.DetallesPersona.FechaNacimiento) .And("@Direccion", user.DetallesPersona.Direccion) .And("@ID_Usuario", user.UserID) .Arguments, transaction)); //Con transaccion (de C#) } return(SqlDataAccess.ExecuteScalarQuery <int>(ConfigurationManager.ConnectionStrings["StringConexion"].ToString(), "[SHARPS].InsertDetallePersona", SqlDataAccessArgs .CreateWith( "@Telefono", user.DetallesPersona.Telefono) .And("@Email", user.DetallesPersona.Email) .And("@Nombre", user.DetallesPersona.Nombre) .And("@Apellido", user.DetallesPersona.Apellido) .And("@DNI", user.DetallesPersona.DNI) .And("@TipoDNI", user.DetallesPersona.TipoDNI) .And("@Sexo", user.DetallesPersona.Sexo) .And("@FechaNacimiento", user.DetallesPersona.FechaNacimiento) .And("@Direccion", user.DetallesPersona.Direccion) .And("@ID_Usuario", user.UserID) .Arguments)); //Sin transaccion (de C#) }
public List <Especialidad> GetAll() { if (SessionData.Contains("Especialidades")) { return(SessionData.Get <List <Especialidad> >("Especialidades")); } var ret = new List <Especialidad>(); var result = SqlDataAccess.ExecuteDataTableQuery(ConfigurationManager.ConnectionStrings["StringConexion"].ToString(), "[SHARPS].GetAllEspecialidades"); if (result != null) { foreach (DataRow row in result.Rows) { ret.Add(new Especialidad() { ID = int.Parse(row["ID"].ToString()), Nombre = row["Descripcion"].ToString() }); } } SessionData.Set("Especialidades", ret); return(ret); }