修改 超管,oem 修改和查看每个用户的附加金额
This commit is contained in:
1 parent
b2e75e6e1d
commit
82ae679dbd
13 files changed
+3303
-2743
No files matched your search
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net462</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<LangVersion>12</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="../../TEMUKJD/UserComponent/InputDialog.cs" Link="InputDialog.cs" />
|
||||
<Compile Include="../../TEMUKJD/UserComponent/InputDialog.Designer.cs" Link="InputDialog.Designer.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TemuKJD.UserComponent;
|
||||
|
||||
public partial class InputDialog
|
||||
{
|
||||
[STAThread]
|
||||
private static void Main()
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
Check(ValidateNumber<int>("123", null, out var integer) == null && integer == 123, "泛型 int");
|
||||
Check(ValidateNumber<float>("1.25", null, out var single) == null && single == 1.25f, "泛型 float");
|
||||
Check(ValidateNumber<double>("1e100", null, out var number) == null && number == 1e100, "泛型 double");
|
||||
Check(ValidateNumber<decimal>("12.50", null, out var amount) == null && amount == 12.50m, "泛型 decimal");
|
||||
Check(ValidateNumber<long>("9223372036854775807", null, out var large) == null && large == long.MaxValue, "泛型 long");
|
||||
Check(ValidateNumber<uint>("-1", null, out _) != null, "无符号负数");
|
||||
Check(ValidateNumber<int>("2147483648", null, out _) != null, "泛型整数溢出");
|
||||
Check(ValidateNumber<float>("1e100", null, out _) != null, "浮点溢出");
|
||||
foreach (string invalid in new[] { "", "abc", "NaN", "Infinity", "-Infinity" })
|
||||
Check(ValidateNumber<double>(invalid, _ => throw new Exception("不应调用"), out _) != null, "无效浮点数:" + invalid);
|
||||
Check(ValidateNumber<int>("0", value => value > 0 ? null : "必须大于零", out _) == "必须大于零", "类型化回调");
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fr-FR");
|
||||
Check(ValidateNumber<double>("1,5", null, out var localized) == null && localized == 1.5, "区域格式");
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
foreach (string value in new[] { "0", "-2147483648", "2147483647" })
|
||||
CheckAccepted(InputDialogType.Integer, value);
|
||||
foreach (string value in new[] { "", "1.5", "abc", "2147483648" })
|
||||
{
|
||||
using var dialog = new InputDialog("整数", defaultValue: value,
|
||||
inputType: InputDialogType.Integer, validator: _ => throw new Exception("不应调用"));
|
||||
dialog.btnOk_Click(null, EventArgs.Empty);
|
||||
Check(dialog.DialogResult == DialogResult.None && dialog.lblError.Text.StartsWith("请输入"), "整数拒绝:" + value);
|
||||
Check(dialog.InputText == "", "失败不能提交输入");
|
||||
}
|
||||
CheckAccepted(InputDialogType.Text, "");
|
||||
CheckAccepted(InputDialogType.Decimal, "-12.50");
|
||||
using (var dialog = new InputDialog("小数", defaultValue: "79228162514264337593543950336",
|
||||
inputType: InputDialogType.Decimal))
|
||||
{
|
||||
dialog.btnOk_Click(null, EventArgs.Empty);
|
||||
Check(dialog.DialogResult == DialogResult.None && dialog.lblError.Text != "", "小数溢出");
|
||||
}
|
||||
|
||||
int calls = 0;
|
||||
using (var dialog = new InputDialog("名称", validator: value =>
|
||||
{
|
||||
calls++;
|
||||
return value == "有效" ? null : "名称无效";
|
||||
}))
|
||||
{
|
||||
dialog.btnOk_Click(null, EventArgs.Empty);
|
||||
Check(dialog.DialogResult == DialogResult.None && dialog.lblError.Text == "名称无效", "回调错误");
|
||||
dialog.txtInput.Text = "有效";
|
||||
Check(dialog.lblError.Text == "", "编辑清除错误");
|
||||
dialog.btnOk_Click(null, EventArgs.Empty);
|
||||
Check(dialog.DialogResult == DialogResult.OK && dialog.InputText == "有效" && calls == 2, "回调通过");
|
||||
}
|
||||
using (var dialog = new InputDialog("异常", validator: _ => throw new InvalidOperationException("测试异常")))
|
||||
{
|
||||
dialog.btnOk_Click(null, EventArgs.Empty);
|
||||
Check(dialog.DialogResult == DialogResult.None && dialog.lblError.Text.Contains("测试异常"), "回调异常");
|
||||
Check(((Button)dialog.AcceptButton).DialogResult == DialogResult.None, "确定按钮不得绕过验证");
|
||||
Check(((Button)dialog.CancelButton).DialogResult == DialogResult.Cancel, "取消按钮");
|
||||
}
|
||||
try
|
||||
{
|
||||
using var dialog = new InputDialog("非法类型", inputType: (InputDialogType)99);
|
||||
throw new Exception("非法类型未拒绝");
|
||||
}
|
||||
catch (ArgumentOutOfRangeException) { }
|
||||
Console.WriteLine("InputDialog self-checks passed.");
|
||||
}
|
||||
|
||||
private static void CheckAccepted(InputDialogType type, string value)
|
||||
{
|
||||
using var dialog = new InputDialog("输入", defaultValue: value, inputType: type, validator: _ => "");
|
||||
dialog.btnOk_Click(null, EventArgs.Empty);
|
||||
Check(dialog.DialogResult == DialogResult.OK && dialog.InputText == value, "接受:" + value);
|
||||
}
|
||||
|
||||
private static void Check(bool condition, string message)
|
||||
{
|
||||
if (!condition)
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user