Browse Source

优化上下线逻辑

callm 3 days ago
parent
commit
245fd1e24c

+ 8 - 0
UAS_MES_YDCY/.workbuddy/memory/2026-10-27.md

@@ -38,5 +38,13 @@
 - 追加(同日):下线扫码时,人员**在线记录上的 `lm_linecode`** 也必须在长线范围内,否则提示「当前在xx上线,该线别不在xx长线范围内,不允许下线」。
   注意:批量勾选下线(`ConfirmDown_Click`)**尚未加此卡控**(用户只提扫码)。
 
+## Query_LoadMan:DGV 加序号列 + 底部行数总计(2026-10-28)
+- Designer 新增 `serial`(`DataGridViewTextBoxColumn`,HeaderText=序号,Width=70,ReadOnly,`SortMode=NotSortable`,**不设 DataPropertyName**),
+  `AddRange` 放最前(序号→勾选→…);新增 `rowcount_label`(Label,12F,`AutoSize=false`,Size 420×32,(36,1182) 固定尺寸,TextAlign=MiddleLeft)。
+- `LoadGridData` 末尾:绑定后按 `for` 循环给 `Cells["serial"].Value = i+1`;`rowcount_label.Text = "当前在线人数: " + DGV.Rows.Count`。
+- 位置依据:DGV (36,154) Size 1635×1024 → 底部 1178,窗体高 1216,Label 放 1182~1214 不重叠。
+- `FillDgvWithDataTable` 内部 `AutoGenerateColumns=false`(`BaseUtil.cs:825`),Designer 手工列会保留,未绑定列可赋值。
+
+
 
 

+ 37 - 11
UAS_MES_YDCY/FunctionCode/Query/Query_LoadMan.Designer.cs

@@ -32,6 +32,7 @@ namespace UAS_MES_NEW.Query
             this.linecode_label = new System.Windows.Forms.Label();
             this.emcode_label = new System.Windows.Forms.Label();
             this.DGV = new System.Windows.Forms.DataGridView();
+            this.serial = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.lm_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.lm_emcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -46,6 +47,7 @@ namespace UAS_MES_NEW.Query
             this.ConfirmDown = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.SelectAll = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.OperateResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
+            this.rowcount_label = new System.Windows.Forms.Label();
             ((System.ComponentModel.ISupportInitialize)(this.DGV)).BeginInit();
             this.SuspendLayout();
             // 
@@ -76,6 +78,7 @@ namespace UAS_MES_NEW.Query
             this.DGV.AllowUserToAddRows = false;
             this.DGV.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.DGV.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.serial,
             this.choose,
             this.lm_id,
             this.lm_emcode,
@@ -91,6 +94,15 @@ namespace UAS_MES_NEW.Query
             this.DGV.Size = new System.Drawing.Size(1635, 1024);
             this.DGV.TabIndex = 5;
             // 
+            // serial
+            // 
+            this.serial.HeaderText = "序号";
+            this.serial.MinimumWidth = 10;
+            this.serial.Name = "serial";
+            this.serial.ReadOnly = true;
+            this.serial.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.serial.Width = 70;
+            // 
             // choose
             // 
             this.choose.HeaderText = "勾选";
@@ -116,18 +128,18 @@ namespace UAS_MES_NEW.Query
             this.lm_emcode.Name = "lm_emcode";
             this.lm_emcode.ReadOnly = true;
             this.lm_emcode.Width = 180;
-            //
+            // 
             // lm_emname
-            //
+            // 
             this.lm_emname.DataPropertyName = "lm_emname";
             this.lm_emname.HeaderText = "人员名称";
             this.lm_emname.MinimumWidth = 10;
             this.lm_emname.Name = "lm_emname";
             this.lm_emname.ReadOnly = true;
             this.lm_emname.Width = 120;
-            //
+            // 
             // lm_linecode
-            //
+            // 
             this.lm_linecode.DataPropertyName = "lm_linecode";
             this.lm_linecode.HeaderText = "线别";
             this.lm_linecode.MinimumWidth = 10;
@@ -159,7 +171,7 @@ namespace UAS_MES_NEW.Query
             this.UpLoadMan.Checked = true;
             this.UpLoadMan.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.UpLoadMan.Location = new System.Drawing.Point(1200, 54);
-            this.UpLoadMan.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+            this.UpLoadMan.Margin = new System.Windows.Forms.Padding(6);
             this.UpLoadMan.Name = "UpLoadMan";
             this.UpLoadMan.Size = new System.Drawing.Size(129, 54);
             this.UpLoadMan.TabIndex = 3;
@@ -173,7 +185,7 @@ namespace UAS_MES_NEW.Query
             this.DownLoadMan.AutoSize = true;
             this.DownLoadMan.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.DownLoadMan.Location = new System.Drawing.Point(1368, 54);
-            this.DownLoadMan.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+            this.DownLoadMan.Margin = new System.Windows.Forms.Padding(6);
             this.DownLoadMan.Name = "DownLoadMan";
             this.DownLoadMan.Size = new System.Drawing.Size(129, 54);
             this.DownLoadMan.TabIndex = 4;
@@ -209,7 +221,7 @@ namespace UAS_MES_NEW.Query
             this.em_code.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.em_code.ID = null;
             this.em_code.Location = new System.Drawing.Point(798, 56);
-            this.em_code.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+            this.em_code.Margin = new System.Windows.Forms.Padding(6);
             this.em_code.Name = "em_code";
             this.em_code.Power = null;
             this.em_code.Size = new System.Drawing.Size(328, 57);
@@ -229,7 +241,7 @@ namespace UAS_MES_NEW.Query
             this.ConfirmDown.Image = null;
             this.ConfirmDown.IsShowBorder = true;
             this.ConfirmDown.Location = new System.Drawing.Point(1697, 55);
-            this.ConfirmDown.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+            this.ConfirmDown.Margin = new System.Windows.Forms.Padding(6);
             this.ConfirmDown.MoveImage = ((System.Drawing.Image)(resources.GetObject("ConfirmDown.MoveImage")));
             this.ConfirmDown.Name = "ConfirmDown";
             this.ConfirmDown.NormalImage = ((System.Drawing.Image)(resources.GetObject("ConfirmDown.NormalImage")));
@@ -249,7 +261,7 @@ namespace UAS_MES_NEW.Query
             this.SelectAll.Image = null;
             this.SelectAll.IsShowBorder = true;
             this.SelectAll.Location = new System.Drawing.Point(1549, 53);
-            this.SelectAll.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+            this.SelectAll.Margin = new System.Windows.Forms.Padding(6);
             this.SelectAll.MoveImage = ((System.Drawing.Image)(resources.GetObject("SelectAll.MoveImage")));
             this.SelectAll.Name = "SelectAll";
             this.SelectAll.NormalImage = ((System.Drawing.Image)(resources.GetObject("SelectAll.NormalImage")));
@@ -269,11 +281,22 @@ namespace UAS_MES_NEW.Query
             this.OperateResult.TabIndex = 6;
             this.OperateResult.Text = "";
             // 
+            // rowcount_label
+            // 
+            this.rowcount_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.rowcount_label.Location = new System.Drawing.Point(36, 1182);
+            this.rowcount_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.rowcount_label.Name = "rowcount_label";
+            this.rowcount_label.Size = new System.Drawing.Size(420, 38);
+            this.rowcount_label.TabIndex = 12;
+            this.rowcount_label.Text = "当前在线人数: 0";
+            this.rowcount_label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
             // Query_LoadMan
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(2340, 1216);
+            this.ClientSize = new System.Drawing.Size(2340, 1229);
             this.Controls.Add(this.SelectAll);
             this.Controls.Add(this.ConfirmDown);
             this.Controls.Add(this.li_code);
@@ -284,8 +307,9 @@ namespace UAS_MES_NEW.Query
             this.Controls.Add(this.DownLoadMan);
             this.Controls.Add(this.DGV);
             this.Controls.Add(this.OperateResult);
+            this.Controls.Add(this.rowcount_label);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+            this.Margin = new System.Windows.Forms.Padding(6);
             this.Name = "Query_LoadMan";
             this.Tag = "Query!LoadMan";
             this.Text = "人员上下线";
@@ -308,7 +332,9 @@ namespace UAS_MES_NEW.Query
         private CustomControl.RichText.RichTextAutoBottom OperateResult;
         private CustomControl.ButtonUtil.NormalButton ConfirmDown;
         private CustomControl.ButtonUtil.NormalButton SelectAll;
+        private System.Windows.Forms.Label rowcount_label;
         private System.Windows.Forms.DataGridViewCheckBoxColumn choose;
+        private System.Windows.Forms.DataGridViewTextBoxColumn serial;
         private System.Windows.Forms.DataGridViewTextBoxColumn lm_id;
         private System.Windows.Forms.DataGridViewTextBoxColumn lm_emcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn lm_emname;

+ 10 - 3
UAS_MES_YDCY/FunctionCode/Query/Query_LoadMan.cs

@@ -30,7 +30,7 @@ namespace UAS_MES_NEW.Query
             li_code.SelectField = "li_code # 线别编号,li_name # 线别名称";
             li_code.FormName = Name;
             li_code.SetValueField = new string[] { "li_code" };
-            li_code.Condition = "li_statuscode='AUDITED' and li_longline='"+User.UserCtCode+"'";
+            li_code.Condition = "li_statuscode='AUDITED' and instr('" + User.UserCtCode + "',li_longline)>0";
             li_code.DbChange += Li_code_DbChange;
             //初始提示
             OperateResult.AppendText(">>请选择线别,输入人员工号后回车执行" + (UpLoadMan.Checked ? "上线" : "下线") + ";下线也可勾选列表后点\"确认下线\"批量处理\n", Color.Black);
@@ -126,7 +126,7 @@ namespace UAS_MES_NEW.Query
             }
             //所选线别必须属于登录人长线(line.li_longline)下的线别,否则上/下线都不允许
             if (dh.getFieldDataByCondition("line", "count(1)",
-                "li_longline='" + User.UserCtCode + "' and li_code='" + linecode + "' and li_statuscode='AUDITED'").ToString() == "0")
+                "instr('" + User.UserCtCode + "',li_longline)>0 and li_code='" + linecode + "' and li_statuscode='AUDITED'").ToString() == "0")
             {
                 OperateResult.AppendText("<<线别" + linecode + "不在" + User.UserCtCode + "范围内,不允许扫码\n", Color.Red, li_code);
                 return;
@@ -178,7 +178,7 @@ namespace UAS_MES_NEW.Query
                 //人员当前在线线体也必须在登录人长线范围内,否则不允许下线
                 string onLineCode = dtOn.Rows[0]["lm_linecode"].ToString();
                 if (dh.getFieldDataByCondition("line", "count(1)",
-                    "li_longline='" + User.UserCtCode + "' and li_code='" + onLineCode + "' and li_statuscode='AUDITED'").ToString() == "0")
+                    "instr('" + User.UserCtCode + "',li_longline)>0 and li_code='" + onLineCode + "' and li_statuscode='AUDITED'").ToString() == "0")
                 {
                     OperateResult.AppendText("<<" + emcode + "当前在" + onLineCode + "上线,该线别不在" + User.UserCtCode + "范围内,不允许下线\n", Color.Red, em_code);
                     em_code.Clear();
@@ -321,8 +321,15 @@ namespace UAS_MES_NEW.Query
             sql += " order by lm.lm_uptime desc";
             DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
             BaseUtil.FillDgvWithDataTable(DGV, dt);
+            //序号列:绑定数据源后按当前行序手工赋号
+            for (int i = 0; i < DGV.Rows.Count; i++)
+            {
+                DGV.Rows[i].Cells["serial"].Value = i + 1;
+            }
             //重新绑定后复选框一律清空,全选按钮文案复位
             SelectAll.Text = "全选";
+            //当前DGV行数总计
+            rowcount_label.Text = "当前在线人数: " + DGV.Rows.Count;
         }
     }
 }