@ -3,15 +3,18 @@ using formula_manage.ViewModel;
using formula_manage.Windows ;
using GalaSoft.MvvmLight ;
using System ;
using System.Collections ;
using System.Collections.Generic ;
using System.Collections.ObjectModel ;
using System.ComponentModel ;
using System.Data ;
using System.Data.SqlClient ;
using System.Linq ;
using System.Reflection ;
using System.Runtime.CompilerServices ;
using System.Text ;
using System.Threading.Tasks ;
using System.Windows.Forms ;
using System.Windows.Threading ;
@ -72,14 +75,14 @@ public class MainWindowViewModel : ViewModelBase
Dissolve_data . Fill ( DissolvedataTable ) ; //machine查询结果存入缓存
conn_SC . Close ( ) ; //关闭连接
//DataGridStuff.ItemsSource = dataTable.DefaultView; //数据加入表格
}
catch ( Exception )
{
System . Windows . MessageBox . Show ( "请求原料信息失败,检查连接" ) ;
return ;
}
DataView defaultView = MACHINEdataTable . DefaultView ;
// IEnumerable STUFFdata = STUFFdataTable.DefaultView;
// Machine.ItemsSource = MACHINEdataTable.DefaultView; // MACHINEdataTable数据集传递到ComboBox:machine
// Workflow.ItemsSource = DissolvedataTable.DefaultView; // DissolvedataTable数据集传递到ComboBox:Workflow
}
@ -90,46 +93,79 @@ public class MainWindowViewModel : ViewModelBase
{
sql_ ( ) ;
// public ObservableCollection (System.Collections.Generic.List<T> list);
// BarCollection = (ObservableCollection<BarModel>)STUFFdataTable.AsDataView();
// var qwe = STUFFdataTable.DefaultView;
var product = STUFFdataTable . DefaultView ;
// BarCollection = (ObservableCollection<Product>)STUFFdata;
/ * BarCollection = new ObservableCollection < Product >
{
new Product { ProductCode = "Bar 10" , } ,
new Product { ProductCode = "Bar 20" , } ,
new Product { ProductCode = "Bar 30" , } ,
} ; * /
/ * FooCollection = new ObservableCollection < FooViewModel >
{
new FooViewModel { Id = 1 , } ,
new FooViewModel { Id = 2 , } ,
new FooViewModel { Id = 3 , } ,
} ; * /
BarCollection = new ObservableCollection < BarModel >
{
new BarModel { Id = 1 , Name = "Bar 1" , } ,
new BarModel { Id = 2 , Name = "Bar 2" , } ,
new BarModel { Id = 3 , Name = "Bar 3" , } ,
} ;
FooCollection = new ObservableCollection < FooViewModel >
/ * product = new ObservableCollection < Product > ;
foreach ( DataRow row in STUFFdataTable . Rows )
{
product . Add ( new Product ( ( int ) row [ 0 ] , ( string ) row [ 1 ] , ( string ) row [ 2 ] ) ) ;
} * /
_ product = new ObservableCollection < Product >
{
new FooViewModel { Id = 1 , } ,
new FooViewModel { Id = 2 , } ,
new FooViewModel { Id = 3 , } ,
new Product { ProductCode = "132" , ProductName = "123" , ProductType = 1 2 , Concentration = 1 2 }
} ;
}
public ObservableCollection < BarModel > BarCollection { get ; set ; }
public ObservableCollection < FooViewModel > FooCollection { get ; set ; }
}
public class FooViewModel : ViewModelBase
{
private BarModel _ bar ;
// private ObservableCollection<string> _selectionList = new ObservableCollection<string>(); //这个是实现的重要一步
public ObservableCollection < Product > _ product { get ; set ; }
// public ObservableCollection<FooViewModel> FooCollection { get; set; }
public int Id { get ; set ; }
public BarModel Bar { get = > _ bar ; set = > Set ( ref _ bar , value ) ; }
}
public class BarModel
/ * public class FooViewModel : ViewModelBase
{
private BarModel _ bar ;
public int Id { get ; set ; }
public BarModel Bar { get = > _ bar ; set = > Set ( ref _ bar , value ) ; }
} * /
public class Product
{
public int Id { get ; set ; }
public string Name { get ; set ; }
public string ProductCode { get ; set ; }
public string ProductName { get ; set ; }
public int ProductType { get ; set ; }
public int Concentration { get ; set ; }
public override string ToString ( )
{
return Name ;
return ProductCod e;
}
}
/// <summary>
/// StuffViewModeldl
@ -150,5 +186,5 @@ public class MainWindowViewModel : ViewModelBase
} * /
}
}