using BaseFunction; using NSAnalysis.DAL; using NSAnalysis.Model; using System; using System.Drawing; using System.Windows.Forms; using Telerik.WinControls.UI; namespace NSAnalysis { public partial class FAddTolerance : Telerik.WinControls.UI.ShapedForm { #region 全局变量 private TMeasureMSSQLDAL tmdal = new TMeasureMSSQLDAL(); private FToleranceSetup gFTS; #endregion 全局变量 #region 鼠标事件 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); } #endregion 鼠标事件 public FAddTolerance(FToleranceSetup fts) { InitializeComponent(); gFTS = fts; } private void FAddTolerance_Load(object sender, EventArgs e) { rddl_ReadType.SelectedIndex = 0; rddl_Position.SelectedIndex = 0; rddl_Status.SelectedIndex = 0; } 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(); if (string.IsNullOrEmpty(rtbCarName.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; } // 对于分发配置,strReadType 进行转换 ,文件内容 对应1 文件名称对应2 if (string.IsNullOrEmpty(strReadType) || (strReadType != "文件内容" && strReadType != "文件名称")) { MessageBox.Show("请选择正确的读取类型! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (strReadType.Equals("文件名称")) { strReadType = "2"; // 文件名称 } else if (strReadType.Equals("文件内容")) { strReadType = "1"; // 文件内容 } if (tmdal.CheckTaskExit(strCarName, strCarType, strReadType)) { MessageBox.Show("该车身类型下,已经存在该测量点位名称和尺寸名称,请修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endregion 防愚操作 //数据转换 if (strPosition.Equals("左侧")) { strPosition = "R"; // 左侧 } else if (strPosition.Equals("右侧")) { strPosition = "L"; // 右侧 } if (strStatus.Equals("启动")) { strStatus = "start"; // 启动 } else if (strStatus.Equals("停止")) { strStatus = "stop"; // 停止 } //添加分发配置 CjlrTaskReleaseModel cJLR_TASK_RELEASE = new CjlrTaskReleaseModel(); 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; //默认未删除 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); } } } }