Files
lserp_cs_6.0/插件库/Lskj.PubBillManagement/FrmAdd.cs
T
2026-07-28 10:16:51 +08:00

113 lines
3.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lskj.Control;
using Lskj.Business;
using Lskj.Business.Impl;
namespace Lskj.PubBillManagement
{
public partial class FrmAdd : BaseForm
{
public int Quantity;
public Label LabelObj { get { return label1; } }
public FrmAdd()
{
InitializeComponent();
}
/// <summary>
/// <para>说明:确定事件</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2019-06-21 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
void OnBtnOKClick(object sender, EventArgs e)
{
try
{
string text=this.txtEdit.Text;
if (string.IsNullOrWhiteSpace(text)) text = "0";
if (!this.IsDigitsOnly(text))
{
MessageUtil.Show("请输入数字");
}
this.Quantity = int.Parse(text);
this.Close();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
catch (Exception ex)
{
LogUtil.WriteError("确定事件出错!", ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:取消事件</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2019-06-21 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
void OnBtnCancelClick(object sender, EventArgs e)
{
this.Close();
}
bool IsDigitsOnly(string input)
{
foreach (char c in input)
{
if (!char.IsDigit(c))
return false;
}
return true;
}
private void txtEdit_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
string text = this.txtEdit.Text;
if (string.IsNullOrWhiteSpace(text)) return;
if (!this.IsDigitsOnly(text))
{
MessageUtil.Show("请输入数字");
}
if (int.Parse(text) > 0)
{
this.Quantity = int.Parse(text);
this.Close();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
else
{
MessageUtil.Show("请检查输入数量");
}
}
}
}
}