コード例 #1
0
        /// <summary>
        /// Handles the toggle switch for filter of interesting checks
        /// </summary>
        private async void ToggleList(object sender, RoutedEventArgs e)
        {
            isToggle = true;
            ToggleSwitch thisSwitch = sender as ToggleSwitch;

            if (thisSwitch.IsOn)
            {
                try
                {
                    DateList.ItemsSource  = problemDateStrings;
                    CheckList.ItemsSource = problemChecksList;
                }
                catch { }
                try { CheckList.SelectedIndex = 0; } catch { }
                try { DateList.SelectedIndex = 0; } catch { }
                await Task.Delay(1000);
            }
            else
            {
                try
                {
                    DateList.ItemsSource  = dateStrings;
                    CheckList.ItemsSource = ChecksList;
                }
                catch { }
                try { CheckList.SelectedIndex = 0; } catch { }
                try { DateList.SelectedIndex = 0; } catch { }
                await Task.Delay(1000);
            }
            for (int i = 0; i < DateList.Items.Count; i++)
            {
                try
                {
                    var    item     = DateList.ContainerFromIndex(i) as ListViewItem;
                    String myString = DateList.Items[i].ToString().Split(':')[0];
                    if (defectDateStrings.Contains(myString))
                    {
                        item.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                        item.Background = new SolidColorBrush(Windows.UI.Colors.WhiteSmoke);
                    }
                    else
                    {
                    }
                }
                catch { }
            }
            isToggle = false;
        }
コード例 #2
0
        /// <summary>
        /// Loads the list of run dates for the selected part
        /// </summary>
        private async void SubmitQuery(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            string PartName = sender.Text;

            dateStrings.Clear();
            defectDateStrings.Clear();
            problemDateStrings.Clear();
            ChecksList.Clear();
            problemChecksList.Clear();
            sender.Text = sender.Text.ToUpper();
            String thisString = "Select DISTINCT CheckDate, LineInfo.LineName FROM QualityCheck INNER JOIN LineInfo ON LineInfo.LineNumber = QualityCheck.LineNumber WHERE PartNumber = '" + PartName + "' ORDER BY CheckDate DESC;";

            //Creates Master List of Part from Database
            using (conn = new SqlConnection(@"Data Source=DESKTOP-10DBF13\SQLEXPRESS;Initial Catalog=QualityControl;Integrated Security=SSPI"))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = thisString;
                    try
                    {
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                balls  = reader.GetDateTime(0);
                                balls2 = reader.GetString(1).TrimEnd();
                                dateStrings.Add(balls.ToString("yyyy-MM-dd") + ":      " + reader.GetString(1).TrimEnd());
                            }
                        }
                    }
                    catch (Exception e) { }

                    String output = "Select DISTINCT CheckDate, LineInfo.LineName FROM QualityCheck" +
                                    " INNER JOIN LineInfo ON LineInfo.LineNumber = QualityCheck.LineNumber" +
                                    " WHERE PartNumber = '" + PartBox.Text + "' AND (NOT('' = CONVERT(varchar(max), Notes)) OR DefectCheck = 1) " +
                                    "ORDER BY CheckDate DESC;";
                    cmd.CommandText = output;
                    try
                    {
                        using (SqlDataReader reader2 = cmd.ExecuteReader())
                        {
                            while (reader2.Read())
                            {
                                var balls = reader2.GetDateTime(0);
                                defectDateStrings.Add(balls.ToString("yyyy-MM-dd"));
                                problemDateStrings.Add(balls.ToString("yyyy-MM-dd") + ":      " + reader2.GetString(1).TrimEnd());
                            }
                        }
                    }
                    catch { }

                    try
                    {
                        DateList.ItemsSource = dateStrings;
                    }
                    catch { }

                    await Task.Delay(1000);

                    for (int i = 0; i < DateList.Items.Count; i++)
                    {
                        try
                        {
                            var    item     = DateList.ContainerFromIndex(i) as ListViewItem;
                            String myString = DateList.Items[i].ToString().Split(':')[0];
                            if (defectDateStrings.Contains(myString))
                            {
                                item.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                                item.Background = new SolidColorBrush(Windows.UI.Colors.WhiteSmoke);
                            }
                            else
                            {
                            }
                        }
                        catch { }
                    }
                }
            }
        }