diff --git a/App.xaml b/App.xaml
index cf3a53b..0fc0efc 100644
--- a/App.xaml
+++ b/App.xaml
@@ -57,6 +57,9 @@
+
+
+
diff --git a/Language/en_US.xaml b/Language/en_US.xaml
index 04e1ddd..d96082a 100644
--- a/Language/en_US.xaml
+++ b/Language/en_US.xaml
@@ -26,7 +26,7 @@
STANDARD_EN_NAME
SHAPE_EN_NAME
INSTITUTE_EN_NAME
-
+ RULE_EN_NAME
Average
diff --git a/Language/zh_CN.xaml b/Language/zh_CN.xaml
index 8d54950..ae150a7 100644
--- a/Language/zh_CN.xaml
+++ b/Language/zh_CN.xaml
@@ -27,13 +27,21 @@
压缩Json
+ 标准
+ 形状
+ 冠部
+ 亭部
+ 重量(ct)
+ 切工等级
+ 对称等级
平均
圆度
深度
最小值
最大值
SYM等级
-
+ 导出
+
是否退出程序?
是否退出
是
@@ -54,6 +62,9 @@
确定
跳过
没有输入钻石编码
+
+ 保存成功
+ 保存失败
圆形
心形
@@ -73,4 +84,19 @@
按钮
+
+ 保存
+ 系统配置
+ 语言设置
+ 上传文件
+ TXT文件
+ STL文件
+ Excel文件
+ Dat文件
+ 保存路径
+ 请输入
+ 选择
+ 定级标准
+ 保存路径不存在
+ RULE_NAME
\ No newline at end of file
diff --git a/Model/Entity/CutterConfigEntity.cs b/Model/Entity/CutterConfigEntity.cs
index a8edfb7..c43ddf1 100644
--- a/Model/Entity/CutterConfigEntity.cs
+++ b/Model/Entity/CutterConfigEntity.cs
@@ -8,26 +8,26 @@ namespace SparkClient.Model.Entity;
/// 系统设置实体
///
-public class CutterConfigEntity : BaseEntity
+public class CutterConfigEntity
{
- public static readonly new string TableName = "CUTTER_CONFIG";
+ public static readonly string TableName = "CUTTER_CONFIG";
[DbField("GUID")]
public Guid GUID { get; set; }
///
/// 项目名称
///
[DbField("ITEM_NAME")]
- public string ItemName { get; set; }
+ public required string ItemName { get; set; }
///
/// key
///
[DbField("KEY")]
- public string Key { get; set; }
+ public required string Key { get; set; }
///
/// value
///
[DbField("VALUE")]
- public string Value { get; set; }
+ public required string Value { get; set; }
private static Dictionary GetFieldMappings()
{
var properties = typeof(CutterConfigEntity).GetProperties(BindingFlags.Public | BindingFlags.Instance);
@@ -49,7 +49,7 @@ public class CutterConfigEntity : BaseEntity
}
// 生成 Update 语句
- public string GenerateUpdateSQL(Dictionary fieldsToUpdate = null)
+ public string GenerateUpdateSQL(Dictionary? fieldsToUpdate = null)
{
if (fieldsToUpdate == null || fieldsToUpdate.Count == 0)
{
@@ -67,7 +67,7 @@ public class CutterConfigEntity : BaseEntity
}
// 生成 Delete 语句
- public string GenerateDeleteSQL(Dictionary conditions = null)
+ public string GenerateDeleteSQL(Dictionary? conditions = null)
{
if (conditions == null || conditions.Count == 0)
{
diff --git a/Model/Helper/DataBaseHelper.cs b/Model/Helper/DataBaseHelper.cs
index e68c52f..db31753 100644
--- a/Model/Helper/DataBaseHelper.cs
+++ b/Model/Helper/DataBaseHelper.cs
@@ -1,5 +1,7 @@
using System.Data;
using System.IO;
+using log4net;
+using log4net.Repository.Hierarchy;
using Microsoft.Data.Sqlite;
namespace SparkClient.Model.Helper;
@@ -8,12 +10,13 @@ namespace SparkClient.Model.Helper;
///
public class DataBaseHelper
{
+ private static readonly ILog Logger = LogManager.GetLogger(typeof(MainWindow));
//连接、查询、查询、关闭
-
+
public static void InitDataBase()
{
string databasePath = Path.Combine(Common.BasePath, Common.DataBaseTempFileName);
-
+ Logger logger;
if (File.Exists(databasePath))
return;
else
@@ -36,8 +39,8 @@ public class DataBaseHelper
static readonly string password = Common.DatabasePwd;
static readonly string dbPath = Common.DataBaseFileName;
- static SqliteConnection connection;
- static SqliteTransaction sqliteTransaction;
+ static SqliteConnection? connection;
+ static SqliteTransaction? sqliteTransaction;
public static void CreateConnection()
{
@@ -59,7 +62,10 @@ public class DataBaseHelper
public static void CloseConnection()
{
- connection.Close();
+ if (connection != null)
+ {
+ connection.Close();
+ }
}
public static void BeginTransaction()
{
@@ -95,7 +101,10 @@ public class DataBaseHelper
SqliteCommand cmd = new SqliteCommand();
cmd.Connection = connection;
cmd.CommandText = sql;
- cmd.Transaction = sqliteTransaction;
+ if (sqliteTransaction != null)
+ {
+ cmd.Transaction = sqliteTransaction;
+ }
if (sqlParameters != null)
{
cmd.Parameters.AddRange(sqlParameters);
@@ -135,8 +144,8 @@ public class DataBaseHelper
}
catch (Exception ex)
{
- System.Windows.MessageBox.Show("检索失败");
- Console.WriteLine(ex.ToString());
+ Logger.Error($"全局异常捕获:{ex.Message}", ex);
+ System.Windows.MessageBox.Show($"应用程序出现错误:{ex.Message}");
}
return null;
}
diff --git a/SparkClient.csproj b/SparkClient.csproj
index 493fc34..a920f72 100644
--- a/SparkClient.csproj
+++ b/SparkClient.csproj
@@ -33,6 +33,9 @@
+
+
+
@@ -46,6 +49,8 @@
+
+
Always
diff --git a/SparkDB.db b/SparkDB.db
index b04de82..88e7081 100644
Binary files a/SparkDB.db and b/SparkDB.db differ
diff --git a/ViewModel/BaseWindow/HomeWindowVM.cs b/ViewModel/BaseWindow/HomeWindowVM.cs
index 5e01694..1030b2c 100644
--- a/ViewModel/BaseWindow/HomeWindowVM.cs
+++ b/ViewModel/BaseWindow/HomeWindowVM.cs
@@ -62,9 +62,13 @@ public class HomeWindowVM : BaseViewModel
// WindowManager.mainViewModel.Content = vm;
// WindowManager.openContent.Add(vm);
// }
- BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("DetectionResult"));
- WindowManager.mainViewModel.Content = vm;
- WindowManager.openContent.Add(vm);
+ //BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("DetectionResult"));
+ //WindowManager.mainViewModel.Content = vm;
+ //WindowManager.openContent.Add(vm);
+
+ StartDialog startDialog = new StartDialog();
+ startDialog.ShowDialog();
+
}
catch (Exception e)
{
diff --git a/ViewModel/Configuration/AlgorithmConfigVM.cs b/ViewModel/Configuration/AlgorithmConfigVM.cs
index 18ef232..1db3fe2 100644
--- a/ViewModel/Configuration/AlgorithmConfigVM.cs
+++ b/ViewModel/Configuration/AlgorithmConfigVM.cs
@@ -34,7 +34,7 @@ public class AlgorithmConfigVM : BaseViewModel
public void InitAlgorithmData(object param)
{
AlgorithmConfigJson = "{}";
- string sql = @"SELECT JSON as json FROM METHOD_CONFIG ORDER BY JSON_ORDER";
+ string sql = @"SELECT JSON as json FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER";
DataTable dataTable = DataBaseHelper.ExecuteQuery(sql);
StringBuilder sb = new StringBuilder();
if (dataTable != null)
@@ -59,16 +59,18 @@ public class AlgorithmConfigVM : BaseViewModel
{
DataBaseHelper.BeginTransaction();
string temp = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(AlgorithmConfigJson));
- string deleteSql = @"DELETE FROM METHOD_CONFIG";
+ string deleteSql = @"DELETE FROM ALGORITHM_CONFIG";
DataBaseHelper.ExecuteNonQuery(deleteSql);
int order = 0;
int insertCount = 0;
while (temp.Length>2000)
{
- MethodConfigEntity entity = new MethodConfigEntity();
- entity.GUID = Guid.NewGuid();
- entity.JsonOrder = order++;
- entity.Json = temp.Substring(0,2000);
+ AlgorithmConfigEntity entity = new AlgorithmConfigEntity()
+ {
+ GUID = Guid.NewGuid(),
+ JsonOrder = order++,
+ Json = temp.Substring(0, 2000),
+ };
temp = temp.Substring(2000);
string sql = entity.GenerateInsertSQL();
SqliteParameter[] sqliteParameters = {
@@ -80,10 +82,12 @@ public class AlgorithmConfigVM : BaseViewModel
}
if (temp.Length>0)
{
- MethodConfigEntity entity = new MethodConfigEntity();
- entity.GUID = Guid.NewGuid();
- entity.JsonOrder = order++;
- entity.Json = temp;
+ AlgorithmConfigEntity entity = new AlgorithmConfigEntity()
+ {
+ GUID = Guid.NewGuid(),
+ JsonOrder = order++,
+ Json = temp
+ };
string sql = entity.GenerateInsertSQL();
SqliteParameter[] sqliteParameters = {
new SqliteParameter("@Json", entity.Json),
@@ -94,12 +98,12 @@ public class AlgorithmConfigVM : BaseViewModel
}
if (insertCount >= 0)
{
- Growl.Info("保存成功");
+ Growl.Info(MultilingualHelper.getString("SaveSuccess"));
DataBaseHelper.commit();
}
else
{
- Growl.Error("保存失败");
+ Growl.Error(MultilingualHelper.getString("SaveFail"));
DataBaseHelper.rollback();
}
}
diff --git a/ViewModel/Configuration/ConfigMenuPageVM.cs b/ViewModel/Configuration/ConfigMenuPageVM.cs
index bcc0b9f..da6042b 100644
--- a/ViewModel/Configuration/ConfigMenuPageVM.cs
+++ b/ViewModel/Configuration/ConfigMenuPageVM.cs
@@ -10,12 +10,14 @@ public class ConfigMenuPageVM : BaseViewModel
public ICommand LevelConfigCommand { get; }
public ICommand AlgorithmConfigCommand { get; }
public ICommand CutConfigCommand { get; }
+ public ICommand SettingConfigCommand { get; }
public ConfigMenuPageVM()
{
CloseCommand = new RelayCommand(CloseVM);
LevelConfigCommand = new RelayCommand(LevelConfig);
AlgorithmConfigCommand = new RelayCommand(AlgorithmConfig);
CutConfigCommand = new RelayCommand(CutConfig);
+ SettingConfigCommand = new RelayCommand(SettingConfig);
}
///
@@ -60,4 +62,10 @@ public class ConfigMenuPageVM : BaseViewModel
WindowManager.openContent.Add(vm);
}
+ public void SettingConfig(object parameter)
+ {
+ BaseControlVM vm = new BaseControlVM(new SettingsVM(), MultilingualHelper.getString("System Settings"));
+ WindowManager.mainViewModel.Content = vm;
+ WindowManager.openContent.Add(vm);
+ }
}
\ No newline at end of file
diff --git a/ViewModel/Configuration/CutConfigVM.cs b/ViewModel/Configuration/CutConfigVM.cs
index a1657a2..4f3dd7b 100644
--- a/ViewModel/Configuration/CutConfigVM.cs
+++ b/ViewModel/Configuration/CutConfigVM.cs
@@ -80,18 +80,20 @@ public class CutConfigVM: BaseViewModel
int insertCount = 0;
foreach (DataRow row in CutterInfos.Rows)
{
- if (row["Key"] == "")
+ if (row["Key"].ToString() == "")
{
continue;
}
- DataRow removerow = dataTable.AsEnumerable().Where(r => r["GUID"].ToString() == row["GUID"].ToString()).FirstOrDefault();
+ DataRow? removerow = dataTable.AsEnumerable().Where(r => r["GUID"].ToString() == row["GUID"].ToString()).FirstOrDefault();
if (removerow != null)
{
- CutterConfigEntity entity = new CutterConfigEntity();
- entity.ItemName = row["ItemName"].ToString();
- entity.Key = row["Key"].ToString();
- entity.Value = row["Value"].ToString();
- entity.GUID = Guid.Parse(row["GUID"].ToString());
+ CutterConfigEntity entity = new CutterConfigEntity()
+ {
+ ItemName = row["ItemName"].ToString() ?? "",
+ Key = row["Key"].ToString() ?? "",
+ Value = row["Value"].ToString() ?? "",
+ GUID = Guid.Parse(row["GUID"].ToString()??"")
+ };
sql = entity.GenerateUpdateSQL();
SqliteParameter[] sqliteParameters = {
new SqliteParameter("@ITEM_NAME", row["ItemName"].ToString()),
@@ -104,10 +106,12 @@ public class CutConfigVM: BaseViewModel
}
else
{
- CutterConfigEntity entity = new CutterConfigEntity();
- entity.ItemName = row["ItemName"].ToString();
- entity.Key = row["Key"].ToString();
- entity.Value = row["Value"].ToString();
+ CutterConfigEntity entity = new CutterConfigEntity()
+ {
+ ItemName = row["ItemName"].ToString() ?? "",
+ Key = row["Key"].ToString() ?? "",
+ Value = row["Value"].ToString() ?? ""
+ };
sql = entity.GenerateInsertSQL();
SqliteParameter[] sqliteParameters = {
new SqliteParameter("@ItemName", row["ItemName"].ToString()),
@@ -120,12 +124,14 @@ public class CutConfigVM: BaseViewModel
}
foreach (DataRow row in dataTable.Rows)
{
- CutterConfigEntity entity = new CutterConfigEntity();
- entity.ItemName = row["ItemName"].ToString();
- entity.Key = row["Key"].ToString();
- entity.Value = row["Value"].ToString();
Guid.TryParse(row["GUID"].ToString(), out Guid result);
- entity.GUID = result;
+ CutterConfigEntity entity = new CutterConfigEntity()
+ {
+ ItemName = row["ItemName"].ToString() ?? "",
+ Key = row["Key"].ToString() ?? "",
+ Value = row["Value"].ToString() ?? "",
+ GUID = result
+ };
sql = entity.GenerateDeleteSQL();
insertCount += DataBaseHelper.ExecuteNonQuery(sql);
}
@@ -145,7 +151,10 @@ public class CutConfigVM: BaseViewModel
/// 行
public void DelCutRow(object row)
{
- DataRowView a = row as DataRowView;
- CutterInfos.Rows.Remove(a.Row);
+ DataRowView? a = row as DataRowView;
+ if (a != null)
+ {
+ CutterInfos.Rows.Remove(a.Row);
+ }
}
}
\ No newline at end of file
diff --git a/ViewModel/Grading/DiamondSelectVM.cs b/ViewModel/Grading/DiamondSelectVM.cs
index e7cd23b..83e9c67 100644
--- a/ViewModel/Grading/DiamondSelectVM.cs
+++ b/ViewModel/Grading/DiamondSelectVM.cs
@@ -109,7 +109,7 @@ public class DiamondSelectVM : BaseViewModel
{
// 模拟耗时操作
//System.Threading.Thread.Sleep(50); // 休眠50毫秒
- await Task.Delay(1000);
+ await Task.Delay(5);
// 更新进度条的值(需要在UI线程上执行)
loading.Dispatcher.Invoke(() =>
{
@@ -117,8 +117,9 @@ public class DiamondSelectVM : BaseViewModel
});
}
+ GradingResult(null);
});
-
+ await Task.Delay(5);
loading.Close();
}
}
@@ -129,7 +130,8 @@ public class DiamondSelectVM : BaseViewModel
///
public void GradingResult(object param)
{
- BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("GradingResult"));
+ WindowManager.mainViewModel.Content = WindowManager.PreviousVM();
+ BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("DetectionResult"));
vm.ShowFunctionButton = System.Windows.Visibility.Hidden;
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
diff --git a/ViewModel/Grading/GradingResultVM.cs b/ViewModel/Grading/GradingResultVM.cs
index 9140d89..7c4e4a0 100644
--- a/ViewModel/Grading/GradingResultVM.cs
+++ b/ViewModel/Grading/GradingResultVM.cs
@@ -1,6 +1,7 @@
using System.Data;
using System.Windows.Input;
using HandyControl.Controls;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
namespace SparkClient.ViewModel.Grading;
@@ -8,10 +9,29 @@ public class GradingResultVM : BaseViewModel
{
private DataTable _dtResults;
-
+
+ private DataTable _info;
+ private DataTable _dsList;
+ private DataTable _gradeList;
+ private string _standard;
+ private string _shape;
+ private string _crownType;
+ private string _pavType;
+ private string _wight;
+ private string _cutLevelTotal;
+ private string _symLevelTotal;
public ICommand ChangeNormCommand { get; }
- public DataTable DtResults{ get { return _dtResults; } set { _dtResults = value; OnPropertyChanged("DtResults"); } }
-
+ public DataTable DtResults{ get { return _dtResults; } set { _dtResults = value; OnPropertyChanged(nameof(DtResults)); } }
+ public DataTable Info { get { return _info; } set { _info = value; OnPropertyChanged(nameof(Info)); } }
+ public string Standard { get { return _standard; } set { _standard = value; OnPropertyChanged(nameof(Standard)); } }
+ public string Shape { get { return _shape; } set { _shape = value; OnPropertyChanged(nameof(Shape)); } }
+ public string CrownType { get { return _crownType; } set { _crownType = value; OnPropertyChanged(nameof(CrownType)); } }
+ public string PavType { get { return _pavType; } set { _pavType = value; OnPropertyChanged(nameof(PavType)); } }
+ public string Wight { get { return _wight; } set { _wight = value; OnPropertyChanged(nameof(Wight)); } }
+ public string CutLevelTotal { get { return _cutLevelTotal; } set { _cutLevelTotal = value; OnPropertyChanged(nameof(CutLevelTotal)); } }
+ public string SymLevelTotal { get { return _symLevelTotal; } set { _symLevelTotal = value; OnPropertyChanged(nameof(SymLevelTotal)); } }
+ public DataTable DSList { get { return _dsList; } set { _dsList = value; OnPropertyChanged(nameof(DSList)); } }
+ public DataTable GradeList { get { return _gradeList; } set { _gradeList = value; OnPropertyChanged(nameof(GradeList)); } }
///
/// 构造
///
@@ -20,9 +40,7 @@ public class GradingResultVM : BaseViewModel
{
ChangeNormCommand = new RelayCommand(ChangeNorm);
_dtResults = new DataTable();
-
-
-
+ InitCombobox();
}
///
@@ -34,9 +52,35 @@ public class GradingResultVM : BaseViewModel
}
+ private void InitCombobox()
+ {
+ // DS下拉列表初始化
+ InitDSlist();
+ // 等级下拉列表初始化
+ InitGradeList();
+ }
+ private void InitDSlist()
+ {
+ DSList = new DataTable();
+ DSList.Columns.Add("Key");
+ DSList.Columns.Add("Value");
+ DSList.Rows.Add("pass", "pass");
+ DSList.Rows.Add("refer", "refer");
+ }
+ private void InitGradeList()
+ {
+ GradeList = new DataTable();
+ GradeList.Columns.Add("Key");
+ GradeList.Columns.Add("Value");
+ GradeList.Rows.Add("极好", "Exc");
+ GradeList.Rows.Add("很好", "VG");
+ GradeList.Rows.Add("好", "G");
+ GradeList.Rows.Add("一般", "F");
+ GradeList.Rows.Add("差", "P");
+ }
#region 钻石操作相关
//暂略
//部分代码(直接操作控件)需要在xaml.cs里边写
//涉及到计算部分,这里做一个中转
- #endregion
+ #endregion
}
\ No newline at end of file
diff --git a/Views/Configuration/ConfigMenuPage.xaml b/Views/Configuration/ConfigMenuPage.xaml
index 1dbce0e..53e6d86 100644
--- a/Views/Configuration/ConfigMenuPage.xaml
+++ b/Views/Configuration/ConfigMenuPage.xaml
@@ -45,6 +45,7 @@
+
@@ -101,6 +102,23 @@
+
diff --git a/Views/Configuration/ConfigMenuPage.xaml.cs b/Views/Configuration/ConfigMenuPage.xaml.cs
index 9f9f9ab..3fd5e76 100644
--- a/Views/Configuration/ConfigMenuPage.xaml.cs
+++ b/Views/Configuration/ConfigMenuPage.xaml.cs
@@ -54,4 +54,18 @@ public partial class ConfigMenuPage
imgCut.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/Cut_Def@3x.png"));
tbCut.Foreground = new SolidColorBrush(Colors.Azure);
}
+
+ private void SettingButton_OnMouseEnter(object sender, MouseEventArgs e)
+ {
+ var brushConverter = new BrushConverter();
+ imgSet.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/Setting_Sel@3x.png"));
+ tbSet.Foreground = (Brush)brushConverter.ConvertFromString("#9C7C5E"); ;
+ }
+
+ private void SettingButton_OnMouseLeave(object sender, MouseEventArgs e)
+ {
+ var brushConverter = new BrushConverter();
+ imgSet.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/Setting_Def@3x.png"));
+ tbSet.Foreground = new SolidColorBrush(Colors.Azure);
+ }
}
\ No newline at end of file
diff --git a/Views/Dialog/StartDialog.xaml b/Views/Dialog/StartDialog.xaml
index a7ca79a..c5edef6 100644
--- a/Views/Dialog/StartDialog.xaml
+++ b/Views/Dialog/StartDialog.xaml
@@ -56,7 +56,7 @@
BorderBrush="Transparent"
FontSize="16" FontFamily="AlibabaPuHui-regular" />
-
+