|
|
@ -1,14 +1,20 @@ |
|
|
using formula_manage.SQLModels; |
|
|
using formula_manage.SQLModels; |
|
|
|
|
|
using formula_manage.ViewModel; |
|
|
using formula_manage.Windows; |
|
|
using formula_manage.Windows; |
|
|
using GalaSoft.MvvmLight; |
|
|
using GalaSoft.MvvmLight; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.ObjectModel; |
|
|
using System.Collections.ObjectModel; |
|
|
|
|
|
using System.ComponentModel; |
|
|
|
|
|
using System.Data; |
|
|
|
|
|
using System.Data.SqlClient; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
using System.Runtime.CompilerServices; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using System.Windows.Threading; |
|
|
using System.Windows.Threading; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace formula_manage.ViewModel |
|
|
namespace formula_manage.ViewModel |
|
|
{ |
|
|
{ |
|
|
///<Summary>
|
|
|
///<Summary>
|
|
|
@ -17,9 +23,74 @@ namespace formula_manage.ViewModel |
|
|
public class MainWindowViewModel : ViewModelBase |
|
|
public class MainWindowViewModel : ViewModelBase |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
DataTable DissolvedataTable = new DataTable(); //建立Dissolve缓存
|
|
|
|
|
|
DataTable STUFFdataTable = new DataTable(); //建立STUFF缓存
|
|
|
|
|
|
DataTable MACHINEdataTable = new DataTable(); //建立Machine缓存
|
|
|
|
|
|
DataTable RRODUCTdataTable = new DataTable(); //建立RRODUCT缓存
|
|
|
|
|
|
DataTable RecipedataTable = new DataTable(); //建立Recipe缓存
|
|
|
|
|
|
|
|
|
|
|
|
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini"; //配置文件路径
|
|
|
|
|
|
|
|
|
|
|
|
string TEXT_SQLIP; |
|
|
|
|
|
string TEXT_SQLNAME; |
|
|
|
|
|
string TEXT_SQMOD; |
|
|
|
|
|
string TEXT_SQLUSER; |
|
|
|
|
|
string TEXT_SQLPASWOR; |
|
|
|
|
|
string Connstr_SC; |
|
|
|
|
|
|
|
|
|
|
|
private async void sql_() |
|
|
|
|
|
{ |
|
|
|
|
|
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);//生效配置读取
|
|
|
|
|
|
TEXT_SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
|
|
|
|
|
|
TEXT_SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2"); |
|
|
|
|
|
TEXT_SQMOD = Configini.IniReadvalue("SQL_SERVER", "SQL3"); |
|
|
|
|
|
TEXT_SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4"); |
|
|
|
|
|
TEXT_SQLPASWOR = Configini.IniReadvalue("SQL_SERVER", "SQL5"); |
|
|
|
|
|
if (TEXT_SQMOD == "0") //判断连接方式
|
|
|
|
|
|
{ |
|
|
|
|
|
Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";Trusted_Connection=SSPI"; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";User ID=" + TEXT_SQLUSER + ";Password=" + TEXT_SQLPASWOR; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 Dissolve_sql = "SELECT DissolveCode ,DissolveName ,MaterialType ,WeightMIN ,WeightMAX REMARK FROM [Dispensing].[dbo].[Dissolve]";//查询语句
|
|
|
|
|
|
|
|
|
|
|
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
await conn_SC.OpenAsync(); //打开数据连接
|
|
|
|
|
|
SqlDataAdapter Stuff_data = new SqlDataAdapter(Stuff_sql, Connstr_SC); //查询stuff
|
|
|
|
|
|
SqlDataAdapter Mac_data = new SqlDataAdapter(MAC_sql, Connstr_SC); //查询machine
|
|
|
|
|
|
SqlDataAdapter Dissolve_data = new SqlDataAdapter(Dissolve_sql, Connstr_SC); //查询Dissolve
|
|
|
|
|
|
|
|
|
|
|
|
Stuff_data.Fill(STUFFdataTable); //stuff查询结果存入缓存
|
|
|
|
|
|
Mac_data.Fill(MACHINEdataTable); //machine查询结果存入缓存
|
|
|
|
|
|
Dissolve_data.Fill(DissolvedataTable); //machine查询结果存入缓存
|
|
|
|
|
|
|
|
|
|
|
|
conn_SC.Close(); //关闭连接
|
|
|
|
|
|
//DataGridStuff.ItemsSource = dataTable.DefaultView; //数据加入表格
|
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception) |
|
|
|
|
|
{ |
|
|
|
|
|
System.Windows.MessageBox.Show("请求原料信息失败,检查连接"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
DataView defaultView = MACHINEdataTable.DefaultView; |
|
|
|
|
|
// Machine.ItemsSource = MACHINEdataTable.DefaultView; // MACHINEdataTable数据集传递到ComboBox:machine
|
|
|
|
|
|
// Workflow.ItemsSource = DissolvedataTable.DefaultView; // DissolvedataTable数据集传递到ComboBox:Workflow
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MainWindowViewModel() |
|
|
public MainWindowViewModel() |
|
|
{ |
|
|
{ |
|
|
|
|
|
sql_(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BarCollection = new ObservableCollection<BarModel> |
|
|
BarCollection = new ObservableCollection<BarModel> |
|
|
{ |
|
|
{ |
|
|
new BarModel { Id = 1, Name = "Bar 1", }, |
|
|
new BarModel { Id = 1, Name = "Bar 1", }, |
|
|
@ -38,6 +109,7 @@ namespace formula_manage.ViewModel |
|
|
|
|
|
|
|
|
public ObservableCollection<BarModel> BarCollection { get; set; } |
|
|
public ObservableCollection<BarModel> BarCollection { get; set; } |
|
|
public ObservableCollection<FooViewModel> FooCollection { get; set; } |
|
|
public ObservableCollection<FooViewModel> FooCollection { get; set; } |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public class FooViewModel : ViewModelBase |
|
|
public class FooViewModel : ViewModelBase |
|
|
|