Advertisement
Guest User

Untitled

a guest
May 29th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14.  
  15. namespace Control
  16. {
  17. /// <summary>
  18. /// Interaction logic for FinishedOrderViewer.xaml
  19. /// </summary>
  20. public partial class FinishedOrderViewer : Window
  21. {
  22. public FinishedOrderViewer()
  23. {
  24. InitializeComponent();
  25. }
  26.  
  27.  
  28.  
  29.  
  30. private void FillGrid(string date)
  31. {
  32. listViewFinishedOrders.Items.Clear();
  33.  
  34. int cum = 0;
  35.  
  36. try
  37. {
  38.  
  39. System.Data.OleDb.OleDbConnection iConnect = new System.Data.OleDb.OleDbConnection();
  40. iConnect.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source = \\Fileserver\public\Highbury Pools\Access DataBase For Panel Build Time\HBPData.mdb";
  41. ;
  42. iConnect.Open();
  43.  
  44. System.Data.OleDb.OleDbCommand iCommand = new System.Data.OleDb.OleDbCommand();
  45. iCommand.Connection = iConnect;
  46. iCommand.CommandText = "Select * from FinishedOrders Where Left(ActualBox,2) = '" + date.Substring(0,2) + "' AND Mid(ActualBox,4,2) = '" + date.Substring(2,2) +"' AND Mid(ActualBox,7,4) = '" + date.Substring(4,4) + "'";
  47.  
  48. System.Data.OleDb.OleDbDataReader iRead = iCommand.ExecuteReader();
  49. while (iRead.Read())
  50. {
  51. StackPanel s = new StackPanel();
  52. s.Orientation = Orientation.Horizontal;
  53. s.Height = 30;
  54.  
  55. Image Type = new Image();
  56. Type.Width = 50;
  57. Type.Height = 30;
  58. Type.Stretch = Stretch.Fill;
  59.  
  60. switch (iRead["PoolType"].ToString())
  61. {
  62. case "42EF":
  63. Type.Source = new BitmapImage(new Uri("/Control;component/images/42EF.png", UriKind.Relative));
  64. break;
  65. case "42FLEX":
  66. Type.Source = new BitmapImage(new Uri("/Control;component/images/42FLEX.png", UriKind.Relative));
  67. break;
  68. case "42IG":
  69. Type.Source = new BitmapImage(new Uri("/Control;component/images/42IG.png", UriKind.Relative));
  70. break;
  71. case "48IG":
  72. Type.Source = new BitmapImage(new Uri("/Control;component/images/48IG.png", UriKind.Relative));
  73. break;
  74. case "48OG":
  75. Type.Source = new BitmapImage(new Uri("/Control;component/images/48OG.png", UriKind.Relative));
  76. break;
  77. case "52OG":
  78. Type.Source = new BitmapImage(new Uri("/Control;component/images/52OG.png", UriKind.Relative));
  79. break;
  80. default:
  81. Type.Source = new BitmapImage(new Uri("/Control;component/images/42IG.png", UriKind.Relative));
  82. break;
  83.  
  84. }
  85.  
  86. s.Children.Add(Type);
  87.  
  88.  
  89. //Order#
  90. Label OrderNumber = new Label();
  91. OrderNumber.Content = iRead["OrderNumber"].ToString();
  92. OrderNumber.Foreground = Brushes.Silver;
  93. OrderNumber.Background = Brushes.Black;
  94. OrderNumber.Height = 30;
  95. OrderNumber.Width = 100;
  96.  
  97. s.Children.Add(OrderNumber);
  98.  
  99.  
  100. Label Customer = new Label();
  101. Customer.Content = iRead["Customer"].ToString();
  102. Customer.Foreground = Brushes.Silver;
  103. Customer.Background = Brushes.Black;
  104. Customer.Height = 30;
  105. Customer.Width = 200;
  106.  
  107. s.Children.Add(Customer);
  108.  
  109. Label Tag = new Label();
  110. Tag.Content = iRead["Tag"].ToString();
  111. Tag.Foreground = Brushes.Silver;
  112. Tag.Background = Brushes.Black;
  113. Tag.Height = 30;
  114. Tag.Width = 200;
  115.  
  116. s.Children.Add(Tag);
  117.  
  118.  
  119. Label TargetBox = new Label();
  120. TargetBox.Content = iRead["TargetBox"].ToString();
  121. TargetBox.Foreground = Brushes.Silver;
  122. TargetBox.Background = Brushes.Black;
  123. TargetBox.Height = 30;
  124. TargetBox.Width = 150;
  125.  
  126. s.Children.Add(TargetBox);
  127.  
  128. Label ActualBox = new Label();
  129. ActualBox.Content = iRead["ActualBox"].ToString();
  130. ActualBox.Foreground = Brushes.Silver;
  131. ActualBox.Background = Brushes.Black;
  132. ActualBox.Height = 30;
  133. ActualBox.Width = 150;
  134.  
  135. s.Children.Add(ActualBox);
  136.  
  137.  
  138. Label Target = new Label();
  139. Target.Content = iRead["Target"].ToString();
  140. Target.Foreground = Brushes.Silver;
  141. Target.Background = Brushes.Black;
  142. Target.Height = 30;
  143. Target.Width = 50;
  144.  
  145. s.Children.Add(Target);
  146.  
  147. Label actual = new Label();
  148. actual.Content = iRead["Actual"].ToString();
  149. actual.Foreground = Brushes.Silver;
  150. actual.Background = Brushes.Black;
  151. actual.Height = 30;
  152. actual.Width = 50;
  153.  
  154. //-?> <
  155. s.Children.Add(actual);
  156.  
  157. Label OverUnder = new Label();
  158. OverUnder.Content = (Convert.ToInt32(Target.Content) - Convert.ToInt32(actual.Content));
  159. if (Convert.ToInt32(OverUnder.Content) > 0)
  160. {
  161. OverUnder.Foreground = Brushes.Green;
  162. }
  163. else
  164. {
  165. OverUnder.Foreground = Brushes.Red;
  166. }
  167. OverUnder.Background = Brushes.Black;
  168. OverUnder.Height = 30;
  169. OverUnder.Width = 50;
  170.  
  171. s.Children.Add(OverUnder);
  172.  
  173. //Most likely we should add a days cumulative here .
  174.  
  175. cum += (Convert.ToInt32(Target.Content) - Convert.ToInt32(actual.Content));
  176.  
  177. Label Cumulative = new Label();
  178. Cumulative.Content = cum.ToString();
  179. if (cum > 0)
  180. {
  181. Cumulative.Foreground = Brushes.Green;
  182.  
  183. }
  184. else
  185. {
  186. Cumulative.Foreground = Brushes.Red;
  187. }
  188. Cumulative.Background = Brushes.Black;
  189. Cumulative.Height = 30;
  190. Cumulative.Width = 50;
  191.  
  192. s.Children.Add(Cumulative);
  193.  
  194. listViewFinishedOrders.Items.Add(s);
  195.  
  196.  
  197.  
  198.  
  199. }
  200.  
  201.  
  202.  
  203. }
  204. catch (Exception ex)
  205. {
  206.  
  207. MessageBox.Show(ex.Message);
  208.  
  209. }
  210.  
  211.  
  212. }
  213.  
  214.  
  215. private void FinishedOrderViewer_Loaded(object sender, RoutedEventArgs e)
  216. {
  217. try
  218. {
  219. TextBoxDate.Text = DateTime.Now.ToString("dd") + DateTime.Now.ToString("MM") + DateTime.Now.Year.ToString();
  220.  
  221. FillGrid(TextBoxDate.Text);
  222.  
  223. }
  224. catch (Exception ex)
  225. {
  226. MessageBox.Show(ex.Message);
  227. }
  228.  
  229.  
  230. }
  231.  
  232. private void ButtonFetch_Click(object sender, RoutedEventArgs e)
  233. {
  234. FillGrid(TextBoxDate.Text);
  235.  
  236. }
  237. }
  238. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement