private void ExecuteUpdateItemCommand() { // 新規登録 if (Person.Id == 0) { Model.Person person = reverseMapper.Map <PersonViewModel, Model.Person>(Person); int res = personRepository.AddItem(person); if (res != 0) { Person.Id = res; People.Add(Person); SelectedIndex = -1; } } // 修正 else { Model.Person person = reverseMapper.Map <PersonViewModel, Model.Person>(Person); int res = personRepository.UpdateItem(person); if (res != 0) { var per = People.Where(x => x.Id == person.Id).FirstOrDefault(); if (per != null) { per = mapper.Map <Model.Person, PersonViewModel>(person); } } } }
public void AddPersonToCollection(Model.Person person) { var address = person.Address; if (address.Id == 0) { using (var connection = SqlConnectionFactory.CreateConnection()) { var sql = $"INSERT INTO ADDRESS(STREET, HOUSENUMBER, ZIP, CITY) VALUES('{address.Street}', '{address.HouseNumber}', '{address.Zip}', '{address.City}'); SELECT SCOPE_IDENTITY();"; var insertCommand = new SqlCommand(sql, connection); connection.Open(); address.Id = Convert.ToInt32(insertCommand.ExecuteScalar()); } } if (person.Id == 0) { using var connection = SqlConnectionFactory.CreateConnection(); var sql = $"INSERT INTO PERSON(FIRSTNAME, LASTNAME, ID_ADDRESS) VALUES ('{person.FirstName}', '{person.LastName}', '{address.Id}'); SELECT SCOPE_IDENTITY();"; var insertCommand = new SqlCommand(sql, connection); connection.Open(); person.Id = Convert.ToInt32(insertCommand.ExecuteScalar()); } }
public async Task <IActionResult> SignupPerson([FromBody] PersonRegisterDTO user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } User user_to_register = new Model.User(); Mapper.Map(user, user_to_register); Person person_to_register = new Model.Person(); Mapper.Map(user, person_to_register); //add user _context.Users.Add(user_to_register); await _context.SaveChangesAsync(); person_to_register.Id = user_to_register.Id; _context.Persons.Add(person_to_register); //update context await _context.SaveChangesAsync(); return(Ok()); }
private void UpdateButtons(Model.Person person) { foreach (var button in ApplicationBar.Buttons.OfType <ApplicationBarIconButton>().ToList()) { if (button.Text == "unpin" || button.Text == "pin") { ApplicationBar.Buttons.Remove(button); } } var existingTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(person.Id)); if (existingTile == null) { var applicationBarIconButton = new ApplicationBarIconButton(new Uri("/Toolkit.Content/ApplicationBar.Pin.png", UriKind.Relative)); applicationBarIconButton.Text = "pin"; applicationBarIconButton.Click += PinClick; ApplicationBar.Buttons.Add(applicationBarIconButton); } else { var applicationBarIconButton = new ApplicationBarIconButton(new Uri("/Toolkit.Content/ApplicationBar.UnPin.png", UriKind.Relative)); applicationBarIconButton.Text = "unpin"; applicationBarIconButton.Click += UnPinClick; ApplicationBar.Buttons.Add(applicationBarIconButton); } }
public Person UpdatePerson(int personId, string firstName, string lastName, DateTime birthday, string email, string phone, DateTime?lastModified) { using (var context = ContextFactory.CreateContext()) { var repository = RepositoryFactory.CreatePersonRepository(context); var updatedPerson = new Model.Person { PersonId = personId, FirstName = firstName, LastName = lastName, Birthday = birthday, Email = email, Phone = phone, LastModified = lastModified }; repository.Update(updatedPerson); try { context.SaveChanges(); return(updatedPerson); } catch (OptimisticConcurrencyException ex) { throw new DataException("Concurrency", ex); } } }
public void UseFSharpFromCSharp() { var person1 = new Model.Person(name: "Sean", birthday: DateTime.Today.AddDays(-1)); var person2 = new Model.Person(name: "Sean", birthday: DateTime.Today.AddDays(-1)); Assert.IsTrue(person1.Equals(person2), "Structural quality is free."); }
private static void DeleteStudent() { string error; Console.WriteLine(); Console.WriteLine("删除学生"); Console.WriteLine("请输入要删除的学生ID:"); string id = Console.ReadLine(); Model.Person student = BLL.AdminBLL.RetrieveStudent(id, out error); if (student != null) { Console.WriteLine("学生ID{0},学生姓名{1}", id, student.Name); Console.Write("确定要删除该学生吗?(Y/N):"); char c = char.Parse(Console.ReadLine()); if (c == 'y' || c == 'Y') { BLL.AdminBLL.DeleteStudent(id, out error); Console.WriteLine(error); } else if (c == 'n' || c == 'N') { Console.WriteLine("操作被取消"); } else { Console.WriteLine("无效操作"); } } else { Console.WriteLine("错误" + error); } }
public Task <DTO.Person> Get(GetPeopleById req) { var name = new Model.Name("Jason", "Malley", "Scott", null, null); var person = new Model.Person(name, new DateTime(1982, 11, 10), Gender.Male); return(Task.FromResult(ToPersonDTO(person))); }
public static bool AddTermCourse(string courseID, string teacherID, out string error) { error = ""; Model.Course course = courses.RetrieveCourse(courseID); if (course == null) { error = "不存在课程ID为" + courseID + "的课程"; return(false); } else { Model.Person teacher = teachers.Retrieve(teacherID); if (teacher == null) { error = "不存在教师ID为" + teacherID + "的教师"; return(false); } else { if (termCourses.RetrieveTermCourse(courseID + teacherID) == null) { termCourses.AddNewTermCourse(new Model.TermCourse(courseID, teacherID)); error = "添加学期课程记录成功"; return(true); } else { error = "添加学期课程记录失败"; return(false); } } } }
public void DeletePerson(Model.Person person) { lock (locker) { //Löschen einer Person in der Datenbank database.Delete(person); } }
public void RoundTripJson() { var person = new Model.Person(name: "Sean", birthday: DateTime.Today.AddDays(-1)); var json = Model.personToJson(person); var deserialisedPerson = JsonConvert.DeserializeObject <Model.Person>(json); Assert.AreEqual("Sean", person.Name); }
public void InsertPerson(Model.Person person) { using (var context = SCMSEntities.Define()) { context.People.Add(person); context.SaveChanges(); } }
public void AddPerson(Model.Person person) { lock (locker) { //Hinzufügen einer Person zur Datenbank database.Insert(person); } }
// List of Festivities. (Festivity) // BAC_Controller() { //NM: Person and Beverage require arguments for their constructors. //NM: Person will be constructed from saved info of the user. If info does not exsist, construct froma default value. Male 150lbs? Person = new Model.Person("Male", 150); //NM: Will more than likely not need to construct a beverage when constructing the controller //Beverage = new Model.Beverage(); }
public async Task CreatePerson(Model.Person person) { if (await personQuery.UserNameExists(person.Username)) { throw new Exception("Username is taken"); } await personCommand.Create(person); }
public ActionResult Registp(FormCollection forms) { string username = forms["username"]; string email = forms["email"]; string pwd = forms["pwd"]; string pwdConfirm = forms["pwdConfirm"]; if (string.IsNullOrWhiteSpace(username) || !Regex.IsMatch(username, @"^([\u4e00-\u9fa5]|[a-zA-Z])([\u4e00-\u9fa5]|[0-9a-zA-Z]){5,17}$")) { //用户名非法 return(GetJson(0, new { flag = 1 })); } if (string.IsNullOrWhiteSpace(email) || !Regex.IsMatch(email, @"^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$")) { //邮箱非法 return(GetJson(0, new { flag = 2 })); } if (string.IsNullOrWhiteSpace(pwd) || !Regex.IsMatch(pwd, @"^[\s|\S]{6,16}$")) { //密码设置非法 return(GetJson(0, new { flag = 3 })); } if (string.IsNullOrWhiteSpace(pwdConfirm) || pwdConfirm != pwd) { //密码不一致 return(GetJson(0, new { flag = 4 })); } Model.Person person = _PersonServices.QueryWhere(item => item.RealName == username).FirstOrDefault(); if (person != null) { //用户名已经被注册,请更换用户名 return(GetJson(2, new { flag = 1 })); } person = _PersonServices.QueryWhere(item => item.Email == email).FirstOrDefault(); if (person != null) { //邮箱已经被绑定,请更换邮箱 return(GetJson(2, new { flag = 2 })); } person = new Model.Person() { RealName = username, Email = email, Password = pwd.ToMd5(), RegTime = DateTime.Now }; _PersonServices.Add(person); if (_PersonServices.SaveChanges() > 0) //注册成功 { return(GetJson(1)); } else //注册失败 { return(GetJson(3)); } }
public void UpdatePerson(Model.Person person) { using (var context = SCMSEntities.Define()) { context.People.Attach(person); ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(person, System.Data.EntityState.Modified); context.SaveChanges(); } }
public void Update(Model.Person person) { using (var db = new LiteDatabase(@ConfigurationServer.Instance.dbConfig)) { var collection = db.GetCollection <Model.Person>("personas"); collection.Update(person); } }
public void edit_person(Model.Person card) { try { string con_str = Properties.Settings.Default.con_str; SqlConnection connection = new SqlConnection(con_str); connection.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = connection; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[dbo].[EditPerson]"; cmd.Parameters.Add(new SqlParameter("@department", card.Department) { Direction = ParameterDirection.Input }); cmd.Parameters.Add(new SqlParameter("@domen_name", card.Domen_name) { Direction = ParameterDirection.Input }); cmd.Parameters.Add(new SqlParameter("@fname", card.Fname) { Direction = ParameterDirection.Input }); //cmd.Parameters.Add(new SqlParameter("@unit", card.Department) { Direction = ParameterDirection.Input }); cmd.Parameters.Add(new SqlParameter("@mail", card.Mail.Split('@')[0]) { Direction = ParameterDirection.Input }); cmd.Parameters.Add(new SqlParameter("@mname", card.Mname) { Direction = ParameterDirection.Input }); cmd.Parameters.Add(new SqlParameter("@phone", card.Phone) { Direction = ParameterDirection.Input }); cmd.Parameters.Add(new SqlParameter("@role", card.Role) { Direction = ParameterDirection.Input }); cmd.Parameters.Add(new SqlParameter("@sname", card.Sname) { Direction = ParameterDirection.Input }); cmd.Parameters.Add(new SqlParameter("@id", card.Id) { Direction = ParameterDirection.Input }); //cmd.Parameters.Add(new SqlParameter("@status_code",100) { Direction=ParameterDirection.Input}; cmd.ExecuteNonQuery(); ((App)App.Current).all_data.stat_it(card.Id, ((App)App.Current).the_person.Id, "success edit_person"); connection.Close(); } catch (Exception e) { MessageBox.Show(e.ToString()); ((App)App.Current).all_data.stat_it(card.Id, ((App)App.Current).the_person.Id, "fail edit_person"); } }
public Person(Model.Person p) { this.Name = p.Name; this.Birthday = p.Birthday; this.Note = p.Note; if (p.Id.HasValue) { this.Id = p.Id.Value; } }
public PersonVm(Model.Person model) { _model = model; Name = model.Name; Age = model.Age; foreach (var professionModel in model.Professions) { Professions.Add(new ProfessionVm(professionModel)); } }
private void AddDefaultItem() { Model.Person per = new Model.Person { IsNewItem = true, Name = "" }; per.db = db; PeopleList.Add(per); db.People.Add(per); }
private async Task SaveUserInfo() { Model.Person user = new Model.Person { Name = UserName, NickName = UserNickName }; var userJson = JsonConvert.SerializeObject(user); var userhttp = new Model.HttpUsersAccess(); await userhttp.HttpPostAsync(userJson); Application.Current.Properties[App.isFirst] = false.ToString(); await Application.Current.SavePropertiesAsync(); }
/// <summary> /// Load an existing person /// </summary> /// <param name="personId"></param> public PersonInfo(int PersonId = 0) { InitializeComponent(); Model.Log.Write("Initialized PersonInfo screen for person #:PersonId.", new Dictionary<string,string>(){{":PersonId", PersonId.ToString()}}); CurrentPerson = new Model.Person(PersonId); TheGrid.DataContext = CurrentPerson; companyBox.ItemsSource = new Model.Company().FindAll(); companyBox.SelectedIndex = Helper.UI.CmbIndexByValue(companyBox, CurrentPerson.company_id); phoneBox.Text = CurrentPerson.Phone; mailBox.Text = CurrentPerson.Email; }
public async Task <List <Model.Hold> > GetAllHoldForPerson(Model.Person person) { var linjeListe = await holdLinjeQuery.GetHoldLinjeListFromPerson(person); var holdList = new List <Model.Hold>(); foreach (var linje in linjeListe) { holdList.Add(linje.Hold); } return(holdList); }
public static Model.Person ToEntity(this SystemUserModel model, Model.Person person) { person = person ?? new Model.Person { Id = Guid.NewGuid() }; person.OfficialEmail = model.Email; person.FirstName = model.FirstName; person.OtherNames = model.OtherNames; person.IDNo = model.IdNumber; person.OfficialPhone = model.OfficialPhone; return(person); }
private async Task GetAttachedEntities() { var type = await GetUserType(); if (type == PersonType.Student) { person = await studentQuery.GetStudentWithIncludes(person.Id); } else if (type == PersonType.Teacher) { person = await teacherQuery.GetTeacherWithIncludes(person.Id); } }
public static Model.Person RetrieveTeacher(string id, out string error) { Model.Person teacher = teachers.Retrieve(id); if (teacher == null) { error = "没有该教师"; return(null); } else { error = "查找成功"; return(teacher); } }
public Model.Person Create(Model.Person person) { try { _context.Add(person); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(person); }
public async Task AttemptLogin(string username, string password) { this.person = await personQuery.GetUserFromNameAndPassword(username, password); if (this.person == null) { throw new Exception("Credentials failed"); } else { await cookieCRUD.CreateCookie("login", this.person, 30); await GetAttachedEntities(); } }
//Create personalised list of people to choose from private List <Model.Person> SelectionList(Model.Person person, List <XMusCringleLib.Model.Person> fullList, Boolean removePartner) { //Create copty of full List removing self and partner List <Model.Person> selPeople = new List <Model.Person>(); foreach (Model.Person p in fullList) { if (p.PersonID != person.PersonID && (p.PersonID != person.PartnerID && removePartner)) { selPeople.Add(p); } } return(selPeople); }
public AgregarPersona(string Usuario, DispatcherTimer mIdlemain) { mIdle = mIdlemain; AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.UnauthenticatedPrincipal); // Crear una identidad con el nombre de usuario IIdentity usuario = new GenericIdentity(Usuario, "Database"); //Crear lista roles String[] roles = { "Usuario", "Administrador" }; // Crear La credencial GenericPrincipal credencial = new GenericPrincipal(usuario, roles); // Asignar e sta credencial a la aplicacion System.Threading.Thread.CurrentPrincipal = credencial; var departamentos = (from d in db.Departamento select d); // ListDepartamento.Items.Insert(0, "Seleccione Departamento"); string myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "img/logo.png"; Uri iconUri = new Uri(myPath.Replace(@"\", @"/")); this.Icon = BitmapFrame.Create(iconUri); InitializeComponent(); LebelUsuario.Content = Usuario; myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "img/logo_central.fw.png"; iconUri = new Uri(myPath.Replace(@"\", @"/")); Logo.Source = new BitmapImage(iconUri); myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "img/bg_banderin.jpg"; iconUri = new Uri(myPath.Replace(@"\", @"/")); Logo_back.Source = new BitmapImage(iconUri); myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "icons/arrow_left.png"; iconUri = new Uri(myPath.Replace(@"\", @"/")); Volver.Source = new BitmapImage(iconUri); TipoDocumento.Items.Insert(0, "Seleccione tipo documento"); TipoDocumento.SelectedItem = TipoDocumento.Items.GetItemAt(0); ListDepartamento.Items.Insert(0, "Seleccione Departamento"); foreach (var dr in departamentos) { ComboBoxItem var2 = new ComboBoxItem(); var2.Tag = dr.IdCodigo; var2.Content = dr.nombre; ListDepartamento.Items.Add(var2); } ListDepartamento.SelectedItem = ListDepartamento.Items.GetItemAt(0); cargarmun(); Model.Person person = new Model.Person(); DataContext = person; }
public Person AddPerson(string firstName, string lastName, DateTime birthday, string email, string phone) { using (var context = ContextFactory.CreateContext()) { var repository = RepositoryFactory.CreatePersonRepository(context); var newPerson = new Model.Person { FirstName = firstName, LastName = lastName, Birthday = birthday, Email = email, Phone = phone }; repository.Add(newPerson); context.SaveChanges(); return newPerson; } }
public Person UpdatePerson(int personId, string firstName, string lastName, DateTime birthday, string email, string phone, DateTime? lastModified) { using (var context = ContextFactory.CreateContext()) { var repository = RepositoryFactory.CreatePersonRepository(context); var updatedPerson = new Model.Person { PersonId = personId, FirstName = firstName, LastName = lastName, Birthday = birthday, Email = email, Phone = phone, LastModified = lastModified }; repository.Update(updatedPerson); try { context.SaveChanges(); return updatedPerson; } catch (OptimisticConcurrencyException ex) { throw new DataException("Concurrency", ex); } } }
public DetallePersona(string NoIdentificacion, string Usuario) { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.UnauthenticatedPrincipal); // Crear una identidad con el nombre de usuario IIdentity usuario = new GenericIdentity(Usuario, "Database"); //Crear lista roles String[] roles = { "Usuario", "Administrador" }; // Crear La credencial GenericPrincipal credencial = new GenericPrincipal(usuario, roles); // Asignar e sta credencial a la aplicacion System.Threading.Thread.CurrentPrincipal = credencial; var departamentos = (from d in db.Departamento select d); // ListDepartamento.Items.Insert(0, "Seleccione Departamento"); string myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "img/logo.png"; Uri iconUri = new Uri(myPath.Replace(@"\", @"/")); this.Icon = BitmapFrame.Create(iconUri); InitializeComponent(); myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "img/logo_central.fw.png"; iconUri = new Uri(myPath.Replace(@"\", @"/")); Logo.Source = new BitmapImage(iconUri); myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "img/bg_banderin.jpg"; iconUri = new Uri(myPath.Replace(@"\", @"/")); Logo_back.Source = new BitmapImage(iconUri); myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "icons/arrow_left.png"; iconUri = new Uri(myPath.Replace(@"\", @"/")); Volver.Source = new BitmapImage(iconUri); LebelUsuario.Content = Thread.CurrentPrincipal.Identity.Name; string tipodoc = NoIdentificacion.ToString().Substring(0, 2); NoIdentificacion = NoIdentificacion.ToString().Replace("CC", "").Replace("TI", "").Replace("CE", "").Replace("PA", ""); var personasedit = (from p in db.Personas where p.NoDocumento.Equals(NoIdentificacion) && p.TipoDocumento.Equals(tipodoc) select p).First(); var UsuarioSync= (from p in db.Personas where p.NoDocumento.Equals(NoIdentificacion) select p.Estado).FirstOrDefault() ; if (UsuarioSync != null) { Editar.Visibility = Visibility.Hidden; } Personas personas = new Personas(); PrimerNombre.Text = personasedit.PrimerNombre; SegundoNombre.Text = personasedit.SegundoNombre; PrimerApellido.Text = personasedit.PrimerApellido; SegundoApellido.Text = personasedit.SegundoApellido; if (personasedit.Sexo == "M") { Sexo.Text = "Masculino"; } else { Sexo.Text = "Femenino"; } TipoDocumento.Text = personasedit.TipoDocumento; NoDocumento.Text = personasedit.NoDocumento; FechaNacimiento.Text = personasedit.FechaNacimiento.ToString("dd/MM/yyyy"); NoDocumento.Text = personasedit.NoDocumento; Departamento.Text = personasedit.Municipio.Departamento.nombre; Ciudad.Text = personasedit.Municipio.nombre; Direccion.Text = personasedit.Direccion; Barrio.Text = personasedit.Barrio; Telefono.Text = personasedit.Telefono; Celular.Text = personasedit.Celular; CorreoElectronico.Text = personasedit.CorreoElectronico; Fecha_Creacion.Text = " " + personasedit.Fecha_Creacion.ToString(); Fecha_Modificacion.Text = " " + personasedit.Fecha_Modificacion.ToString(); Fecha_Sincronizacion.Text = " " + personasedit.Fecha_Sincronizacion.ToString(); if(personasedit.Estado==true){ Estado.Text = " Sincronizado con Exito"; Detalle.Text = "Oferente registrado en el Servicio Público de Empleo"; }else{ if (personasedit.Estado == null) { Estado.Text = " Sin sincronizar"; Detalle.Text = "Ofrente pendiente por sincronizar"; } else { if (personasedit.UsuarioValido == false) { Estado.Text = " Usuario ya existe"; Detalle.Text = personasedit.Respuesta; } else { Estado.Text = " Oferente ya registrado"; Detalle.Text = personasedit.Respuesta; } } } Detalle.TextWrapping = TextWrapping.Wrap; Model.Person person = new Model.Person(); DataContext = person; }
/// <summary> /// Create new person /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, RoutedEventArgs e) { int PersonId = new Model.Person().New(); Switcher.Switch(new PersonInfo(PersonId)); }
public EditPersona(string NoIdentificacion, string Usuario) { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.UnauthenticatedPrincipal); // Crear una identidad con el nombre de usuario IIdentity usuario = new GenericIdentity(Usuario, "Database"); //Crear lista roles String[] roles = { "Usuario", "Administrador" }; // Crear La credencial GenericPrincipal credencial = new GenericPrincipal(usuario, roles); // Asignar e sta credencial a la aplicacion System.Threading.Thread.CurrentPrincipal = credencial; var departamentos = (from d in db.Departamento select d); // ListDepartamento.Items.Insert(0, "Seleccione Departamento"); string myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "img/logo.png"; Uri iconUri = new Uri(myPath.Replace(@"\", @"/")); this.Icon = BitmapFrame.Create(iconUri); InitializeComponent(); LebelUsuario.Content = Usuario; myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "img/logo_central.fw.png"; iconUri = new Uri(myPath.Replace(@"\", @"/")); Logo.Source = new BitmapImage(iconUri); myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "img/bg_banderin.jpg"; iconUri = new Uri(myPath.Replace(@"\", @"/")); Logo_back.Source = new BitmapImage(iconUri); myPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "icons/arrow_left.png"; iconUri = new Uri(myPath.Replace(@"\", @"/")); Volver.Source = new BitmapImage(iconUri); string tipodoc = NoIdentificacion.ToString().Substring(0, 2); NoIdentificacion = NoIdentificacion.ToString().Replace("CC", "").Replace("TI", "").Replace("CE", "").Replace("PA", ""); var personasedit = (from p in db.Personas where p.NoDocumento.Equals(NoIdentificacion) && p.TipoDocumento.Equals(tipodoc) select p).First(); ID_persona.Text = personasedit.Id.ToString(); PrimerNombre.Text = personasedit.PrimerNombre; SegundoNombre.Text = personasedit.SegundoNombre; PrimerApellido.Text = personasedit.PrimerApellido; SegundoApellido.Text = personasedit.SegundoApellido; if (personasedit.Sexo == "F") { Femenino.IsChecked = true; } else { Masculino.IsChecked = true; } FechaNacimientodata.Text = personasedit.FechaNacimiento.ToString(); NoDocumento.Text = personasedit.NoDocumento; NoDocumentoPASS.Password = personasedit.NoDocumento; RepetirNoDocumento.Text = personasedit.NoDocumento; //Departamento foreach (var dr in departamentos) { ComboBoxItem var2 = new ComboBoxItem(); var2.Tag = dr.IdCodigo; var2.Content = dr.nombre; ListDepartamento.Items.Add(var2); if(var2.Tag.Equals(personasedit.Departamento)) { ListDepartamento.SelectedItem = var2; } } //Municipio var Municipios = (from m in db.Municipio where m.department_id.Contains(personasedit.Departamento) select m); Ciudad.Items.Clear(); foreach (var dr in Municipios) { ComboBoxItem var2 = new ComboBoxItem(); var2.Tag = dr.IdCodigo; var2.Content = dr.nombre; Ciudad.Items.Add(var2); if (var2.Tag.Equals(personasedit.Municipio.IdCodigo)) { Ciudad.SelectedItem = var2; } } Vereda.Items.Clear(); var Veredas = (from v in db.Veredas where v.municipality_id.Contains(personasedit.Municipio.IdCodigo) select v); Vereda.Items.Add(""); foreach (var dr in Veredas) { ComboBoxItem var2 = new ComboBoxItem(); var2.Tag = dr.IdCodigo; var2.Content = dr.nombre; Vereda.Items.Add(var2); if (var2.Tag.Equals(personasedit.Vereda)) { Vereda.SelectedItem = var2; } } Direccion.Text = personasedit.Direccion; Barrio.Text = personasedit.Barrio; Telefono.Text = personasedit.Telefono; Celular.Text = personasedit.Celular; if (personasedit.CorreoElectronico != "") { CorreoElectronico.Text = personasedit.CorreoElectronico; CorreoElectronicoPASS.Password = personasedit.CorreoElectronico; CorreoElectronicoRepeat.Text = personasedit.CorreoElectronico; } CorreoElectronicoPASS.Visibility = Visibility.Visible; CorreoElectronico.Visibility = Visibility.Hidden; CorreoElectronicoError.Visibility = Visibility.Hidden; foreach (ComboBoxItem item in TipoDocumento.Items) { if(item.Tag.Equals(personasedit.TipoDocumento)) { TipoDocumento.SelectedItem = item; } } Model.Person person = new Model.Person(); DataContext = person; }