Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace Control
- {
- /// <summary>
- /// Interaction logic for FinishedOrderViewer.xaml
- /// </summary>
- public partial class FinishedOrderViewer : Window
- {
- public FinishedOrderViewer()
- {
- InitializeComponent();
- }
- private void FillGrid(string date)
- {
- listViewFinishedOrders.Items.Clear();
- int cum = 0;
- try
- {
- System.Data.OleDb.OleDbConnection iConnect = new System.Data.OleDb.OleDbConnection();
- iConnect.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source = \\Fileserver\public\Highbury Pools\Access DataBase For Panel Build Time\HBPData.mdb";
- ;
- iConnect.Open();
- System.Data.OleDb.OleDbCommand iCommand = new System.Data.OleDb.OleDbCommand();
- iCommand.Connection = iConnect;
- 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) + "'";
- System.Data.OleDb.OleDbDataReader iRead = iCommand.ExecuteReader();
- while (iRead.Read())
- {
- StackPanel s = new StackPanel();
- s.Orientation = Orientation.Horizontal;
- s.Height = 30;
- Image Type = new Image();
- Type.Width = 50;
- Type.Height = 30;
- Type.Stretch = Stretch.Fill;
- switch (iRead["PoolType"].ToString())
- {
- case "42EF":
- Type.Source = new BitmapImage(new Uri("/Control;component/images/42EF.png", UriKind.Relative));
- break;
- case "42FLEX":
- Type.Source = new BitmapImage(new Uri("/Control;component/images/42FLEX.png", UriKind.Relative));
- break;
- case "42IG":
- Type.Source = new BitmapImage(new Uri("/Control;component/images/42IG.png", UriKind.Relative));
- break;
- case "48IG":
- Type.Source = new BitmapImage(new Uri("/Control;component/images/48IG.png", UriKind.Relative));
- break;
- case "48OG":
- Type.Source = new BitmapImage(new Uri("/Control;component/images/48OG.png", UriKind.Relative));
- break;
- case "52OG":
- Type.Source = new BitmapImage(new Uri("/Control;component/images/52OG.png", UriKind.Relative));
- break;
- default:
- Type.Source = new BitmapImage(new Uri("/Control;component/images/42IG.png", UriKind.Relative));
- break;
- }
- s.Children.Add(Type);
- //Order#
- Label OrderNumber = new Label();
- OrderNumber.Content = iRead["OrderNumber"].ToString();
- OrderNumber.Foreground = Brushes.Silver;
- OrderNumber.Background = Brushes.Black;
- OrderNumber.Height = 30;
- OrderNumber.Width = 100;
- s.Children.Add(OrderNumber);
- Label Customer = new Label();
- Customer.Content = iRead["Customer"].ToString();
- Customer.Foreground = Brushes.Silver;
- Customer.Background = Brushes.Black;
- Customer.Height = 30;
- Customer.Width = 200;
- s.Children.Add(Customer);
- Label Tag = new Label();
- Tag.Content = iRead["Tag"].ToString();
- Tag.Foreground = Brushes.Silver;
- Tag.Background = Brushes.Black;
- Tag.Height = 30;
- Tag.Width = 200;
- s.Children.Add(Tag);
- Label TargetBox = new Label();
- TargetBox.Content = iRead["TargetBox"].ToString();
- TargetBox.Foreground = Brushes.Silver;
- TargetBox.Background = Brushes.Black;
- TargetBox.Height = 30;
- TargetBox.Width = 150;
- s.Children.Add(TargetBox);
- Label ActualBox = new Label();
- ActualBox.Content = iRead["ActualBox"].ToString();
- ActualBox.Foreground = Brushes.Silver;
- ActualBox.Background = Brushes.Black;
- ActualBox.Height = 30;
- ActualBox.Width = 150;
- s.Children.Add(ActualBox);
- Label Target = new Label();
- Target.Content = iRead["Target"].ToString();
- Target.Foreground = Brushes.Silver;
- Target.Background = Brushes.Black;
- Target.Height = 30;
- Target.Width = 50;
- s.Children.Add(Target);
- Label actual = new Label();
- actual.Content = iRead["Actual"].ToString();
- actual.Foreground = Brushes.Silver;
- actual.Background = Brushes.Black;
- actual.Height = 30;
- actual.Width = 50;
- //-?> <
- s.Children.Add(actual);
- Label OverUnder = new Label();
- OverUnder.Content = (Convert.ToInt32(Target.Content) - Convert.ToInt32(actual.Content));
- if (Convert.ToInt32(OverUnder.Content) > 0)
- {
- OverUnder.Foreground = Brushes.Green;
- }
- else
- {
- OverUnder.Foreground = Brushes.Red;
- }
- OverUnder.Background = Brushes.Black;
- OverUnder.Height = 30;
- OverUnder.Width = 50;
- s.Children.Add(OverUnder);
- //Most likely we should add a days cumulative here .
- cum += (Convert.ToInt32(Target.Content) - Convert.ToInt32(actual.Content));
- Label Cumulative = new Label();
- Cumulative.Content = cum.ToString();
- if (cum > 0)
- {
- Cumulative.Foreground = Brushes.Green;
- }
- else
- {
- Cumulative.Foreground = Brushes.Red;
- }
- Cumulative.Background = Brushes.Black;
- Cumulative.Height = 30;
- Cumulative.Width = 50;
- s.Children.Add(Cumulative);
- listViewFinishedOrders.Items.Add(s);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void FinishedOrderViewer_Loaded(object sender, RoutedEventArgs e)
- {
- try
- {
- TextBoxDate.Text = DateTime.Now.ToString("dd") + DateTime.Now.ToString("MM") + DateTime.Now.Year.ToString();
- FillGrid(TextBoxDate.Text);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void ButtonFetch_Click(object sender, RoutedEventArgs e)
- {
- FillGrid(TextBoxDate.Text);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement