protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { try { string cp_id = ((Literal)e.Item.FindControl("CPID")).Text; Hospital__Physician cp = (from r in myEntities.Hospital__Physician where r.CP_ID == cp_id && r.H_ID == hid select r).SingleOrDefault(); switch (e.CommandName) { case "Delete": myEntities.DeleteObject(cp); myEntities.SaveChanges(); break; case "Save": cp.Unit = ((TextBox)e.Item.FindControl("CPUnit")).Text; myEntities.SaveChanges(); break; } Response.Redirect("~/Hospital/Management/Physicians.aspx"); } catch (Exception ex) { //notify = true; //note = ex.Message; } } }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Delete") { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { try { string bed = ((Literal)e.Item.FindControl("Bed")).Text; var beds = (from r in myEntities.Hospital__Bed where (r.H_ID == hid && r.BedNo == bed) select r).Single(); if (beds.Occupied == false) { myEntities.DeleteObject(beds); } myEntities.SaveChanges(); } catch (Exception ex) { //notify = true; //note = ex.Message; } } Response.Redirect("~/Hospital/Management/Beds.aspx"); } }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Delete") { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { try { int did = Convert.ToInt32(((Literal)e.Item.FindControl("DID")).Text); var dept = from r in myEntities.Hospital__Department where (r.D_ID == did && r.H_ID == hid) select r; myEntities.DeleteObject(dept.Single()); myEntities.SaveChanges(); } catch (Exception ex) { notify = true; note = ex.Message; } } Response.Redirect("~/Hospital/Management/Departments.aspx"); } }
protected void Insert_Click(object sender, EventArgs e) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { try { Hospital__Physician relation = new Hospital__Physician(); relation.CP_ID = cpid; relation.H_ID = hid; relation.UpdatedBy = Profile.UserName; relation.UpdateDateTime = DateTime.Now; relation.UpdateUserName = Profile.Name; myEntities.AddToHospital__Physician(relation); myEntities.SaveChanges(); } catch (Exception ex) { Notification.Text = ex.Message; } } Response.Redirect("~/Hospital/Management/Physicians.aspx"); }
protected void Insert_Click(object sender, EventArgs e) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { try { Physician__Patient relation = new Physician__Patient(); relation.CP_ID = cpid; relation.P_ID = pid; relation.UpdatedBy = Profile.UserName; relation.UpdateDateTime = DateTime.Now; relation.UpdateUserName = Profile.Name; myEntities.AddToPhysician__Patient(relation); myEntities.SaveChanges(); } catch (Exception ex) { Notification.Text = ex.Message; } } Response.Redirect(String.Format("~/Hospital/PatientInfo/Physicians.aspx?PID={0}", RegID.Text)); }
protected void Insert_Click(object source, EventArgs e) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { try { Hospital__Department relation = new Hospital__Department(); relation.D_ID = Convert.ToInt32(DSearchList.SelectedValue); relation.H_ID = hid; relation.UpdatedBy = Profile.UserName; relation.UpdateDateTime = DateTime.Now; relation.UpdateUserName = Profile.Name; myEntities.AddToHospital__Department(relation); myEntities.SaveChanges(); } catch (Exception ex) { notify = true; note = ex.Message; } } Response.Redirect("~/Hospital/Management/Departments.aspx"); }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { try { if (e.CommandName == "Delete") { string cp_id = ((Literal)e.Item.FindControl("CPID")).Text; Physician__Patient cp = (from r in myEntities.Physician__Patient where (r.CP_ID == cp_id && r.P_ID == pid) select r).SingleOrDefault(); myEntities.DeleteObject(cp); myEntities.SaveChanges(); } Response.Redirect(String.Format("~/Hospital/PatientInfo/Physicians.aspx?PID={0}", pid)); } catch (Exception ex) { //notify = true; //note = ex.Message; } } }
protected void Save_Click(object sender, EventArgs e) { if (Page.IsValid) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { Hospital__Staff profile; if (sid != null) { profile = (from r in myEntities.Hospital__Staff where r.Staff_ID == sid select r).SingleOrDefault(); if (profile != null) { // Update profile information profile.StaffName = Name.Text; profile.PhotoURL = Photo.ImageUrl; profile.Designation = Designation.Text; profile.Qualification = Qualification.Text; profile.RelevantInfo = Info.Text; profile.Address = Address.Text; profile.State = State.Text; profile.Country = Country.Text; profile.Pincode = Pincode.Text; profile.Phone1 = Contact1.Text; profile.Phone2 = Contact2.Text; profile.Email = Email.Text; profile.UpdateDateTime = DateTime.Now; profile.UpdatedBy = Profile.UserName; profile.UpdateUserName = Profile.Name; myEntities.SaveChanges(); //Notification.Text = "Changes saved successfully."; //System.Threading.Thread.Sleep(5000); //Notification.Text = null; } else { MultiView1.ActiveViewIndex = 1; } } else { MultiView1.ActiveViewIndex = 1; } } } Response.Redirect(String.Format("~/Hospital/Management/StaffProfile.aspx?SID={0}", StfID.Text)); }
protected void Add_Click(object sender, EventArgs e) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { Hospital__Bed bed = new Hospital__Bed(); bed.BedNo = BedNoA.Text; bed.Type = TypeA.Text; bed.H_ID = hid; bed.Occupied = false; bed.UpdateDateTime = DateTime.Now; bed.UpdatedBy = Profile.UserName; bed.UpdateUserName = Profile.Name; myEntities.AddToHospital__Bed(bed); myEntities.SaveChanges(); } Response.Redirect("~/Hospital/Management/Beds.aspx"); }
protected void Save_Click(object sender, EventArgs e) { if (Page.IsValid) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { Patient__Profile profile; if (pid != null) { profile = (from r in myEntities.Patient__Profile where r.Registration_ID == pid select r).SingleOrDefault(); if (profile != null) { profile.Diagnosis = Diagnosis.Text; profile.UpdateDateTime = DateTime.Now; profile.UpdatedBy = Profile.UserName; profile.UpdateUserName = Profile.Name; myEntities.SaveChanges(); Notification.Text = "Changes saved successfully."; System.Threading.Thread.Sleep(10000); Notification.Text = null; } else { MultiView1.ActiveViewIndex = 1; } } else { MultiView1.ActiveViewIndex = 1; } } } }
protected void Add_Click(object sender, EventArgs e) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { try { Module__Department relation = new Module__Department(); relation.Name = AddDept.Text.Trim(); relation.UpdatedBy = Profile.UserName; relation.UpdateDateTime = DateTime.Now; relation.UpdateUserName = Profile.Name; myEntities.AddToModule__Department(relation); myEntities.SaveChanges(); } catch (Exception ex) { notify = true; note = ex.Message; } } }
protected void Save_Click(object sender, EventArgs e) { if (Page.IsValid) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { Hospital__Profile hospital = (from r in myEntities.Hospital__Profile where r.Hospital_ID == hid select r).SingleOrDefault(); // Update hospital information hospital.Hospital_ID = HospitalID.Text; hospital.HospitalName = Name.Text; hospital.LogoUrl = Logo.ImageUrl; hospital.ESTD = Convert.ToInt16(ESTD.Text); hospital.Website = Website.Text; hospital.Email = Email.Text; hospital.Address = Address.Text; hospital.City = City.Text; hospital.Pincode = Pincode.Text; hospital.State = State.Text; hospital.Country = Country.Text; hospital.Phone1 = Phone1.Text; hospital.Phone2 = Phone2.Text; hospital.Phone3 = Phone3.Text; hospital.Phone4 = Phone4.Text; Fax.Text = hospital.Fax; hospital.UpdateDateTime = DateTime.Now; hospital.UpdatedBy = Profile.UserName; hospital.UpdateUserName = Profile.Name; myEntities.SaveChanges(); } } Response.Redirect("~/Hospital/Management/EditInfo.aspx"); }
protected void Register_Click(object sender, EventArgs e) { if (Page.IsValid) { try { // Create account and assign role 'Patient' string pswd = Password.Text; if (RndPswd.Checked) { pswd = Membership.GeneratePassword(Membership.MinRequiredPasswordLength, Membership.MinRequiredNonAlphanumericCharacters); } Membership.CreateUser(UserName.Text, pswd, Email.Text); ProfileCommon pc = new ProfileCommon(); pc.Initialize(UserName.Text, true); pc.Name = PatientName.Text; pc.Save(); Roles.AddUserToRole(UserName.Text, "Patient"); // Send account confirmation email string fileName = Server.MapPath("~/App_Data/AccountConfirmation.txt"); string mailBody = File.ReadAllText(fileName); mailBody = mailBody.Replace("##Name##", PatientName.Text); mailBody = mailBody.Replace("##Role##", "Patient"); mailBody = mailBody.Replace("##Username##", UserName.Text); mailBody = mailBody.Replace("##Password##", pswd); MailMessage emailMessage = new MailMessage(); emailMessage.Subject = "New Account Confirmation"; emailMessage.Body = mailBody; emailMessage.From = new MailAddress("*****@*****.**", "NMHC"); emailMessage.To.Add(new MailAddress(Email.Text, PatientName.Text)); SmtpClient mySmtpClient = new SmtpClient(); mySmtpClient.Send(emailMessage); // Register above patient using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { Patient__Profile profile = new Patient__Profile(); profile.Registration_ID = UserName.Text; profile.PatientName = PatientName.Text; profile.RegistrationDateTime = DateTime.Now; profile.Email = Email.Text; profile.H_ID = (from r in myEntities.Hospital__Staff where r.Staff_ID == Profile.UserName select r.H_ID).SingleOrDefault(); profile.UpdatedBy = Profile.UserName; profile.UpdateUserName = Profile.Name; profile.UpdateDateTime = profile.RegistrationDateTime; myEntities.AddToPatient__Profile(profile); myEntities.SaveChanges(); } Notification.Text = "Your account has been created successfully. " + "An email has been sent to " + Email.Text + " containing your Username and Password."; } catch (Exception ex) { Notification.Text = ex.Message; Back.Visible = true; Continue.Visible = false; // Delete partially created user data in case of exception using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { var profile = (from r in myEntities.Patient__Profile where r.Registration_ID == UserName.Text select r).SingleOrDefault(); if (profile != null) { myEntities.Patient__Profile.DeleteObject(profile); } myEntities.SaveChanges(); } if (Membership.GetUser(UserName.Text) != null) { Membership.DeleteUser(UserName.Text, true); } } MultiView1.ActiveViewIndex = 1; } }
protected void Save_Click(object sender, EventArgs e) { if (Page.IsValid) { using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities()) { Patient__Profile profile; if (pid != null) { profile = (from r in myEntities.Patient__Profile where r.Registration_ID == pid select r).SingleOrDefault(); if (profile != null) { // Update profile information profile.Department = Department.SelectedValue; profile.CurrentBedNo = (Bed.SelectedValue == "Unoccupied") ? null : Bed.SelectedValue; profile.PatientName = Name.Text; profile.PhotoURL = Photo.ImageUrl; profile.Sex = Sex.SelectedValue; profile.Age = Convert.ToInt16(AgeValue.Text); profile.AgeUnit = AgeUnit.SelectedValue; profile.BodyWeight = Convert.ToInt16(Weight.Text); profile.Height = Convert.ToInt16(Height.Text); profile.MaritalStatus = MaritalStatus.SelectedValue; profile.C_o = Co.Text; profile.C_o_Relation = CoRelation.SelectedValue; profile.MothersName = MotherName.Text; profile.MLC_No = MLC.Text; profile.ReferredBy = RName.Text; profile.RefContactNo = RContact.Text; profile.IfPreviouslyTreated = PrevTreated.Checked; profile.LastTreatedRegistration_ID = PrevID.Text; profile.Occupation = Occupation.Text; profile.Financing = Financing.Text; profile.LocalAddress = LAddress.Text; profile.LState = LState.Text; profile.LCountry = LCountry.Text; profile.LPincode = LPincode.Text; profile.LContactNo1 = LContact1.Text; profile.LContactNo2 = LContact2.Text; profile.Email = LEmail.Text; profile.PermanentAddress = PAddress.Text; profile.PState = PState.Text; profile.PCountry = PCountry.Text; profile.PPincode = PPincode.Text; profile.PContactNo1 = PContact1.Text; profile.PContactNo2 = PContact2.Text; profile.EmergencyContactPerson = CName.Text; profile.CPRelationship = CRelation.Text; profile.CPAddress = CAddress.Text; profile.CPContactNo1 = CContact1.Text; profile.CPContactNo2 = CContact2.Text; profile.CPEmail = CEmail.Text; profile.AdmittingPerson = AName.Text; profile.APRelationship = ARelation.Text; profile.APAddress = AAddress.Text; profile.APContactNo1 = AContact1.Text; profile.APContactNo2 = AContact2.Text; profile.UpdateDateTime = DateTime.Now; profile.UpdatedBy = Profile.UserName; profile.UpdateUserName = Profile.Name; // Update bed information Hospital__Bed b = (from r in myEntities.Hospital__Bed where (r.H_ID == profile.H_ID && r.BedNo == PBed.Text) select r).SingleOrDefault(); if (b != null) { b.Occupied = false; // Previous bed occupied status: false } b = (from r in myEntities.Hospital__Bed where (r.H_ID == profile.H_ID && r.BedNo == Bed.SelectedValue) select r).SingleOrDefault(); if (b != null) { b.Occupied = true; // Current Bed occupied status: true if selected value is not "Unoccupied" } myEntities.SaveChanges(); //Notification.Text = "Changes saved successfully."; //System.Threading.Thread.Sleep(5000); //Notification.Text = null; } else { MultiView1.ActiveViewIndex = 1; } } else { MultiView1.ActiveViewIndex = 1; } } } Response.Redirect(String.Format("~/Hospital/PatientInfo/EditInfo.aspx?PID={0}", RegID.Text)); }