Example #1
0
        private void btnEquipment_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(txtFirst.Text) || String.IsNullOrEmpty(txtFirst.Text))
            {
                UniversalError ue = new UniversalError("Uh-Oh!", "Please swipe your card or enter your student ID in first");
                ue.ShowDialog();
            }
            else
            {
                if (isStudent(txtFirst.Text))
                {
                    string studentNumber = getID(txtFirst.Text).Trim();

                    Loan ln = new Loan(studentNumber);
                    this.Close();
                    ln.Show();
                }
                else
                {
                    UniversalError ue = new UniversalError("Please Register", "You must register for an account first.");
                    ue.ShowDialog();
                    txtFirst.Text = "";
                }
            }
        }
Example #2
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(txtFirst.Text) || String.IsNullOrEmpty(txtFirst.Text))
            {
                UniversalError ue = new UniversalError("Uh-Oh!", "Please swipe your card or enter your student ID in first");
                ue.ShowDialog();
            }
            else
            {
                bool currentStudent = isStudent(txtFirst.Text);

                if (currentStudent)
                {
                    bool activeSession = db.Sessions.Where(x => x.studentID == txtFirst.Text && x.active == true).Any();

                    if (activeSession)
                    {
                        UniversalError ue = new UniversalError("Uh-Oh!", "You can't edit your information until you've signed out of the lab.");
                        ue.ShowDialog();
                    }
                    else
                    {
                        Edit edit = new Edit(txtFirst.Text);
                        this.Close();
                        edit.ShowDialog();
                    }
                }
                else
                {
                    UniversalError ue = new UniversalError("Please Register", "There is no account in the system with that information. Please register.");
                    ue.ShowDialog();
                }
            }
        }
Example #3
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            stu = db.Students.First(x => x.studentnumber == studentID);

            stu.firstname     = this.txtFirst.Text.ToLower().Trim();
            stu.middleinitial = this.txtMI.Text.ToLower().Trim();
            stu.lastname      = this.txtLast.Text.ToLower().Trim();
            stu.email         = this.txtEmail.Text.ToLower().Trim();
            stu.phone         = this.txtPhone.Text.ToLower().Trim();
            stu.cardnumber    = this.txtCard.Text.ToLower().Trim();
            stu.pinnumber     = this.txtPIN.Password.ToString();

            bool problem = false;

            if (db.Students.Where(x => x.email == stu.email && x.studentnumber != studentID).Any())
            {
                problem = true;
            }
            else if (!String.IsNullOrWhiteSpace(txtCard.Text))
            {
                if (db.Students.Where(x => x.cardnumber == stu.cardnumber && x.studentnumber != studentID).Any())
                {
                    problem = true;
                }
            }

            if (problem)
            {
                UniversalError ue = new UniversalError("Error!", "Some of the information you've entered is already associated with another account.");
                ue.ShowDialog();
            }
            else
            {
                db.SaveChanges();

                SignIn           si = new SignIn();
                UniversalSuccess us = new UniversalSuccess("Yay!", "Your information has been saved.");
                us.ShowDialog();
                this.Close();
                si.Show();
            }
        }
        private void btnReturn_Click(object sender, RoutedEventArgs e)
        {
            bool isConfirmed = db.Admins.Where(x => x.pin == txtPIN.Password.ToString()).Any();
            int  recordID;
            bool isRecord;

            if (string.IsNullOrWhiteSpace(txtID.Text))
            {
                txtID.Background = Brushes.LightPink;
                UniversalError ue = new UniversalError("Error!", "Please enter the ID of the record that's being returned");
                ue.ShowDialog();
            }
            else
            {
                recordID = Int32.Parse(txtID.Text);
                isRecord = db.Loans.Where(x => x.id == recordID && x.studentID == studentId).Any();

                if (!isRecord)
                {
                    UniversalError ue = new UniversalError("Error!", "Either that's an invalid record ID, or that record doesn't belong to this student.");
                    ue.ShowDialog();
                }
                else
                {
                    if (!isConfirmed)
                    {
                        txtPIN.Background = Brushes.LightPink;
                        UniversalError ue = new UniversalError("Error!", "The Admin's password is incorrect.");
                        ue.ShowDialog();
                    }
                    else
                    {
                        Loan ln = db.Loans.Where(x => x.id == recordID).First();
                        ln.active = false;
                        db.SaveChanges();
                        UniversalSuccess us = new UniversalSuccess("Success!", "The item has been returned.");
                        us.ShowDialog();
                        this.Close();
                    }
                }
            }
        }
Example #5
0
        private void btnEquipmentIn_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(txtFirst.Text) || String.IsNullOrEmpty(txtFirst.Text))
            {
                UniversalError ue = new UniversalError("Uh-Oh!", "Please swipe your card or enter your student ID in first.");
                ue.ShowDialog();
            }
            else
            {
                String studentId;
                bool   hasEquipment;

                if (isStudent(txtFirst.Text))
                {
                    studentId = getID(txtFirst.Text);

                    hasEquipment = db.Loans.Any(x => x.studentID == studentId && x.active == true);

                    if (hasEquipment)
                    {
                        ReturnEquipment re = new ReturnEquipment(studentId);
                        txtFirst.Text = "";
                        re.ShowDialog();
                    }
                    else
                    {
                        UniversalError ue = new UniversalError("Uh-Oh", "We don't show that you have any equipment checked out.");
                        txtFirst.Text = "";
                        ue.ShowDialog();
                    }
                }
                else
                {
                    UniversalError ue = new UniversalError("Please Register", "You must register for an account first.");
                    ue.ShowDialog();
                }
            }
        }
Example #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtFirst.Text) || txtFirst.Text == "REQUIRED")
            {
                txtFirst.Background = Brushes.LightPink;
                txtFirst.Text       = "REQUIRED";
            }
            else if (string.IsNullOrWhiteSpace(txtLast.Text) || txtLast.Text == "REQUIRED")
            {
                txtLast.Background = Brushes.LightPink;
                txtLast.Text       = "REQUIRED";
            }
            else if (string.IsNullOrWhiteSpace(txtEmail.Text) || txtEmail.Text == "REQUIRED")
            {
                txtEmail.Background = Brushes.LightPink;
                txtEmail.Text       = "REQUIRED";
            }
            else if (string.IsNullOrWhiteSpace(txtID.Text) || txtID.Text == "REQUIRED")
            {
                txtID.Background = Brushes.LightPink;
                txtID.Text       = "REQUIRED";
            }
            else if (string.IsNullOrWhiteSpace(txtPIN.Password.ToString()))
            {
                txtPIN.Background = Brushes.LightPink;
            }
            else
            {
                alreadyRegistered = false;

                if (db.Students.Where(x => x.studentnumber == txtID.Text).Any())
                {
                    alreadyRegistered = true;
                }
                else if (db.Students.Where(x => x.email == txtEmail.Text).Any())
                {
                    alreadyRegistered = true;
                }
                else if (!String.IsNullOrWhiteSpace(txtCard.Text))
                {
                    if (db.Students.Where(x => x.cardnumber == txtCard.Text).Any())
                    {
                        alreadyRegistered = true;
                    }
                }

                if (alreadyRegistered)
                {
                    UniversalError ue = new UniversalError("Error!", "Some of the information you included is already associated with another account.");
                    ue.ShowDialog();
                }
                else
                {
                    stu = new Student();

                    stu.firstname     = txtFirst.Text.ToLower().Trim();
                    stu.lastname      = txtLast.Text.ToLower().Trim();
                    stu.middleinitial = txtMI.Text.ToLower().Trim();
                    stu.email         = txtEmail.Text.ToLower().Trim();
                    stu.phone         = txtPhone.Text.Trim();
                    stu.studentnumber = txtID.Text.Trim();
                    stu.cardnumber    = txtCard.Text.Trim();
                    stu.pinnumber     = txtPIN.Password.ToString().Trim();

                    db.Students.Add(stu);
                    db.SaveChanges();

                    txtFirst.Text = "";
                    txtMI.Text    = "";
                    txtLast.Text  = "";
                    txtMI.Text    = "";
                    txtEmail.Text = "";
                    txtPhone.Text = "";
                    txtID.Text    = "";
                    txtCard.Text  = "";
                    txtPIN.Clear();

                    txtFirst.Background = Brushes.White;
                    txtLast.Background  = Brushes.White;
                    txtEmail.Background = Brushes.White;
                    txtID.Background    = Brushes.White;
                    txtPIN.Background   = Brushes.White;

                    UniversalSuccess us     = new UniversalSuccess("Account Created!", "To sign in, enter your student number or card number on the home screen.");
                    SignIn           signIn = new SignIn();
                    us.ShowDialog();
                    this.Close();
                    signIn.ShowDialog();
                }
            }
        }
Example #7
0
        private void btnCheckOut_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(txtID.Text))
            {
                txtID.Background = Brushes.LightPink;
            }
            else if (String.IsNullOrWhiteSpace(cmbEquipment.Text))
            {
                cmbEquipment.Background = Brushes.LightPink;
            }
            else if (String.IsNullOrWhiteSpace(txtPin.Password.ToString()))
            {
                txtPin.Background = Brushes.LightPink;
            }
            else if (String.IsNullOrWhiteSpace(txtAdminPin.Password.ToString()))
            {
                txtAdminPin.Background = Brushes.LightPink;
            }
            else
            {
                Student stu         = new Student();
                bool    isConfirmed = false;

                stu = db.Students.Where(x => x.studentnumber == txtID.Text || x.cardnumber == txtID.Text).First();

                if (txtPin.Password.ToString() != stu.pinnumber)
                {
                    UniversalError ue = new UniversalError("Error!", "This is not the correct pin number for " + stu.firstname + "'s account.");
                    ue.ShowDialog();
                    txtPin.Background = Brushes.LightPink;
                }
                else
                {
                    isConfirmed = db.Admins.Where(x => x.pin == txtAdminPin.Password.ToString()).Any();

                    if (!isConfirmed)
                    {
                        UniversalError ue = new UniversalError("Error!", "The Admin's password is incorrect.");
                        ue.ShowDialog();
                        txtAdminPin.Background = Brushes.LightPink;
                    }
                    else
                    {
                        //Create a new loan here and add it to the database.
                        Loan loan = new Loan(stu.studentnumber);
                        loan.studentID     = stu.studentnumber;
                        loan.description   = txtNote.Text;
                        loan.tagnumber     = txtTag.Text;
                        loan.loandate      = DateTime.Today.Date;
                        loan.serialnumber  = txtSerial.Text;
                        loan.equipmenttype = cmbEquipment.Text;
                        loan.active        = true;

                        db.Loans.Add(loan);
                        db.SaveChanges();

                        SignIn           pop = new SignIn();
                        UniversalSuccess us  = new UniversalSuccess("Success!", "The item has been checked out.");
                        us.ShowDialog();
                        this.Close();
                        pop.Show();
                    }
                }
            }
        }