修改 超管,oem 修改和查看每个用户的附加金额
This commit is contained in:
1 parent
b2e75e6e1d
commit
82ae679dbd
13 files changed
+3303
-2743
No files matched your search
+157
@@ -0,0 +1,157 @@
|
||||
namespace TemuKJD.UserComponent;
|
||||
|
||||
partial class InputDialog
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.layout = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.lblPrompt = new System.Windows.Forms.Label();
|
||||
this.txtInput = new System.Windows.Forms.TextBox();
|
||||
this.buttons = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.btnOk = new System.Windows.Forms.Button();
|
||||
this.lblError = new System.Windows.Forms.Label();
|
||||
this.layout.SuspendLayout();
|
||||
this.buttons.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// layout
|
||||
//
|
||||
this.layout.AutoSize = true;
|
||||
this.layout.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.layout.ColumnCount = 1;
|
||||
this.layout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.layout.Controls.Add(this.lblPrompt, 0, 0);
|
||||
this.layout.Controls.Add(this.txtInput, 0, 1);
|
||||
this.layout.Controls.Add(this.buttons, 0, 2);
|
||||
this.layout.Controls.Add(this.lblError, 0, 3);
|
||||
this.layout.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.layout.Location = new System.Drawing.Point(0, 0);
|
||||
this.layout.Name = "layout";
|
||||
this.layout.Padding = new System.Windows.Forms.Padding(15);
|
||||
this.layout.RowCount = 4;
|
||||
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.layout.Size = new System.Drawing.Size(360, 143);
|
||||
this.layout.TabIndex = 0;
|
||||
//
|
||||
// lblPrompt
|
||||
//
|
||||
this.lblPrompt.AutoSize = true;
|
||||
this.lblPrompt.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lblPrompt.Location = new System.Drawing.Point(15, 15);
|
||||
this.lblPrompt.Margin = new System.Windows.Forms.Padding(0, 0, 0, 10);
|
||||
this.lblPrompt.MaximumSize = new System.Drawing.Size(330, 0);
|
||||
this.lblPrompt.Name = "lblPrompt";
|
||||
this.lblPrompt.Size = new System.Drawing.Size(330, 12);
|
||||
this.lblPrompt.TabIndex = 0;
|
||||
this.lblPrompt.Text = "请输入:";
|
||||
//
|
||||
// txtInput
|
||||
//
|
||||
this.txtInput.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtInput.Location = new System.Drawing.Point(15, 37);
|
||||
this.txtInput.Margin = new System.Windows.Forms.Padding(0, 0, 0, 12);
|
||||
this.txtInput.Name = "txtInput";
|
||||
this.txtInput.Size = new System.Drawing.Size(330, 21);
|
||||
this.txtInput.TabIndex = 0;
|
||||
this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged);
|
||||
//
|
||||
// buttons
|
||||
//
|
||||
this.buttons.AutoSize = true;
|
||||
this.buttons.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.buttons.Controls.Add(this.btnCancel);
|
||||
this.buttons.Controls.Add(this.btnOk);
|
||||
this.buttons.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.buttons.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
|
||||
this.buttons.Location = new System.Drawing.Point(15, 70);
|
||||
this.buttons.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.buttons.Name = "buttons";
|
||||
this.buttons.Size = new System.Drawing.Size(330, 28);
|
||||
this.buttons.TabIndex = 1;
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Location = new System.Drawing.Point(255, 0);
|
||||
this.btnCancel.Margin = new System.Windows.Forms.Padding(10, 0, 0, 0);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 28);
|
||||
this.btnCancel.TabIndex = 1;
|
||||
this.btnCancel.Text = "取消";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.Location = new System.Drawing.Point(170, 0);
|
||||
this.btnOk.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.Size = new System.Drawing.Size(75, 28);
|
||||
this.btnOk.TabIndex = 0;
|
||||
this.btnOk.Text = "确定";
|
||||
this.btnOk.UseVisualStyleBackColor = true;
|
||||
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
|
||||
//
|
||||
// lblError
|
||||
//
|
||||
this.lblError.AutoSize = true;
|
||||
this.lblError.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lblError.ForeColor = System.Drawing.Color.Firebrick;
|
||||
this.lblError.Location = new System.Drawing.Point(15, 108);
|
||||
this.lblError.Margin = new System.Windows.Forms.Padding(0, 10, 0, 0);
|
||||
this.lblError.MaximumSize = new System.Drawing.Size(330, 0);
|
||||
this.lblError.MinimumSize = new System.Drawing.Size(0, 20);
|
||||
this.lblError.Name = "lblError";
|
||||
this.lblError.Size = new System.Drawing.Size(330, 20);
|
||||
this.lblError.TabIndex = 2;
|
||||
//
|
||||
// InputDialog
|
||||
//
|
||||
this.AcceptButton = this.btnOk;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.CancelButton = this.btnCancel;
|
||||
this.ClientSize = new System.Drawing.Size(360, 144);
|
||||
this.Controls.Add(this.layout);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(376, 39);
|
||||
this.Name = "InputDialog";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "输入";
|
||||
this.layout.ResumeLayout(false);
|
||||
this.layout.PerformLayout();
|
||||
this.buttons.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel layout;
|
||||
private System.Windows.Forms.Label lblPrompt;
|
||||
private System.Windows.Forms.TextBox txtInput;
|
||||
private System.Windows.Forms.FlowLayoutPanel buttons;
|
||||
private System.Windows.Forms.Button btnOk;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.Label lblError;
|
||||
}
|
||||
@@ -1,81 +1,130 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TemuKJD.UserComponent;
|
||||
|
||||
public class InputDialog : Form
|
||||
public partial class InputDialog : Form
|
||||
{
|
||||
private TextBox txtInput;
|
||||
private Button btnOk;
|
||||
private Button btnCancel;
|
||||
private readonly InputDialogType inputType;
|
||||
private readonly Func<string, string> validator;
|
||||
|
||||
/// <summary>用户输入的内容(点确定后有效)</summary>
|
||||
public string InputText { get; private set; } = string.Empty;
|
||||
|
||||
public InputDialog(string prompt, string title = "输入", string defaultValue = "")
|
||||
public InputDialog() : this(string.Empty)
|
||||
{
|
||||
// 窗体基本设置
|
||||
this.Text = title;
|
||||
this.FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
this.StartPosition = FormStartPosition.CenterParent;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.ClientSize = new Size(360, 130);
|
||||
|
||||
// 提示标签
|
||||
var lblPrompt = new Label
|
||||
{
|
||||
Text = prompt,
|
||||
Location = new Point(15, 15),
|
||||
AutoSize = true,
|
||||
MaximumSize = new Size(330, 0)
|
||||
};
|
||||
|
||||
// 输入框
|
||||
txtInput = new TextBox
|
||||
{
|
||||
Text = defaultValue,
|
||||
Location = new Point(15, 45),
|
||||
Width = 330
|
||||
};
|
||||
txtInput.SelectAll();
|
||||
|
||||
// 确定按钮
|
||||
btnOk = new Button
|
||||
{
|
||||
Text = "确定",
|
||||
DialogResult = DialogResult.OK,
|
||||
Location = new Point(185, 85),
|
||||
Width = 75
|
||||
};
|
||||
btnOk.Click += (s, e) =>
|
||||
{
|
||||
InputText = txtInput.Text;
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
};
|
||||
|
||||
// 取消按钮
|
||||
btnCancel = new Button
|
||||
{
|
||||
Text = "取消",
|
||||
DialogResult = DialogResult.Cancel,
|
||||
Location = new Point(270, 85),
|
||||
Width = 75
|
||||
};
|
||||
|
||||
this.Controls.AddRange(new Control[] { lblPrompt, txtInput, btnOk, btnCancel });
|
||||
this.AcceptButton = btnOk;
|
||||
this.CancelButton = btnCancel;
|
||||
}
|
||||
|
||||
/// <summary>便捷静态方法:弹出输入框并返回输入内容,取消返回 null</summary>
|
||||
public static string Show(string prompt, string title = "输入", string defaultValue = "")
|
||||
/// <param name="inputType">输入类型,数字按当前区域格式验证。</param>
|
||||
/// <param name="validator">类型验证通过后调用;返回错误信息,null 或空字符串表示通过。</param>
|
||||
public InputDialog(string prompt, string title = "输入", string defaultValue = "",
|
||||
InputDialogType inputType = InputDialogType.Text, Func<string, string> validator = null)
|
||||
{
|
||||
using (var dlg = new InputDialog(prompt, title, defaultValue))
|
||||
if (!Enum.IsDefined(typeof(InputDialogType), inputType))
|
||||
throw new ArgumentOutOfRangeException(nameof(inputType));
|
||||
|
||||
InitializeComponent();
|
||||
this.inputType = inputType;
|
||||
this.validator = validator;
|
||||
Text = title;
|
||||
lblPrompt.Text = prompt;
|
||||
txtInput.Text = defaultValue;
|
||||
txtInput.SelectAll();
|
||||
}
|
||||
|
||||
private void btnOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
string value = txtInput.Text;
|
||||
string error = null;
|
||||
if (inputType == InputDialogType.Integer && !int.TryParse(value, out _))
|
||||
error = "请输入有效的整数(-2147483648 至 2147483647)。";
|
||||
else if (inputType == InputDialogType.Decimal && !decimal.TryParse(value, out _))
|
||||
error = "请输入有效的小数。";
|
||||
else if (validator != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
error = validator(value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = "验证失败:" + ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
lblError.Text = error ?? string.Empty;
|
||||
if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
txtInput.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
InputText = value;
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void txtInput_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
lblError.Text = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>弹出输入框并返回输入内容,取消返回 null;validator 返回错误信息,空值表示通过。</summary>
|
||||
public static string Show(string prompt, string title = "输入", string defaultValue = "",
|
||||
InputDialogType inputType = InputDialogType.Text, Func<string, string> validator = null)
|
||||
{
|
||||
using (var dlg = new InputDialog(prompt, title, defaultValue, inputType, validator))
|
||||
{
|
||||
return dlg.ShowDialog() == DialogResult.OK ? dlg.InputText : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>输入数值,取消返回 null;支持整数、float、double 和 decimal,按当前区域格式解析。</summary>
|
||||
/// <param name="validator">接收解析后的数值,返回错误信息;null 或空字符串表示通过。</param>
|
||||
public static T? Show<T>(string prompt, string title = "输入", T defaultValue = default,
|
||||
Func<T, string> validator = null) where T : struct, IConvertible
|
||||
{
|
||||
var typeCode = Type.GetTypeCode(typeof(T));
|
||||
if (typeof(T).IsEnum || typeCode < TypeCode.SByte || typeCode > TypeCode.Decimal)
|
||||
throw new NotSupportedException("仅支持整数、float、double 和 decimal 类型。");
|
||||
|
||||
T value = default;
|
||||
using (var dlg = new InputDialog(prompt, title, defaultValue.ToString(CultureInfo.CurrentCulture),
|
||||
validator: text => ValidateNumber(text, validator, out value)))
|
||||
{
|
||||
return dlg.ShowDialog() == DialogResult.OK ? value : (T?)null;
|
||||
}
|
||||
}
|
||||
|
||||
private static string ValidateNumber<T>(string text, Func<T, string> validator, out T value)
|
||||
where T : struct, IConvertible
|
||||
{
|
||||
value = default;
|
||||
try
|
||||
{
|
||||
value = (T)Convert.ChangeType(text, typeof(T), CultureInfo.CurrentCulture);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
return $"请输入有效的 {typeof(T).Name} 数值。";
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
return $"输入超出 {typeof(T).Name} 的取值范围。";
|
||||
}
|
||||
|
||||
if (value is float single && (float.IsNaN(single) || float.IsInfinity(single))
|
||||
|| value is double number && (double.IsNaN(number) || double.IsInfinity(number)))
|
||||
return "请输入有限数值。";
|
||||
|
||||
return validator?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
public enum InputDialogType
|
||||
{
|
||||
Text,
|
||||
Integer,
|
||||
Decimal
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in new issue
Block a user