Merge branch 'master' of http://www.scserverddns.top:13000/sc/formula_manage
This commit is contained in:
commit
13b13e817a
3 files changed
+208
-66
No files matched your search
+5
-5
@@ -9,7 +9,9 @@
|
|||||||
DataContext="{Binding Source={StaticResource Locator}, Path=Main}"
|
DataContext="{Binding Source={StaticResource Locator}, Path=Main}"
|
||||||
BorderBrush="White" Background="#FFE0E0E0">
|
BorderBrush="White" Background="#FFE0E0E0">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
|
<CollectionViewSource x:Key="UnitList" Source="{Binding Path=UnitList}"/>
|
||||||
<CollectionViewSource x:Key="BarCollectionSource" Source="{Binding Path=BarCollection}"/>
|
<CollectionViewSource x:Key="BarCollectionSource" Source="{Binding Path=BarCollection}"/>
|
||||||
|
<CollectionViewSource x:Key="defaultView" Source="{Binding Path=defaultView}"/>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -163,11 +165,9 @@
|
|||||||
<DataGridTemplateColumn.CellTemplate>
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ComboBox x:Name="CP_PRODUCT_CODE" BorderThickness="0,0,0,0"
|
<ComboBox x:Name="CP_PRODUCT_CODE" BorderThickness="0,0,0,0"
|
||||||
|
ItemsSource="{Binding Path=DataContext.BarCollection, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
|
||||||
DisplayMemberPath="Name"
|
|
||||||
SelectedItem="{Binding Bar, UpdateSourceTrigger=LostFocus}"
|
|
||||||
ItemsSource="{Binding Source={StaticResource BarCollectionSource}}"
|
|
||||||
|
|
||||||
Text="{Binding PRODUCT_CODE}"
|
Text="{Binding PRODUCT_CODE}"
|
||||||
BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" KeyDown="CP_PRODUCT_CODE_KeyUp"
|
BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" KeyDown="CP_PRODUCT_CODE_KeyUp"
|
||||||
>
|
>
|
||||||
|
|||||||
+126
-56
@@ -28,6 +28,7 @@ using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
|
|||||||
using static System.Net.Mime.MediaTypeNames;
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
//using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
//using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
|
||||||
namespace formula_manage
|
namespace formula_manage
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -54,12 +55,14 @@ namespace formula_manage
|
|||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
|
// DataContext =new MainWindow();
|
||||||
|
|
||||||
int ID_N = 1;
|
int ID_N = 1;
|
||||||
|
|
||||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.Closing += Window_Closing; //添加窗口关闭事件
|
this.Closing += Window_Closing; //添加窗口关闭事件
|
||||||
|
|
||||||
USER.Text = App.USER_Purview;
|
USER.Text = App.USER_Purview;
|
||||||
|
|
||||||
RecipedataTable.Columns.Add("DYELOT", typeof(int));
|
RecipedataTable.Columns.Add("DYELOT", typeof(int));
|
||||||
@@ -119,84 +122,151 @@ namespace formula_manage
|
|||||||
|
|
||||||
Grid_RRODUCT.ItemsSource = RRODUCTdataTable.DefaultView;
|
Grid_RRODUCT.ItemsSource = RRODUCTdataTable.DefaultView;
|
||||||
|
|
||||||
this.DataContext = STUFFdataTable;
|
DataView defaultView = MACHINEdataTable.DefaultView;
|
||||||
|
// UnitList = defaultView;
|
||||||
|
|
||||||
/* DataGridTemplateColumn tempColumn = Grid_RRODUCT.Columns[1] as DataGridTemplateColumn;
|
|
||||||
FrameworkElement element1 = Grid_RRODUCT.Columns[1].GetCellContent(Grid_RRODUCT.Items[1]);
|
// DataContext = MACHINEdataTable.DefaultView;
|
||||||
System.Windows.Controls.ComboBox comboBox1 = tempColumn.CellTemplate.FindName("CP_PRODUCT_CODE", element1) as System.Windows.Controls.ComboBox;
|
|
||||||
|
// CP_PRODUCT_CODE.ItemsSource= STUFFdataTable.;
|
||||||
|
/* DataGridTemplateColumn tempColumn = Grid_RRODUCT.Columns[1] as DataGridTemplateColumn;
|
||||||
|
FrameworkElement element1 = Grid_RRODUCT.Columns[1].GetCellContent(Grid_RRODUCT.Items[1]);
|
||||||
|
System.Windows.Controls.ComboBox comboBox1 = tempColumn.CellTemplate.FindName("CP_PRODUCT_CODE", element1) as System.Windows.Controls.ComboBox;
|
||||||
|
|
||||||
|
comboBox1.ItemsSource = STUFFdataTable.DefaultView;*/
|
||||||
|
|
||||||
|
/* SelectionList.Add("Name1");
|
||||||
|
|
||||||
|
SelectionList.Add("Name2");*/
|
||||||
|
|
||||||
|
|
||||||
comboBox1.ItemsSource = STUFFdataTable.DefaultView;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string[] UnitList { get; set; }
|
||||||
|
|
||||||
/* private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private int g_TypeNameDicNo =123; //枪型号名
|
||||||
{
|
|
||||||
var cb = (sender as System.Windows.Controls.ComboBox);
|
|
||||||
if (cb == null || cb.Tag == null) return;
|
|
||||||
int idx = int.Parse(cb.Tag.ToString());
|
|
||||||
// var bindDataGridDatas = this.Grid_RRODUCT.ItemsSource as BindDataGridData[];//成员变量和这里转换都可以。
|
|
||||||
// bindDataGridDatas[idx].UnitStr = (string)cb.SelectedItem;//手动保存到数据结构
|
|
||||||
// bindDataGridDatas[idx].UpdateKBValue(); //联动CoefK值
|
|
||||||
}
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public int G_TypeNameDicNo
|
||||||
|
|
||||||
private void PropertiesC([CallerMemberName] string propertyName = "")
|
|
||||||
{
|
|
||||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Idx { get; set; } = 0;
|
|
||||||
|
|
||||||
string unitstr = "Pa";
|
|
||||||
|
|
||||||
public string UnitStr
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this.unitstr;
|
return g_TypeNameDicNo;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.unitstr = value;
|
g_TypeNameDicNo = value;
|
||||||
this.PropertiesC();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public string G_TypeNameDicNoStr
|
||||||
public string[] UnitList { get; set; } = new string[] { "Pa", "kPa", "MPa" };
|
|
||||||
|
|
||||||
public static readonly float[][] KBList = new float[][] { new float[] { 1, 1 }, new float[] { 1000, 2 }, new float[] { 1000000, 3 } };
|
|
||||||
|
|
||||||
float coefK { get; set; } = 1f;
|
|
||||||
|
|
||||||
public float CoefK
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this.coefK;
|
return gunNameTypeDic[g_TypeNameDicNo]; //查找Dictionary返回它的Value
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.coefK = value;
|
int selectedIndex = 0;
|
||||||
this.PropertiesC();
|
foreach (KeyValuePair<int, string> pair in gunNameTypeDic)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateKBValue()
|
|
||||||
{
|
|
||||||
int idx = -1;
|
|
||||||
for (int j = 0; j < this.UnitList.Length; j++)
|
|
||||||
{
|
|
||||||
if (this.UnitList[j] == this.unitstr)
|
|
||||||
{
|
{
|
||||||
idx = j; break;
|
if (pair.ToString().Equals(value)) //对比键值对
|
||||||
|
{
|
||||||
|
selectedIndex = pair.Key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
G_TypeNameDicNo = selectedIndex;
|
||||||
}
|
}
|
||||||
if (idx == -1) return;
|
}
|
||||||
//throw new System.Exception("no Unit in UnitList: unit " + this.UnitStr + " UnitList {" + string.Join(", ", this.UnitList)+"}");
|
|
||||||
|
|
||||||
//this.CoefK = BindDataGridData.KBList[idx][0];
|
private Dictionary<int, string> gunNameTypeDic;
|
||||||
}*/
|
public Dictionary<int, string> GunNameTypeDic
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return gunNameTypeDic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<string> SelectionList //ObservableCollection这是一个类,需引用(using System.Collections.ObjectModel)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
get { return _selectionList; }
|
||||||
|
|
||||||
|
set { _selectionList = value; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ObservableCollection<string> _selectionList = new ObservableCollection<string>(); //这个是实现的重要一步
|
||||||
|
|
||||||
|
/* private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var cb = (sender as System.Windows.Controls.ComboBox);
|
||||||
|
if (cb == null || cb.Tag == null) return;
|
||||||
|
int idx = int.Parse(cb.Tag.ToString());
|
||||||
|
// var bindDataGridDatas = this.Grid_RRODUCT.ItemsSource as BindDataGridData[];//成员变量和这里转换都可以。
|
||||||
|
// bindDataGridDatas[idx].UnitStr = (string)cb.SelectedItem;//手动保存到数据结构
|
||||||
|
// bindDataGridDatas[idx].UpdateKBValue(); //联动CoefK值
|
||||||
|
}
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
private void PropertiesC([CallerMemberName] string propertyName = "")
|
||||||
|
{
|
||||||
|
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Idx { get; set; } = 0;
|
||||||
|
|
||||||
|
string unitstr = "Pa";
|
||||||
|
|
||||||
|
public string UnitStr
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.unitstr;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.unitstr = value;
|
||||||
|
this.PropertiesC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] UnitList { get; set; } = new string[] { "Pa", "kPa", "MPa" };
|
||||||
|
|
||||||
|
public static readonly float[][] KBList = new float[][] { new float[] { 1, 1 }, new float[] { 1000, 2 }, new float[] { 1000000, 3 } };
|
||||||
|
|
||||||
|
float coefK { get; set; } = 1f;
|
||||||
|
|
||||||
|
public float CoefK
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.coefK;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.coefK = value;
|
||||||
|
this.PropertiesC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateKBValue()
|
||||||
|
{
|
||||||
|
int idx = -1;
|
||||||
|
for (int j = 0; j < this.UnitList.Length; j++)
|
||||||
|
{
|
||||||
|
if (this.UnitList[j] == this.unitstr)
|
||||||
|
{
|
||||||
|
idx = j; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (idx == -1) return;
|
||||||
|
//throw new System.Exception("no Unit in UnitList: unit " + this.UnitStr + " UnitList {" + string.Join(", ", this.UnitList)+"}");
|
||||||
|
|
||||||
|
//this.CoefK = BindDataGridData.KBList[idx][0];
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -520,7 +590,7 @@ namespace formula_manage
|
|||||||
|
|
||||||
Procedures_N.Text = "1";
|
Procedures_N.Text = "1";
|
||||||
Procedures_P.Text = "1";
|
Procedures_P.Text = "1";
|
||||||
// RecipedataTable = RRODUCTdataTable;
|
RecipedataTable = RRODUCTdataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_NewOrder(object sender, RoutedEventArgs e) //新料单按钮
|
private void Button_NewOrder(object sender, RoutedEventArgs e) //新料单按钮
|
||||||
|
|||||||
@@ -1,25 +1,96 @@
|
|||||||
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>
|
||||||
/// RRODUCTiewModel
|
/// RRODUCTiewModel
|
||||||
///</Summary>
|
///</Summary>
|
||||||
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", },
|
||||||
@@ -35,9 +106,10 @@ 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
|
||||||
|
|||||||
Reference in new issue
Block a user