Ejemplo n.º 1
0
        private void courseChangeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var number = new frmSubmitText("Learner Number", "Please enter learner number");
            number.ShowDialog();
            while (Database.Count("learner_details", "LearnerNumber = '" + number.Selection + "' AND Division = '" +
                clsGlobal.loggedOnUserDivison + "'") == 0)
            {
                if (number.Selection == "***")
                    return;
                MessageBox.Show("Invalid Learner Number", "Error");
                number.ShowDialog();
            }
            var reason = new frmSubmitText("Reason", "Please enter reason for course change");
            reason.ShowDialog();
            var list = new ArrayList();
            var courses = Database.Query("courses", "Not Type = 'CC'");
            foreach (DataRow theRow in courses.Tables["courses"].Rows)
            {
                list.Add(theRow["Name"]);
            }
            var frmSelect = new frmSelectSingle("Select Course", "New Course to Enroll In", list);
            frmSelect.ShowDialog();
            if (frmSelect.Selection == "***" || reason.Selection == "***")
                return;
            var report = new rptCourseChange();
            var data =
                Database.Row("learner_details a, enrollments b, enrollmentscourses c, courses d",
                               "a.Division = '" + clsGlobal.loggedOnUserDivison + "' AND a.LearnerNumber = '" +
                               number.Selection + "' AND b.LearnerKey = a.LearnerKey AND c.idEnrollments = b.idEnrollments AND" +
                               " d.idCourses = c.idCourses");
            report.DataDefinition.FormulaFields["date"].Text = "\"" + DateTime.Now.ToLongDateString() + "\"";
            report.DataDefinition.FormulaFields["college"].Text = "\"" + clsGlobal.LoggedOnUserDivision + "\"";
            report.DataDefinition.FormulaFields["principle"].Text = "\"" + clsGlobal.DivisionPrinciple + "\"";
            report.DataDefinition.FormulaFields["learnerNumber"].Text = "\"" + number.Selection + "\"";
            report.DataDefinition.FormulaFields["reason"].Text = "\"" + reason.Selection + "\"";
            report.DataDefinition.FormulaFields["currentProgramme"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";
            report.DataDefinition.FormulaFields["learnerName"].Text = "\"" + Convert.ToString(data["Name"]) + " " +
                                                                      Convert.ToString(data["Surname"]) + "\"";
            report.DataDefinition.FormulaFields["newProgram"].Text = "\"" + frmSelect.Selection + "\"";
            //report.DataDefinition.FormulaFields["course"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";

            //logs.WriteXml(@"C:\tmpXml.xml");
            var frmReport = new frmReport(report) { Text = "Cancellation Request" };
            frmReport.ShowDialog();
        }
Ejemplo n.º 2
0
        private void ScanFromTextBox(object sender, EventArgs e)
        {
            panel1.Visible = false;
            noteLabel.Text = "";
            specialNeedsLabel.Text = "";
            alertLabel.Text = "";
            nameLabel.Text = "";
            statusLabel.Text = "";
            _pastelString = "";
            _scanNumber = scanText.Text;
            _checkNotesFlag = false;

            #region Employees

            if (Database.Count("employees", "idNumber = '" + _scanNumber + "'") > 0)
            {
                var employee = Database.Row("employees", "idNumber = '" + _scanNumber + "'");
                _scanNumber = (string)employee["employeeNumber"];
                if (radOut.Checked)
                {
                    if (Database.Count("scannedEmployees", "employeeNumber = '" + _scanNumber + "'") == 0)
                    {
                        MessageBox.Show("This Employee: " + _scanNumber + " is not scanned in.", "Employee Not Scanned In");

                        return;
                    }

                    Database.Command("INSERT INTO employeeActivity(`employeeNumber`,`dateTime`,division, `type`, details,`user`) VALUES('" + _scanNumber + "','" +
                    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + GlobalProperties.loggedOnUserDivison + "','Scan','Out','" + GlobalProperties.LoggedOnUser + "')");
                    int insertId = (int)Database.RetrieveDouble("SELECT MAX(id) FROM employeeActivity WHERE employeeNumber = '" + _scanNumber + "'");
                    var link = Database.Row(@"SELECT * FROM scannedEmployees se JOIN employees e ON e.employeeNumber = se.employeeNumber
                        WHERE se.employeeNumber = '" + _scanNumber + "'");
                    Database.Command("UPDATE employeeActivity SET partnerID = '" + insertId + "' WHERE id = " + link["scanID"]);
                    Database.Command("DELETE FROM scannedEmployees WHERE employeeNumber = '" + _scanNumber + "'");

                    AddNode(new ListNode(DateTime.Now, _scanNumber,
                        Convert.ToString(link["Name"]) + " " + Convert.ToString(link["Surname"]), "Out", "Access Granted",null,null,null));
                }
                else
                {
                    if (Database.Count("scannedEmployees", "employeeNumber = '" + _scanNumber + "'") > 0)
                    {
                        MessageBox.Show("This Employee: " + _scanNumber + " is already scanned in.", "Employee Already Scanned In");
                        return;
                    }

                    var link = Database.Row(@"SELECT * FROM scannedEmployees se RIGHT JOIN employees e ON e.employeeNumber = se.employeeNumber
                        WHERE e.employeeNumber = '" + _scanNumber + "'");

                    if (Convert.ToString(link["status"]) == "Maternity Leave")
                    {
                        AddNode(new ListNode(DateTime.Now, _scanNumber,
                        Convert.ToString(link["Name"]) + " " + Convert.ToString(link["Surname"]), "In", "Access Denied",null,"This Employee is on Maternity Leave",
                        "This employee has not been scanned in."));
                        return;
                    }

                    Database.Command("INSERT INTO employeeActivity(`employeeNumber`,`dateTime`,division, `type`, details, `user`) VALUES('" + _scanNumber + "','" +
                    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + GlobalProperties.loggedOnUserDivison + "','Scan','In','" + GlobalProperties.LoggedOnUser + "')");

                    int insertId = (int)Database.RetrieveDouble("SELECT MAX(id) FROM employeeActivity WHERE employeeNumber = '" + _scanNumber + "'");

                    Database.Command("INSERT INTO scannedEmployees(employeeNumber,scanId) VALUES('" + _scanNumber + "'," + insertId + ")");
                    AddNode(new ListNode(DateTime.Now, _scanNumber,
                        Convert.ToString(link["Name"]) + " " + Convert.ToString(link["Surname"]), "In", "Access Granted",null,null,null));
                }
                scanText.Text = "";
            }
            #endregion

            #region Learners

            else
            {
                _scanNumber = LearnerNumberHelpers.PrefixedLearnerNumber(CleanBarcode(scanText.Text), GlobalProperties.loggedOnUserDivison);
                if (!LearnerExistsQuery.Run(_scanNumber, GlobalProperties.loggedOnUserDivison))
                {
                    MessageBox.Show("Learner doesn't exist!");
                    return;
                }

                var learner = Database.Row("learner_details",
                                               "LearnerNumber = '" + _scanNumber + "' AND division = '" +
                                               GlobalProperties.loggedOnUserDivison + "'");

                if (learner["matricCert"] == DBNull.Value)
                {
                    var levels = Database.Retrieve("qualificationLevels");
                    var theList = new ArrayList();
                    foreach (DataRow theRow in levels.Tables[0].Rows)
                    {
                        theList.Add(theRow["Name"]);
                    }

                    var listForm = new frmSelectSingle("Select Level", "Please select highest qualification for learner:", theList);
                    listForm.ShowDialog();
                    if (listForm.Selection == "***") return;
                    Database.Command("UPDATE learner_details SET matricCert = "+
                        Database.Retrieve("qualificationLevels","Name = '" + listForm.Selection + "'","idQualificationLevels") +
                        " WHERE ID = '" + learner["ID"] + "'");

                }

                var id = Convert.ToString(learner["ID"]);
                var name = Convert.ToString(learner["Name"]) + " " + Convert.ToString(learner["Surname"]);

                if (radOut.Checked && !radAdmin.Checked)
                {
                    ScanOutLearner(_scanNumber, name);
                    scanText.Text = "";
                    CheckNotes(id);
                }
                else
                {
                    if (!radAdmin.Checked && (radIn.Checked || radWorkshop.Checked || radMeeting.Checked))
                    {
                        if (!ScannedInCheck(_scanNumber))
                        {
                            MessageBox.Show("User already scanned in");
                            scanText.Text = "";
                            return;
                        }
                    }
                    if (radIn.Checked && !SessionCheck())
                    {
                        MessageBox.Show(
                            "Cannot Scan in new learners before previous session's learners are scanned out");
                        scanText.Text = "";
                        return;
                    }
                    if (!radAdmin.Checked && clsFunctions.GetCurrentSession() == "Out of Session")
                    {
                        MessageBox.Show("Not acception scan in's now: Out of Session");
                        scanText.Text = "";
                        return;
                    }
                    try
                    {
                        id = Convert.ToString(learner["ID"]);
                        var accesGranted = AccessGrant();
                        if (!accesGranted)
                        {
                            if (!radAdmin.Checked)
                            AddNode(new ListNode(DateTime.Now, _scanNumber, name, "In", "Access Denied",
                                _pastelString, CheckNotes(id), _accessDeniedReason));
                            else
                                SetNotes(AccessState.Denied,name, _scanNumber,_pastelString,CheckNotes(id),_accessDeniedReason);
                        }
                        else
                        {
                            alertLabel.Text += CheckResubs();
                            alertLabel.Text += CheckBirthday();
                            specialNeedsLabel.Text += CheckNotes(id);
                            alertLabel.Text += CheckRegistration();
                            noteLabel.Text = _pastelString;
                            if (!radAdmin.Checked)
                                AddNode(new ListNode(DateTime.Now, _scanNumber, name, "In", "Access Granted", noteLabel.Text, specialNeedsLabel.Text, alertLabel.Text));
                            else
                                SetNotes(AccessState.Granted, name, _scanNumber, _pastelString, CheckNotes(id), _accessDeniedReason);
                        }

                        if (!radAdmin.Checked)
                        {
                            if (radIn.Checked)
                                ScanInLearner(_scanNumber, ScanType.Attendance,accesGranted);
                            if (radWorkshop.Checked)
                                ScanInLearner(_scanNumber, ScanType.Workshop,accesGranted);
                            if (radMeeting.Checked)
                                ScanInLearner(_scanNumber, ScanType.Meeting,accesGranted);
                            if (radExam.Checked)
                                ScanInLearner(_scanNumber, ScanType.Exam,accesGranted);
                        }

                    }
                    catch(Exception error)
                    {
                        new ExceptionHandler
                        {
                            Mode = Mode.Offiline,
                            LoggedOnUser = GlobalProperties.loggedOnUser,
                            Exception = error
                        }.handleException();
                        MessageBox.Show(@"An error occurred when trying to scan learner!");
                    }

                    scanText.Text = "";
                    scanText.Focus();
                }
            }

            #endregion

            MyHandler();
        }
Ejemplo n.º 3
0
        private void transfersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var number = new frmSubmitText("Learner Number", "Please enter learner number");
            number.ShowDialog();
            while(Database.Count("learner_details","LearnerNumber = '" + number.Selection + "' AND Division = '" +
                clsGlobal.loggedOnUserDivison + "'") == 0)
            {
                if (number.Selection == "***")
                    return;
                MessageBox.Show("Invalid Learner Number", "Error");
                number.ShowDialog();
            }
            var divisions = Database.Retrieve("division");
            var theList = new ArrayList();
            foreach (DataRow theRow in divisions.Tables[0].Rows)
            {
                theList.Add(Convert.ToString(theRow["DivisionName"]));
            }
            var select = new frmSelectSingle("Division", "Please select division", theList);
            select.ShowDialog();
            var report = new rptTransfer();
            var data =
                Database.Row("learner_details a, enrollments b, enrollmentscourses c, courses d, paymentinfo e",
                               "a.Division = '" + clsGlobal.loggedOnUserDivison + "' AND a.LearnerNumber = '" +
                               number.Selection + "' AND b.LearnerKey = a.LearnerKey AND c.idEnrollments = b.idEnrollments AND"+
                               " e.idEnrollments = c.idEnrollments AND d.idCourses = c.idCourses");
            report.DataDefinition.FormulaFields["learnerNumber"].Text = "\"" + number.Selection + "\"";
            report.DataDefinition.FormulaFields["transferBranch"].Text = "\"" + select.Selection + "\"";
            report.DataDefinition.FormulaFields["learnerName"].Text = "\"" + Convert.ToString(data["Name"]) + " " +
                                                                      Convert.ToString(data["Surname"]) + "\"";
            report.DataDefinition.FormulaFields["learnerTel"].Text = "\"" + Convert.ToString(data["Tel1"]) + "\"";
            report.DataDefinition.FormulaFields["Date"].Text = "\"" + DateTime.Now.ToString("dd/MM/yyyy") + "\"";
            report.DataDefinition.FormulaFields["Branch"].Text = "\"" + clsGlobal.LoggedOnUserDivision + "\"";
            report.DataDefinition.FormulaFields["clerk"].Text = "\"" + clsGlobal.LoggedOnUser + "\"";
            report.DataDefinition.FormulaFields["course"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";
            report.DataDefinition.FormulaFields["coursePrice"].Text = "\"" + Convert.ToString(data["totalContractPrice"]) + "\"";
            //report.DataDefinition.FormulaFields["course"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";

            //logs.WriteXml(@"C:\tmpXml.xml");
            var frmReport = new frmReport(report) {Text = "Transfer Request"};
            frmReport.ShowDialog();
        }