refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
+93
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MECF.Framework.UI.Client.TrayThickness
|
||||
{
|
||||
public class PMDataViewManager
|
||||
{
|
||||
PMCoatingThickness PMData;
|
||||
PMDataViewSqlHelp pmDataHelp = new PMDataViewSqlHelp();
|
||||
private string PMGuid;
|
||||
public PMDataViewManager(PMCoatingThickness pmData, string pmGuid)
|
||||
{
|
||||
PMData = pmData;
|
||||
PMGuid = pmGuid;
|
||||
}
|
||||
public void UpTrayCoatingThickness()
|
||||
{
|
||||
PMCoatingThickness _pmCoatingThickness = pmDataHelp.GetTrayCoatingThickness(PMGuid);
|
||||
if (_pmCoatingThickness != null )
|
||||
{
|
||||
PMData.MinorCycle.Update(_pmCoatingThickness.MinorCycle);
|
||||
PMData.MajorCycle.Update(_pmCoatingThickness.MajorCycle);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 界面数据设置到数据库
|
||||
/// </summary>
|
||||
public bool SET(out string reason)
|
||||
{
|
||||
reason = "";
|
||||
|
||||
// 校验托盘组件数据
|
||||
if (!PMData.Validate(out reason))
|
||||
return false;
|
||||
|
||||
List<CoatingData> coatingDataList = new List<CoatingData>()
|
||||
{
|
||||
PMData.MinorCycle,
|
||||
PMData.MajorCycle,
|
||||
};
|
||||
|
||||
//检查单个环对象是否存在空数据
|
||||
foreach (var item in coatingDataList)
|
||||
{
|
||||
if (item.GetType().GetProperties()
|
||||
.Where(pi => pi.PropertyType == typeof(string))
|
||||
.Select(pi => (string)pi.GetValue(item))
|
||||
.Any(string.IsNullOrEmpty))
|
||||
{
|
||||
reason = $"Please check empty value";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var ret = pmDataHelp.UpTrayNumberData(PMData, PMGuid, coatingDataList);
|
||||
if (!ret)
|
||||
reason = "Failed to write tray Info. to database.";
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户输入数据时,去数据库查询更新到界面
|
||||
/// </summary>
|
||||
/// <param name="part"></param>
|
||||
public void LoadCoatingData(string part)
|
||||
{
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case "MinorCycle":
|
||||
ForUpCoatingData(PMData.MinorCycle.SerialNumber, PMData.MinorCycle);
|
||||
break;
|
||||
case "MajorCycle":
|
||||
ForUpCoatingData(PMData.MajorCycle.SerialNumber, PMData.MajorCycle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ForUpCoatingData(string number, CoatingData data)
|
||||
{
|
||||
var coatingData = pmDataHelp.GetCoatingData(number, out var isExistedInDb);
|
||||
if (isExistedInDb)
|
||||
{
|
||||
data.Update(coatingData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace MECF.Framework.UI.Client.TrayThickness
|
||||
{
|
||||
public class PMDataViewSqlHelp
|
||||
{
|
||||
private string minor_cycle, major_cycle, ring_inner_number, ring_outer_number;
|
||||
/// <summary>
|
||||
/// 获取Truy对象整体的数据
|
||||
/// </summary>
|
||||
/// <param name="_trayGuid"></param>
|
||||
/// <returns></returns>
|
||||
public PMCoatingThickness GetTrayCoatingThickness(string _trayGuid)
|
||||
{
|
||||
//这是一次查询一个对象
|
||||
PMCoatingThickness trayCoatingThickness = null;
|
||||
try
|
||||
{
|
||||
//根据TrayID获取对应内外编号
|
||||
string cmdID = $"select * from pm_thickness_data where pm_guid = '{_trayGuid}'";
|
||||
DataTable DataTable = QueryDataClient.Instance.Service.QueryData(cmdID);
|
||||
if (DataTable != null && DataTable.Rows.Count > 0)
|
||||
{
|
||||
|
||||
trayCoatingThickness = new PMCoatingThickness();
|
||||
minor_cycle = DataTable.Rows[0]["pm_minor_cycle"].ToString();
|
||||
major_cycle = DataTable.Rows[0]["pm_major_cycle"].ToString();
|
||||
|
||||
trayCoatingThickness.MinorCycle = GetCoatingData(minor_cycle, out _);
|
||||
trayCoatingThickness.MajorCycle = GetCoatingData(major_cycle, out _);
|
||||
}
|
||||
|
||||
|
||||
return trayCoatingThickness;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
return trayCoatingThickness;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个的数据
|
||||
/// </summary>
|
||||
/// <param name="sn"></param>
|
||||
/// <param name="isExistedInDb"></param>
|
||||
/// <returns></returns>
|
||||
public CoatingData GetCoatingData(string sn, out bool isExistedInDb)
|
||||
{
|
||||
var cmd = $"select * from pm_thickness_main where pm_cycle = '{sn}' ORDER BY create_time DESC LIMIT 1";
|
||||
var dt = QueryDataClient.Instance.Service.QueryData(cmd);
|
||||
|
||||
if (dt is { Rows.Count: > 0 })
|
||||
{
|
||||
var coatingData = new CoatingData()
|
||||
{
|
||||
SerialNumber = dt.Rows[0]["pm_cycle"].ToString(),
|
||||
MAX = dt.Rows[0]["pm_max_thickness"].ToString(),
|
||||
PmOwned = dt.Rows[0]["pm_number"].ToString(),
|
||||
Current = dt.Rows[0]["pm_coating_thickness"].ToString()
|
||||
};
|
||||
isExistedInDb = true;
|
||||
return coatingData;
|
||||
|
||||
}
|
||||
isExistedInDb = false;
|
||||
return new CoatingData();
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存用户输入的数据到数据库
|
||||
/// </summary>
|
||||
/// <param name="trayCoatingThickness"></param>
|
||||
/// <param name="trayUid"></param>
|
||||
public bool UpTrayNumberData(PMCoatingThickness trayCoatingThickness, string trayUid, List<CoatingData> coatingData)
|
||||
{
|
||||
List<string> cmdList = new List<string>();
|
||||
|
||||
string cmdID = $"select * from pm_thickness_data where pm_guid = '{trayUid}'";
|
||||
var dt = QueryDataClient.Instance.Service.QueryData(cmdID);
|
||||
if (dt is { Rows.Count: > 0 })
|
||||
cmdList.Add(Cmd_update(trayCoatingThickness, trayUid));
|
||||
else
|
||||
cmdList.Add(Cmd_data_insert(trayCoatingThickness, trayUid));
|
||||
foreach (var item in coatingData)
|
||||
{
|
||||
cmdList.Add(Cmd_main_insert(item));
|
||||
}
|
||||
bool result = QueryDataClient.Instance.Service.ExcuteTransAction(cmdList);
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool GetPartSnByTrayUid(string trayUid, out List<CoatingData> coatingData)
|
||||
{
|
||||
coatingData = new List<CoatingData>();
|
||||
var sql =
|
||||
$"select minor_cycle, major_cycle from pm_thickness_data WHERE pm_guid = '{trayUid}' limit 1";
|
||||
var dt = QueryDataClient.Instance.Service.QueryData(sql);
|
||||
if (dt is { Rows.Count: > 0 })
|
||||
{
|
||||
//partSnList.Add();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PM中对象编号插入Sql语句拼接
|
||||
/// </summary>
|
||||
/// <param name="pmCoatingThickness"></param>
|
||||
/// <param name="pmGuid"></param>
|
||||
/// <returns></returns>
|
||||
private string Cmd_data_insert(PMCoatingThickness pmCoatingThickness, string pmGuid)
|
||||
{
|
||||
string cmd_data_insert =
|
||||
"insert into pm_thickness_data" +
|
||||
"(pm_guid,pm_minor_cycle, pm_major_cycle)" +
|
||||
$"values ('{pmGuid}'," +
|
||||
$"'{pmCoatingThickness.MinorCycle.SerialNumber}'," +
|
||||
$"'{pmCoatingThickness.MajorCycle.SerialNumber}')";
|
||||
return cmd_data_insert;
|
||||
}
|
||||
/// <summary>
|
||||
/// PM中对象编号更新Sql语句拼接
|
||||
/// </summary>
|
||||
/// <param name="PMCoatingThickness"></param>
|
||||
/// <param name="pmGuid"></param>
|
||||
/// <returns></returns>
|
||||
private string Cmd_update(PMCoatingThickness PMCoatingThickness, string pmGuid)
|
||||
{
|
||||
string cmd_update =
|
||||
$"update pm_thickness_data set " +
|
||||
$"pm_minor_cycle = '{PMCoatingThickness.MinorCycle.SerialNumber}', " +
|
||||
$"pm_major_cycle= '{PMCoatingThickness.MajorCycle.SerialNumber}'" +
|
||||
$" where pm_guid = '{pmGuid}'";
|
||||
return cmd_update;
|
||||
}
|
||||
/// <summary>
|
||||
/// 每个环对应的数据插入Sql语句拼接
|
||||
/// </summary>
|
||||
/// <param name="coatingData"></param>
|
||||
/// <returns></returns>
|
||||
private string Cmd_main_insert(CoatingData coatingData)
|
||||
{
|
||||
return "insert into pm_thickness_main" +
|
||||
"(pm_guid,pm_cycle,pm_number, pm_coating_thickness, pm_max_thickness,pm_label,create_time)" +
|
||||
$"values ('{Guid.NewGuid()}'," +
|
||||
$"'{coatingData.SerialNumber}'," +
|
||||
$"'{coatingData.PmOwned}'," +
|
||||
$"'{coatingData.Current}'," +
|
||||
$"'{coatingData.MAX}'," +
|
||||
$"'{coatingData.Caption}'," +
|
||||
$"'{coatingData.CreatTime}')";
|
||||
}
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
<Window x:Class="MECF.Framework.UI.Client.TrayThickness.WinPMThicknessDataView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
xmlns:cal="http://www.caliburn.org"
|
||||
mc:Ignorable="d"
|
||||
Height="150" Width="700" >
|
||||
<Window.Resources>
|
||||
|
||||
<Style TargetType="TextBlock" >
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
<Setter Property="TextAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="TextWrapping" Value="Wrap" />
|
||||
<Setter Property="Margin" Value="3"/>
|
||||
<Setter Property="FontFamily" Value="Arial Black"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Background" Value="{DynamicResource Table_BG_Title}" />
|
||||
<Setter Property="BorderBrush" Value="Gray"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
</Style>
|
||||
|
||||
|
||||
</Window.Resources>
|
||||
|
||||
|
||||
<Grid >
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="3"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--界面标题-->
|
||||
<Border CornerRadius="0,0,0,0" Grid.ColumnSpan="6" Background="#FF243664" >
|
||||
<TextBlock Text="PM Coating Thickness" FontSize="15" Foreground="White" HorizontalAlignment="Center" Padding="8,0,0,0"/>
|
||||
</Border >
|
||||
|
||||
<!--首行标签-->
|
||||
<Border Grid.Row="1" Padding="5,1,0,1" BorderThickness="1,0,1,1" >
|
||||
<TextBlock Text="Component" />
|
||||
</Border>
|
||||
<Border Grid.Row="1" Grid.Column="1" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
|
||||
<TextBlock Text="SN"/>
|
||||
</Border>
|
||||
<Border Grid.Row="1" Grid.Column="2" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
|
||||
<TextBlock Text="Coating"/>
|
||||
</Border>
|
||||
<Border Grid.Row="1" Grid.Column="3" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
|
||||
<TextBlock Text="MAX"/>
|
||||
</Border>
|
||||
|
||||
|
||||
|
||||
<!--对象行-->
|
||||
<Border Grid.Row="2" Padding="5,1,0,1" BorderThickness="1,0,1,1" >
|
||||
<TextBlock Text="{Binding PMData.MinorCycle.Caption}"/>
|
||||
</Border>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding PMData.MinorCycle.SerialNumber}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="LostFocus">
|
||||
<micro:ActionMessage MethodName="LoadCoatingData">
|
||||
<micro:Parameter Value="MinorCycle" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</TextBox>
|
||||
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding PMData.MinorCycle.Current}" TextChanged="TextBox_TextChanged" />
|
||||
<TextBox Grid.Row="2" Grid.Column="3" Text="{Binding PMData.MinorCycle.MAX}" TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Border Grid.Row="3" Padding="5,1,0,1" BorderThickness="1,1,1,1" >
|
||||
<TextBlock Text="{Binding PMData.MajorCycle.Caption}"/>
|
||||
</Border>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding PMData.MajorCycle.SerialNumber}" >
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="LostFocus">
|
||||
<micro:ActionMessage MethodName="LoadCoatingData">
|
||||
<micro:Parameter Value="MajorCycle" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</TextBox>
|
||||
<TextBox Grid.Row="3" Grid.Column="2" Text="{Binding PMData.MajorCycle.Current}" TextChanged="TextBox_TextChanged"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="3" Text="{Binding PMData.MajorCycle.MAX}" TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="4" Grid.RowSpan="3">
|
||||
<Button
|
||||
|
||||
Content="SET"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SET">
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<!--</Viewbox>-->
|
||||
</Window>
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MECF.Framework.UI.Client.TrayThickness
|
||||
{
|
||||
/// <summary>
|
||||
/// WinPMThicknessDataView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class WinPMThicknessDataView : Window
|
||||
{
|
||||
public WinPMThicknessDataView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
TextBox textBox = sender as TextBox;
|
||||
double input;
|
||||
if (!double.TryParse(textBox.Text, out input))
|
||||
textBox.Foreground = Brushes.Red;
|
||||
else if (input < 0 || input > 9999999)
|
||||
textBox.Foreground = Brushes.Red;
|
||||
else
|
||||
textBox.Foreground = Brushes.Black;
|
||||
}
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using OpenSEMI.ClientBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MECF.Framework.UI.Client.TrayThickness
|
||||
{
|
||||
public class WinPMThicknessDataViewModel : UiViewModelBase
|
||||
{
|
||||
PMDataViewManager pmDataViewManager;
|
||||
string trayID;
|
||||
public PMCoatingThickness PMData { get; set; }
|
||||
public WinPMThicknessDataViewModel(string _pmGuid)
|
||||
{
|
||||
PMData = new PMCoatingThickness(_pmGuid);
|
||||
pmDataViewManager = new PMDataViewManager(PMData, _pmGuid);
|
||||
UpTrayCoatingThickness();
|
||||
}
|
||||
public void UpTrayCoatingThickness()//打开时,初始化界面数据
|
||||
{
|
||||
pmDataViewManager.UpTrayCoatingThickness();
|
||||
}
|
||||
public void SET()//设置到数据库
|
||||
{
|
||||
if (pmDataViewManager.SET(out var reason))
|
||||
{
|
||||
DialogBox.ShowInfo("MinorCycle Info. created successfully!");
|
||||
TryClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogBox.ShowError(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadCoatingData(string part)//人工输入名称后,查询数据
|
||||
{
|
||||
pmDataViewManager.LoadCoatingData(part);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user