private void PrintDocument_PrintPage(object sender, PrintPageEventArgs e) { Graphics g = e.Graphics; g.DrawImage(Resources.logo1, new Point(offsetX, offsetY)); int titleOffset = offsetX; Font font = new Font("Arial", 20); Brush brush = Brushes.Black; //g.DrawString("Over Surgery", font, brush, titleOffset, offsetY); float imageHeightPrint = Resources.logo1.Height / Resources.logo1.VerticalResolution * 100; offsetY += (int)imageHeightPrint; font = new Font("Arial", 16); int stringHeight = (int)g.MeasureString("Over Surgery", font).Height; StaffFactory sf = new StaffFactory(dbCon); PatientFactory pf = new PatientFactory(dbCon); Staff s = sf.GetStaffByID(a.StaffId)[0]; Patient p = pf.GetPatientsByID(a.PatientId)[0]; string s1 = "You have an appointment booked to see: "; string s2 = $"{s.JobRole} {s.FirstName} {s.LastName} on "; string s3 = $"{a.AppointmentDate.ToShortDateString()} at {a.AppointmentTime.ToShortTimeString()}"; string s4 = "If you cannot attend please contact reception to cancel."; AddAllStringsTo(g, font, brush, titleOffset, offsetY, stringHeight, s1, s2, s3, s4); }
public void DestroyStaff_GivenANullStaff_ThrowsArgumentException() { var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = new Mock <ILookupValueRepository>(); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository.Object); staffFactory.DestroyStaff(null); }
public AdminForm(DBConnection dbCon) { InitializeComponent(); this.dbCon = dbCon; sf = new StaffFactory(dbCon); this.button3.Click += button3_Click; this.dataGridView1.CellFormatting += DataGridView1_CellFormatting; }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(CreateStaffRequest request, GetStaffDtoResponse response) { var staff = new StaffFactory().Create(request.OrganizationKey, request.Name); if (staff != null) { var staffDto = Mapper.Map <Staff, StaffDto> (staff); response.DataTransferObject = staffDto; } }
public void CreateStaff_NullAgency_ThrowsArgumentException() { var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = new Mock <ILookupValueRepository>(); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository.Object); StaffProfile staffProfile = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); staffFactory.CreateStaff(null, staffProfile); }
private void populateEditInfomation() { //Lable Button this.Text = button1.Text = "Update Staff Member"; //Query sf = new StaffFactory(dbCon); List <Staff> staffMember = sf.GetStaffByID(StaffID); textBox2.Text = staffMember.ElementAtOrDefault(0).FirstName; textBox3.Text = staffMember.ElementAtOrDefault(0).LastName; textBox4.Text = staffMember.ElementAtOrDefault(0).Address; textBox6.Text = staffMember.ElementAtOrDefault(0).Postcode; textBox5.Text = staffMember.ElementAtOrDefault(0).Email; comboBox1.Text = staffMember.ElementAtOrDefault(0).JobRole; }
public void CreateStaff_GivenValidArguments_CreatesAStaff() { var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = CreateMockLookupRepository(); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository); var agency = new Mock <Agency>(); StaffProfile staffProfile = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); Staff staff = staffFactory.CreateStaff(agency.Object, staffProfile); Assert.IsNotNull(staff); }
public void DestroyStaff_GivenAStaff_StaffIsMadeTransient() { bool isTransient = false; var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = new Mock <ILookupValueRepository>(); staffRepository.Setup(s => s.MakeTransient(It.IsAny <Staff>())).Callback(() => isTransient = true); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository.Object); var staff = new Mock <Staff>(); staffFactory.DestroyStaff(staff.Object); Assert.IsTrue(isTransient); }
public ReceptionistForm(DBConnection dbCon) { InitializeComponent(); this.dbCon = dbCon; infoFac = new PatientFactory(dbCon); this.dataGridView1.SelectionChanged += dataGridView1_SelectionChanged; this.Load += ReceptionistForm_Load; this.selectedAppointments = new List <Appointment>(); af = new AppointmentFactory(dbCon); sf = new StaffFactory(dbCon); this.firstNameTextbox.KeyUp += FirstNameTextbox_KeyUp; this.lastNameTextbox.KeyUp += FirstNameTextbox_KeyUp; this.tabControl1.SelectedIndexChanged += TabControl1_SelectedIndexChanged; this.seerotadateTimePicker1.KeyUp += SeerotadateTimePicker1_KeyUp; this.d1 = DateTime.Now; this.d2 = DateTime.Now; }
public AddAppointmentForm(DBConnection dbCon, int staffID, int patientID, Appointment app, ReceptionistForm parent, bool editMode) { InitializeComponent(); this.dbCon = dbCon; this.pf = new PatientFactory(dbCon); this.sf = new StaffFactory(dbCon); this.af = new AppointmentFactory(dbCon); this.staffID = staffID; this.patientID = patientID; this.app = app; this.parent = parent; this.KeyUp += AddAppointmentForm_KeyUp; this.editMode = editMode; if (editMode) { this.Text = "Edit Appointment Details"; } QueryBuilder b = new QueryBuilder(); b.Select(Tables.ALL).From(Tables.STAFF_TABLE).Where(b.IsEqual(Tables.STAFF_TABLE.JobRole, "Doctor"), b.Or(), b.IsEqual(Tables.STAFF_TABLE.JobRole, "Nurse")); patients = pf.GetPatients(); staff = sf.GetStaff(b); if (editMode) { staff = sf.GetStaffByID(staffID); patients = pf.GetPatientsByID(patientID); firstnametextBox1.Visible = false; lastnametextBox2.Visible = false; findPatientButton.Visible = false; } else { this.statusComboBox.Enabled = false; } ctf = new CustomTableFactory(dbCon); this.statusComboBox.SelectedIndex = 0; PopulateComboBoxes(); }
public void CreateStaff_GivenValidArguments_StaffChecklistIsCreated() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = new LookupValueRepositoryFixture(); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository); var agency = new Mock <Agency>(); StaffProfile staffProfile = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); var staff = staffFactory.CreateStaff(agency.Object, staffProfile); AssertStaffChecklistCreation(staff, lookupValueRepository); } }
public void CreateStaff_GivenValidArguments_StaffIsMadePersistent() { bool isPersistent = false; var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = CreateMockLookupRepository(); staffRepository.Setup(s => s.MakePersistent(It.IsAny <Staff>())).Callback(() => isPersistent = true); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository); var agency = new Mock <Agency>(); StaffProfile staffProfile = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); staffFactory.CreateStaff(agency.Object, staffProfile); Assert.IsTrue(isPersistent); }
private void button6_Click(object sender, EventArgs e) { if (appointmentDataGridView.SelectedRows.Count > 0) { int rowNum = appointmentDataGridView.CurrentCell.RowIndex; string docFName = appointmentDataGridView.Rows[rowNum].Cells[0].Value.ToString(); string docLName = appointmentDataGridView.Rows[rowNum].Cells[1].Value.ToString(); string patFName = appointmentDataGridView.Rows[rowNum].Cells[2].Value.ToString(); string patLName = appointmentDataGridView.Rows[rowNum].Cells[3].Value.ToString(); StaffFactory sf = new StaffFactory(dbCon); PatientFactory pf = new PatientFactory(dbCon); int staffID = sf.GetStaffByName(docFName, docLName)[0].ID; int patientID = pf.GetPatientsByName(patFName, patLName)[0].ID; AddAppointmentForm aaf = new AddAppointmentForm(dbCon, staffID, patientID, selectedAppointments[rowNum], this, true); //aaf.staffIDTextBox.Text = docFName + " " + docLName; //aaf.patientIDTextBox.Text = patFName + " " + patLName; //aaf.staffIDTextBox.Enabled = false; //aaf.patientIDTextBox.Enabled = false; aaf.dateTimePicker1.Value = (DateTime)appointmentDataGridView.Rows[rowNum].Cells[4].Value; // aaf.dateTimePicker2.Format = DateTimePickerFormat.Custom; //aaf.dateTimePicker2.CustomFormat = "HH:mm tt"; // aaf.dateTimePicker2.Value = aaf.dateTimePicker2.Value.Date + (TimeSpan) appointmentDataGridView.Rows[rowNum].Cells[5].Value; Log.WriteLine("Time object is: " + appointmentDataGridView.Rows[rowNum].Cells[5].Value); aaf.statusComboBox.Text = appointmentDataGridView.Rows[rowNum].Cells[6].Value.ToString(); aaf.causeTextBox.Text = appointmentDataGridView.Rows[rowNum].Cells[7].Value.ToString(); Log.WriteLine("Index of selected timeslot is: " + aaf.timeslotcomboBox1.Items.IndexOf(appointmentDataGridView.Rows[rowNum].Cells[5].Value)); aaf.timeslotcomboBox1.SelectedIndex = aaf.timeslotcomboBox1.FindStringExact(appointmentDataGridView.Rows[rowNum].Cells[5].Value.ToString()); aaf.ValidateTimeslots(); aaf.Show(); } else { MessageBox.Show("No appointment selected.", "Please Select an Appointment"); } }
public void CreateStaff_GivenValidArguments_StaffIsEditable() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = CreateMockLookupRepository(); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository); var agency = new Mock <Agency>(); StaffProfile staffProfileWithoutMiddleName = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); var staff = staffFactory.CreateStaff(agency.Object, staffProfileWithoutMiddleName); StaffProfile staffProfileWithMiddleName = new StaffProfileBuilder().WithStaffName( new PersonNameBuilder().WithFirst("Fred").WithLast("Smith").WithMiddle("Middle Name")); staff.ReviseStaffProfile(staffProfileWithMiddleName); } }
private void button1_Click(object sender, EventArgs e) { object cbi = this.staffJobComboBox.SelectedItem; if (Program.ENFORCE_LOGIN) { if (staffIDtextBox1.Text == "" || staffPasswordtextBox2.Text == "") { MessageBox.Show("Please enter both your ID and password."); return; } int staffID; try { staffID = int.Parse(staffIDtextBox1.Text); }catch (FormatException exc1) { MessageBox.Show("Your Staff ID should be a number. Contact an Admin if you have forgotten your ID.", "Incorrect Details"); return; } string password = staffPasswordtextBox2.Text; // After grabbing the password we have to hash it string hashedPassword = Program.GetHashedString(password); Log.WriteLine("Searching for ID:{0} Password:{1}", staffID, password); StaffFactory sf = new StaffFactory(dbCon); List <Staff> s = sf.GetStaffByID(staffID); // If count is more than 1 we have found a person if (s.Count > 0) { // If the passwords match, we set their job role if (s[0].Password == hashedPassword) { cbi = s[0].JobRole; read(); } else { MessageBox.Show("Password is not correct. Please contact an Admin if you need a password reset.", "Incorrect Details"); string key = s[0].FirstName + " " + s[0].LastName; if (!incorrectLoginAttempts.ContainsKey(key)) { incorrectLoginAttempts.Add(key, 0); } incorrectLoginAttempts[key]++; read(); return; } } else { MessageBox.Show("ID not recognized. Contact an Admin if you have forgotten your ID.", "Incorrect Details"); return; } } Console.Out.WriteLine("Object: " + cbi); // Depending on which job role was returned, we create the appropriate form this.Hide(); switch (cbi) { case "Admin": AdminForm af = new AdminForm(dbCon); af.WindowState = FormWindowState.Maximized; af.ShowDialog(); break; case "Doctor": GPNurse gpnf = new GPNurse(dbCon, true); gpnf.WindowState = FormWindowState.Maximized; gpnf.ShowDialog(); break; case "Nurse": GPNurse gpnf2 = new GPNurse(dbCon, false); gpnf2.WindowState = FormWindowState.Maximized; gpnf2.ShowDialog(); break; case "Receptionist": ReceptionistForm rf = new ReceptionistForm(dbCon); rf.WindowState = FormWindowState.Maximized; rf.ShowDialog(); break; } this.staffIDtextBox1.Text = ""; this.staffPasswordtextBox2.Text = ""; this.Show(); this.staffIDtextBox1.Focus(); }
private void button1_Click(object sender, EventArgs e) { b = new QueryBuilder(); rf = new RotaFactory(dbCon); s = new Staff(); bool validatePassed; switch (StaffID) { case 0: object[] valuesToInput = new object[8]; //ID sf = new StaffFactory(dbCon); int id = sf.GetNextAvailableStaffID(); valuesToInput[0] = id; //first Name valuesToInput[1] = textBox2.Text; //Last Name valuesToInput[2] = textBox3.Text; //Job Role valuesToInput[3] = comboBox1.Text; //Password valuesToInput[4] = textBox7.Text.Equals(null) ? null : Program.GetHashedString(textBox7.ToString()); //Email valuesToInput[5] = textBox5.Text; //Address valuesToInput[6] = textBox4.Text; //Post Code valuesToInput[7] = textBox6.Text; validatePassed = ValidateInput(valuesToInput, 1); if (validatePassed) { b.Insert(Tables.STAFF_TABLE).Values(valuesToInput); MySqlCommand cmdAdd = new MySqlCommand(b.ToString(), dbCon.GetConnection()); cmdAdd.ExecuteNonQuery(); s.ID = id; rf.InsertStaff(s); MessageBox.Show("Staff Add Successful", "Completed"); this.Close(); } else { MessageBox.Show("You have not entered all the data, please fill out the form to continue.", "Error"); } break; default: //Update Staff object[] valuesToInsert = new object[12]; valuesToInsert[0] = Tables.STAFF_TABLE.FirstName; valuesToInsert[1] = textBox2.Text; valuesToInsert[2] = Tables.STAFF_TABLE.LastName; valuesToInsert[3] = textBox3.Text; valuesToInsert[4] = Tables.STAFF_TABLE.Address; valuesToInsert[5] = textBox4.Text; valuesToInsert[6] = Tables.STAFF_TABLE.Email; valuesToInsert[7] = textBox5.Text; valuesToInsert[8] = Tables.STAFF_TABLE.Postcode; valuesToInsert[9] = textBox6.Text; valuesToInsert[10] = Tables.STAFF_TABLE.JobRole; valuesToInsert[11] = comboBox1.Text; validatePassed = ValidateInput(valuesToInsert, 2); if (validatePassed) { b.Update(Tables.STAFF_TABLE).Set(valuesToInsert).Where(b.IsEqual(Tables.STAFF_TABLE.ID, StaffID)); MySqlCommand cmdEdit = new MySqlCommand(b.ToString(), dbCon.GetConnection()); cmdEdit.ExecuteNonQuery(); MessageBox.Show("Staff Edit Successful", "Completed Staff Edit"); this.Close(); } else { MessageBox.Show("You have not entered all the data, please fill out the form to continue.", "Error"); } break; } }
/* Login button */ private void Login_Click(object sender, EventArgs e) { // Get entered data username = usernameTextBox.Text; password = passwordTextBox.Text; if (attempts == 0) // If no more attempts left { // Current user locked out attemptsMsgLabel.Text = ("No more attempts, contact admin"); this.usernameTextBox.Enabled = false; this.passwordTextBox.Enabled = false; this.loginButton.Enabled = false; } else if (attempts > 0) { if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) // If something is entered into both textboxes { User account = db.LoginCheck(username, password); // Gets user with username and password entered if (account != null) // If account exists { UserFactory factory = null; if (account.IsStaff) // User is staff { factory = new StaffFactory(account.ID, account.AccountNo, account.Username, account.Password, account.FirstName, account.LastName, account.Email, account.Address, account.PostCode, account.DateOfBirth); } else if (account.IsAdmin) // User is an admin { factory = new AdminFactory(account.ID, account.AccountNo, account.Username, account.Password); } else // User is a customer { factory = new CustomerFactory(account.ID, account.AccountNo, account.Username, account.Password, account.FirstName, account.LastName, account.Email, account.Address, account.PostCode, account.DateOfBirth); } Main.CurrentUser = factory.CreateUser(); // Set current user to created user type MessageBox.Show("You are granted access"); // Conformation message this.Close(); // Close current form } else // If account does not exist { attempts--; MessageBox.Show("You are not granted access!"); // Error message attemptsMsgLabel.Text = ("You Have Only " + Convert.ToString(attempts + 1) + " Attempts Left To Try"); // Update attempts label text attemptsMsgLabel.Visible = true; } } else // If either of the textboxes are empty { MessageBox.Show("You haven't filled in all the fields. Please try again!"); // Error message } } // Clears textboxes usernameTextBox.Clear(); passwordTextBox.Clear(); }