Explorar el Código

更新出货工具

yhluo hace 1 semana
padre
commit
cc35c1f479

+ 7 - 4
UAS_Tools_HY/Login.cs

@@ -44,7 +44,10 @@ namespace UAS_MES_Tools
                     showMsg.Invoke(new Action(() =>
                     {
                         showMsg.Text = result;
-                        LoginIN.Enabled = true;
+                        if (result.Substring(0,2) == "OK")
+                        {
+                            LoginIN.Enabled = true;
+                        }
                     }));
                 }
 
@@ -181,16 +184,16 @@ namespace UAS_MES_Tools
             {
                 if (ConnectDB.TestConnection())
                 {
-                    return $"数据库连接成功";
+                    return $"OK,数据库连接成功";
                 }
                 else
                 {
-                    return $"数据库连接失败";
+                    return $"NG,数据库连接失败";
                 }
             }
             catch (Exception ex)
             {
-                return $"{ex.Message}";
+                return $"NG,{ex.Message}";
             }
         }
     }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1055 - 46
UAS_Tools_HY/Main.Designer.cs


+ 263 - 1
UAS_Tools_HY/Main.cs

@@ -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;
+        }
+
     }
 }

+ 54 - 0
UAS_Tools_HY/Main.resx

@@ -117,6 +117,60 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="DbarCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="DboxCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="DcountCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="DtimeCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="Duser.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="DisCheckdcr.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="Dresult.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="RulesCol1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="RulesCol2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="RulesCol3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="RulesCol4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="RulesCol5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="RulesCol6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="dataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="dataGridViewTextBoxColumn5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>

+ 18 - 0
UAS_Tools_HY/Properties/Resources.Designer.cs

@@ -60,6 +60,24 @@ namespace UAS_Tools_HY.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找类似于 System.IO.MemoryStream 的 System.IO.UnmanagedMemoryStream 类型的本地化资源。
+        /// </summary>
+        internal static System.IO.UnmanagedMemoryStream NG {
+            get {
+                return ResourceManager.GetStream("NG", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   查找类似于 System.IO.MemoryStream 的 System.IO.UnmanagedMemoryStream 类型的本地化资源。
+        /// </summary>
+        internal static System.IO.UnmanagedMemoryStream OK {
+            get {
+                return ResourceManager.GetStream("OK", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
         /// </summary>

+ 6 - 0
UAS_Tools_HY/Properties/Resources.resx

@@ -118,6 +118,12 @@
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  <data name="NG" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\Audio\NG.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </data>
+  <data name="OK" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\Audio\OK.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </data>
   <data name="U_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\U_Icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>

+ 16 - 0
UAS_Tools_HY/PublicMethods/FormMethods.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace UAS_MES_Tools
+{
+    internal static class FormMethods
+    {
+        
+    }
+}

BIN
UAS_Tools_HY/Resources/Audio/NG.wav


BIN
UAS_Tools_HY/Resources/Audio/OK.wav


+ 1 - 0
UAS_Tools_HY/UAS_Tools_HY.csproj

@@ -86,6 +86,7 @@
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="PublicMethods\ConnectDB.cs" />
     <Compile Include="PublicMethods\BaseUtil.cs" />
+    <Compile Include="PublicMethods\FormMethods.cs" />
     <Compile Include="PublicMethods\LogManager.cs" />
     <Compile Include="PublicMethods\SystemCacheClass.cs" />
     <EmbeddedResource Include="Login.resx">

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio