示例#1
0
        private void RefreshList()
        {
            //clear all the items from the ListView
            lsvClass.Items.Clear(); // make sure it is not just lvXXX.Clear()

            //read all the records from the table
            List <ClassModel> classes = new ClassTable().readAll();

            //loop through all the records
            foreach (var clss in classes)
            {
                var programIndex       = new ForeignKeyHelper().findIndexOfProgramID(programList, clss.programId);
                var programDescription = programList[programIndex].name;

                var staffIndex = new ForeignKeyHelper().findIndexOfStaffID(staffList, clss.staffId);
                var staffName  = staffList[staffIndex].name;

                //create an array that will hold all the fields in a row
                var row = new string[] { clss.id.ToString(), programDescription, staffName, clss.classDate.ToString(), clss.startTime.ToString(), clss.endTime.ToString() };
                var lvi = new ListViewItem(row);

                //Save the model in the tag property so we can use it if row is selected
                lvi.Tag = clss;

                //add new row to the ListView
                lsvClass.Items.Add(lvi);
            }
            lsvClass.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
示例#2
0
        private void RefreshList()
        {
            //clear all the items from the ListView
            lsvProgram.Items.Clear(); // make sure it is not just lvXXX.Clear()

            //read all the records from the table
            List <ProgramModel> programs = new ProgramTable().readAll();

            //loop through all the records
            foreach (var program in programs)
            {
                var programVarietyIndex = new ForeignKeyHelper().findIndexOfProgramVarietyID(programVarietyList, program.programVarietyId);
                var programVarietyName  = programVarietyList[programVarietyIndex].name;

                //create an array that will hold all the fields in a row
                var row = new string[] { program.id.ToString(), program.name, programVarietyName };
                var lvi = new ListViewItem(row);

                //Save the model in the tag property so we can use it if row is selected
                lvi.Tag = program;

                //add new row to the ListView
                lsvProgram.Items.Add(lvi);
            }
            lsvProgram.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
示例#3
0
        private void RefreshList()
        {
            //clear all the items from the ListView
            lsvDog.Items.Clear(); // make sure it is not just lvXXX.Clear()

            //read all the records from the table
            List <DogModel> dogList = new DogTable().readAll();

            //loop through all the records
            foreach (var dog in dogList)
            {
                var clientIndex = new ForeignKeyHelper().findIndexOfClientID(clientList, dog.clientID);
                var clientName  = clientList[clientIndex].displayName;
                //create an array that will hold all the fields in a row
                var row = new string[] { dog.id.ToString(), dog.clientID.ToString(), clientName, dog.name, dog.age.ToString(), dog.breed, dog.experienceOrQualification.ToString() };
                var lvi = new ListViewItem(row);

                //Save the model in the tag property so we can use it if row is selected
                lvi.Tag = dog;

                //add new row to the ListView
                lsvDog.Items.Add(lvi);
            }
            lsvDog.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
示例#4
0
        private void RefreshList()
        {
            //clear all the items from the ListView
            lsvPayment.Items.Clear(); // make sure it is not just lvXXX.Clear()

            //read all the records from the table
            List <PaymentModel>    paymentList    = new PaymentTable().readAll();
            List <EnrollmentModel> enrollmentList = new EnrollmentTable().readAll();


            //loop through all the records
            foreach (var payment in paymentList)
            {
                var enrollmentIndex = new ForeignKeyHelper().findIndexOfEnrollmentID(enrollmentList, payment.enrollmentId);
                var enrollmentName  = enrollmentList[enrollmentIndex].name;
                //create an array that will hold all the fields in a row
                var row = new string[] { payment.id.ToString(), enrollmentName, payment.paymentAmountDue.ToString(), payment.paymentType, payment.paymentAmountDueDate.ToString(), payment.paymentRecieved.ToString(), payment.paymentRecievedDate.ToString(), payment.recieptIssued.ToString() };
                var lvi = new ListViewItem(row);

                //Save the model in the tag property so we can use it if row is selected
                lvi.Tag = payment;

                //add new row to the ListView
                lsvPayment.Items.Add(lvi);
            }
            lsvPayment.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
示例#5
0
        private void RefreshList()
        {
            //clear all the items from the ListView
            lsvEnrollment.Items.Clear(); // make sure it is not just lvXXX.Clear()

            //read all the records from the table
            List <EnrollmentModel> enrollmentList = new EnrollmentTable().readAll();

            //loop through all the records
            foreach (var enrollment in enrollmentList)
            {
                var programIndex       = new ForeignKeyHelper().findIndexOfProgramID(programList, enrollment.programId);
                var programDescription = programList[programIndex].name;

                var clientIndex = new ForeignKeyHelper().findIndexOfClientID(clientList, enrollment.clientId);
                var clientName  = clientList[clientIndex].displayName;

                var dogIndex = new ForeignKeyHelper().findIndexOfDogID(dogList, enrollment.dogId);
                var dogName  = dogList[dogIndex].name;

                var paymentMethodDescription = new PaymentConstants().fetchPaymentMethod(enrollment.paymentMethod);

                //create an array that will hold all the fields in a row
                var row = new string[] { enrollment.id.ToString(), enrollment.name, clientName, dogName, programDescription, paymentMethodDescription, enrollment.joinDate.ToString(), enrollment.inviteIssued.ToString() };
                var lvi = new ListViewItem(row);

                //Save the model in the tag property so we can use it if row is selected
                lvi.Tag = enrollment;

                //add new row to the ListView
                lsvEnrollment.Items.Add(lvi);
            }
            lsvEnrollment.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
示例#6
0
        private void fetchDogs()
        {
            dogList = new DogTable().readAll();

            cbxDog.DisplayMember = "Text";
            cbxDog.ValueMember   = "Value";

            foreach (var dog in dogList)
            {
                var clientIndex = new ForeignKeyHelper().findIndexOfClientID(clientList, dog.clientID);
                cbxDog.Items.Add(new { Text = dog.name + " (owned by " + clientList[clientIndex].displayName + ")", Value = dog.id });
            }
        }
示例#7
0
        public Boolean IsProgramFullyEnrolled()
        {
            List <EnrollmentModel> enrollmentList = new EnrollmentTable().readAll();
            var enrollmentForProgramList          = enrollmentList.Where(enrollment => enrollment.programId == (cbxProgram.SelectedItem as dynamic).Value);
            var enrollmentCountForProgram         = enrollmentForProgramList.Count();

            var programIndex     = new ForeignKeyHelper().findIndexOfProgramID(programList, (cbxProgram.SelectedItem as dynamic).Value);
            var programVarietyId = programList[programIndex].programVarietyId;

            var programVarietyIndex = new ForeignKeyHelper().findIndexOfProgramVarietyID(programVarietyList, programVarietyId);
            var dogSpacesMaximum    = programVarietyList[programVarietyIndex].dogSpacesMaximum;

            if (enrollmentCountForProgram == dogSpacesMaximum)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsProgramFullyEnrolled() == true)
            {
                MessageBox.Show("This program is fully enrolled already.\n\nPlease apply for a different program.", "Fully booked");
                return;
            }

            if (selectedEnrollment.id != 0 && selectedEnrollment.inviteIssued == true)
            {
                MessageBox.Show("Sorry, this record cannot be updated.\n\nPlease delete this enrollment record and create a new one.", "Cannot update record");
                return;
            }

            if (cbxProgram.Text == PLEASE_SELECT)
            {
                MessageBox.Show("Please select a program", "Missing input");
                return;
            }

            if (cbxClient.Text == PLEASE_SELECT)
            {
                MessageBox.Show("Please select a client", "Missing input");
                return;
            }

            if (cbxDog.Text == PLEASE_SELECT)
            {
                MessageBox.Show("Please select a dog", "Missing input");
                return;
            }

            if (rbtnPayInFull.Checked == false && rbtnPayByInstallments.Checked == false)
            {
                MessageBox.Show("Please select a payment method", "Missing input");
                return;
            }

            if (rbtnInviteIssuedNo.Checked == false && rbtnInviteIssuedYes.Checked == false)
            {
                MessageBox.Show("Please select a payment method", "Missing input");
                return;
            }

            try
            {
                //fill up the model with all the input fields
                selectedEnrollment.name      = cbxDog.Text + " in " + cbxProgram.Text;
                selectedEnrollment.programId = (cbxProgram.SelectedItem as dynamic).Value;
                selectedEnrollment.clientId  = (cbxClient.SelectedItem as dynamic).Value;
                selectedEnrollment.dogId     = (cbxDog.SelectedItem as dynamic).Value;
                if (rbtnPayInFull.Checked)
                {
                    selectedEnrollment.paymentMethod = 1;
                }
                if (rbtnPayByInstallments.Checked)
                {
                    selectedEnrollment.paymentMethod = 2;
                }
                selectedEnrollment.joinDate = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy"));
                if (rbtnInviteIssuedYes.Checked)
                {
                    selectedEnrollment.inviteIssued = true;
                }
                if (rbtnInviteIssuedNo.Checked)
                {
                    selectedEnrollment.inviteIssued = false;
                }


                var dogIndex    = new ForeignKeyHelper().findIndexOfDogID(dogList, selectedEnrollment.dogId);
                var clientIndex = new ForeignKeyHelper().findIndexOfClientID(clientList, dogList[dogIndex].clientID);
                if (dogList[dogIndex].clientID != selectedEnrollment.clientId)
                {
                    string message = ("Sorry, " + dogList[dogIndex].name + " belongs to " + clientList[clientIndex].displayName);
                    MessageBox.Show(message, "dog mixup");
                    return;
                }

                //The id will be 0 if New button was clicked

                var newEnrollment = false;
                if (selectedEnrollment.id == 0)
                {
                    var enrollmentId = new EnrollmentTable().create(selectedEnrollment);
                    newEnrollment         = true;
                    selectedEnrollment.id = enrollmentId;
                    MessageBox.Show("Payment is now due.\n\nPlease process payment on the payment screen.", "Payment due");
                }
                else
                {
                    new EnrollmentTable().update(selectedEnrollment);
                }

                createPayments(newEnrollment);

                //reset everything
                enableInputs();
                ClearInputs();
                RefreshList();
                selectedEnrollment = new EnrollmentModel();
            }
            catch (Exception ex)
            {
                String message = new ExceptionMessageGenerator().generateMessage(ex.Message);
                MessageBox.Show(message);
            }
        }