protected void changePasswordBtn_Click(object sender, EventArgs e) { try { var ConnectionString = new HospitalDBEntities(); string username = usernameTxt.Text; Employee emp = ConnectionString.Employees.FirstOrDefault(x => (x.Email == username)); if (PasswordTxt.Text.Equals(emp.Password)) { if (changePasswordTxt2.Text != null) { emp.Password = changePasswordTxt2.Text; ConnectionString.SaveChangesAsync(); passwordSuccess.Text = " Password changed successfully"; passwordFailure.Text = ""; } } else { passwordFailure.Text = "Old Password is incorrect"; passwordSuccess.Text = ""; } }catch { passwordFailure.Text = "password doesnot change"; } }
protected void placeOrderButton_Click(object sender, EventArgs e) { try { var connectionString = new HospitalDBEntities(); MedicalItem1 medicalItem1 = new MedicalItem1(); medicalItem1.Inventory = Convert.ToInt32(inventoryIDList.SelectedValue); medicalItem1.Name = nameTxt.Text; medicalItem1.Supplier = supplierTxt.Text; medicalItem1.Description = descriptionTxt.Text; medicalItem1.Price = Convert.ToDecimal(priceTxt.Text); medicalItem1.Quantity = Convert.ToInt32(quantityTxt.Text); connectionString.MedicalItems1.Add(medicalItem1); connectionString.SaveChanges(); errorLabel.Text = "Order Placed successfully"; nameTxt.Text = ""; supplierTxt.Text = ""; descriptionTxt.Text = ""; priceTxt.Text = ""; quantityTxt.Text = ""; } catch (NullReferenceException ex) { errorLabel.Text = ex.Message; } }
protected void Button1_Click(object sender, EventArgs e) { //DB context var context = new HospitalDBEntities(); //Holds Appointment ID from Session State int appointmentID = (int)Session["AppointmentID"]; //Holds patient id from database. int patientID = (int)Session["PatientID"]; //the employee ID variable if (String.IsNullOrWhiteSpace(PrescriptionTextBox.Text) == false && String.IsNullOrWhiteSpace(DiagnosisTextBox.Text) == false && End_Calendar.SelectedDate != DateTime.MinValue && String.IsNullOrWhiteSpace(EndTime.Text) == false) { try { //Holds employee id from session state. int employeeID = ConnectionClass.GetAppointmentEmployeeID(appointmentID); string precription = PrescriptionTextBox.Text; string diagnosis = DiagnosisTextBox.Text; DateTime endCalendarValue = End_Calendar.SelectedDate; string endTime = endCalendarValue.ToShortDateString() + " " + EndTime.Text; ConnectionClass.UpdateAndCloseAppointment(appointmentID, endTime, diagnosis, precription); ConnectionClass.AddReportWithAppointmentID(employeeID, patientID, diagnosis, precription, appointmentID); errorLabel.ForeColor = System.Drawing.Color.Green; errorLabel.Text = "Appointment Closed Successfully"; Response.Redirect("ViewPatientsAppointmentPage.aspx"); } catch { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Closure Failed"; } } else { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Closure Failed"; } }
protected void submit_Click(object sender, EventArgs e) { int id = int.Parse(idTxtBox.Text.ToString()); String password = passwordTxtBox.Text.ToString(); var context = new HospitalDBEntities(); Employee employee = context.Employees.FirstOrDefault(x => (x.EmployeeID == id && x.Password == password)); if (employee == null) { errorMessageDiv.Visible = true; errorMessage.Text = "UserId or Password is Inncorrect !!"; errorMessage.Font.Bold = true; } else { Session["employee"] = employee; Response.Redirect("SearchInventoryPharma.aspx"); } }
protected void registerBtn_Click(object sender, EventArgs e) { try { var connectionString = new HospitalDBEntities(); Employee emp = new Employee(); emp.Ward = Convert.ToInt32(wardNumber.Text); emp.EmployeeType = Convert.ToInt32(employeeType.Text); emp.FirstName = firstName.Text; emp.LastName = lastName.Text; emp.PhoneNumber = contactNumber.Text; emp.Address = address.Text; emp.Email = emailID.Text; emp.Password = userPassword.Text; emp.SIN = sinNumber.Text; connectionString.Employees.Add(emp); connectionString.SaveChanges(); wardNumber.Text = " "; employeeType.Text = " "; firstName.Text = " "; lastName.Text = " "; contactNumber.Text = " "; address.Text = " "; emailID.Text = " "; userPassword.Text = " "; sinNumber.Text = " "; registerLblSuccess.Text = "User Registered Successfully with login Employee ID " + emp.EmployeeID; registerLblError.Text = ""; } catch { registerLblError.Text = "User is not registered"; } }
/* * protected override void OnPreInit(EventArgs e) * { * int position = 0; * string variable = "Login to continue"; * //Checks which user is entering the system and chooses the master pages for them * //checks if the session is null or not * if (Session.Count > 0) * * * { * position = ((Employee)Session["employee"]).EmployeeType.Value; * if (position == 5) * { * MasterPageFile = "~/Receptionist.Master"; * } * else if (position == 4) * { * MasterPageFile = "~/Laboratory.Master"; * } * else if (position == 3) * { * MasterPageFile = "~/Nurse.Master"; * } * else if (position == 2) * { * MasterPageFile = "~/Pharmacist.Master"; * } * else if (position == 1) * { * MasterPageFile = "~/Doctor.Master"; * } * else * { * MasterPageFile = "~/Site1.Master"; * } * } * else * { * ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + variable + "');", true); * Response.Redirect("LoginPage.aspx"); * } * } */ //Event handler for the create apointment button protected void Button1_Click(object sender, EventArgs e) { //DB context var context = new HospitalDBEntities(); //Holds employee id from textbox int i = 0; //Holds patient id from textbox int p = 0; //the employee ID variable if (int.TryParse(EmployeeTextBox.Text, out i) == true && int.TryParse(PatientTextBox.Text, out p) && Begin_Calendar.SelectedDate != DateTime.MinValue) { i = Convert.ToInt32(EmployeeTextBox.Text); p = Convert.ToInt32(PatientTextBox.Text); //the patient //One Appointment Appointment appointment = context.Appointments.FirstOrDefault(x => x.Employee == i); Employee employee1 = context.Employees.FirstOrDefault(x => x.EmployeeID == i); // Query for all appointments with names starting with employee ID var appoint = from b in context.Appointments where b.Employee.Value.Equals(i) select b; //gets patient Patient patient = context.Patients.FirstOrDefault(x => (x.PatientID == p)); //converting all the appointments found to a list List <Appointment> listOfAppointments = appoint.ToList(); DateTime startCalendarValue = Begin_Calendar.SelectedDate; Label2.Text = listOfAppointments.Count.ToString(); //Value will be tue if appointment is valid if (appoint.Count() != 0 && patient != null) { //Dispose of db Context context.Dispose(); //Adds the appointment to the database Appointment appointmentToBeAdded = new Appointment(); string start = startCalendarValue.ToShortDateString() + " " + BeginTime.Text; appointmentToBeAdded.StartTime = start; appointmentToBeAdded.Patient = p; appointmentToBeAdded.Employee = i; appointmentToBeAdded.Diagnosis = " "; appointmentToBeAdded.Prescription = " "; try { ConnectionClass.AddSchedule(appointmentToBeAdded); errorLabel.ForeColor = System.Drawing.Color.Green; errorLabel.Text = "Appointment Added Successfully"; } catch (Exception f) { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Appointment Could not be Added"; } } }//End of if else { errorLabel.ForeColor = System.Drawing.Color.Red; errorLabel.Text = "Appointment Could not Be Added, Please fill out all fields"; } }