diff --git a/App.config b/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/App.xaml b/App.xaml
new file mode 100644
index 0000000..31d7333
--- /dev/null
+++ b/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/App.xaml.cs b/App.xaml.cs
new file mode 100644
index 0000000..3be5ab5
--- /dev/null
+++ b/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace ProcessManagGUI
+{
+ ///
+ /// App.xaml 的交互逻辑
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/IniFile.cs b/IniFile.cs
new file mode 100644
index 0000000..536b47d
--- /dev/null
+++ b/IniFile.cs
@@ -0,0 +1,52 @@
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace StatisticsUI
+{
+ internal class IniFile
+ {
+ public class IniFiles
+ {
+ public string path;
+ [DllImport("kernel32")] //返回0表示失败,非0为成功
+ private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
+ [DllImport("kernel32")] //返回取得字符串缓冲区的长度
+ private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
+ ///
+ /// 保存ini文件的路径
+ /// 调用示例:var ini = IniFiles("C:\file.ini");
+ ///
+ ///
+ public IniFiles(string iniPath)
+ {
+ this.path = iniPath;
+ }
+ ///
+ /// 写Ini文件
+ /// 调用示例:ini.IniWritevalue("Server","name","localhost");
+ ///
+ /// [缓冲区]
+ /// 键
+ /// 值
+ public void IniWritevalue(string Section, string Key, string value)
+ {
+ WritePrivateProfileString(Section, Key, value, this.path);
+ }
+ ///
+ /// 读Ini文件
+ /// 调用示例:ini.IniWritevalue("Server","name");
+ ///
+ /// [缓冲区]
+ /// 键
+ /// 值
+ public string IniReadvalue(string Section, string Key)
+ {
+ StringBuilder temp = new StringBuilder(255);
+
+ int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
+ return temp.ToString();
+ }
+
+ }
+ }
+}
diff --git a/MainWindow.xaml b/MainWindow.xaml
new file mode 100644
index 0000000..99461f9
--- /dev/null
+++ b/MainWindow.xaml
@@ -0,0 +1,142 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
new file mode 100644
index 0000000..e9a60f5
--- /dev/null
+++ b/MainWindow.xaml.cs
@@ -0,0 +1,163 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+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;
+using System.Windows.Threading;
+
+namespace StatisticsUI
+{
+ ///
+ /// MainWindow.xaml 的交互逻辑
+ ///
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+
+
+ private static IniFile.IniFiles Configini = new IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "ProcessManageConfigini.ini");
+ private static string SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
+ private static string SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2");
+ private static string SQMOD = Configini.IniReadvalue("SQL_SERVER", "SQL3");
+ private static string SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4");
+ private static string SQLPASWORD = Configini.IniReadvalue("SQL_SERVER", "SQL5");
+ private static DataTable DyelotsBulkedRecipe = new DataTable();
+ private static DataTable Machine = new DataTable();
+ private static DataTable Gram = new DataTable();
+ private static DataTable Machine_Gram = new DataTable();
+ SqlConnection conn_SC;
+ string Connstr_SC;
+ public static string DataGridStatistics_ProductCode = null;
+ public static string date_start_time;
+ public static string date_end_time;
+ public static string query_start = null;//全局变量开始时间
+ public static string query_end = null;//全局变量结束时间
+ public static int type = 0;//全局变量结束时间
+
+ private void DataGridStatistics_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
+ {
+ int rownum = DataGridStatistics.SelectedIndex;//获取鼠标选中行并定义变量
+ if (rownum != -1)//判断鼠标定位是否有效
+ {
+ /*定位选中行及指定列单元格文本信息*/
+ DataGridStatistics_ProductCode = (DataGridStatistics.Columns[0].GetCellContent(DataGridStatistics.Items[rownum]) as TextBlock).Text;//定位第0列,原料代码
+ }
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ query_start = this.query_date_start.Text;//传递开始日期
+ date_start_time = this.query_date_start_time.Text;//传递开始时间
+ query_end = this.query_date_end.Text;//传递结束日期
+ date_end_time = this.query_date_end_time.Text;//传递结束时间
+ string t = DateTime.Now.ToString("yyyy-MM-dd");
+ int query_endT = DateTime.Compare(Convert.ToDateTime(query_end), Convert.ToDateTime(t)); //比较结束时间及当期,小于-1 等于0 大于1
+ if (query_endT == 0) query_end = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"); //如果结束时间为空则填入当天时间加1天
+ if (query_end == DateTime.Now.ToString("yyyy-MM-dd")) query_end = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
+ int query_TimeCompare = DateTime.Compare(Convert.ToDateTime(query_start), Convert.ToDateTime(query_end)); //比较开始结束时间,小于-1 等于0 大于1
+ if (query_TimeCompare == 1)//判断查询时间是否有效,等于1无效
+ {
+ MessageBox.Show("SC:无效查询时间", "错误");//返回无效时间弹窗
+ }
+ else
+ {
+ string DyelotsBulkedRecipe_sql;
+ string Machine_sql;
+ if (this.stuff_ProductType.Text == "染料") type = 1;//原料类型
+ if (this.stuff_ProductType.Text == "助剂") type = 2;
+ if (this.stuff_ProductType.Text == "粉体助剂") type = 3;
+ if (this.stuff_ProductType.Text == "全部原料")
+ {
+ DyelotsBulkedRecipe_sql =
+ "SELECT [ProductCode],[ProductName],SUM(DispenseGrams)/1000 as TotalDispenseGrams,COUNT(*) as PrescriptionCount " +
+ "FROM [BatchDyeingCentral].[dbo].[DyelotsBulkedRecipe] where Created > '" + query_start + " " +
+ date_start_time + "' AND Created < '" + query_end + " " + date_end_time + "'AND DispenseGrams IS NOT NULL" +
+ " GROUP BY [ProductCode],[ProductName] ORDER BY TotalDispenseGrams DESC ";
+ Machine_sql =
+ "SELECT m.Name AS MachineName," +
+ "COUNT(DISTINCT d.Dyelot) AS DyelotCount," +
+ "ISNULL(SUM(dbr.DispenseGrams)/1000, 0) AS TotalDispenseGrams," +
+ "COUNT(DISTINCT CASE WHEN dbr.Dyelot IS NOT NULL AND dbr.DispenseResult = 301" +
+ "THEN CONCAT(dbr.Dyelot, '|', ISNULL(dbr.ReDye, ''), '|', ISNULL(CAST(dbr.StepNumber AS NVARCHAR(10)), ''))" +
+ "END ) AS UniqueRecipeCount FROM Machines m LEFT JOIN Dyelots d ON m.Name = d.Machine " +
+ "LEFT JOIN DyelotsBulkedRecipe dbr ON d.Dyelot = dbr.Dyelot GROUP BY m.Name ORDER BY m.Name";
+ }
+ else
+ {
+ DyelotsBulkedRecipe_sql =
+ "SELECT [ProductCode],[ProductName],SUM(DispenseGrams)/1000 as TotalDispenseGrams,COUNT(*) as PrescriptionCount " +
+ "FROM [BatchDyeingCentral].[dbo].[DyelotsBulkedRecipe] where Created >= '" + query_start + " " + date_start_time + "' AND Created < '" +
+ query_end + " " + date_end_time + "'AND ProductType='"+ type + "'AND DispenseGrams IS NOT NULL" +
+ " GROUP BY [ProductCode],[ProductName] ORDER BY TotalDispenseGrams DESC ";
+ Machine_sql =
+ "SELECT m.Name AS MachineName," +
+ "COUNT(DISTINCT d.Dyelot) AS DyelotCount," +
+ "ISNULL(SUM(CASE WHEN dbr.ProductType = '"+type+"' THEN dbr.DispenseGrams END)/1000, 0) AS TotalDispenseGrams," +
+ "COUNT(DISTINCT CASE WHEN dbr.Dyelot IS NOT NULL AND dbr.DispenseResult = 301 AND dbr.ProductType = '"+type+
+ "'THEN CONCAT(dbr.Dyelot, '|', ISNULL(dbr.ReDye, ''), '|', ISNULL(CAST(dbr.StepNumber AS NVARCHAR(10)), ''))" +
+ "END ) AS UniqueRecipeCount FROM Machines m LEFT JOIN Dyelots d ON m.Name = d.Machine " +
+ "AND d.CreationTime >= '" + query_start + " " + date_start_time + "' AND d.CreationTime < '" + query_end +
+ " " + date_end_time + "' LEFT JOIN DyelotsBulkedRecipe dbr ON d.Dyelot = dbr.Dyelot AND dbr.Created>='" + query_start +
+ " " + date_start_time + "' AND dbr.Created < '" + query_end + " " + date_end_time + "' GROUP BY m.Name ORDER BY m.Name";
+ }
+ conn_SC.OpenAsync(); //连接数据库
+ Machine.Clear();
+ DyelotsBulkedRecipe.Clear();
+ SqlDataAdapter DyelotsBulkedRecipe_ = new SqlDataAdapter(DyelotsBulkedRecipe_sql, Connstr_SC);
+ SqlDataAdapter Machine_ = new SqlDataAdapter(Machine_sql, Connstr_SC);
+ try
+ {
+ // DyelotsBulkedRecipe.Clear();
+ DyelotsBulkedRecipe_.Fill(DyelotsBulkedRecipe);
+ DataGridStatistics.ItemsSource = DyelotsBulkedRecipe.DefaultView;
+ // DyelotsBulkedRecipe.Clear();
+
+ //Machine.Clear();
+ Machine_.Fill(Machine);
+ DataGridStatistics_mac.ItemsSource = Machine.DefaultView;
+ // Machine.Clear();
+
+ }
+ catch (Exception ex)
+ {
+ }
+ finally
+ {
+ conn_SC.Close();
+ }
+ }
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";User ID=" + SQLUSER + ";Password=" + SQLPASWORD;
+ conn_SC = new SqlConnection(Connstr_SC);
+
+ Gram.Columns.Add("ProductCode", typeof(string));
+ Gram.Columns.Add("ProductName", typeof(string));
+ Gram.Columns.Add("TotalDispenseGrams", typeof(string));
+ Gram.Columns.Add("PrescriptionCount", typeof(string));
+
+ Machine_Gram.Columns.Add("MachineName", typeof(string));
+ Machine_Gram.Columns.Add("TotalDispenseGrams", typeof(string));
+ Machine_Gram.Columns.Add("DyelotCount", typeof(string));
+ Machine_Gram.Columns.Add("UniqueRecipeCount", typeof(string));
+ }
+ }
+}
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f035443
--- /dev/null
+++ b/Properties/AssemblyInfo.cs
@@ -0,0 +1,52 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("ProcessManagGUI")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ProcessManagGUI")]
+[assembly: AssemblyCopyright("Copyright © 2025")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请设置
+//.csproj 文件中的 CultureYouAreCodingWith
+//在 中。例如,如果你使用的是美国英语。
+//使用的是美国英语,请将 设置为 en-US。 然后取消
+//对以下 NeutralResourceLanguage 特性的注释。 更新
+//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //主题特定资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //或应用程序资源字典中找到时使用)
+ ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //、应用程序或任何主题专用资源字典中找到时使用)
+)]
+
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..e74ffe4
--- /dev/null
+++ b/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace ProcessManagGUI.Properties
+{
+
+
+ ///
+ /// 强类型资源类,用于查找本地化字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// 返回此类使用的缓存 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProcessManagGUI.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..77c91b2
--- /dev/null
+++ b/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace ProcessManagGUI.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StatisticsUI.csproj b/StatisticsUI.csproj
new file mode 100644
index 0000000..68fbcff
--- /dev/null
+++ b/StatisticsUI.csproj
@@ -0,0 +1,104 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {9D677FAF-CB71-49A1-B327-060E16D45E17}
+ WinExe
+ ProcessManagGUI
+ ProcessManagGUI
+ v4.7.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StatisticsUI.sln b/StatisticsUI.sln
new file mode 100644
index 0000000..4624a11
--- /dev/null
+++ b/StatisticsUI.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36511.14
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatisticsUI", "StatisticsUI.csproj", "{9D677FAF-CB71-49A1-B327-060E16D45E17}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9D677FAF-CB71-49A1-B327-060E16D45E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9D677FAF-CB71-49A1-B327-060E16D45E17}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9D677FAF-CB71-49A1-B327-060E16D45E17}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9D677FAF-CB71-49A1-B327-060E16D45E17}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {2B17EF6F-2576-43B7-91BC-F480E72D06C9}
+ EndGlobalSection
+EndGlobal
diff --git a/sunlight_logo.ico b/sunlight_logo.ico
new file mode 100644
index 0000000..2fe6131
Binary files /dev/null and b/sunlight_logo.ico differ