Guest User

Untitled

a guest
May 28th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 KB | None | 0 0
  1. public class MainViewModel : INotifyPropertyChanged
  2. {
  3. public MainViewModel() { }
  4.  
  5. private LoadCurrentViewModel _LoadCurrentVM;
  6. public LoadCurrentViewModel LoadCurrentVM { get { return _LoadCurrentVM; } set { _LoadCurrentVM = value; NotifyPropertyChanged("LoadCurrentVM"); } }
  7. private LoadingHistoryTopView _LoadHistoryTopActiveVM = new LoadingHistoryTopView();
  8. public LoadingHistoryTopView LoadHistoryTopActiveVM { get { return _LoadHistoryTopActiveVM; } set { _LoadHistoryTopActiveVM = value; NotifyPropertyChanged("LoadHistoryTopActiveVM"); } }
  9. private LoadCurrentViewModel _LoadCurrentViewModelData = new LoadCurrentViewModel();
  10. public LoadCurrentViewModel LoadCurrentViewModelData { get { return _LoadCurrentViewModelData; } set { _LoadCurrentViewModelData = value; NotifyPropertyChanged("LoadCurrentViewModelData"); } }
  11.  
  12. public event PropertyChangedEventHandler PropertyChanged;
  13. public void NotifyPropertyChanged(string propName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName)); }
  14.  
  15.  
  16. }
  17.  
  18. //public LoadCurrentViewModel LoadCurrentViewModelData { get; set; } = new LoadCurrentViewModel();
  19. LoadCurrentBetween objMain = new LoadCurrentBetween();
  20. LoadingHistory objLoadHistory = new LoadingHistory();
  21. MainViewModel _MainViewModel = new MainViewModel();
  22. LoadHistoryUC objLoad = new LoadHistoryUC();
  23. public Scanner()
  24. {
  25. DataContext = _MainViewModel;
  26. InitializeComponent();
  27. }
  28. private void PaintScan(object sender, RoutedEventArgs e)
  29. {
  30. //Insert Scanned values to db
  31. DbOperations.InsertScanHistory(_MainViewModel.LoadCurrentViewModelData.Part, Convert.ToInt32(_MainViewModel.LoadCurrentViewModelData.NoofHook), 2, _MainViewModel.LoadCurrentViewModelData.Date, _MainViewModel.LoadCurrentViewModelData.Time);
  32. //objLoad.PopulateHistory(objLoad);
  33. objLoadHistory.PopulateHistory();
  34. MessageBox.Show("PaintScan Done");
  35. }
  36.  
  37. public partial class LoadingHistory : Window
  38. {
  39. public List<LoadingHistoryModel> LoadhistoryVM = new List<LoadingHistoryModel>();
  40. public LoadingHistoryTopView LoadhistorytopVM = new LoadingHistoryTopView();
  41. public MainViewModel _MainViewModel = new MainViewModel();
  42. public LoadingHistory()
  43. {
  44. InitializeComponent();
  45. DataContext = _MainViewModel;
  46. PopulateHistory();
  47. }
  48. public void PopulateHistory()
  49. {
  50. LoadhistoryVM = DbOperations.GetLoadHistory();
  51. if (LoadhistoryVM.Count > 0)
  52. {
  53. for (var i = 0; i < LoadhistoryVM[0].GroupPartNumbers.Count(); i++)
  54. {
  55. switch (LoadhistoryVM[0].GroupPartNumbers[i].LinePosition)
  56. {
  57. case 1:
  58. //LoadhistoryVM[i].IsLoaded = true;
  59. break;
  60. case 2:
  61. PainttopView paint = new PainttopView();
  62. paint.Hookno = LoadhistoryVM[0].GroupPartNumbers[i].HookNumber;
  63. paint.LinePosition = LoadhistoryVM[0].GroupPartNumbers[i].LinePosition;
  64. paint.isEmpty = LoadhistoryVM[0].GroupPartNumbers[i].HookNumber == 0 ? true : false;
  65. if (!paint.isEmpty)
  66. paint.ImgSource = "/Views/Image/Bluering.png";
  67. else
  68. paint.ImgSource = "/Views/Image/RedStop.png";
  69. _MainViewModel.LoadHistoryTopActiveVM.Paint.Add(paint);
  70. break;
  71. case 3:
  72. BaketopView bake = new BaketopView();
  73. bake.Hookno = LoadhistoryVM[0].GroupPartNumbers[i].HookNumber;
  74. bake.LinePosition = LoadhistoryVM[0].GroupPartNumbers[i].LinePosition;
  75. bake.isEmpty = LoadhistoryVM[0].GroupPartNumbers[i].HookNumber == 0 ? true : false;
  76. if (!bake.isEmpty)
  77. bake.ImgSource = "/Views/Image/Bluering.png";
  78. else
  79. bake.ImgSource = "/Views/Image/RedStop.png";
  80. _MainViewModel.LoadHistoryTopActiveVM.Bake.Add(bake);
  81. break;
  82. case 4:
  83. CooltopView cool = new CooltopView();
  84. cool.Hookno = LoadhistoryVM[0].GroupPartNumbers[i].HookNumber;
  85. cool.LinePosition = LoadhistoryVM[0].GroupPartNumbers[i].LinePosition;
  86. cool.isEmpty = LoadhistoryVM[0].GroupPartNumbers[i].HookNumber == 0 ? true : false;
  87. if (!cool.isEmpty)
  88. cool.ImgSource = "/Views/Image/Bluering.png";
  89. else
  90. cool.ImgSource = "/Views/Image/RedStop.png";
  91. _MainViewModel.LoadHistoryTopActiveVM.Cool.Add(cool);
  92. break;
  93. case 5:
  94. //LoadhistoryVM[i].IsUnloaded = true;
  95. break;
  96. }
  97.  
  98. _MainViewModel.LoadHistoryTopActiveVM.Hooks.Add(LoadhistoryVM[0].GroupPartNumbers[i].HookNumber);
  99. if (i == 0)
  100. {
  101. _MainViewModel.LoadHistoryTopActiveVM.HookNumber = LoadhistoryVM[0].GroupPartNumbers[i].HookNumber;
  102. _MainViewModel.LoadHistoryTopActiveVM.LinePosition = LoadhistoryVM[0].GroupPartNumbers[i].LinePosition;
  103. _MainViewModel.LoadHistoryTopActiveVM.PartNumber = LoadhistoryVM[0].GroupPartNumbers[i].PartNumber;
  104. _MainViewModel.LoadHistoryTopActiveVM.Workorder = LoadhistoryVM[0].GroupPartNumbers[i].Workorder;
  105. _MainViewModel.LoadHistoryTopActiveVM.Date = LoadhistoryVM[0].GroupPartNumbers[i].Date;
  106. }
  107. }
  108. }
  109. DataContext = _MainViewModel;
  110. }
  111. }
  112.  
  113. <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3">
  114. <Border BorderBrush="Black" BorderThickness="1" Margin="10">
  115. <Grid Background="White" DataContext="{Binding LoadHistoryTopActiveVM}">..........
Add Comment
Please, Sign In to add comment