Ei kuvausta

ChooseRecord.xaml.cs 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Shapes;
  13. using System.Data.Sql;
  14. using System.Data.SqlClient;
  15. namespace WpfApplication19
  16. {
  17. /// <summary>
  18. /// Interaction logic for ChooseRecord.xaml
  19. /// </summary>
  20. public partial class ChooseRecord : Window
  21. {
  22. private SqlConnection _proConn;
  23. public ChooseRecord(string lotNo)
  24. {
  25. InitializeComponent();
  26. this.LotNo = lotNo;
  27. try
  28. {
  29. _proConn = Utils.createSqlConnection("productionDbCS");
  30. }
  31. catch (SqlException se)
  32. {
  33. MessageBox.Show("productionDbCS : ", se.Message);
  34. }
  35. SetupObject();
  36. //LotNoLabel.Content = LotNo;
  37. }
  38. private void SetupObject()
  39. {
  40. SqlDataReader reader = Utils.Query(_proConn, "select updated_at from data where lot_no = '"+this.LotNo+"' group by updated_at");
  41. while (reader.Read())
  42. {
  43. DateTimeCB.Items.Add(new ComboBoxItem() { Tag = "a", Content = reader["updated_at"].ToString() });
  44. }
  45. reader.Close();
  46. //DateTimeCB.ItemsSource =
  47. }
  48. public string LotNo { get; set; }
  49. private void PreviewBtn_Click(object sender, RoutedEventArgs e)
  50. {
  51. Application.Current.MainWindow.Show();
  52. var w = (MainWindow)Application.Current.MainWindow;
  53. var s = ((ComboBoxItem)DateTimeCB.SelectedItem).Content.ToString();
  54. w.setFilterLogData(((ComboBoxItem)DateTimeCB.SelectedItem).Content.ToString());
  55. Close();
  56. }
  57. }
  58. }