private void InfoSaveButton_Click(object sender, EventArgs e) { try { using (var databaseContext = new DatabaseContext()) { var details = new DocDetails() { AddressLine1 = WorkPlaceAddressLine1TextBox.Text.ToString(), AddressLine2 = WorkPlaceAddressLine2TextBox.Text.ToString(), AddressLine3 = WorkPlaceAddressLine3TextBox.Text.ToString(), Degree = DegreeTextBox.Text.ToString(), Doctor = UserInfo.UserEmail.ToString(), IsVerified = false, LicenceNo = LicenceTextBox.Text.ToString(), Specialities = SpecialityTextBox.Text.ToString(), State = StateTextBox.Text.ToString(), WorkPlace = WorkPlaceTextBox.Text.ToString(), WorkPlaceContact = WorkPlaceContactTextBox.Text.ToString(), ZipCode = ZipCodeTextBox.Text.ToString(), }; databaseContext.DocDetails.Add(details); databaseContext.SaveChanges(); MessageBox.Show("Details are saved, this windows will close now to continue further.", "SuccessValidation", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { MessageBox.Show("It seems some fields are left blank, make sure to fill them up before saving", "FieldRequiredValidation", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public HomeForm() { InitializeComponent(); this.StartPosition = FormStartPosition.Manual; this.Location = new Point(150, 150); UsernameLabel.Text = UserInfo.UserName; using (DatabaseContext databaseContext = new DatabaseContext()) { DocDetails docDetails = databaseContext.DocDetails.Where(e => e.Doctor == UserInfo.UserEmail).FirstOrDefault <DocDetails>(); UserInfo.IsInfoFilled = docDetails == null ? false : true; UserInfo.DoctorHospitalName = UserInfo.IsInfoFilled == true?docDetails.WorkPlace.ToString() : null; } }
public JsonResult GetDocumentDetails(string FileID) { DocDetails detail = new DocDetails(); Document s = db.Documents.Where(n => n.FileId == FileID).FirstOrDefault(); if (s != null) { detail.FileId = s.FileId; detail.Subject = s.Subject; detail.Description = s.Description; detail.FileType = db.FileTypes.Where(n => n.FileTypeId == s.FileTypeId).FirstOrDefault().Description; detail.DateCreated = s.DateCreated.Value.ToShortDateString(); detail.UserID = MiscClass.GetFullName(s.UserID); return(Json(detail, JsonRequestBehavior.AllowGet)); } else { detail = null; return(Json("Empty", JsonRequestBehavior.AllowGet)); } }
private void LoginButton_Click(object sender, EventArgs e) { if (loginButton.Text == "Logout") { UserInfo.UserEmail = null; UserInfo.UserName = null; UserInfo.UserType = null; Close(); } using (var databaseContext = new DatabaseContext()) { User user = databaseContext.Users.Where(u => u.Email == emailTextBox.Text.ToString()).FirstOrDefault <User>(); if (user == null) { MessageBox.Show("User with email " + emailTextBox.Text.ToString() + " not found"); } else { //Decryption of password byte[] data = Convert.FromBase64String(user.Password.ToString()); byte[] decrypted = ProtectedData.Unprotect(data, null, DataProtectionScope.CurrentUser); if (Encoding.Unicode.GetString(decrypted) == passwordTextBox.Text.ToString()) { // Managing session MessageBox.Show("Logging In to the app...", "Authenticated", MessageBoxButtons.OK, MessageBoxIcon.Information); UserInfo.UserEmail = user.Email.ToString(); UserInfo.UserName = user.Firstname.ToString(); UserInfo.UserType = user.UserType.ToString(); UserInfo.UserID = user.UniqueID.ToString(); UserInfo.UserLastName = user.Lastname.ToString(); emailTextBox.Clear(); passwordTextBox.Clear(); if (UserInfo.UserEmail != null) { loginButton.Text = "Logout"; emailTextBox.Enabled = false; passwordTextBox.Enabled = false; registerButton.Enabled = false; } if (UserInfo.UserID.StartsWith("P")) { PatientHomeForm patientHomeForm = new PatientHomeForm(); patientHomeForm.Tag = this; patientHomeForm.ShowDialog(this); } if (UserInfo.UserID.StartsWith("L")) { LaboratorianDetail laboratorianDetail = databaseContext.LaboratorianDetails.Where(l => l.Laboratorian == UserInfo.UserEmail).FirstOrDefault <LaboratorianDetail>(); if (laboratorianDetail == null) { LaboratorianExtraDetailsForm laboratorianExtraDetailsForm = new LaboratorianExtraDetailsForm(); laboratorianExtraDetailsForm.Tag = this; laboratorianExtraDetailsForm.ShowDialog(this); } else { UserInfo.IsInfoFilled = true; UserInfo.LaboratorianLabName = laboratorianDetail.WorkPlace.ToString(); LaboratorianHomeForm laboratorianHomeForm = new LaboratorianHomeForm(); laboratorianHomeForm.Tag = this; laboratorianHomeForm.ShowDialog(this); } } if (UserInfo.UserID.StartsWith("D")) { DocDetails docDetails = databaseContext.DocDetails.Where(a => a.Doctor == UserInfo.UserEmail).FirstOrDefault <DocDetails>(); if (docDetails == null) { DocExtraDetails docExtraDetails = new DocExtraDetails(); docExtraDetails.Tag = this; docExtraDetails.ShowDialog(this); //this.Enabled = false; } else { UserInfo.IsInfoFilled = true; HomeForm homeForm = new HomeForm(); homeForm.Tag = this; homeForm.ShowDialog(this); //this.Enabled = false; } } //Redirecting to Home Form if user gets logged in. } else { MessageBox.Show("Couldn't Sign in to the app, make sure credentials are valid", "Failed to Authenticate", MessageBoxButtons.OK, MessageBoxIcon.Error); passwordTextBox.Focus(); } } } }