private void buttonAdd_Click(object sender, RoutedEventArgs e) { var editDoctor = new EditDoctor(true); editDoctor.ShowDialog(); //this.Presenter.LoadDoctorsByCriterias(); }
//private Doctor GetSelectedDoctor() //{ // //var row = this.dataGridViewResult.SelectedItem;//currentrow было вместо колумна // //if (row == null) // //{ // // return null; // //} // //var doctor = (Doctor)row;//row.DataBoundItem; // //return doctor; //} private void buttonEdit_Click(object sender, RoutedEventArgs e) { var row = (System.Data.DataRowView)dataGridViewResult.SelectedItems[0]; var editDoctor = new EditDoctor(DoctorDataAccess.GetDoctorById(Convert.ToInt32(row.Row.ItemArray[0].ToString()))); editDoctor.ShowDialog(); //this.Presenter.LoadDoctorsByCriterias(); }
public async Task <IActionResult> Edit(long id) { Doctor doctor = null; if (User.IsInRole("Doctor")) { doctor = _context.Doctors.Include(d => d.User).Where(d => d.User.Id == _userManager.GetUserId(User)).Single(); } else { doctor = _context.Doctors.Include(d => d.User).Single(d => d.Id == id); } if (doctor == null) { return(NotFound()); } EditDoctor model = new EditDoctor { Id = doctor.Id, FirstName = doctor.FirstName, MiddleName = doctor.MiddleName, LastName = doctor.LastName, Gender = doctor.Gender, Image = doctor.Image, Mobile = doctor.Mobile, About = doctor.About, Speciality = doctor.Speciality, Time = doctor.Time, DisplayName = doctor.DisplayName, Address = doctor.Address, Username = doctor.User.UserName, Email = doctor.User.Email, Phone = doctor.User.PhoneNumber }; return(View(model)); }
private void edirDoctor_Click(object sender, EventArgs e) { EditDoctor upcl = new EditDoctor(); upcl.id.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString(); upcl.textBsur.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString(); upcl.textBname.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); upcl.textBotch.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString(); upcl.comboBsex.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString(); upcl.dateBirth.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString(); upcl.maskedSer.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString(); upcl.maskedNum.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString(); upcl.comboSpecialty.Text = dataGridView1.CurrentRow.Cells[8].Value.ToString(); upcl.textBpost.Text = dataGridView1.CurrentRow.Cells[9].Value.ToString(); upcl.maskedOklad.Text = dataGridView1.CurrentRow.Cells[10].Value.ToString(); upcl.maskedPhone.Text = dataGridView1.CurrentRow.Cells[11].Value.ToString(); upcl.textBemail.Text = dataGridView1.CurrentRow.Cells[12].Value.ToString(); this.Hide(); upcl.ShowDialog(); updateData(); this.Show(); }
private void editDoctorBtn_Click(object sender, RoutedEventArgs e) { EditDoctor edit = new EditDoctor(); edit.Show(); }
public async Task <IActionResult> Edit(long id, EditDoctor model, IFormFile file) { string returnAction = "Search"; if (id != model.Id) { return(NotFound()); } Doctor doctor = null; if (ModelState.IsValid) { if (User.IsInRole("Doctor")) { doctor = _context.Doctors.Include(d => d.User).Where(d => d.User.Id == _userManager.GetUserId(User)).Single(); returnAction = "Profile"; } else { doctor = _context.Doctors.Include(d => d.User).Single(d => d.Id == model.Id); } IdentityUser user = doctor.User; var username = await _userManager.GetUserNameAsync(user); if (model.Username != username) { if (_userManager.Users.Any(u => u.UserName == model.Username)) { ModelState.AddModelError(String.Empty, "User name already taken"); return(View(model)); } var setUserNameResult = await _userManager.SetUserNameAsync(user, model.Username); if (!setUserNameResult.Succeeded) { var userId = await _userManager.GetUserIdAsync(user); throw new InvalidOperationException($"Unexpected error occurred setting username for user with ID '{userId}'."); } } if (file != null) { var filePath = Path.GetTempFileName(); using (FileStream filestream = System.IO.File.Create(_environment.WebRootPath + "\\images\\" + file.FileName)) { model.Image = file.FileName; file.CopyTo(filestream); filestream.Flush(); } } try { doctor.FirstName = model.FirstName; doctor.MiddleName = model.MiddleName; doctor.LastName = model.LastName; doctor.Gender = model.Gender; doctor.Image = model.Image; doctor.Mobile = model.Mobile; doctor.About = model.About; doctor.Speciality = model.Speciality; doctor.Time = model.Time; doctor.DisplayName = model.DisplayName; doctor.Address = model.Address; var email = await _userManager.GetEmailAsync(user); if (model.Email != email) { var setEmailResult = await _userManager.SetEmailAsync(user, model.Email); if (!setEmailResult.Succeeded) { var userId = await _userManager.GetUserIdAsync(user); throw new InvalidOperationException($"Unexpected error occurred setting email for user with ID '{userId}'."); } } var phoneNumber = await _userManager.GetPhoneNumberAsync(user); if (model.Phone != phoneNumber) { var setPhoneResult = await _userManager.SetPhoneNumberAsync(user, model.Phone); if (!setPhoneResult.Succeeded) { var userId = await _userManager.GetUserIdAsync(user); throw new InvalidOperationException($"Unexpected error occurred setting phone number for user with ID '{userId}'."); } } doctor.User = user; _context.Doctors.Update(doctor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DoctorExists(doctor.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(returnAction)); } return(View(model)); }