소스 검색

添加查询条件

章政 7 년 전
부모
커밋
9032017e7b
2개의 변경된 파일88개의 추가작업 그리고 17개의 파일을 삭제
  1. 63 1
      PLCDataReader/Main.Designer.cs
  2. 25 16
      PLCDataReader/Main.cs

+ 63 - 1
PLCDataReader/Main.Designer.cs

@@ -168,6 +168,10 @@ namespace UAS_PLCDataReader
             this.pl_dccode = new DevExpress.XtraGrid.Columns.GridColumn();
             this.pl_remark = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PageDeviceStatus = new DevExpress.XtraTab.XtraTabPage();
+            this.ComboxDeviceDepartment = new DevExpress.XtraEditors.ComboBoxEdit();
+            this.ComboxDeviceFloor = new DevExpress.XtraEditors.ComboBoxEdit();
+            this.label_ComboxDeviceFloor = new DevExpress.XtraEditors.LabelControl();
+            this.label_ComboxDeviceDepartment = new DevExpress.XtraEditors.LabelControl();
             this.ComboxDeviceStatusWC = new DevExpress.XtraEditors.ComboBoxEdit();
             this.ComboxDeviceStatusLC = new DevExpress.XtraEditors.ComboBoxEdit();
             this.CheckEditDeviceStatusEnable = new DevExpress.XtraEditors.CheckEdit();
@@ -234,6 +238,8 @@ namespace UAS_PLCDataReader
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).BeginInit();
             this.PageDeviceStatus.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.ComboxDeviceDepartment.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.ComboxDeviceFloor.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.ComboxDeviceStatusWC.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.ComboxDeviceStatusLC.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.CheckEditDeviceStatusEnable.Properties)).BeginInit();
@@ -1618,6 +1624,10 @@ namespace UAS_PLCDataReader
             // 
             // PageDeviceStatus
             // 
+            this.PageDeviceStatus.Controls.Add(this.ComboxDeviceDepartment);
+            this.PageDeviceStatus.Controls.Add(this.ComboxDeviceFloor);
+            this.PageDeviceStatus.Controls.Add(this.label_ComboxDeviceFloor);
+            this.PageDeviceStatus.Controls.Add(this.label_ComboxDeviceDepartment);
             this.PageDeviceStatus.Controls.Add(this.ComboxDeviceStatusWC);
             this.PageDeviceStatus.Controls.Add(this.ComboxDeviceStatusLC);
             this.PageDeviceStatus.Controls.Add(this.CheckEditDeviceStatusEnable);
@@ -1630,6 +1640,52 @@ namespace UAS_PLCDataReader
             this.PageDeviceStatus.Text = "xtraTabPage1";
             this.PageDeviceStatus.VisibleChanged += new System.EventHandler(this.PageDeviceStatus_VisibleChanged);
             // 
+            // ComboxDeviceDepartment
+            // 
+            this.ComboxDeviceDepartment.Location = new System.Drawing.Point(365, 10);
+            this.ComboxDeviceDepartment.MenuManager = this.RibbonNav;
+            this.ComboxDeviceDepartment.Name = "ComboxDeviceDepartment";
+            this.ComboxDeviceDepartment.Properties.Appearance.Font = new System.Drawing.Font("黑体", 11F);
+            this.ComboxDeviceDepartment.Properties.Appearance.Options.UseFont = true;
+            this.ComboxDeviceDepartment.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
+            this.ComboxDeviceDepartment.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
+            this.ComboxDeviceDepartment.Size = new System.Drawing.Size(100, 22);
+            this.ComboxDeviceDepartment.TabIndex = 6;
+            this.ComboxDeviceDepartment.SelectedIndexChanged += new System.EventHandler(this.ComboxDeviceStatusLC_SelectedIndexChanged);
+            // 
+            // ComboxDeviceFloor
+            // 
+            this.ComboxDeviceFloor.Location = new System.Drawing.Point(517, 10);
+            this.ComboxDeviceFloor.MenuManager = this.RibbonNav;
+            this.ComboxDeviceFloor.Name = "ComboxDeviceFloor";
+            this.ComboxDeviceFloor.Properties.Appearance.Font = new System.Drawing.Font("黑体", 11F);
+            this.ComboxDeviceFloor.Properties.Appearance.Options.UseFont = true;
+            this.ComboxDeviceFloor.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
+            this.ComboxDeviceFloor.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
+            this.ComboxDeviceFloor.Size = new System.Drawing.Size(100, 22);
+            this.ComboxDeviceFloor.TabIndex = 7;
+            this.ComboxDeviceFloor.SelectedIndexChanged += new System.EventHandler(this.ComboxDeviceStatusLC_SelectedIndexChanged);
+            // 
+            // label_ComboxDeviceFloor
+            // 
+            this.label_ComboxDeviceFloor.Appearance.Font = new System.Drawing.Font("黑体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.label_ComboxDeviceFloor.Location = new System.Drawing.Point(477, 13);
+            this.label_ComboxDeviceFloor.Name = "label_ComboxDeviceFloor";
+            this.label_ComboxDeviceFloor.Size = new System.Drawing.Size(32, 16);
+            this.label_ComboxDeviceFloor.TabIndex = 9;
+            this.label_ComboxDeviceFloor.Text = "楼层";
+            // 
+            // label_ComboxDeviceDepartment
+            // 
+            this.label_ComboxDeviceDepartment.Appearance.Font = new System.Drawing.Font("黑体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.label_ComboxDeviceDepartment.Location = new System.Drawing.Point(326, 13);
+            this.label_ComboxDeviceDepartment.Name = "label_ComboxDeviceDepartment";
+            this.label_ComboxDeviceDepartment.Size = new System.Drawing.Size(32, 16);
+            this.label_ComboxDeviceDepartment.TabIndex = 8;
+            this.label_ComboxDeviceDepartment.Text = "部门";
+            // 
             // ComboxDeviceStatusWC
             // 
             this.ComboxDeviceStatusWC.Location = new System.Drawing.Point(61, 10);
@@ -1660,7 +1716,7 @@ namespace UAS_PLCDataReader
             // 
             // CheckEditDeviceStatusEnable
             // 
-            this.CheckEditDeviceStatusEnable.Location = new System.Drawing.Point(332, 12);
+            this.CheckEditDeviceStatusEnable.Location = new System.Drawing.Point(628, 13);
             this.CheckEditDeviceStatusEnable.MenuManager = this.RibbonNav;
             this.CheckEditDeviceStatusEnable.Name = "CheckEditDeviceStatusEnable";
             this.CheckEditDeviceStatusEnable.Properties.Appearance.Font = new System.Drawing.Font("黑体", 10F);
@@ -1992,6 +2048,8 @@ namespace UAS_PLCDataReader
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).EndInit();
             this.PageDeviceStatus.ResumeLayout(false);
             this.PageDeviceStatus.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.ComboxDeviceDepartment.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.ComboxDeviceFloor.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.ComboxDeviceStatusWC.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.ComboxDeviceStatusLC.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.CheckEditDeviceStatusEnable.Properties)).EndInit();
@@ -2177,5 +2235,9 @@ namespace UAS_PLCDataReader
         private DevExpress.XtraGrid.Views.Grid.GridView repositoryItemSearchLookUpEdit1View;
         private DevExpress.XtraEditors.Repository.RepositoryItemSearchLookUpEdit PollSettingDeviceSearchLookUpEdit;
         private System.Windows.Forms.Timer TimerUpdateSQL;
+        private ComboBoxEdit ComboxDeviceDepartment;
+        private ComboBoxEdit ComboxDeviceFloor;
+        private LabelControl label_ComboxDeviceFloor;
+        private LabelControl label_ComboxDeviceDepartment;
     }
 }

+ 25 - 16
PLCDataReader/Main.cs

@@ -248,13 +248,11 @@ namespace UAS_PLCDataReader
             string WC = BaseUtil.GetComboxEditValue(ComboxDeviceListWC);
             string LC = BaseUtil.GetComboxEditValue(ComboxDeviceListLC);
             DeviceListQuerySQL.Append("select 0 CHECKEDCOLUMN,de_id,de_code,de_name,de_spec,de_indate,de_runstatus,de_address,de_wccode, ");
-            DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_inman,de_linecode,de_stepcode,de_stepname,DE_SOURCECODE,de_item1,de_item2,de_item3 from device ");
-            if (WC != "全部" && LC != "全部")
-                DeviceListQuerySQL.Append(" where de_wccode='" + WC + "' and de_linecode='" + LC + "' ");
-            if (WC == "全部" && LC != "全部")
-                DeviceListQuerySQL.Append(" where de_linecode='" + LC + "' ");
-            if (WC != "全部" && LC == "全部")
-                DeviceListQuerySQL.Append(" where de_wccode='" + WC + "' ");
+            DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_inman,de_linecode,de_stepcode,de_stepname,DE_SOURCECODE,de_item1,de_item2,de_item3 from device where 1=1");
+            if (WC != "全部")
+                DeviceListQuerySQL.Append(" and de_wccode='" + WC + "' ");
+            if (LC != "全部")
+                DeviceListQuerySQL.Append(" and de_linecode='" + LC + "' ");
             DeviceListQuerySQL.Append("order by de_code");
             RefreshDeviceData();
         }
@@ -676,6 +674,10 @@ namespace UAS_PLCDataReader
                 //填充筛选条件,车间和线体
                 DataTable dt = (DataTable)dh.ExecuteSql("select wc_code,wc_name from workcenter", "select");
                 BaseUtil.FillComBoxEditWidthDataTable(ComboxDeviceStatusWC, "wc_name", "wc_code", dt, true);
+                dt = (DataTable)dh.ExecuteSql("select dp_code,dp_name from department", "select");
+                BaseUtil.FillComBoxEditWidthDataTable(ComboxDeviceDepartment, "dp_name", "dp_code", dt, true);
+                dt = (DataTable)dh.ExecuteSql("select distinct de_address from device", "select");
+                BaseUtil.FillComBoxEditWidthDataTable(ComboxDeviceFloor, "de_address", "de_address", dt, true);
             }
         }
 
@@ -724,26 +726,34 @@ namespace UAS_PLCDataReader
             DeviceStatusQuerySQL.Clear();
             string WC = BaseUtil.GetComboxEditValue(ComboxDeviceStatusWC);
             string LC = BaseUtil.GetComboxEditValue(ComboxDeviceStatusLC);
+            string DE = BaseUtil.GetComboxEditValue(ComboxDeviceDepartment);
+            string FL = BaseUtil.GetComboxEditValue(ComboxDeviceFloor);
             if (CheckEditDeviceStatusEnable.Checked)
             {
                 DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join ");
-                DeviceStatusQuerySQL.Append("devicerunstatus on dr_decode=de_code ");
+                DeviceStatusQuerySQL.Append("devicerunstatus on dr_decode=de_code where 1=1");
                 if (WC != "全部")
                     DeviceStatusQuerySQL.Append(" and de_wccode='" + WC + "' ");
                 if (LC != "全部")
                     DeviceStatusQuerySQL.Append(" and de_linecode='" + LC + "' ");
+                if (DE != "全部")
+                    DeviceStatusQuerySQL.Append(" and DE_CURRENTCENTERCODE='" + DE + "' ");
+                if (FL != "全部")
+                    DeviceStatusQuerySQL.Append(" and DE_ADDRESS='" + FL + "' ");
                 DeviceStatusQuerySQL.Append(" order by de_code");
             }
             else
             {
                 DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join ");
-                DeviceStatusQuerySQL.Append("devicerunstatus on dr_decode=de_code ");
-                if (WC != "全部" && LC != "全部")
-                    DeviceStatusQuerySQL.Append(" where de_wccode='" + WC + "' and de_linecode='" + LC + "' ");
-                if (WC == "全部" && LC != "全部")
-                    DeviceStatusQuerySQL.Append(" where de_linecode='" + LC + "' ");
-                if (WC != "全部" && LC == "全部")
-                    DeviceStatusQuerySQL.Append(" where de_wccode='" + WC + "' ");
+                DeviceStatusQuerySQL.Append("devicerunstatus on dr_decode=de_code where 1=1");
+                if (WC != "全部")
+                    DeviceStatusQuerySQL.Append(" and de_wccode='" + WC + "' ");
+                if (LC != "全部")
+                    DeviceStatusQuerySQL.Append(" and de_linecode='" + LC + "' ");
+                if (DE != "全部")
+                    DeviceStatusQuerySQL.Append(" and DE_CURRENTCENTERCODE='" + DE + "' ");
+                if (FL != "全部")
+                    DeviceStatusQuerySQL.Append(" and DE_ADDRESS='" + FL + "' ");
                 DeviceStatusQuerySQL.Append("order by de_code");
             }
             PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
@@ -751,7 +761,6 @@ namespace UAS_PLCDataReader
 
         private void PaintDeviceStatusControl(string SQL)
         {
-            Console.WriteLine(SQL);
             DataTable dt = (DataTable)dh.ExecuteSql(SQL, "select");
             //界面重新展示时如过数量不一致则重新绘制
             if (PanelDeviceStatus.Controls.Count != dt.Rows.Count)