#002 对分发任务的 数据对象,操作对象,查询,新增,编辑,与删除功能进行开发

This commit is contained in:
HM-CN\zhengxuan.zhang
2025-08-04 16:46:14 +08:00
parent 1857eea8a4
commit 03ee90302f
92 changed files with 6322 additions and 28105 deletions
+169 -126
View File
@@ -1,5 +1,6 @@
using BaseFunction;
using DAL;
using NSAnalysis.Model;
using System;
using System.Drawing;
using System.Windows.Forms;
@@ -8,152 +9,194 @@ using Telerik.WinControls.UI;
namespace NSAnalysis
{
public partial class FAddTolerance : Telerik.WinControls.UI.ShapedForm
{
#region
{
#region
//private TMeasureSQLiteDAL tmdal = new TMeasureSQLiteDAL();
private TMeasureMSSQLDAL tmdal = new TMeasureMSSQLDAL();
private FToleranceSetup gFTS;
private TMeasureMSSQLDAL tmdal = new TMeasureMSSQLDAL();
private FToleranceSetup gFTS;
#endregion
#endregion
#region
#region
private void btn_MouseHover(object sender, EventArgs e)
{
RadButton btn = sender as RadButton;
btn.BackColor = Color.FromArgb(0, 151, 186);
}
private void btn_MouseHover(object sender, EventArgs e)
{
RadButton btn = sender as RadButton;
btn.BackColor = Color.FromArgb(0, 151, 186);
}
private void btn_MouseLeave(object sender, EventArgs e)
{
RadButton btn = sender as RadButton;
btn.BackColor = Color.FromArgb(19, 46, 53);
}
private void btn_MouseLeave(object sender, EventArgs e)
{
RadButton btn = sender as RadButton;
btn.BackColor = Color.FromArgb(19, 46, 53);
}
#endregion
#endregion
public FAddTolerance(FToleranceSetup fts)
{
InitializeComponent();
private void InitLanguage()
{
if (!ConfigDfn.bLanguage)
{
this.Text = "Add Tolerance";
labTitle.Text = "Add Tolerance";
radLabel5.Text = "CNC ID : ";
radLabel2.Text = "CNC Name : ";
radLabel4.Text = "CNC Location : ";
radLabel3.Text = "CNC Type : ";
radLabel7.Text = "CNC IP : ";
radLabel1.Text = "Remark : ";
rbtnOK.Text = "Add";
rbtnCancel.Text = "Cancel";
}
}
gFTS = fts;
}
public FAddTolerance(FToleranceSetup fts)
{
InitializeComponent();
InitLanguage();
gFTS = fts;
}
private void SFAddCNC_Load(object sender, EventArgs e)
{
rddl_ReadType.SelectedIndex = 0;
rddl_Position.SelectedIndex = 0;
rddl_Status.SelectedIndex = 0;
}
private void SFAddCNC_Load(object sender, EventArgs e)
{
rddlDimensionName.SelectedIndex = 0;
}
private void rbtnOK_Click(object sender, EventArgs e)
{
#region
private void rbtnOK_Click(object sender, EventArgs e)
{
#region
string strCarName = rtbCarName.Text.Trim();
string strCarType = rtbCarType.Text.Trim();
string strReadType = rddl_ReadType.Text.Trim();
string strPosition = rddl_Position.Text.Trim();
string strStatus = rddl_Status.Text.Trim();
string strCarType = rtbCarType.Text.Trim();
string strMesPointName = rtbMesPointName.Text.Trim();
if (string.IsNullOrEmpty(rtbCarName.Text.Trim()))
{
MessageBox.Show("车型名称不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string strDimensionName = rddlDimensionName.Text.Trim();
if (string.IsNullOrEmpty(rtbCarType.Text.Trim()))
{
MessageBox.Show("车身类型不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (string.IsNullOrEmpty(rtbCarType.Text.Trim()))
{
MessageBox.Show("车型代码不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (string.IsNullOrEmpty(rtb_sourceFilePath.Text.Trim()))
{
MessageBox.Show("源文件路径不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (string.IsNullOrEmpty(rtb_targetFilePath.Text.Trim()))
{
MessageBox.Show("目标文件路径不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (string.IsNullOrEmpty(rtbMesPointName.Text.Trim()))
{
MessageBox.Show("测量点位名称不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (string.IsNullOrEmpty(rtbLower.Text.Trim()))
{
MessageBox.Show("下限值不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (string.IsNullOrEmpty(rtbUpper.Text.Trim()))
{
MessageBox.Show("上限值不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (!string.IsNullOrEmpty(rtbLower.Text.Trim()))
{
try
{
double dtemp = double.Parse(rtbLower.Text.Trim());
}
catch (Exception)
{
MessageBox.Show("下限值必须是数字,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
if (!string.IsNullOrEmpty(rtbUpper.Text.Trim()))
{
try
{
double dtemp = double.Parse(rtbUpper.Text.Trim());
}
catch (Exception)
{
MessageBox.Show("上限值必须是数字,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
if (tmdal.CheckMeaPointNameExit(strCarType, strMesPointName, strDimensionName))
{
MessageBox.Show("该车身类型下,已经存在该测量点位名称和尺寸名称,请修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
// 对于分发配置,strReadType 进行转换 ,文件内容 对应1 文件名称对应2
if (string.IsNullOrEmpty(strReadType) || (strReadType != "文件内容" && strReadType != "文件名称"))
{
MessageBox.Show("请选择正确的读取类型! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
return;
}
if (strReadType.Equals("文件名称"))
{
strReadType = "2"; // 文件名称
}
else if (strReadType.Equals("文件内容"))
{
strReadType = "1"; // 文件内容
}
#endregion
if (tmdal.CheckTaskExit(strCarName, strCarType, strReadType))
{
MessageBox.Show("该车身类型下,已经存在该测量点位名称和尺寸名称,请修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
TToleranceModel ttm = new TToleranceModel();
ttm.CarType = strCarType;
ttm.MeasurePointName = strMesPointName;
ttm.DimensionName = strDimensionName;
ttm.TolLower = double.Parse(rtbLower.Text.Trim());
ttm.TolUpper = double.Parse(rtbUpper.Text.Trim());
ttm.Remark = rtbRemark.Text.Trim();
ttm.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
return;
}
try
{
tmdal.InsertTTolerance(ttm);
}
catch (Exception ex)
{
MessageBox.Show("添加公差带信息失败,原因:" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
#endregion
MyBase.TraceWriteLine("添加公差带信息失败,原因:" + ex.ToString());
return;
}
//数据转换
if (strPosition.Equals("左侧"))
{
strPosition = "R"; // 左侧
}
else if (strPosition.Equals("右侧"))
{
strPosition = "L"; // 右侧
}
MessageBox.Show("添加公差带信息成功! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if(strStatus.Equals("启动"))
{
strStatus = "start"; // 启动
}
else if (strStatus.Equals("停止"))
{
strStatus = "stop"; // 停止
}
gFTS.rtbnSearch_Click(null, null);
}
//添加分发配置
CJLR_TASK_RELEASE cJLR_TASK_RELEASE = new CJLR_TASK_RELEASE();
cJLR_TASK_RELEASE.ModelsName = strCarName;
cJLR_TASK_RELEASE.ModelsCode = strCarType;
cJLR_TASK_RELEASE.Position = strPosition;
cJLR_TASK_RELEASE.SourceFile = rtb_sourceFilePath.Text.Trim();
cJLR_TASK_RELEASE.TargetFile = rtb_targetFilePath.Text.Trim();
cJLR_TASK_RELEASE.ReadType = int.Parse(strReadType);
cJLR_TASK_RELEASE.IsDelete = 1; //默认未删除
private void rbtnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
cJLR_TASK_RELEASE.Status = strStatus;
try
{
tmdal.InsertTask(cJLR_TASK_RELEASE);
}
catch (Exception ex)
{
MessageBox.Show("添加分发配置失败,原因:" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
MyBase.TraceWriteLine("添加分发配置失败,原因:" + ex.ToString());
return;
}
MessageBox.Show("添加分发配置成功! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
gFTS.rtbnSearch_Click(null, null);
}
private void rbtnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btn_sourceFile_Click(object sender, EventArgs e) //原路径
{
// 创建 FolderBrowserDialog 实例
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog
{
Description = "选择源文件夹"
};
// 显示文件夹浏览对话框
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
// 设置选中的文件夹路径到文本框
rtb_sourceFilePath.Text = folderBrowserDialog.SelectedPath;
}
else
{
// 显示未选择文件夹的提示信息
MessageBox.Show("未选择源文件夹", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void btn_targetFile_Click(object sender, EventArgs e) //目标路径
{
// 创建 FolderBrowserDialog 实例
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog
{
Description = "选择目标文件夹"
};
// 显示文件夹浏览对话框
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
// 设置选中的文件夹路径到文本框
rtb_targetFilePath.Text = folderBrowserDialog.SelectedPath;
}
else
{
// 显示未选择文件夹的提示信息
MessageBox.Show("未选择目标文件夹", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}