Exemple #1
0
        private void BindJobData(DateTime startDate, DateTime endDate)
        {
            StringBuilder sb = new StringBuilder();

            foreach (eJobState jobState in m_jobStates)
            {
                if (sb.Length > 0)
                {
                    sb.Append(",");
                }
                sb.Append(((int)jobState).ToString());
            }
            string jobStatesCSV = sb.ToString();

            // Refilter the jobs.

            if (m_searchString == null || m_searchString == string.Empty || m_searchString == C_INVALID_SEARCH_STRING_VS)
            {
                lblResultCount.Text = "0";
            }
            else
            {
                Facade.IJob facJob = new Facade.Job();
                switch (m_searchString.ToUpper().Substring(0, 1))
                {
                case "T":
                    // Trailer only search.
                    string trailerReference = m_searchString.Substring(1);
                    try
                    {
                        // The rest of the text is a number.
                        int trailerId = int.Parse(trailerReference);

                        m_jobSearchField = eJobSearchField.TrailerReference;
                        cboJobSearchField.ClearSelection();
                        cboJobSearchField.Items.FindByText(Utilities.UnCamelCase(Enum.GetName(typeof(eJobSearchField), eJobSearchField.TrailerReference))).Selected = true;
                        // Remove the preceeding T.
                        m_searchString = m_searchString.Substring(1);
                    }
                    catch { }
                    break;
                }

                // Support searching for orders
                if (m_searchString.Length > 2 && m_searchString.Substring(0, 2).ToLower() == "o:")
                {
                    m_jobSearchField = eJobSearchField.OrderID;
                    m_searchString   = m_searchString.Substring(2);
                }

                // Support searching for Dehire Note Numbers (Receipt Numbers)
                if (m_searchString.Length > 2 && m_searchString.Substring(0, 2).ToLower() == "d:")
                {
                    m_jobSearchField = eJobSearchField.DehireReceiptNumber;
                    m_searchString   = m_searchString.Substring(2);
                }

                m_dsJobsData = facJob.FindJob(m_searchString, m_jobSearchField, jobStatesCSV, startDate, endDate, ((Entities.CustomPrincipal)Page.User).IdentityId);

                if (m_dsJobsData != null && m_dsJobsData.Tables.Count != 0)
                {
                    lblResultCount.Text = m_dsJobsData.Tables[0].Rows.Count.ToString();

                    dgJobs.DataSource = m_dsJobsData;
                    dgJobs.UnSelectAll();
                    //dgJobs.GroupBy = "JobState";
                    if (m_dsJobsData.Tables[0].Rows.Count == 1)
                    {
                        m_singleJobId           = (int)m_dsJobsData.Tables[0].Rows[0]["JobId"];
                        dgJobs.PreExpandOnGroup = true;
                    }
                    else
                    {
                        dgJobs.PreExpandOnGroup = false;
                    }
                }
                else
                {
                    lblResultCount.Text = "0";
                    dgJobs.Visible      = false;
                }

                // hide the filter display
                this.ClientScript.RegisterStartupScript(this.GetType(), "hideFilters", "FilterOptionsDisplayHide();", true);
            }
        }