示例#1
0
        private void button3_Click(object sender, EventArgs e)
        {
            //cancel button clicked
            home h = new home();

            h.Show();
            Close();
        }
示例#2
0
        private void fadeOut_Tick(object sender, EventArgs e)
        {
            errorLabel.Visible = false;
            for (double fade = .99; fade > 0; fade = fade - .01)
            {
                Console.WriteLine("this is how we dew fade");
                this.Opacity = fade;
            }
            fadeOut.Stop();

            home h = new home();

            h.Show();
            Close();
        }
示例#3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            // SUBMIT BUTTON CLICKED //
            daIndex  = 0;
            daOne    = new int[100];
            daOne[0] = -10;
            //set error visibility
            error.ForeColor = System.Drawing.Color.LightGreen;
            error.Text      = "Creating Report...";
            error.Visible   = true;
            bool pass    = true;
            bool proceed = true;

            //check box fileters
            if (checkBox1.Checked == true)
            {
                ch1 = true;
            }
            if (checkBox2.Checked == true)
            {
                ch2 = true;
            }
            if (checkBox3.Checked == true)
            {
                ch3 = true;
            }

            //combo box filters


            if (comboBox1.SelectedIndex == 0)
            {
                cb1 = 1;
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                cb1 = 2;
            }
            else if (comboBox1.SelectedIndex == 2)
            {
                cb1 = 3;
            }

            if (comboBox2.SelectedIndex == 0)
            {
                cb2 = 1;
            }
            if (comboBox2.SelectedIndex == 1)
            {
                cb2 = 2;
            }
            else if (comboBox2.SelectedIndex == 2)
            {
                cb2 = 3;
            }

            //make sure combo box's are not both empty
            if (comboBox1.SelectedIndex == 0 || comboBox1.SelectedIndex == 1 || comboBox1.SelectedIndex == 2)
            {
                Console.WriteLine("past stage 1");
                if (comboBox2.SelectedIndex == 0 || comboBox2.SelectedIndex == 1 || comboBox2.SelectedIndex == 2)
                {
                    Console.WriteLine("past stage 2");
                    if (button4.BackColor.Equals(normalcola) == false || button6.BackColor.Equals(normalcola) == false)
                    {
                        //test if everything was left blank
                        if (a == false && b == false && c == false && d == false && el == false && f == false && g == false && h == false)
                        {
                            //error nothing was selected
                            error.Text    = "*At least one field selection is required";
                            error.Visible = true;
                        }
                        else
                        {
                            //something was selected continue
                            //open fbla database
                            Excel.Application myExcelApp2;
                            Excel.Workbooks   myExcelWorkbooks2;
                            Excel.Workbook    myExcelWorkbook2;
                            object            misValue = System.Reflection.Missing.Value;
                            Console.WriteLine("stuff has been created");
                            myExcelApp2               = new Excel.Application();
                            myExcelApp2.Visible       = false;
                            myExcelApp2.DisplayAlerts = false;

                            Console.WriteLine("More stuff has been created lljlkjlj");
                            string fileName = "C:\\fblaManager\\fblaDatabase.xls";
                            //myExcelWorkbooks2 = myExcelApp2.Workbooks;
                            myExcelWorkbook2 = myExcelApp2.Workbooks.Open(fileName, misValue, misValue, misValue, "lambda3b", misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);
                            Excel.Worksheet myExcelWorksheet2 = (Excel.Worksheet)myExcelWorkbook2.ActiveSheet;

                            //now read and find results based on user filters
                            //row read x int
                            int x = 0;
                            while (data != "" || x == 0)
                            {
                                pass = true;
                                //if first intracation
                                if (x == 0)
                                {
                                    x += 1;
                                }
                                data = myExcelWorksheet2.get_Range("A" + x, misValue).Formula.ToString();
                                //school checkmark filter
                                if (ch1 == true)
                                {
                                    if (t1.Text == myExcelWorksheet2.get_Range("D" + x).Formula.ToString())
                                    {
                                        //passes the filter
                                    }
                                    else
                                    {
                                        //does not pass the filter
                                        pass = false;
                                    }
                                }
                                //grade checkmark filter
                                if (ch2 == true)
                                {
                                    if (t2.Text == myExcelWorksheet2.get_Range("E" + x).Formula.ToString())
                                    {
                                        Console.WriteLine("Passed the filter!");
                                        //passes the filter
                                    }
                                    else
                                    {
                                        //does not pass the filter
                                        pass = false;
                                    }
                                }
                                //state checkmark filter
                                if (ch3 == true)
                                {
                                    if (t3.Text == myExcelWorksheet2.get_Range("F" + x).Formula.ToString())
                                    {
                                        //passes the filter
                                    }
                                    else
                                    {
                                        //does not pas the filter
                                        pass = false;
                                    }
                                }

                                //if it passed checkmark filters
                                if (pass == true)
                                {
                                    //passed
                                    //see if it passes the combobox filter
                                    if (cb1 == 1)
                                    {
                                        //active state doesnt matter
                                        pass = true;
                                    }
                                    else if (cb1 == 2)
                                    {
                                        //active only
                                        if ("yes" == myExcelWorksheet2.get_Range("I" + x).Formula.ToString())
                                        {
                                            pass = true;
                                        }
                                        else
                                        {
                                            //person is not active
                                            pass = false;
                                        }
                                    }
                                    else if (cb1 == 3)
                                    {
                                        //nonactive only
                                        if ("no" == myExcelWorksheet2.get_Range("I" + x).Formula.ToString())
                                        {
                                            pass = true;
                                        }
                                        else
                                        {
                                            //person is not nonactive
                                            pass = false;
                                        }
                                    }

                                    //we finished filter tests
                                    if (pass == true)
                                    {
                                        Console.WriteLine("setting daOne[daIndex] to " + daIndex + " [] " + x);
                                        daOne[daIndex] = x;
                                        daIndex++;
                                    }
                                    else
                                    {
                                        //just move on again, current x does not qualify
                                        Console.WriteLine(x + " Did not qualify");
                                    }
                                }
                                else
                                {
                                    //didnt pass
                                }
                                x++;
                            }
                            //read loop is done!

                            //check if there are no results
                            if (daOne[0] == -10)
                            {
                                //no results
                                error.Text    = "*No results";
                                error.Visible = true;
                            }
                            else
                            {
                                //there were results
                                //now create report not closing read file cuz we still need to read and write
                                //create temp file
                                Excel.Application startup = new Excel.Application();
                                startup.Visible       = false;
                                startup.DisplayAlerts = false;
                                Excel.Workbooks startWorkbooks;
                                Excel.Workbook  startWorkbook;
                                Excel.Worksheet startWorksheet;
                                object          misValue2 = System.Reflection.Missing.Value;
                                startWorkbooks      = startup.Workbooks;
                                startWorkbook       = startup.Workbooks.Add(misValue2);
                                startWorksheet      = (Excel.Worksheet)startWorkbook.ActiveSheet;
                                startWorksheet.Name = "FBLA Report";
                                //write to that temp file
                                string[] alpha    = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" };
                                int      daNumber = daOne.Length;
                                Console.WriteLine("The length of daONe.length is " + daNumber);
                                int nRow = 1;
                                int cd   = 0;

                                int readRow = -1;
                                for (int bb = 0; bb < daNumber; bb++)
                                {
                                    if (nRow == 1)
                                    {
                                        bb = 0;
                                    }
                                    cd      = 0;
                                    readRow = daOne[bb];
                                    Console.WriteLine(readRow.ToString());
                                    if (readRow != 0)
                                    {
                                        Console.WriteLine("Another one");
                                        Console.WriteLine(readRow.ToString());
                                        if (a == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "MemberNumber"; cd++;
                                            }
                                            else
                                            {
                                                Console.WriteLine("Done Deal a == true");
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("A" + readRow, misValue).Formula.ToString();
                                                cd++;
                                            }
                                        }
                                        if (b == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "First"; cd++;
                                            }
                                            else
                                            {
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("B" + readRow, misValue).Formula.ToString();
                                                cd++;
                                            }
                                        }
                                        if (c == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "Last"; cd++;
                                            }
                                            else
                                            {
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("C" + readRow, misValue).Formula.ToString();
                                                cd++;
                                            }
                                        }
                                        if (d == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "School"; cd++;
                                            }
                                            else
                                            {
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("D" + readRow, misValue).Formula.ToString();
                                                cd++;
                                            }
                                        }
                                        if (el == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "Grade"; cd++;
                                            }
                                            else
                                            {
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("E" + readRow, misValue).Formula.ToString();
                                                cd++;
                                            }
                                        }
                                        if (f == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "State"; cd++;
                                            }
                                            else
                                            {
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("F" + readRow, misValue).Formula.ToString();
                                                cd++;
                                            }
                                        }
                                        if (g == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "Email"; cd++;
                                            }
                                            else
                                            {
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("G" + readRow, misValue).Formula.ToString();
                                                cd++;
                                            }
                                        }
                                        if (h == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "Year Joined"; cd++;
                                            }
                                            else
                                            {
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("H" + readRow, misValue).Formula.ToString();
                                                cd++;
                                            }
                                        }
                                        if (i == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "Active?";
                                            }
                                            else
                                            {
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("I" + readRow, misValue).Formula.ToString();
                                            }
                                            cd++;
                                        }

                                        if (j == true)
                                        {
                                            if (nRow == 1)
                                            {
                                                startWorksheet.get_Range(alpha[cd] + 1, misValue2).Formula = "Money Owed";
                                            }
                                            else
                                            {
                                                startWorksheet.get_Range(alpha[cd] + nRow, misValue2).Formula = myExcelWorksheet2.get_Range("J" + readRow, misValue).Formula.ToString();
                                                cd++;
                                            }
                                        }


                                        if (nRow == 1)
                                        {
                                            cd = 0;
                                        }

                                        nRow++;
                                    }
                                    else
                                    {
                                        //dont add this one
                                    }
                                }
                                Console.WriteLine("done writing");
                                //done writing now to view save print based on user standards and close everything out
                                //close reading stream
                                myExcelWorkbook2.Close();
                                myExcelApp2.Quit();
                                Console.WriteLine("done closing and quitting excelapp2 and worksheet2");
                                //format width autofit

                                Excel.Range excelCells = (Excel.Range)startWorksheet.UsedRange;
                                excelCells.Columns.AutoFit();
                                excelCells.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;

                                error.Visible = false;
                                //save?
                                if (l == true)
                                {
                                    startup.Visible       = true;
                                    startup.DisplayAlerts = true;
                                    startup.UserControl   = true;
                                    try
                                    {
                                        startWorkbook.SaveCopyAs(misValue);
                                    }
                                    catch
                                    {
                                        //whatever big deal
                                    }
                                }

                                //print?
                                if (m == true)
                                {
                                    startup.Visible       = true;
                                    startup.DisplayAlerts = true;
                                    try
                                    {
                                        startWorksheet.PrintPreview();
                                        //don't do .printoutEx() bad dont do
                                    }
                                    catch
                                    {
                                        //whatever big deal
                                    }
                                }

                                //view?
                                if (k == true)
                                {
                                    startup.Visible = true;
                                }
                                //do not quit written file for it is in eyes of user

                                home backHome = new home();
                                backHome.Show();
                                Close();
                            }
                        }
                    }
                    else
                    {
                        //something must be selected
                        error.Text    = "*At least view or print must be selected";
                        error.Visible = true;
                    }
                }
                else
                {
                    error.Text    = "*Combo boxes cannot remain empty";
                    error.Visible = true;
                }
            }
            else
            {
                error.Text    = "*Combo boxes cannot remain null";
                error.Visible = true;
                proceed       = false;
            }
        }