|
|
@@ -3,17 +3,26 @@ using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
+using System.Globalization;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Media;
|
|
|
using System.Security.Principal;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
+using UAS_Tools_HY.PublicMethods;
|
|
|
|
|
|
namespace UAS_MES_Tools
|
|
|
{
|
|
|
public partial class Main : Form
|
|
|
{
|
|
|
- private string _Account, _Password;
|
|
|
+ string _Account, _Password, _UserName;
|
|
|
+
|
|
|
+ DataTable dt;
|
|
|
+ Timer loadTime;
|
|
|
+
|
|
|
+ string minTime, maxTime;
|
|
|
|
|
|
public Main(string account, string password)
|
|
|
{
|
|
|
@@ -22,5 +31,258 @@ namespace UAS_MES_Tools
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
|
|
|
+ private void Main_Load(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ currUser.Text = "当前账户: " + _Account;
|
|
|
+
|
|
|
+ dt = ConnectDB.ExecuteSelect($"select * from employee where em_code = '{_Account}'");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ _UserName = dt.Rows[0]["em_name"].ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ loadTime_Tick(null, null);
|
|
|
+ loadTime = new Timer();
|
|
|
+ loadTime.Interval = 1000;
|
|
|
+ loadTime.Tick += loadTime_Tick;
|
|
|
+ loadTime.Start();
|
|
|
+
|
|
|
+ SN.SelectAll();
|
|
|
+ SN.Focus();
|
|
|
+
|
|
|
+ settingLeftInput1.Text = BaseUtil.GetCacheData("SettingCount").ToString();
|
|
|
+ settingLeftInput2.Text = BaseUtil.GetCacheData("SettingVolume").ToString();
|
|
|
+
|
|
|
+ settingRightInput1.Text = BaseUtil.GetCacheData("SettingNGPath").ToString();
|
|
|
+ settingRightInput2.Text = BaseUtil.GetCacheData("SettingExportPath").ToString();
|
|
|
+
|
|
|
+ QDcheckbox1.Checked = true;
|
|
|
+ QDdtp1.Value = QDdtp2.Value.AddDays(-1);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SN_KeyDown(object sender, KeyEventArgs e)
|
|
|
+ {
|
|
|
+ if (e.KeyCode != Keys.Enter) return;
|
|
|
+
|
|
|
+ if (CheckEnter()) return;
|
|
|
+
|
|
|
+ bool checkRes = false;
|
|
|
+
|
|
|
+
|
|
|
+ DataGridViewRow row = new DataGridViewRow();
|
|
|
+ row.CreateCells(Datas);
|
|
|
+ row.Cells[0].Value = SN.Text.Trim();
|
|
|
+ row.Cells[1].Value = "";
|
|
|
+ row.Cells[2].Value = 1;
|
|
|
+ row.Cells[3].Value = currTime.Text;
|
|
|
+ row.Cells[4].Value = _UserName;
|
|
|
+ row.Cells[5].Value = radio1.Checked ? "是" : "否";
|
|
|
+ row.Cells[6].Value = checkRes ? "OK": "NG";
|
|
|
+ Datas.Rows.Add(row);
|
|
|
+
|
|
|
+ Datas.FirstDisplayedScrollingRowIndex = Datas.Rows.Count - 1;
|
|
|
+ PlaySound("OK");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BoxNo_KeyDown(object sender, KeyEventArgs e)
|
|
|
+ {
|
|
|
+ if (e.KeyCode != Keys.Enter) return;
|
|
|
+
|
|
|
+ if (CheckEnter()) return;
|
|
|
+
|
|
|
+ BoxNo.Enabled = false;
|
|
|
+ SN.SelectAll();
|
|
|
+ SN.Focus();
|
|
|
+ if (Datas.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ foreach(DataGridViewRow item in Datas.Rows)
|
|
|
+ {
|
|
|
+ item.Cells[1].Value = BoxNo.Text.Trim();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool CheckEnter()
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(settingLeftInput1.Text))
|
|
|
+ {
|
|
|
+ MessageBox.Show("请维护列表记录数", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(settingLeftInput2.Text))
|
|
|
+ {
|
|
|
+ MessageBox.Show("请维护箱内容量", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void settingLeftSubmit_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(settingLeftInput1.Text))
|
|
|
+ {
|
|
|
+ MessageBox.Show("请输入列表记录数", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(settingLeftInput2.Text))
|
|
|
+ {
|
|
|
+ MessageBox.Show("请输入箱内容量", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BaseUtil.SetCacheData("SettingCount", settingLeftInput1.Text);
|
|
|
+ BaseUtil.SetCacheData("SettingVolume", settingLeftInput2.Text);
|
|
|
+ MessageBox.Show("已提交扫描设置", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void settingRightSubmit_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(settingRightInput2.Text))
|
|
|
+ {
|
|
|
+ MessageBox.Show("请选择导出文件目录", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(!string.IsNullOrEmpty(settingRightInput1.Text)) BaseUtil.SetCacheData("SettingNGPath", settingRightInput1.Text);
|
|
|
+
|
|
|
+ BaseUtil.SetCacheData("SettingExportPath", settingRightInput2.Text);
|
|
|
+ MessageBox.Show("已提交文件设置", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void QDquery_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(QDInput1.Text) && string.IsNullOrEmpty(QDInput2.Text) && !QDcheckbox1.Checked)
|
|
|
+ {
|
|
|
+ MessageBox.Show("请添加筛选条件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (QDcheckbox1.Checked)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void QDexport_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if(QDDatas.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show("请筛选数据", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void boxBtn_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ BoxNo.Enabled = true;
|
|
|
+ BoxNo.Focus();
|
|
|
+ BoxNo.SelectAll();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void settingRightInput1_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
|
|
+ {
|
|
|
+ openFileDialog.Title = "请选择告警文件";
|
|
|
+ openFileDialog.Filter = "可执行文件 (*.wav)|*.wav|所有文件 (*.*)|*.*";
|
|
|
+ openFileDialog.FilterIndex = 1;
|
|
|
+ openFileDialog.RestoreDirectory = true;
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(settingRightInput1.Text) && System.IO.File.Exists(settingRightInput1.Text))
|
|
|
+ {
|
|
|
+ openFileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(settingRightInput1.Text);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
|
|
+ }
|
|
|
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
|
+ {
|
|
|
+ settingRightInput1.Text = openFileDialog.FileName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void settingRightInput2_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
|
|
|
+ {
|
|
|
+ folderBrowserDialog.Description = "请选择导出文件夹";
|
|
|
+ if (!string.IsNullOrEmpty(settingRightInput2.Text) && System.IO.Directory.Exists(settingRightInput2.Text))
|
|
|
+ {
|
|
|
+ folderBrowserDialog.SelectedPath = settingRightInput2.Text;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ folderBrowserDialog.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // folderBrowserDialog.SelectedPath = "";
|
|
|
+ }
|
|
|
+ if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
|
|
+ {
|
|
|
+ settingRightInput2.Text = folderBrowserDialog.SelectedPath;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void QDdtp1_ValueChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (QDdtp1.Value > QDdtp2.Value)
|
|
|
+ {
|
|
|
+ QDdtp1.Value = QDdtp2.Value.AddDays(-1);
|
|
|
+ MessageBox.Show("时间不得大于最大时间", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ minTime = QDdtp1.Value.ToString("yyyy-mm-dd hh:mm:ss");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void QDdtp2_ValueChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (QDdtp2.Value < QDdtp1.Value)
|
|
|
+ {
|
|
|
+ QDdtp2.Value = QDdtp1.Value.AddDays(1);
|
|
|
+ MessageBox.Show("时间不得小于最小时间", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ maxTime = QDdtp2.Value.ToString("yyyy-mm-dd hh:mm:ss");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PlaySound(string type)
|
|
|
+ {
|
|
|
+ if (type == "OK")
|
|
|
+ {
|
|
|
+ using (var stream = UAS_Tools_HY.Properties.Resources.OK)
|
|
|
+ {
|
|
|
+ SoundPlayer player = new SoundPlayer(stream);
|
|
|
+ player.Play();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(settingRightInput1.Text))
|
|
|
+ {
|
|
|
+ using (var stream = UAS_Tools_HY.Properties.Resources.NG)
|
|
|
+ {
|
|
|
+ SoundPlayer player = new SoundPlayer(stream);
|
|
|
+ player.Play();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string customPath = settingRightInput1.Text.Trim();
|
|
|
+ if (File.Exists(customPath))
|
|
|
+ {
|
|
|
+ SoundPlayer player = new SoundPlayer(customPath);
|
|
|
+ player.Play();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void loadTime_Tick(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ string currentDate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
|
|
|
+ currTime.Text = currentDate;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|