Merge branch 'master' of http://www.scserverddns.top:13000/sc/formula_manage
This commit is contained in:
commit
020fdc37c8
5 files changed
+174
-137
No files matched your search
@@ -58,7 +58,7 @@ public class MainWindowViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
string Stuff_sql = "SELECT ProductCode ,ProductName ,ProductType ,Concentration FROM [Dispensing].[dbo].[PRODUCT] order by ProductCode asc";//查询STUFF语句
|
||||
string MAC_sql = "SELECT Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note FROM [Dispensing].[dbo].[MACHINE] order by Name asc";//查询machine语句
|
||||
string MAC_sql = "SELECT Name ,Capacity ,Volume FROM [Dispensing].[dbo].[MACHINE] order by Name asc";//查询machine语句
|
||||
string Dissolve_sql = "SELECT DissolveCode ,DissolveName ,MaterialType ,WeightMIN ,WeightMAX REMARK FROM [Dispensing].[dbo].[Dissolve]";//查询语句
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
@@ -71,96 +71,82 @@ public class MainWindowViewModel : ViewModelBase
|
||||
|
||||
Stuff_data.Fill(STUFFdataTable); //stuff查询结果存入缓存
|
||||
Mac_data.Fill(MACHINEdataTable); //machine查询结果存入缓存
|
||||
Dissolve_data.Fill(DissolvedataTable); //machine查询结果存入缓存
|
||||
|
||||
Dissolve_data.Fill(DissolvedataTable); //Dissolve_data查询结果存入缓存
|
||||
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求原料信息失败,检查连接");
|
||||
return;
|
||||
}
|
||||
|
||||
// IEnumerable STUFFdata = STUFFdataTable.DefaultView;
|
||||
// Machine.ItemsSource = MACHINEdataTable.DefaultView; // MACHINEdataTable数据集传递到ComboBox:machine
|
||||
// Workflow.ItemsSource = DissolvedataTable.DefaultView; // DissolvedataTable数据集传递到ComboBox:Workflow
|
||||
}
|
||||
|
||||
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
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, },
|
||||
|
||||
};*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* 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>((IEnumerable<Product>));
|
||||
// {
|
||||
// new Product{ ProductCode= STUFFdataTable.Rows,ProductName= "123", ProductType= 12,Concentration= 12}
|
||||
// };
|
||||
|
||||
stuff_Product = ToObservableCollection<Product>(STUFFdataTable); //stuff_Product表转换
|
||||
mac_Machine = ToObservableCollection<Machine>(MACHINEdataTable);
|
||||
flow_Workflow = ToObservableCollection<Workflow>(DissolvedataTable);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// private ObservableCollection<string> _selectionList = new ObservableCollection<string>(); //这个是实现的重要一步
|
||||
|
||||
public ObservableCollection<Product> _product { get; set; }
|
||||
// public ObservableCollection<FooViewModel> FooCollection { get; set; }
|
||||
public ObservableCollection<Product> stuff_Product { get; set; } //stuff_Product动态表实力化
|
||||
public ObservableCollection<Machine> mac_Machine { get; set; } //mac_Machine动态表实力化
|
||||
public ObservableCollection<Workflow> flow_Workflow { get; set; } //Dissolve动态表实力化
|
||||
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
|
||||
{
|
||||
Type t = typeof(T);
|
||||
PropertyInfo[] propertys = t.GetProperties();
|
||||
ObservableCollection<T> lst = new ObservableCollection<T>();
|
||||
string typeName = string.Empty;
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
T entity = new T();
|
||||
foreach (PropertyInfo pi in propertys)
|
||||
{
|
||||
typeName = pi.Name;
|
||||
if (dt.Columns.Contains(typeName))
|
||||
{
|
||||
if (!pi.CanWrite) continue;
|
||||
object value = dr[typeName];
|
||||
if (value == DBNull.Value) continue;
|
||||
if (pi.PropertyType == typeof(string))
|
||||
{
|
||||
pi.SetValue(entity, value.ToString(), null);
|
||||
}
|
||||
else if (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(int?))
|
||||
{
|
||||
pi.SetValue(entity, int.Parse(value.ToString()), null);
|
||||
}
|
||||
else if (pi.PropertyType == typeof(DateTime?) || pi.PropertyType == typeof(DateTime))
|
||||
{
|
||||
pi.SetValue(entity, DateTime.Parse(value.ToString()), null);
|
||||
}
|
||||
else if (pi.PropertyType == typeof(float))
|
||||
{
|
||||
pi.SetValue(entity, float.Parse(value.ToString()), null);
|
||||
}
|
||||
else if (pi.PropertyType == typeof(double))
|
||||
{
|
||||
pi.SetValue(entity, double.Parse(value.ToString()), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
pi.SetValue(entity, value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
lst.Add(entity);
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* 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 class Product //stuff_Product
|
||||
{
|
||||
public string ProductCode { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
@@ -172,25 +158,47 @@ public class MainWindowViewModel : ViewModelBase
|
||||
return ProductCode;
|
||||
}
|
||||
}
|
||||
public class Machine //mac
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public float Volume { get; set; }
|
||||
public float Capacity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// StuffViewModeldl
|
||||
/// </summary>
|
||||
/* public RRODUCTiewModel()
|
||||
public override string ToString()
|
||||
{
|
||||
//products = new ProductProvider().Select();
|
||||
DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(0.1)
|
||||
};
|
||||
timer.Tick += Tick_Event;
|
||||
timer.Start();
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class Workflow //Dissolve
|
||||
{
|
||||
public string DissolveName { get; set; }
|
||||
public int MaterialType { get; set; }
|
||||
public int WeightMIN { get; set; }
|
||||
public int WeightMAX { get; set; }
|
||||
|
||||
void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件
|
||||
public override string ToString()
|
||||
{
|
||||
return DissolveName;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// StuffViewModeldl
|
||||
/// </summary>
|
||||
/* public RRODUCTiewModel()
|
||||
{
|
||||
//products = new ProductProvider().Select();
|
||||
DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(0.1)
|
||||
};
|
||||
timer.Tick += Tick_Event;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user