Esempio n. 1
0
 public ItemsModel()
 {
     Service1Client clnt = new Service1Client();
     Items =new List<Tuple<int,DateTime,string,string,int,float,float>>();
     foreach (Tuple<int, DateTime, string, string, int, Single, Single> k in clnt.GetRpt())
     {
         Items.Add(Tuple.Create(k.Item1,k.Item2,k.Item3,k.Item4,k.Item5,k.Item6,k.Item7));
     }
 }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Service1Client c = new Service1Client("BasicHttpBinding_IService1");
            Tuple<int, DateTime, string,string, int, float,float>[] myt=c.GetRpt();
            //c.NewItem("Dell Laptop",5,1,DateTime.Now);
            //MessageBox.Show(myt[0].Item4);
            int irow = 1;
            foreach (var tb in myt)
            {
                DataGrid1.RowDefinitions.Add(new RowDefinition());
                TextBox mytb = new TextBox();
                mytb.Text = tb.Item1.ToString();
                mytb.SetValue(Grid.RowProperty, irow);
                mytb.SetValue(Grid.ColumnProperty,0);
                DataGrid1.Children.Add(mytb);

                mytb = new TextBox();
                mytb.Text = tb.Item2.ToString("yyyy-MM-dd");
                mytb.SetValue(Grid.RowProperty, irow);
                mytb.SetValue(Grid.ColumnProperty, 1);
                DataGrid1.Children.Add(mytb);

                mytb = new TextBox();
                mytb.Text = tb.Item3.ToString();
                mytb.SetValue(Grid.RowProperty, irow);
                mytb.SetValue(Grid.ColumnProperty, 2);
                DataGrid1.Children.Add(mytb);

                mytb = new TextBox();
                mytb.Text = tb.Item4.ToString();
                mytb.SetValue(Grid.RowProperty, irow);
                mytb.SetValue(Grid.ColumnProperty, 3);
                DataGrid1.Children.Add(mytb);
                ss = mytb.Style;
                mytb.MouseEnter += new MouseEventHandler(Tx_MouseEnter);
                mytb.MouseLeave += new MouseEventHandler(Tx_MouseLeave);

                mytb = new TextBox();
                mytb.Text = tb.Item5.ToString();
                mytb.SetValue(Grid.RowProperty, irow);
                mytb.SetValue(Grid.ColumnProperty, 4);
                DataGrid1.Children.Add(mytb);

                mytb = new TextBox();
                mytb.Text = tb.Item6.ToString();
                mytb.SetValue(Grid.RowProperty, irow);
                mytb.SetValue(Grid.ColumnProperty, 5);
                DataGrid1.Children.Add(mytb);

                mytb = new TextBox();
                mytb.Text = tb.Item7.ToString();
                mytb.SetValue(Grid.RowProperty, irow);
                mytb.SetValue(Grid.ColumnProperty, 6);
                DataGrid1.Children.Add(mytb);
                if (tb.Item7 > 10000)
                {
                    Style s = new Style();
                    s.Setters.Add(new Setter(TextBox.BackgroundProperty, Brushes.Red));
                    mytb.Style = s;
                }else if(tb.Item7<500)
                {
                    Style s = new Style();
                    s.Setters.Add(new Setter(TextBox.ForegroundProperty, Brushes.LightSeaGreen));
                    mytb.Style = s;
                }
                irow+=1;
            }
        }