You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/RfidWeb/Frm/FormPlanAdd.cs

89 lines
2.2 KiB
C#

6 days ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DB.Entity;
using DB.Service;
using Tool;
4 days ago
using Tool.Model;
6 days ago
namespace RfidWeb.Frm
{
public partial class FormPlanAdd : Form
{
private FromPlanService fromPlanService = new FromPlanService();
private FromPlan fromPlan = null;
private long id = default;
public FormPlanAdd()
{
InitializeComponent();
this.ucCode.InputText = fromPlanService.GetMaxCode();
this.ucNo.InputText = "50";
fromPlan = new FromPlan();
fromPlan.ID = SnowflakeFactory.NewId;
}
public FormPlanAdd(long id)
{
InitializeComponent();
this.id = id;
fromPlan = fromPlanService.Query(id);
this.ucNo.InputText = fromPlan.Num.ToString();
this.ucCode.InputText=fromPlan.Code;
}
private void btnCancel_BtnClick(object sender, EventArgs e)
{
this.Close();
}
4 days ago
bool IsValidNumber(string input)
6 days ago
{
4 days ago
// 检查是否是纯数字
if (int.TryParse(input, out int number))
{
// 检查范围是否符合
return number > 0 && number < 2000;
}
return false;
}
6 days ago
4 days ago
private void btnOK_BtnClick(object sender, EventArgs e)
{
var code = ucNo.InputText.ToInt();
fromPlan.Num = code;
6 days ago
fromPlan.Code=ucCode.InputText.ToString();
3 days ago
if (!IsValidNumber(ucNo.InputText))
4 days ago
{
MessageBox.Show("请输入0-2000 有效范围");
return;
}
6 days ago
if (id == 0)
{
fromPlanService.Insert(fromPlan);
}
else
{
fromPlanService.Update(fromPlan);
}
4 days ago
PlcConnect.Instance.Write(HmiPointInfo.Product_counter_CH, int.Parse(code.ToString()));
6 days ago
this.Close();
}
}
}