Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="form"></param>
 public AddPrescription(DBConnection connection, GPNurse form)
 {
     this.dbCon         = connection;
     getMedications     = new MedicineInFactory(dbCon);
     managePrescription = new PrescriptionFactory(dbCon);
     medFact            = new MedicationFactory(dbCon);
     controlGP          = form;
     InitializeComponent();
     showMedications();
     this.FormClosing += AddPrescription_FormClosing;
 }
Beispiel #2
0
        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();
        }