protected void edsUsuario_Inserted(object sender, EntityDataSourceChangedEventArgs e) { SISMed.Models.Usuario u = e.Entity as SISMed.Models.Usuario; if (u.TipoDeUsuarioId > 1) { sdsMedico.InsertParameters.Add(new Parameter("Usuario_Id", TypeCode.String, u.Id.ToString())); sdsMedico.Insert(); } Response.Redirect(string.Format("./Show.aspx?id={0}&success=VXN1w6FyaW8gY2FkYXN0cmFkbyBjb20gc3VjZXNzby4=", u.Id)); }
protected void edsUsuario_Updating(object sender, EntityDataSourceChangingEventArgs e) { SISMed.Models.Usuario u = e.Entity as SISMed.Models.Usuario; using (var context = new SISMedEntities(e.Context.Connection as EntityConnection)) { var antigo = context.Pessoas.OfType <SISMed.Models.Usuario>().First(c => c.Id == u.Id); TextBox txbSenha = fvUsuario.FindControl("SenhaTextBox") as TextBox; if (string.IsNullOrWhiteSpace(txbSenha.Text)) { u.Senha = antigo.Senha; } else { u.Senha = Password.HashPassword(u.Senha); } } }
protected void edsMudarSenha_Updating(object sender, EntityDataSourceChangingEventArgs e) { SISMed.Models.Usuario novo = e.Entity as SISMed.Models.Usuario; using (var context = new SISMedEntities(e.Context.Connection as EntityConnection)) { var antigo = context.Pessoas.OfType <SISMed.Models.Usuario>().First(c => c.Id == novo.Id); TextBox txbSenhaAtual = fvMudarSenha.FindControl("txbSenhaAtual") as TextBox; if (antigo.Senha == Password.HashPassword(txbSenhaAtual.Text)) { novo.Senha = Password.HashPassword(novo.Senha); Response.Redirect("./Default.aspx?successPassword=U2VuaGEgYWx0ZXJhZGEgY29tIHN1Y2Vzc28u"); } else { Response.Redirect("./Default.aspx?errorPassword=QSBzZW5oYSBhdHVhbCBlc3TDoSBpbmNvcnJldGEu"); e.Cancel = true; } } }
protected void edsUsuario_Updated(object sender, EntityDataSourceChangedEventArgs e) { SISMed.Models.Usuario u = e.Entity as SISMed.Models.Usuario; Response.Redirect(string.Format("./Show.aspx?id={0}&success=VXN1w6FyaW8gYXR1YWxpemFkbyBjb20gc3VjZXNzby4=", u.Id)); }
protected void edsUsuario_Inserting(object sender, EntityDataSourceChangingEventArgs e) { SISMed.Models.Usuario u = e.Entity as SISMed.Models.Usuario; u.Senha = Password.HashPassword(u.Senha); }