/// <summary>
        /// Clear the filters and set everything back to default.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_clearFilters_Click(object sender, EventArgs e)
        {
            Filters.ClbDictionaryValues.Clear();
            Filters.FitlerValues.Clear();
            Filters.FilterQuery            = string.Empty;
            Filters.SecondaryFilterQuery   = string.Empty;
            Filters.PrDateRangeFilterAdded = false;
            Filters.PoDateRangeFilterAdded = false;

            HasFiltersAdded();
            if (!FiltersAdded)
            {
                FiltersApplied = false;
                overallData    = new Overall();
                PRPO_DB_Utils.DataLoadProcessStarted = false;
                PRPO_DB_Utils.DataLoaded             = false;
                PRPO_DB_Utils.CompletedDataLoads     = 0;
                PRPO_DB_Utils.ScheduledDataLoads     = 0;
                DataLoaderTimer.Start();
            }
            else
            {
                MessageBox.Show("Loading data with no filters but filters has filters applied.");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function will be called when the form loads.
        /// </summary>
        /// <param name="sender">The form</param>
        /// <param name="e">The load event</param>
        private void KPA_KPI_UI_Load(object sender, EventArgs e)
        {
            mainNavActiveBtn          = btn_Dashboard; // set the active button as the first button (Dashboard)
            FilterUtils.UpdateFilter += UpdateFilters;


            if (PRPO_DB_Utils.DatabaseConnection != null)
            {
                try
                {
                    PRPO_DB_Utils.ConnectToDatabase();
                    btn_DatabaseConnectionStatus.Image = Properties.Resources.databaseConn_Connected_Icon;
                    Logger.Log(AppDirectoryUtils.LogFiles.DbConnectionEvents, "Successfully Connected to MS Access Database");

                    if (AccessUtils.US_PRPO_TableExists && AccessUtils.MX_PRPO_TableExists)
                    {
                        NavigationLocked = true;
                        pnl_CountrySelector.BringToFront();
                    }
                    else if (AccessUtils.US_PRPO_TableExists)
                    {
                        Overall.SelectedCountry = AccessInfo.MainTables.US_PRPO;
                        PRPO_DB_Utils.DataLoadProcessStarted = false;
                        PRPO_DB_Utils.DataLoaded             = false;
                        PRPO_DB_Utils.CompletedDataLoads     = 0;
                        PRPO_DB_Utils.ScheduledDataLoads     = 0;
                        DataLoaderTimer.Start();
                    }
                    else // There is a Mexico table within the database.
                    {
                        Overall.SelectedCountry = AccessInfo.MainTables.MX_PRPO;
                        PRPO_DB_Utils.DataLoadProcessStarted = false;
                        PRPO_DB_Utils.DataLoaded             = false;
                        PRPO_DB_Utils.CompletedDataLoads     = 0;
                        PRPO_DB_Utils.ScheduledDataLoads     = 0;
                        DataLoaderTimer.Start();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Application load error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }
            else
            {
                pnl_loadingScreen.Visible = false;
                tblpnl_DragDrop.BringToFront();
            }
        }
        /// <summary>
        /// Triggered when the user clicks the load data button. Once this button is clicked, the data timer
        /// will be triggered.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_LoadData_Click(object sender, EventArgs e)
        {
            if (btn_usSwitch.Value)
            {
                Overall.SelectedCountry = AccessInfo.MainTables.US_PRPO;
                lbl_country.Text        = "United States";
            }
            else
            {
                Overall.SelectedCountry = AccessInfo.MainTables.MX_PRPO;
                lbl_country.Text        = "Mexico";
            }



            overallData = new Overall();
            PRPO_DB_Utils.DataLoadProcessStarted = false;
            PRPO_DB_Utils.DataLoaded             = false;
            PRPO_DB_Utils.CompletedDataLoads     = 0;
            PRPO_DB_Utils.ScheduledDataLoads     = 0;
            DataLoaderTimer.Start();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Once an import, filter apply and filter removal occur, this timer will initiate. The data contained within
        /// the access database will then be loaded into the application where calculations will occur.        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataLoaderTimer_Tick(object sender, EventArgs e)
        {
            NavigationLocked = true;
            if (!PRPO_DB_Utils.DataLoadProcessStarted)
            {
                PRPO_DB_Utils.DataLoadProcessStarted = true;
                PRPO_DB_Utils.KPITablesLoaded        = false;

                pnl_activePage.Controls.Clear();
                pnl_loadingScreen.Visible = true;
                pnl_loadingScreen.BringToFront();
                lbl_loadingStatus.Text = "Loading Data...";


                Thread KPA_PlanThread = new Thread(() =>
                {
                    overallData.kpa.plan.LoadData();
                });


                Thread KPA_PurchThread = new Thread(() =>
                {
                    overallData.kpa.purch.LoadData();
                });


                Thread KPA_PurchSubThread = new Thread(() =>
                {
                    overallData.kpa.purchSub.LoadData();
                });


                Thread KPA_PurchTotalThread = new Thread(() =>
                {
                    overallData.kpa.purchTotal.LoadData();
                });


                Thread KPA_FollowUpThread = new Thread(() =>
                {
                    overallData.kpa.followUp.LoadData();
                });


                Thread KPA_HotJobs = new Thread(() =>
                {
                    overallData.kpa.hotJobs.LoadData();
                });



                Thread KPA_CurrPlanVsActualThread = new Thread(() =>
                {
                    overallData.kpa.currPlanVsActual.LoadData();
                });



                PRPO_DB_Utils.ScheduledDataLoads = 16;

                Thread tableLoadThread = new Thread(() => {
                    overallData.LoadKPITables(Overall.SelectedCountry);
                });



                KPA_PlanThread.Start();
                KPA_PurchThread.Start();
                KPA_PurchSubThread.Start();
                KPA_PurchTotalThread.Start();
                KPA_FollowUpThread.Start();
                KPA_HotJobs.Start();
                KPA_CurrPlanVsActualThread.Start();
                tableLoadThread.Start();
            }


            if (PRPO_DB_Utils.KPITablesLoaded)
            {
                PRPO_DB_Utils.KPITablesLoaded = false;

                // KPI
                Thread KPI_PlanThread = new Thread(() =>
                {
                    overallData.kpi.plan.LoadData();
                });

                Thread KPI_PurchThread = new Thread(() =>
                {
                    overallData.kpi.purch.LoadData();
                });


                Thread KPI_FollowUpThread = new Thread(() =>
                {
                    overallData.kpi.followUp.LoadData();
                });


                Thread KPI_PurchTwoThread = new Thread(() =>
                {
                    overallData.kpi.purchTwo.LoadData();
                });


                Thread KPI_PurchSubThread = new Thread(() =>
                {
                    overallData.kpi.purchSub.LoadData();
                });


                Thread KPI_PurchTotalThread = new Thread(() =>
                {
                    overallData.kpi.purchTotal.LoadData();
                });


                Thread KPI_PurchPlanThread = new Thread(() =>
                {
                    overallData.kpi.purchPlan.LoadData();
                });

                Thread KPI_OtherThread = new Thread(() =>
                {
                    overallData.kpi.other.LoadData();
                });


                KPI_PlanThread.Start();
                KPI_PurchThread.Start();
                KPI_FollowUpThread.Start();
                KPI_PurchTwoThread.Start();
                KPI_PurchSubThread.Start();
                KPI_PurchTotalThread.Start();
                KPI_PurchPlanThread.Start();
                KPI_OtherThread.Start();
            }



            if (PRPO_DB_Utils.DataLoaded)
            {
                DataLoaderTimer.Stop();
                PRPO_DB_Utils.DataLoaded = false;

                if (!FiltersApplied)
                {
                    FilterUtils.FiltersLoaded            = false;
                    FilterUtils.FilterLoadProcessStarted = false;
                    FiltersTimer.Start();
                }
                else
                {
                    pnl_loadingScreen.Visible = false;
                    tblpnl_Filters.BringToFront();
                    btn_clearFilters.Enabled = true;
                    NavigationLocked         = false;
                }

                if (Overall.SelectedCountry == AccessInfo.MainTables.US_PRPO)
                {
                    using (StreamReader sr = new StreamReader(AppDirectoryUtils.logFiles[(int)AppDirectoryUtils.LogFiles.LoadedUSDate]))
                    {
                        lbl_dashboardDate.Text = sr.ReadLine();
                    }
                }
                else
                {
                    using (StreamReader sr = new StreamReader(AppDirectoryUtils.logFiles[(int)AppDirectoryUtils.LogFiles.LoadedMXDate]))
                    {
                        lbl_dashboardDate.Text = sr.ReadLine();
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Once the data is loaded into the application this timer will begin. This timer event will begin
        /// running condition checks and then making a call to remove the data that is not needed from the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataRemovalTimer_Tick(object sender, EventArgs e)
        {
            if (!PRPO_DB_Utils.DataRemovalProcessStarted)
            {
                PRPO_DB_Utils.DataRemovalProcessStarted = true;

                if (AccessUtils.US_PRPO_TableExists)
                {
                    PRPO_DB_Utils.ScheduledDataRemovals++;

                    usThread = new Thread(() =>
                    {
                        PRPO_DB_Utils.RemoveData(PRPOCommands.DatabaseTables.MainTables.US_PRPO);
                    });
                    usThread.Start();
                }

                if (AccessUtils.MX_PRPO_TableExists)
                {
                    PRPO_DB_Utils.ScheduledDataRemovals++;

                    mxThread = new Thread(() =>
                    {
                        PRPO_DB_Utils.RemoveData(PRPOCommands.DatabaseTables.MainTables.MX_PRPO);
                    });
                    mxThread.Start();
                }
            }


            if (PRPO_DB_Utils.DataRemoved)
            {
                DataRemovalTimer.Stop();
                PRPO_DB_Utils.DataRemoved = false;

                if (PRPO_DB_Utils.DatabaseConnection != null & PRPO_DB_Utils.DatabaseConnection.State == System.Data.ConnectionState.Open)
                {
                    btn_DatabaseConnectionStatus.Image = Properties.Resources.databaseConn_Connected_Icon;
                }
                else
                {
                    MessageBox.Show("There was an error while attempting to connect to the database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }



                if (AccessUtils.US_PRPO_TableExists && AccessUtils.MX_PRPO_TableExists)
                {
                    pnl_CountrySelector.BringToFront();
                }
                else if (AccessUtils.US_PRPO_TableExists)
                {
                    Overall.SelectedCountry = AccessInfo.MainTables.US_PRPO;
                    PRPO_DB_Utils.DataLoadProcessStarted = false;
                    PRPO_DB_Utils.DataLoaded             = false;
                    PRPO_DB_Utils.CompletedDataLoads     = 0;
                    PRPO_DB_Utils.ScheduledDataLoads     = 0;
                    DataLoaderTimer.Start();
                }
                else // only the mexico file exists.
                {
                    Overall.SelectedCountry = AccessInfo.MainTables.MX_PRPO;
                    PRPO_DB_Utils.DataLoadProcessStarted = false;
                    PRPO_DB_Utils.DataLoaded             = false;
                    PRPO_DB_Utils.CompletedDataLoads     = 0;
                    PRPO_DB_Utils.ScheduledDataLoads     = 0;
                    DataLoaderTimer.Start();
                }
            }
        }
        /// <summary>
        /// Apply the filters and load the data again with the filters applied.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_applyFilters_Click(object sender, EventArgs e)
        {
            Filters.FitlerValues.Clear();

            foreach (int i in ChkdListBx_Material.CheckedIndices)
            {
                Filters.FitlerValues.material.Add(ChkdListBx_Material.Items[i].ToString());
            }

            foreach (int i in ChkdListBx_MaterialGroup.CheckedIndices)
            {
                Filters.FitlerValues.materialGroup.Add(ChkdListBx_MaterialGroup.Items[i].ToString());
            }

            foreach (int i in ChkdListBx_Vendor.CheckedIndices)
            {
                Filters.FitlerValues.vendor.Add(ChkdListBx_Vendor.Items[i].ToString());
            }

            foreach (int i in ChkdListBx_VendorDesc.CheckedIndices)
            {
                Filters.FitlerValues.vendorDesc.Add(ChkdListBx_VendorDesc.Items[i].ToString());
            }

            foreach (int i in ChkdListBx_PurchGroup.CheckedIndices)
            {
                Filters.FitlerValues.purchGroup.Add(ChkdListBx_PurchGroup.Items[i].ToString());
            }

            foreach (int i in ChkdListBx_IRSuppName.CheckedIndices)
            {
                Filters.FitlerValues.irSuppName.Add(ChkdListBx_IRSuppName.Items[i].ToString());
            }

            foreach (int i in ChkdListBx_FxdSuppName.CheckedIndices)
            {
                Filters.FitlerValues.fxdSuppName.Add(ChkdListBx_FxdSuppName.Items[i].ToString());
            }

            foreach (int i in ChkdListBx_DsrdSuppName.CheckedIndices)
            {
                Filters.FitlerValues.dsrdSuppName.Add(ChkdListBx_DsrdSuppName.Items[i].ToString());
            }

            foreach (int i in ChkdListBx_CommodityCat.CheckedIndices)
            {
                Filters.FitlerValues.commCategory.Add(ChkdListBx_CommodityCat.Items[i].ToString());
            }


            BuildQueryFilters();
            HasFiltersAdded();
            if (FiltersAdded)
            {
                Filters.SecondaryFilterQuery = filters;
                filters             = " AND " + filters;
                Filters.FilterQuery = filters;
                FiltersApplied      = true;
            }
            else
            {
                filters                      = string.Empty;
                Filters.FilterQuery          = filters;
                Filters.SecondaryFilterQuery = filters;
                FiltersApplied               = false;
            }



            // Check if the user added a PR date range
            if (Filters.PrDateRangeFilterAdded)
            {
                Filters.PrFromDate = dp_PRFromDate.Value;
                Filters.PrToDate   = dp_PRToDate.Value;
                FiltersApplied     = true;
            }



            // Check if the user added a PO date range
            if (Filters.PoDateRangeFilterAdded)
            {
                Filters.PoFromDate = dp_POFromDate.Value;
                Filters.PoToDate   = dp_POToDate.Value;
                FiltersApplied     = true;
            }



            overallData = new Overall();
            PRPO_DB_Utils.DataLoadProcessStarted = false;
            PRPO_DB_Utils.DataLoaded             = false;
            PRPO_DB_Utils.CompletedDataLoads     = 0;
            PRPO_DB_Utils.ScheduledDataLoads     = 0;
            DataLoaderTimer.Start();
        }