浏览代码

添加采集项次不符合提示

章政 7 年之前
父节点
当前提交
5543e8c9d5
共有 1 个文件被更改,包括 20 次插入5 次删除
  1. 20 5
      UAS-出货标签管理/UAS_出货标签管理.cs

+ 20 - 5
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -462,7 +462,18 @@ namespace UAS_LabelMachine
             }
             else
             {
-                for (int i = 0; i < Input.Text.Split(sg_separator.Text.ToCharArray()).Length; i++)
+                int DataCount = Input.Text.Split(sg_separator.Text.ToCharArray()).Length;
+                if (DataCount > ItemData.Length)
+                {
+                    MessageBox.Show("采集数据大于采集项次");
+                    return;
+                }
+                else if (DataCount < ItemData.Length)
+                {
+                    MessageBox.Show("采集数据小于采集项次");
+                    return;
+                }
+                for (int i = 0; i < DataCount; i++)
                     CollectData.Add(ItemData[i].ToString().ToUpper(), Input.Text.Split(sg_separator.Text.ToCharArray())[i]);
             }
             //首先判断当前采集的个数,如果采集的个数为1则不对数据进行分隔符验证
@@ -1345,7 +1356,8 @@ namespace UAS_LabelMachine
                             }
                             LogManager.DoLog(ParamLog.ToString());
                             //保存参数打印
-                            if (EnablePrint) {
+                            if (EnablePrint)
+                            {
                                 SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
                                 SingleDoc.PrintDocument();
                             }
@@ -1844,7 +1856,8 @@ namespace UAS_LabelMachine
                 }
             }
             //保存参数打印
-            if (EnablePrint) {
+            if (EnablePrint)
+            {
                 MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
                 MidDoc.PrintDocument();
             }
@@ -1928,7 +1941,8 @@ namespace UAS_LabelMachine
                 }
             }
             //保存参数打印
-            if (EnablePrint) {
+            if (EnablePrint)
+            {
                 MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
                 MidDoc.PrintDocument();
             }
@@ -2022,7 +2036,8 @@ namespace UAS_LabelMachine
                     }
                 }
                 //保存参数打印
-                if (EnablePrint) {
+                if (EnablePrint)
+                {
                     OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
                     OutBoxDoc.PrintDocument();
                 }