using NSAnalysis.DAL; using NSAnalysis.Model; using System; using System.Drawing; using System.Windows.Forms; using Telerik.WinControls.UI; namespace NSAnalysis { public partial class FEditConfig : Telerik.WinControls.UI.ShapedForm { #region 全局变量 private CjlrDAL tmdal = new CjlrDAL(); private FConfigSetup 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 FEditConfig(FConfigSetup fts) { InitializeComponent(); gFTS = fts; } private void FEditTolerance_Load(object sender, EventArgs e) { rtbCarName.Text = gFTS.dgvTolList.Rows[gFTS.idgvSelectRowNumber].Cells["modelsName"].Value.ToString(); rtbCarType.Text = gFTS.dgvTolList.Rows[gFTS.idgvSelectRowNumber].Cells["modelsCode"].Value.ToString(); rtb_sourceFilePath.Text = gFTS.dgvTolList.Rows[gFTS.idgvSelectRowNumber].Cells["sourceFile"].Value.ToString(); rtb_targetFilePath.Text = gFTS.dgvTolList.Rows[gFTS.idgvSelectRowNumber].Cells["targetFile"].Value.ToString(); string strReadTyple = gFTS.dgvTolList.Rows[gFTS.idgvSelectRowNumber].Cells["readType"].Value.ToString(); if (strReadTyple.Equals("1")) { rddl_ReadType.Text = "文件内容"; } else { rddl_ReadType.SelectedIndex = -1; // 未匹配到,设置为无选中项 } string strPosition = gFTS.dgvTolList.Rows[gFTS.idgvSelectRowNumber].Cells["position"].Value.ToString(); if (strPosition.Equals("L")) { rddl_Position.Text = "左侧"; } else if (strPosition.Equals("R")) { rddl_Position.Text = "右侧"; } else { rddl_Position.SelectedIndex = -1; // 未匹配到,设置为无选中项 } string strStatus = gFTS.dgvTolList.Rows[gFTS.idgvSelectRowNumber].Cells["status"].Value.ToString(); if (strStatus.Equals("start")) { rddl_Status.Text = "启动"; } else if (strStatus.Equals("stop")) { rddl_Status.Text = "停止"; } else { rddl_Status.SelectedIndex = -1; // 未匹配到,设置为无选中项 } } 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 = "1"; // 文件名称 } else if (strReadType.Equals("文件内容")) { strReadType = "2"; // 文件内容 } #endregion 防愚操作 try { CjlrTaskReleaseModel cjlrTaskRelease = new CjlrTaskReleaseModel { Id = int.Parse(gFTS.dgvTolList.Rows[gFTS.idgvSelectRowNumber].Cells["Id"].Value.ToString()), ModelsName = strCarName, ModelsCode = strCarType, Position = strPosition.Equals("左侧") ? "L" : "R", SourceFile = rtb_sourceFilePath.Text.Trim(), TargetFile = rtb_targetFilePath.Text.Trim(), Status = strStatus.Equals("启动") ? "start" : "stop", CreateDate = DateTime.Now, IsDelete = 1, //未删除 ReadType = strReadType.Equals("文件内容") ? 2 : 1 // 文件内容对应1,文件名称对应2 }; tmdal.UpdateTaskRelease(cjlrTaskRelease); } catch (Exception ex) { MessageBox.Show("修改分发配置失败,原因:" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MessageBox.Show("修改分发配置成功! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); gFTS.rtbnSearch_Click(null, null); this.Close(); } private void rbtnCancel_Click(object sender, EventArgs e) { this.Close(); } private void btn_sourceFile_Click(object sender, EventArgs e) { // 文件路径对话框 FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog { Description = "请选择源文件所在的文件夹", ShowNewFolderButton = true }; 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 = new FolderBrowserDialog { Description = "请选择目标文件所在的文件夹", ShowNewFolderButton = true }; if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { rtb_targetFilePath.Text = folderBrowserDialog.SelectedPath; // 设置目标文件路径 } else { // 显示未选择文件夹的提示信息 MessageBox.Show("未选择目标文件夹", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }