feat:登录画面

master
sunhonglei 7 months ago
parent 278c30b108
commit eda88ecdb4
  1. 2
      App.xaml
  2. 9
      App.xaml.cs
  3. 2
      Language/zh_CN.xaml
  4. 12
      LoginWindow.xaml
  5. 86
      LoginWindow.xaml.cs
  6. 3
      MainWindow.xaml.cs
  7. 4
      Model/Entity/ApiEntity/AlgorithmResultEntity.cs
  8. 2
      Model/Helper/Common.cs
  9. 13
      ViewModel/BaseWindow/HomeWindowVM.cs
  10. 2
      ViewModel/Grading/DiamondSelectVM.cs
  11. 25
      ViewModel/Grading/GradingResultVM.cs

@ -15,7 +15,7 @@
xmlns:settingPages="clr-namespace:SparkClient.Views.Configuration.SettingPages"
xmlns:configuration="clr-namespace:System.Configuration;assembly=System.Configuration.ConfigurationManager"
xmlns:sparkClient="clr-namespace:SparkClient"
StartupUri="MainWindow.xaml">
StartupUri="LoginWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

@ -6,6 +6,7 @@ using System.Windows.Media;
using System.Windows.Threading;
using log4net.Config;
using SparkClient.Model.Helper;
using SparkClient.ViewModel.Configuration.SettingsPages;
namespace SparkClient;
@ -23,6 +24,12 @@ public partial class App : Application
Log4NetHelper.ArchiveOldLogs();
//打开数据库连接
//读取数据库多语言配置
DataBaseHelper.CreateConnection();
string LanguageId = Settings.SelectValueByName("LanguageId");
if (LanguageId.Length == 0)
{
LanguageId = "zh-cn";
}
MultilingualHelper.setLanguage(LanguageId);
}
}

@ -23,7 +23,7 @@
<sys:String x:Key="AlgorithmConfig">算法配置</sys:String>
<sys:String x:Key="LevelConfig">定级配置</sys:String>
<sys:String x:Key="CutConfig">切工仪配置</sys:String>
<sys:String x:Key="NoPassword">用户名或密码错误,请重试</sys:String>
<!-- <sys:String x:Key="LevelConfig">定级配置</sys:String> -->
<sys:String x:Key="DeleteConfig">删除配置</sys:String>
<sys:String x:Key="ImportConfig">导入配置</sys:String>

@ -67,7 +67,7 @@
<hc:TextBox Grid.Column="1" Grid.ColumnSpan="2" BorderThickness="0" FontSize="18" HorizontalAlignment="Stretch"
Background="Transparent" Padding="5 0" hc:InfoElement.ShowClearButton="True"
VerticalAlignment="Stretch" TextAlignment="Left" x:Name="AccountTextBox"
hc:InfoElement.Placeholder="{StaticResource LoginWindowAccount}"
hc:InfoElement.Placeholder="{StaticResource LoginWindowAccount}"
/>
<!-- <Image Grid.Column="2" Width="25" Height="25" Source="Resource/Images/UIResource/08-4.png" MouseLeftButtonDown="UIElement_OnMouseLeftButtonDown" /> -->
</Grid>
@ -85,20 +85,20 @@
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Width="25" Height="25" Source="Resource/Images/UIResource/08-3.png" />
<hc:PasswordBox Grid.Column="1" Grid.ColumnSpan="2" ShowEyeButton="True" BorderThickness="0"
<hc:PasswordBox Grid.Column="1" Grid.ColumnSpan="2" ShowEyeButton="True" BorderThickness="0" x:Name="PasswordBox"
FontSize="18" HorizontalAlignment="Stretch" hc:InfoElement.Necessary="True" Background="Transparent"
hc:InfoElement.Placeholder="{StaticResource LoginWindowPassword}"/>
hc:InfoElement.Placeholder="{StaticResource LoginWindowPassword}" />
</Grid>
</Border>
</Grid>
<!-- 记住密码 -->
<CheckBox Grid.Row="5" Content="{StaticResource LoginWindowRemember}"
Background="#8ea4c9" IsChecked="True" Foreground="#8c8c8c" FontSize="16"
<CheckBox Grid.Row="5" Content="{StaticResource LoginWindowRemember}" IsChecked="True"
Background="#8ea4c9" Foreground="#8c8c8c" FontSize="16" x:Name="IsRemberPassword"
Margin="45 5"/>
<!-- 登录按钮 -->
<Button x:Name="ConfirmButton" Grid.Row="6" Padding="0" Margin="0 10 0 10" Height="50"
Width="360 "
Width="360 " Click="ConfirmButton_Click"
BorderThickness="0" Background="Transparent" FocusVisualStyle="{x:Null}">
<Border
HorizontalAlignment="Center"

@ -1,3 +1,6 @@
using SparkClient.Model.Helper;
using SparkClient.ViewModel.Configuration.SettingsPages;
using System.Data;
using System.Windows;
using System.Windows.Input;
@ -8,7 +11,9 @@ public partial class LoginWindow : Window
public LoginWindow()
{
InitializeComponent();
WindowStartupLocation = WindowStartupLocation.CenterScreen;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
AccountTextBox.Text = Settings.SelectValueByName("SAVE_ACCOUNT");
PasswordBox.Password = Settings.SelectValueByName("SAVE_PASSWORD");
}
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
@ -28,4 +33,83 @@ public partial class LoginWindow : Window
this.Close();
Environment.Exit(0);
}
private void ConfirmButton_Click(object sender, RoutedEventArgs e)
{
#if DEBUG
new MainWindow().Show();
this.Close();
#else
string account = AccountTextBox.Text;
string password = PasswordBox.Password;
string passwordEnc = Common.GenerateMd5Hash(password);
string passworddb = getPassword(account);
string passworddbEnc = Common.GenerateMd5Hash(passworddb);
if (string.IsNullOrEmpty(passworddb) || !passwordEnc.Equals(passworddbEnc))
{
MessageBox.Show(MultilingualHelper.getString("NoPassword"));
return;
}
savePassword();
new MainWindow().Show();
this.Close();
#endif
}
private void savePassword()
{
if (IsRemberPassword.IsChecked ?? false || "Admin".Equals(AccountTextBox.Text))
{
Settings saveAccount = new Settings()
{
Key = "SAVE_ACCOUNT",
ItemName = "保存用户名",
Value = AccountTextBox.Text,
};
saveAccount.insert();
Settings savePassword = new Settings()
{
Key = "SAVE_PASSWORD",
ItemName = "保存密码",
Value = PasswordBox.Password,
};
savePassword.insert();
}
else
{
Settings saveAccount = new Settings()
{
Key = "SAVE_ACCOUNT",
ItemName = "保存用户名",
Value = "",
};
saveAccount.insert();
Settings savePassword = new Settings()
{
Key = "SAVE_PASSWORD",
ItemName = "保存密码",
Value = "",
};
savePassword.insert();
}
Settings PERMISSIONS = new Settings()
{
Key = "PERMISSIONS",
ItemName = "权限",
Value = PasswordBox.Password,
};
PERMISSIONS.insert();
}
private string getPassword(string userName)
{
string password = string.Empty;
string sql = $"SELECT USER_PASSWORD FROM USER WHERE USER_NAME='{userName}'";
DataTable dt = DataBaseHelper.ExecuteQuery(sql);
if (dt != null && dt.Rows.Count > 0)
{
password = dt.Rows[0]["USER_PASSWORD"].ToString();
}
return password;
}
}

@ -60,8 +60,7 @@ public partial class MainWindow
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
//初始化
// ConfigHelper.Instance.SetLang("en");
DataBaseHelper.CreateConnection();
this.WindowState = WindowState.Maximized;
}

@ -50,6 +50,10 @@ namespace SparkClient.Model.Entity.ApiEntity
public double GIRDLE_BONE { get; set; }
public double GIRDLE_BONE_MIN { get; set; }
public double GIRDLE_BONE_MAX { get; set; }
public double GIRDLE { get; set; }
public double GIRDLE_DEV { get; set; }
public double GIRDLE_MIN { get; set; }
public double GIRDLE_MAX { get; set; }
public double GIRDLE_VALLEY { get; set; }
public double GIRDLE_VALLEY_DEV { get; set; }
public double GIRDLE_VALLEY_MIN { get; set; }

@ -91,7 +91,7 @@ public class Common
return entityList;
}
private static string GenerateMd5Hash(string input)
public static string GenerateMd5Hash(string input)
{
using (var md5 = MD5.Create())
{

@ -58,14 +58,17 @@ public class HomeWindowVM : BaseViewModel
//WindowManager.openContent.Add(vm);
MessageBox messageBox = new MessageBox();
messageBox.ShowInput(MultilingualHelper.getString("UpdateDiamondCode"),out string inputStr,
MessageBoxResult result = messageBox.ShowInput(MultilingualHelper.getString("UpdateDiamondCode"),out string inputStr,
MultilingualHelper.getString("ok"),
MultilingualHelper.getString("Skip")
);
BaseControlVM vm = new BaseControlVM(new DiamondSelectVM(inputStr), MultilingualHelper.getString("DiamondSelect"));
vm.ShowFunctionButton = System.Windows.Visibility.Hidden;
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
if (result != MessageBoxResult.None)
{
BaseControlVM vm = new BaseControlVM(new DiamondSelectVM(inputStr), MultilingualHelper.getString("DiamondSelect"));
vm.ShowFunctionButton = System.Windows.Visibility.Hidden;
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
}
catch (Exception e)
{

@ -102,7 +102,7 @@ public class DiamondSelectVM : BaseViewModel
};
List<ButtonViewModel> tempButtons2 = new List<ButtonViewModel>();
var bitmap = new BitmapImage(new Uri("pack://application:,,,/Resource/Images/UIResource/round_P8-P8.png", UriKind.RelativeOrAbsolute));
ButtonViewModel button = new ButtonViewModel() { Text = "P8-P8", ImageSource = bitmap, Type = "round P8 P8", Command = StartGradingCommand };
ButtonViewModel button = new ButtonViewModel() { Text = "P8-P8", ImageSource = bitmap, Type = "ROUND P8 P8", Command = StartGradingCommand };
tempButtons2.Add(button);
Buttons2 = tempButtons2;
}

@ -406,11 +406,11 @@ public class GradingResultVM : BaseViewModel
DataInfo info = new DataInfo();
info.TestItemId = "GIRDLE";
info.TestItemName = GetName("GIRDLE");
info.Avg = FormatDouble_P(result.measurements.GIRDLE_VALLEY);
info.Dev = FormatDouble_P(result.measurements.GIRDLE_VALLEY_DEV);
info.Min = FormatDouble_P(result.measurements.GIRDLE_VALLEY_MIN);
info.Max = FormatDouble_P(result.measurements.GIRDLE_VALLEY_MAX);
info.CutLevel = calGrade_GIRDLE(result.measurements.GIRDLE_VALLEY_MIN, result.measurements.GIRDLE_VALLEY_MAX);
info.Avg = FormatDouble_P(result.measurements.GIRDLE);
info.Dev = FormatDouble_P(result.measurements.GIRDLE_DEV);
info.Min = FormatDouble_P(result.measurements.GIRDLE_MIN);
info.Max = FormatDouble_P(result.measurements.GIRDLE_MAX);
info.CutLevel = calGrade_GIRDLE(result.measurements.GIRDLE_MIN, result.measurements.GIRDLE_MAX);
return info;
}
@ -732,9 +732,9 @@ public class GradingResultVM : BaseViewModel
stream.WriteLine($"PAV ANGLE={info.PAV_ANGLE}");
stream.WriteLine($"PAV ANGLE MIN={info.PAV_ANGLE_MIN}");
stream.WriteLine($"PAV ANGLE MAX={info.PAV_ANGLE_MAX}");
stream.WriteLine($"GIRDLE={info.GIRDLE_VALLEY * 100}");
stream.WriteLine($"GIRDLE MIN={info.GIRDLE_VALLEY_MIN * 100}");
stream.WriteLine($"GIRDLE MAX={info.GIRDLE_VALLEY_MAX * 100}");
stream.WriteLine($"GIRDLE={info.GIRDLE * 100}");
stream.WriteLine($"GIRDLE MIN={info.GIRDLE_MIN * 100}");
stream.WriteLine($"GIRDLE MAX={info.GIRDLE_MAX * 100}");
stream.WriteLine($"TOTAL DEPTH={info.TOTAL_DEPTH * 100}");
stream.WriteLine($"CULET={info.CULET*100}");
stream.WriteLine($"MACHINE={machine}");
@ -797,8 +797,9 @@ public class GradingResultVM : BaseViewModel
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.TOTAL_DEPTH)}%");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.CROWN_ANGLE)}°");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.PAV_ANGLE)}°");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.CULET_SIZE)}(mm)");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.GIRDLE_VALLEY)}%");
// TODO 底尖直径
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.CULET)}(mm)");
dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.GIRDLE)}%");
// TODO 腰部厚度英文
dataRow.CreateCell(col++).SetCellValue($"{calGirdleName(info)}");
dataRow.CreateCell(col++).SetCellValue($"");
@ -822,10 +823,10 @@ public class GradingResultVM : BaseViewModel
string girdleName = "";
// 有问题 问题1 1.6时为thin to slight thick,那么 thin为什么时刻出现
// 问题2 假如最小值为very thin,最大值为thick时用哪个
decimal min = Convert.ToDecimal(info.GIRDLE_VALLEY_MIN * 100);
decimal min = Convert.ToDecimal(info.GIRDLE_MIN * 100);
girdleName += calGirdleName(min,true);
girdleName += " to ";
decimal max = Convert.ToDecimal(info.GIRDLE_VALLEY_MAX * 100);
decimal max = Convert.ToDecimal(info.GIRDLE_MAX * 100);
girdleName += calGirdleName(max,false);
return girdleName;
}

Loading…
Cancel
Save