From 3ae459e2e79e567dfd4a552a3b5b8c1fce495167 Mon Sep 17 00:00:00 2001 From: xcd <834800634@qq.com> Date: 星期四, 16 七月 2020 17:23:35 +0800 Subject: [PATCH] Merge branch 'master' of http://gitblit.broconcentric.com:8088/r/M071 --- src/Bro.UI.Config/App.config | 1 src/Bro.M071.Process/UI/M071_DataForm.resx | 48 +++ src/Bro.M071.Model/Model/KeyUnitData.cs | 37 ++ src/Bro.M071.Process/UI/M071_DataForm.cs | 218 ++++++++++++++ src/Bro.M071.DBManager/MeasurementUnitResultManager.cs | 98 ++++++ src/Bro.M071.Process/UI/M071_DataForm.Designer.cs | 368 ++++++++++++++++-------- src/Bro.M071.Model/Model/MeasurementUnitResult.cs | 85 +++++ 7 files changed, 721 insertions(+), 134 deletions(-) diff --git a/src/Bro.M071.DBManager/MeasurementUnitResultManager.cs b/src/Bro.M071.DBManager/MeasurementUnitResultManager.cs index cfd2a15..29a5303 100644 --- a/src/Bro.M071.DBManager/MeasurementUnitResultManager.cs +++ b/src/Bro.M071.DBManager/MeasurementUnitResultManager.cs @@ -1,6 +1,7 @@ 锘縰sing Bro.Common.Helper; using Bro.M071.Model; using Bro.M071.Model.Model; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; using System; using System.Collections; using System.Collections.Generic; @@ -29,7 +30,7 @@ { } - public List<MeasurementUnitResult> GetMeasurementUnitResult(MeasurementUnitResultRequest request) + public List<MeasurementUnitResult_DTO> GetMeasurementUnitResult(MeasurementUnitResultRequest request) { using (DBModel context = new DBModel()) { @@ -70,17 +71,106 @@ join measurementUnitResult in mList on productionMeasurementRecords.ID equals measurementUnitResult.ProductionMeasurementRecordsId //into pmList - select new MeasurementUnitResult + select new MeasurementUnitResult_DTO { ProductionCode = productionMeasurementRecords.ProductionCode, - ProductionBarcode = productionMeasurementRecords.ProductionBarcode + ProductionBarcode = productionMeasurementRecords.ProductionBarcode, + ProductionMeasurementRecordsId = productionMeasurementRecords.ID, + OperationStartTime = productionMeasurementRecords.OperationStartTime, + OperationEndTime = productionMeasurementRecords.OperationEndTime, + + Id = measurementUnitResult.ID, + MeasurementName = measurementUnitResult.MeasurementName, + MeasurementType = measurementUnitResult.MeasurementType, + MeasurementValue = measurementUnitResult.MeasurementValue, + MeasurementResult = measurementUnitResult.MeasurementResult }; - var pageList = query.OrderBy(u => u.CREATE_TIME).ToPagedList(request); + var pageList = query.OrderBy(u => u.OperationStartTime).ToPagedList(request); request.TotalNum = mList.Count(); return pageList; } } + + public ProductionMeasurementUnitResultExportDataSet GetProductionMeasurementUnitResultExportDataSet(MeasurementUnitResultRequest request) + { + ProductionMeasurementUnitResultExportDataSet productionMeasurementUnitResultExportDataSet = new ProductionMeasurementUnitResultExportDataSet(); + using (DBModel context = new DBModel()) + { + var mList = context.MeasurementUnitResult.Where(u => u.IS_DELETED == 0); + var pList = context.ProductionMeasurementRecords.Where(u => u.IS_DELETED == 0); + var kList = context.KeyUnitData.Where(u => u.IS_DELETED == 0); + + if (!string.IsNullOrWhiteSpace(request.ProductionBarcode)) + { + pList = pList.Where(u => u.ProductionBarcode.Contains(request.ProductionBarcode)); + } + if (!string.IsNullOrWhiteSpace(request.ProductionCode)) + { + pList = pList.Where(u => u.ProductionCode.Contains(request.ProductionCode)); + } + if (request.StartTime != null) + { + pList = pList.Where(u => u.OperationStartTime >= request.StartTime); + } + if (request.EndTime != null) + { + pList = pList.Where(u => u.OperationStartTime <= request.EndTime); + } + + //mList + if (!string.IsNullOrWhiteSpace(request.MeasurementName)) + { + mList = mList.Where(u => u.MeasurementName.Contains(request.MeasurementName)); + } + if (!string.IsNullOrWhiteSpace(request.MeasurementResult)) + { + mList = mList.Where(u => u.MeasurementResult == request.MeasurementResult); + } + if (!string.IsNullOrWhiteSpace(request.MeasurementType)) + { + mList = mList.Where(u => u.MeasurementType == request.MeasurementType); + } + + productionMeasurementUnitResultExportDataSet.ProductionMeasurementRecordList = pList.ToList(); + var measurementUnitResults = from productionMeasurementRecords in pList + join measurementUnitResult in mList on productionMeasurementRecords.ID equals measurementUnitResult.ProductionMeasurementRecordsId + select new MeasurementUnitResult_DTO + { + ProductionCode = productionMeasurementRecords.ProductionCode, + ProductionBarcode = productionMeasurementRecords.ProductionBarcode, + ProductionMeasurementRecordsId = productionMeasurementRecords.ID, + OperationStartTime = productionMeasurementRecords.OperationStartTime, + OperationEndTime = productionMeasurementRecords.OperationEndTime, + + Id = measurementUnitResult.ID, + MeasurementName = measurementUnitResult.MeasurementName, + MeasurementType = measurementUnitResult.MeasurementType, + MeasurementValue = measurementUnitResult.MeasurementValue, + MeasurementResult = measurementUnitResult.MeasurementResult + }; + + productionMeasurementUnitResultExportDataSet.MeasurementUnitResultList = measurementUnitResults.ToList(); + + var keyUnitDataQuery = from productionMeasurementRecords in pList + join keyUnitData in kList on productionMeasurementRecords.ID equals + keyUnitData.ProductionMeasurementRecordsId + select new KeyUnitData_DTO + { + ProductionCode = productionMeasurementRecords.ProductionCode, + ProductionBarcode = productionMeasurementRecords.ProductionBarcode, + ProductionMeasurementRecordsId = productionMeasurementRecords.ID, + + Id = keyUnitData.ID, + Key = keyUnitData.Key, + MeasurementItem = keyUnitData.MeasurementItem, + ItemValue = keyUnitData.ItemValue, + }; + productionMeasurementUnitResultExportDataSet.KeyUnitDataList = keyUnitDataQuery.ToList(); + + return productionMeasurementUnitResultExportDataSet; + } + } public void BatchAddMeasurementUnitResult(List<MeasurementUnitResult> records) { try diff --git a/src/Bro.M071.Model/Model/KeyUnitData.cs b/src/Bro.M071.Model/Model/KeyUnitData.cs index b583e78..3c58fe3 100644 --- a/src/Bro.M071.Model/Model/KeyUnitData.cs +++ b/src/Bro.M071.Model/Model/KeyUnitData.cs @@ -34,6 +34,11 @@ [StringLength(64)] public string ItemValue { get; set; } + /// <summary> + /// 浜у搧缂栫爜 + /// </summary> + [NotMapped] + public string ProductionCode { get; set; } [NotMapped] public string ProductionBarcode { get; set; } } @@ -42,4 +47,36 @@ { } + public class KeyUnitData_DTO + { + public string Id { get; set; } + + /// <summary> + /// 浜у搧娴嬮噺璁板綍Id + /// </summary> + public string ProductionMeasurementRecordsId { get; set; } + + /// <summary> + /// 閿崟鍏� + /// </summary> + public string Key { get; set; } + + /// <summary> + /// 妫�娴嬮」 + /// </summary> + public string MeasurementItem { get; set; } + + /// <summary> + /// 璇ラ敭 妫�娴嬮」 鐨勫�� + /// </summary> + public string ItemValue { get; set; } + + /// <summary> + /// 浜у搧缂栫爜 + /// </summary> + public string ProductionCode { get; set; } + + public string ProductionBarcode { get; set; } + } + } diff --git a/src/Bro.M071.Model/Model/MeasurementUnitResult.cs b/src/Bro.M071.Model/Model/MeasurementUnitResult.cs index ef6ba51..881a51a 100644 --- a/src/Bro.M071.Model/Model/MeasurementUnitResult.cs +++ b/src/Bro.M071.Model/Model/MeasurementUnitResult.cs @@ -90,7 +90,7 @@ /// <summary> /// 鍏崇郴鏁版嵁 /// </summary> - public List<MeasurementAndKeyDataRelation> MeasurementAndKeyDataRelationList{ get; set; } + public List<MeasurementAndKeyDataRelation> MeasurementAndKeyDataRelationList { get; set; } /// <summary> /// 妫�娴嬬粨鏋� @@ -108,7 +108,90 @@ MeasurementUnitResultList = new List<MeasurementUnitResult>(); KeyUnitDataList = new List<KeyUnitData>(); } + } + public class ProductionMeasurementUnitResultExportDataSet + { + + public List<ProductionMeasurementRecords> ProductionMeasurementRecordList { get; set; } + + ///// <summary> + ///// 鍏崇郴鏁版嵁 + ///// </summary> + //public List<MeasurementAndKeyDataRelation> MeasurementAndKeyDataRelationList { get; set; } + + /// <summary> + /// 妫�娴嬬粨鏋� + /// </summary> + public List<MeasurementUnitResult_DTO> MeasurementUnitResultList { get; set; } + + /// <summary> + /// 鍘熷鏁版嵁 + /// </summary> + public List<KeyUnitData_DTO> KeyUnitDataList { get; set; } + + public ProductionMeasurementUnitResultExportDataSet() + { + ProductionMeasurementRecordList = new List<ProductionMeasurementRecords>(); + MeasurementUnitResultList = new List<MeasurementUnitResult_DTO>(); + KeyUnitDataList = new List<KeyUnitData_DTO>(); + } + } + + /// <summary> + /// MeasurementUnitResult_DTO 鏁版嵁搴撴煡璇娇鐢� + /// </summary> + public class MeasurementUnitResult_DTO + { + + /// <summary> + /// 浜у搧娴嬮噺璁板綍Id + /// </summary> + public string Id { get; set; } + + /// <summary> + /// 浜у搧娴嬮噺璁板綍Id + /// </summary> + public string ProductionMeasurementRecordsId { get; set; } + /// <summary> + /// 妫�娴嬪悕绉� + /// </summary> + public string MeasurementName { get; set; } + + /// <summary> + /// 妫�娴嬬粨鏋滅被鍨� (Slant Alignment... ) + /// </summary> + public string MeasurementType { get; set; } + + /// <summary> + /// 妫�娴嬬粨鏋滃�� + /// </summary> + public string MeasurementValue { get; set; } + + /// <summary> + /// 妫�娴嬬粨鏋� ok ng + /// </summary> + public string MeasurementResult { get; set; } + + /// <summary> + /// 浜у搧缂栫爜 + /// </summary> + public string ProductionCode { get; set; } + + /// <summary> + /// 浜у搧鏉$爜 + /// </summary> + public string ProductionBarcode { get; set; } + + /// <summary> + /// 鎿嶄綔寮�濮嬫椂闂� + /// </summary> + public DateTime OperationStartTime { get; set; } + + /// <summary> + /// 鎿嶄綔缁撴潫鏃堕棿 + /// </summary> + public DateTime OperationEndTime { get; set; } } } diff --git a/src/Bro.M071.Process/UI/M071_DataForm.Designer.cs b/src/Bro.M071.Process/UI/M071_DataForm.Designer.cs index d8186a4..b637a0b 100644 --- a/src/Bro.M071.Process/UI/M071_DataForm.Designer.cs +++ b/src/Bro.M071.Process/UI/M071_DataForm.Designer.cs @@ -28,8 +28,10 @@ /// </summary> private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle45 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle46 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle47 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle48 = new System.Windows.Forms.DataGridViewCellStyle(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); @@ -63,13 +65,23 @@ this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.panel2 = new System.Windows.Forms.Panel(); - this.textBox2 = new System.Windows.Forms.TextBox(); - this.button5 = new System.Windows.Forms.Button(); - this.button6 = new System.Windows.Forms.Button(); - this.button7 = new System.Windows.Forms.Button(); - this.button8 = new System.Windows.Forms.Button(); + this.labelTotal_MR = new System.Windows.Forms.Label(); + this.textBoxPageNum_MR = new System.Windows.Forms.TextBox(); + this.buttonToLastPage_MR = new System.Windows.Forms.Button(); + this.buttonToNextPage_MR = new System.Windows.Forms.Button(); + this.buttonToBeforePage_MR = new System.Windows.Forms.Button(); + this.buttonToFirstPage_MR = new System.Windows.Forms.Button(); this.dataGridView2 = new System.Windows.Forms.DataGridView(); + this.ProductionCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ProductionBarcode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MeasurementName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MeasurementType = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MeasurementValue = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MeasurementResult = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.OperationStartTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.OperationEndTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); + this.comboBoxMeasurementType_MR = new System.Windows.Forms.ComboBox(); this.label10 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.textBoxPCode_MR = new System.Windows.Forms.TextBox(); @@ -80,14 +92,12 @@ this.label8 = new System.Windows.Forms.Label(); this.textBoxMeasurementName_MR = new System.Windows.Forms.TextBox(); this.label11 = new System.Windows.Forms.Label(); - this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker(); + this.dateTimePickerStartTime_MR = new System.Windows.Forms.DateTimePicker(); this.label12 = new System.Windows.Forms.Label(); - this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker(); - this.buttonQuery_MR = new System.Windows.Forms.Button(); - this.comboBoxMeasurementType_MR = new System.Windows.Forms.ComboBox(); - this.labelTotal_MR = new System.Windows.Forms.Label(); - this.buttonExport_MR = new System.Windows.Forms.Button(); + this.dateTimePickerEndTime_MR = new System.Windows.Forms.DateTimePicker(); this.panel3 = new System.Windows.Forms.Panel(); + this.buttonExport_MR = new System.Windows.Forms.Button(); + this.buttonQuery_MR = new System.Windows.Forms.Button(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -176,6 +186,7 @@ this.textBoxPageNum.Name = "textBoxPageNum"; this.textBoxPageNum.Size = new System.Drawing.Size(80, 21); this.textBoxPageNum.TabIndex = 2; + this.textBoxPageNum.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ToPage); // // buttonToLastPage // @@ -187,6 +198,7 @@ this.buttonToLastPage.TabIndex = 1; this.buttonToLastPage.Text = "鏈�鍚庨〉"; this.buttonToLastPage.UseVisualStyleBackColor = true; + this.buttonToLastPage.Click += new System.EventHandler(this.buttonToLastPage_Click); // // buttonToNextPage // @@ -198,6 +210,7 @@ this.buttonToNextPage.TabIndex = 1; this.buttonToNextPage.Text = "鍚庝竴椤�"; this.buttonToNextPage.UseVisualStyleBackColor = true; + this.buttonToNextPage.Click += new System.EventHandler(this.buttonToNextPage_Click); // // buttonToBeforePage // @@ -209,6 +222,7 @@ this.buttonToBeforePage.TabIndex = 1; this.buttonToBeforePage.Text = "鍓嶄竴椤�"; this.buttonToBeforePage.UseVisualStyleBackColor = true; + this.buttonToBeforePage.Click += new System.EventHandler(this.buttonToBeforePage_Click); // // buttonToFirstPage // @@ -220,9 +234,12 @@ this.buttonToFirstPage.TabIndex = 1; this.buttonToFirstPage.Text = "绗竴椤�"; this.buttonToFirstPage.UseVisualStyleBackColor = true; + this.buttonToFirstPage.Click += new System.EventHandler(this.buttonToFirstPage_Click); // // labelTotal // + this.labelTotal.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); this.labelTotal.AutoSize = true; this.labelTotal.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); this.labelTotal.Location = new System.Drawing.Point(3, 3); @@ -275,9 +292,9 @@ // Column4 // this.Column4.DataPropertyName = "OperationStartTime"; - dataGridViewCellStyle3.Format = "G"; - dataGridViewCellStyle3.NullValue = null; - this.Column4.DefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle45.Format = "G"; + dataGridViewCellStyle45.NullValue = null; + this.Column4.DefaultCellStyle = dataGridViewCellStyle45; this.Column4.HeaderText = "鐢熶骇鏃堕棿(寮�濮�)"; this.Column4.Name = "Column4"; this.Column4.ReadOnly = true; @@ -286,9 +303,9 @@ // Column5 // this.Column5.DataPropertyName = "OperationEndTime"; - dataGridViewCellStyle4.Format = "G"; - dataGridViewCellStyle4.NullValue = null; - this.Column5.DefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle46.Format = "G"; + dataGridViewCellStyle46.NullValue = null; + this.Column5.DefaultCellStyle = dataGridViewCellStyle46; this.Column5.HeaderText = "鐢熶骇鏃堕棿(缁撴潫)"; this.Column5.Name = "Column5"; this.Column5.ReadOnly = true; @@ -489,59 +506,86 @@ // panel2 // this.panel2.Controls.Add(this.labelTotal_MR); - this.panel2.Controls.Add(this.textBox2); - this.panel2.Controls.Add(this.button5); - this.panel2.Controls.Add(this.button6); - this.panel2.Controls.Add(this.button7); - this.panel2.Controls.Add(this.button8); + this.panel2.Controls.Add(this.textBoxPageNum_MR); + this.panel2.Controls.Add(this.buttonToLastPage_MR); + this.panel2.Controls.Add(this.buttonToNextPage_MR); + this.panel2.Controls.Add(this.buttonToBeforePage_MR); + this.panel2.Controls.Add(this.buttonToFirstPage_MR); this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; this.panel2.Location = new System.Drawing.Point(3, 658); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(751, 24); this.panel2.TabIndex = 1; // - // textBox2 + // labelTotal_MR // - this.textBox2.Location = new System.Drawing.Point(542, 2); - this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(80, 21); - this.textBox2.TabIndex = 2; + this.labelTotal_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.labelTotal_MR.AutoSize = true; + this.labelTotal_MR.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); + this.labelTotal_MR.Location = new System.Drawing.Point(0, 3); + this.labelTotal_MR.Name = "labelTotal_MR"; + this.labelTotal_MR.Size = new System.Drawing.Size(97, 17); + this.labelTotal_MR.TabIndex = 3; + this.labelTotal_MR.Text = "鏁伴噺锛氭�婚〉鏁�:"; // - // button5 + // textBoxPageNum_MR // - this.button5.Location = new System.Drawing.Point(693, 0); - this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(55, 23); - this.button5.TabIndex = 1; - this.button5.Text = "鏈�鍚庨〉"; - this.button5.UseVisualStyleBackColor = true; + this.textBoxPageNum_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxPageNum_MR.Location = new System.Drawing.Point(542, 2); + this.textBoxPageNum_MR.Name = "textBoxPageNum_MR"; + this.textBoxPageNum_MR.Size = new System.Drawing.Size(80, 21); + this.textBoxPageNum_MR.TabIndex = 2; + this.textBoxPageNum_MR.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ToPageMR); // - // button6 + // buttonToLastPage_MR // - this.button6.Location = new System.Drawing.Point(632, 1); - this.button6.Name = "button6"; - this.button6.Size = new System.Drawing.Size(55, 23); - this.button6.TabIndex = 1; - this.button6.Text = "鍚庝竴椤�"; - this.button6.UseVisualStyleBackColor = true; + this.buttonToLastPage_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.buttonToLastPage_MR.Location = new System.Drawing.Point(693, 0); + this.buttonToLastPage_MR.Name = "buttonToLastPage_MR"; + this.buttonToLastPage_MR.Size = new System.Drawing.Size(55, 23); + this.buttonToLastPage_MR.TabIndex = 1; + this.buttonToLastPage_MR.Text = "鏈�鍚庨〉"; + this.buttonToLastPage_MR.UseVisualStyleBackColor = true; + this.buttonToLastPage_MR.Click += new System.EventHandler(this.buttonToLastPage_MR_Click); // - // button7 + // buttonToNextPage_MR // - this.button7.Location = new System.Drawing.Point(477, 1); - this.button7.Name = "button7"; - this.button7.Size = new System.Drawing.Size(55, 23); - this.button7.TabIndex = 1; - this.button7.Text = "鍓嶄竴椤�"; - this.button7.UseVisualStyleBackColor = true; + this.buttonToNextPage_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.buttonToNextPage_MR.Location = new System.Drawing.Point(632, 1); + this.buttonToNextPage_MR.Name = "buttonToNextPage_MR"; + this.buttonToNextPage_MR.Size = new System.Drawing.Size(55, 23); + this.buttonToNextPage_MR.TabIndex = 1; + this.buttonToNextPage_MR.Text = "鍚庝竴椤�"; + this.buttonToNextPage_MR.UseVisualStyleBackColor = true; + this.buttonToNextPage_MR.Click += new System.EventHandler(this.buttonToNextPage_MR_Click); // - // button8 + // buttonToBeforePage_MR // - this.button8.Location = new System.Drawing.Point(416, 1); - this.button8.Name = "button8"; - this.button8.Size = new System.Drawing.Size(55, 23); - this.button8.TabIndex = 1; - this.button8.Text = "绗竴椤�"; - this.button8.UseVisualStyleBackColor = true; + this.buttonToBeforePage_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.buttonToBeforePage_MR.Location = new System.Drawing.Point(477, 1); + this.buttonToBeforePage_MR.Name = "buttonToBeforePage_MR"; + this.buttonToBeforePage_MR.Size = new System.Drawing.Size(55, 23); + this.buttonToBeforePage_MR.TabIndex = 1; + this.buttonToBeforePage_MR.Text = "鍓嶄竴椤�"; + this.buttonToBeforePage_MR.UseVisualStyleBackColor = true; + this.buttonToBeforePage_MR.Click += new System.EventHandler(this.buttonToBeforePage_MR_Click); + // + // buttonToFirstPage_MR + // + this.buttonToFirstPage_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.buttonToFirstPage_MR.Location = new System.Drawing.Point(416, 1); + this.buttonToFirstPage_MR.Name = "buttonToFirstPage_MR"; + this.buttonToFirstPage_MR.Size = new System.Drawing.Size(55, 23); + this.buttonToFirstPage_MR.TabIndex = 1; + this.buttonToFirstPage_MR.Text = "绗竴椤�"; + this.buttonToFirstPage_MR.UseVisualStyleBackColor = true; + this.buttonToFirstPage_MR.Click += new System.EventHandler(this.buttonToFirstPage_MR_Click); // // dataGridView2 // @@ -549,6 +593,15 @@ this.dataGridView2.AllowUserToDeleteRows = false; this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.MenuBar; this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ProductionCode, + this.ProductionBarcode, + this.MeasurementName, + this.MeasurementType, + this.MeasurementValue, + this.MeasurementResult, + this.OperationStartTime, + this.OperationEndTime}); this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView2.Location = new System.Drawing.Point(3, 73); this.dataGridView2.Name = "dataGridView2"; @@ -556,6 +609,70 @@ this.dataGridView2.RowTemplate.Height = 23; this.dataGridView2.Size = new System.Drawing.Size(751, 579); this.dataGridView2.TabIndex = 2; + // + // ProductionCode + // + this.ProductionCode.DataPropertyName = "ProductionCode"; + this.ProductionCode.HeaderText = "浜у搧缂栫爜"; + this.ProductionCode.Name = "ProductionCode"; + this.ProductionCode.ReadOnly = true; + // + // ProductionBarcode + // + this.ProductionBarcode.DataPropertyName = "ProductionBarcode"; + this.ProductionBarcode.HeaderText = "浜у搧鏉$爜"; + this.ProductionBarcode.Name = "ProductionBarcode"; + this.ProductionBarcode.ReadOnly = true; + // + // MeasurementName + // + this.MeasurementName.DataPropertyName = "MeasurementName"; + this.MeasurementName.HeaderText = "妫�娴嬪悕绉�"; + this.MeasurementName.Name = "MeasurementName"; + this.MeasurementName.ReadOnly = true; + // + // MeasurementType + // + this.MeasurementType.DataPropertyName = "MeasurementType"; + this.MeasurementType.HeaderText = "妫�娴嬬被鍨�"; + this.MeasurementType.Name = "MeasurementType"; + this.MeasurementType.ReadOnly = true; + // + // MeasurementValue + // + this.MeasurementValue.DataPropertyName = "MeasurementValue"; + this.MeasurementValue.HeaderText = "妫�娴嬪��"; + this.MeasurementValue.Name = "MeasurementValue"; + this.MeasurementValue.ReadOnly = true; + // + // MeasurementResult + // + this.MeasurementResult.DataPropertyName = "MeasurementResult"; + this.MeasurementResult.HeaderText = "妫�娴嬬粨鏋�"; + this.MeasurementResult.Name = "MeasurementResult"; + this.MeasurementResult.ReadOnly = true; + // + // OperationStartTime + // + this.OperationStartTime.DataPropertyName = "OperationStartTime"; + dataGridViewCellStyle47.Format = "G"; + dataGridViewCellStyle47.NullValue = null; + this.OperationStartTime.DefaultCellStyle = dataGridViewCellStyle47; + this.OperationStartTime.HeaderText = "鐢熶骇鏃堕棿(寮�濮�)"; + this.OperationStartTime.Name = "OperationStartTime"; + this.OperationStartTime.ReadOnly = true; + this.OperationStartTime.Width = 120; + // + // OperationEndTime + // + this.OperationEndTime.DataPropertyName = "OperationEndTime"; + dataGridViewCellStyle48.Format = "G"; + dataGridViewCellStyle48.NullValue = null; + this.OperationEndTime.DefaultCellStyle = dataGridViewCellStyle48; + this.OperationEndTime.HeaderText = "鐢熶骇鏃堕棿(缁撴潫)"; + this.OperationEndTime.Name = "OperationEndTime"; + this.OperationEndTime.ReadOnly = true; + this.OperationEndTime.Width = 120; // // tableLayoutPanel4 // @@ -579,9 +696,9 @@ this.tableLayoutPanel4.Controls.Add(this.label8, 6, 0); this.tableLayoutPanel4.Controls.Add(this.textBoxMeasurementName_MR, 7, 0); this.tableLayoutPanel4.Controls.Add(this.label11, 2, 1); - this.tableLayoutPanel4.Controls.Add(this.dateTimePicker1, 3, 1); + this.tableLayoutPanel4.Controls.Add(this.dateTimePickerStartTime_MR, 3, 1); this.tableLayoutPanel4.Controls.Add(this.label12, 4, 1); - this.tableLayoutPanel4.Controls.Add(this.dateTimePicker2, 5, 1); + this.tableLayoutPanel4.Controls.Add(this.dateTimePickerEndTime_MR, 5, 1); this.tableLayoutPanel4.Controls.Add(this.panel3, 6, 1); this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 3); @@ -592,6 +709,16 @@ this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel4.Size = new System.Drawing.Size(751, 64); this.tableLayoutPanel4.TabIndex = 3; + // + // comboBoxMeasurementType_MR + // + this.comboBoxMeasurementType_MR.Dock = System.Windows.Forms.DockStyle.Fill; + this.comboBoxMeasurementType_MR.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); + this.comboBoxMeasurementType_MR.FormattingEnabled = true; + this.comboBoxMeasurementType_MR.Location = new System.Drawing.Point(73, 35); + this.comboBoxMeasurementType_MR.Name = "comboBoxMeasurementType_MR"; + this.comboBoxMeasurementType_MR.Size = new System.Drawing.Size(111, 25); + this.comboBoxMeasurementType_MR.TabIndex = 19; // // label10 // @@ -661,6 +788,7 @@ // // comboBoxResult_MR // + this.comboBoxResult_MR.Dock = System.Windows.Forms.DockStyle.Fill; this.comboBoxResult_MR.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); this.comboBoxResult_MR.FormattingEnabled = true; this.comboBoxResult_MR.Location = new System.Drawing.Point(447, 3); @@ -701,15 +829,15 @@ this.label11.Text = "鐢熶骇鏃堕棿"; this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // dateTimePicker1 + // dateTimePickerStartTime_MR // - this.dateTimePicker1.CalendarFont = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); - this.dateTimePicker1.Dock = System.Windows.Forms.DockStyle.Fill; - this.dateTimePicker1.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); - this.dateTimePicker1.Location = new System.Drawing.Point(260, 35); - this.dateTimePicker1.Name = "dateTimePicker1"; - this.dateTimePicker1.Size = new System.Drawing.Size(111, 24); - this.dateTimePicker1.TabIndex = 15; + this.dateTimePickerStartTime_MR.CalendarFont = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); + this.dateTimePickerStartTime_MR.Dock = System.Windows.Forms.DockStyle.Fill; + this.dateTimePickerStartTime_MR.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); + this.dateTimePickerStartTime_MR.Location = new System.Drawing.Point(260, 35); + this.dateTimePickerStartTime_MR.Name = "dateTimePickerStartTime_MR"; + this.dateTimePickerStartTime_MR.Size = new System.Drawing.Size(111, 24); + this.dateTimePickerStartTime_MR.TabIndex = 15; // // label12 // @@ -721,59 +849,17 @@ this.label12.Size = new System.Drawing.Size(64, 32); this.label12.TabIndex = 16; this.label12.Text = "~"; - this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // dateTimePicker2 + // dateTimePickerEndTime_MR // - this.dateTimePicker2.CalendarFont = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); - this.dateTimePicker2.Dock = System.Windows.Forms.DockStyle.Fill; - this.dateTimePicker2.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); - this.dateTimePicker2.Location = new System.Drawing.Point(447, 35); - this.dateTimePicker2.Name = "dateTimePicker2"; - this.dateTimePicker2.Size = new System.Drawing.Size(111, 24); - this.dateTimePicker2.TabIndex = 17; - // - // buttonQuery_MR - // - this.buttonQuery_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.buttonQuery_MR.Location = new System.Drawing.Point(110, -1); - this.buttonQuery_MR.Name = "buttonQuery_MR"; - this.buttonQuery_MR.Size = new System.Drawing.Size(75, 26); - this.buttonQuery_MR.TabIndex = 18; - this.buttonQuery_MR.Text = "鏌ヨ"; - this.buttonQuery_MR.UseVisualStyleBackColor = true; - // - // comboBoxMeasurementType_MR - // - this.comboBoxMeasurementType_MR.Dock = System.Windows.Forms.DockStyle.Fill; - this.comboBoxMeasurementType_MR.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); - this.comboBoxMeasurementType_MR.FormattingEnabled = true; - this.comboBoxMeasurementType_MR.Location = new System.Drawing.Point(73, 35); - this.comboBoxMeasurementType_MR.Name = "comboBoxMeasurementType_MR"; - this.comboBoxMeasurementType_MR.Size = new System.Drawing.Size(111, 25); - this.comboBoxMeasurementType_MR.TabIndex = 19; - // - // labelTotal_MR - // - this.labelTotal_MR.AutoSize = true; - this.labelTotal_MR.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); - this.labelTotal_MR.Location = new System.Drawing.Point(0, 3); - this.labelTotal_MR.Name = "labelTotal_MR"; - this.labelTotal_MR.Size = new System.Drawing.Size(97, 17); - this.labelTotal_MR.TabIndex = 3; - this.labelTotal_MR.Text = "鏁伴噺锛氭�婚〉鏁�:"; - // - // buttonExport_MR - // - this.buttonExport_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.buttonExport_MR.Location = new System.Drawing.Point(35, -1); - this.buttonExport_MR.Name = "buttonExport_MR"; - this.buttonExport_MR.Size = new System.Drawing.Size(64, 26); - this.buttonExport_MR.TabIndex = 18; - this.buttonExport_MR.Text = "瀵煎嚭"; - this.buttonExport_MR.UseVisualStyleBackColor = true; + this.dateTimePickerEndTime_MR.CalendarFont = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); + this.dateTimePickerEndTime_MR.Dock = System.Windows.Forms.DockStyle.Fill; + this.dateTimePickerEndTime_MR.Font = new System.Drawing.Font("Tahoma", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134))); + this.dateTimePickerEndTime_MR.Location = new System.Drawing.Point(447, 35); + this.dateTimePickerEndTime_MR.Name = "dateTimePickerEndTime_MR"; + this.dateTimePickerEndTime_MR.Size = new System.Drawing.Size(111, 24); + this.dateTimePickerEndTime_MR.TabIndex = 17; // // panel3 // @@ -785,6 +871,30 @@ this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(184, 26); this.panel3.TabIndex = 20; + // + // buttonExport_MR + // + this.buttonExport_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.buttonExport_MR.Location = new System.Drawing.Point(35, -1); + this.buttonExport_MR.Name = "buttonExport_MR"; + this.buttonExport_MR.Size = new System.Drawing.Size(64, 26); + this.buttonExport_MR.TabIndex = 18; + this.buttonExport_MR.Text = "瀵煎嚭"; + this.buttonExport_MR.UseVisualStyleBackColor = true; + this.buttonExport_MR.Click += new System.EventHandler(this.buttonExport_MR_Click); + // + // buttonQuery_MR + // + this.buttonQuery_MR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.buttonQuery_MR.Location = new System.Drawing.Point(110, -1); + this.buttonQuery_MR.Name = "buttonQuery_MR"; + this.buttonQuery_MR.Size = new System.Drawing.Size(75, 26); + this.buttonQuery_MR.TabIndex = 18; + this.buttonQuery_MR.Text = "鏌ヨ"; + this.buttonQuery_MR.UseVisualStyleBackColor = true; + this.buttonQuery_MR.Click += new System.EventHandler(this.buttonQuery_MR_Click); // // M071_DataForm // @@ -833,11 +943,11 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.TextBox textBox2; - private System.Windows.Forms.Button button5; - private System.Windows.Forms.Button button6; - private System.Windows.Forms.Button button7; - private System.Windows.Forms.Button button8; + private System.Windows.Forms.TextBox textBoxPageNum_MR; + private System.Windows.Forms.Button buttonToLastPage_MR; + private System.Windows.Forms.Button buttonToNextPage_MR; + private System.Windows.Forms.Button buttonToBeforePage_MR; + private System.Windows.Forms.Button buttonToFirstPage_MR; private System.Windows.Forms.DataGridView dataGridView2; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4; private System.Windows.Forms.Button buttonQuery; @@ -866,13 +976,21 @@ private System.Windows.Forms.Label label8; private System.Windows.Forms.TextBox textBoxMeasurementName_MR; private System.Windows.Forms.Label label11; - private System.Windows.Forms.DateTimePicker dateTimePicker1; + private System.Windows.Forms.DateTimePicker dateTimePickerStartTime_MR; private System.Windows.Forms.Label label12; - private System.Windows.Forms.DateTimePicker dateTimePicker2; + private System.Windows.Forms.DateTimePicker dateTimePickerEndTime_MR; private System.Windows.Forms.Button buttonQuery_MR; private System.Windows.Forms.ComboBox comboBoxMeasurementType_MR; private System.Windows.Forms.Label labelTotal_MR; private System.Windows.Forms.Button buttonExport_MR; private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.DataGridViewTextBoxColumn ProductionCode; + private System.Windows.Forms.DataGridViewTextBoxColumn ProductionBarcode; + private System.Windows.Forms.DataGridViewTextBoxColumn MeasurementName; + private System.Windows.Forms.DataGridViewTextBoxColumn MeasurementType; + private System.Windows.Forms.DataGridViewTextBoxColumn MeasurementValue; + private System.Windows.Forms.DataGridViewTextBoxColumn MeasurementResult; + private System.Windows.Forms.DataGridViewTextBoxColumn OperationStartTime; + private System.Windows.Forms.DataGridViewTextBoxColumn OperationEndTime; } } \ No newline at end of file diff --git a/src/Bro.M071.Process/UI/M071_DataForm.cs b/src/Bro.M071.Process/UI/M071_DataForm.cs index e4ec30c..5b306db 100644 --- a/src/Bro.M071.Process/UI/M071_DataForm.cs +++ b/src/Bro.M071.Process/UI/M071_DataForm.cs @@ -1,11 +1,15 @@ -锘縰sing Bro.M071.DBManager; +锘縰sing Bro.Common.Helper; +using Bro.M071.DBManager; using Bro.M071.Model.Model; using Bro.UI.Model.Winform; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; using System; using System.Collections.Generic; using System.ComponentModel; +using System.Configuration; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -17,6 +21,11 @@ public partial class M071_DataForm : MenuFrmBase { public ProductionMeasurementRecordsManager _productionMeasurementRecordsManager = new ProductionMeasurementRecordsManager(); + public MeasurementUnitResultManager _measurementUnitResultManager = new MeasurementUnitResultManager(); + + ProductionMeasurementRecordsRequest recordsRequest = new ProductionMeasurementRecordsRequest(); + MeasurementUnitResultRequest resultRequest = new MeasurementUnitResultRequest(); + public M071_DataForm() { InitializeComponent(); @@ -32,7 +41,54 @@ private void buttonQuery_Click(object sender, EventArgs e) { - ProductionMeasurementRecordsRequest recordsRequest = new ProductionMeasurementRecordsRequest(); + recordsRequest.PageNum = 1; + GetProductionMeasurementRecords(); + } + private void buttonToFirstPage_Click(object sender, EventArgs e) + { + recordsRequest.PageNum = 1; + GetProductionMeasurementRecords(); + } + private void buttonToBeforePage_Click(object sender, EventArgs e) + { + if (recordsRequest.PageNum != 1) + { + recordsRequest.PageNum = recordsRequest.PageNum - 1; + GetProductionMeasurementRecords(); + } + } + private void buttonToNextPage_Click(object sender, EventArgs e) + { + if (recordsRequest.PageNum != recordsRequest.TotalPage && recordsRequest.TotalPage != 0) + { + recordsRequest.PageNum = recordsRequest.PageNum + 1; + GetProductionMeasurementRecords(); + } + } + private void buttonToLastPage_Click(object sender, EventArgs e) + { + if (recordsRequest.TotalPage != 0) + { + recordsRequest.PageNum = recordsRequest.TotalPage; + GetProductionMeasurementRecords(); + } + } + + private void ToPage(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + recordsRequest.PageNum = Convert.ToInt32(textBoxPageNum.Text); + if (recordsRequest.PageNum > recordsRequest.TotalPage) + { + recordsRequest.PageNum = recordsRequest.TotalPage == 0 ? 1 : recordsRequest.TotalPage; + } + GetProductionMeasurementRecords(); + } + } + + private void GetProductionMeasurementRecords() + { recordsRequest.ProductionCode = textBoxPCode.Text; recordsRequest.ProductionBarcode = textBoxPBarCode.Text; recordsRequest.ProductionResult = comboBoxPResult.SelectedItem?.ToString(); @@ -45,15 +101,169 @@ labelTotal.Text = $"鏁伴噺:{recordsRequest.TotalNum} 鎬婚〉鏁�:{recordsRequest.TotalPage}"; textBoxPageNum.Text = recordsRequest.PageNum.ToString(); } - #endregion #region 娴嬮噺缁撴灉 private void InitialMeasurementResultLayout() { + comboBoxResult_MR.DataSource = new List<string>() { "", "OK", "NG" }; + comboBoxMeasurementType_MR.DataSource = new List<string>() { "", "Slant", "Alignment", "RowAlignment" }; + } + + private void buttonQuery_MR_Click(object sender, EventArgs e) + { + resultRequest.PageNum = 1; + GetMeasurementUnitResult(); + } + + private void GetMeasurementUnitResult() + { + resultRequest.ProductionCode = textBoxPCode_MR.Text; + resultRequest.ProductionBarcode = textBoxtextBoxPBarCode_MR.Text; + resultRequest.MeasurementName = textBoxMeasurementName_MR.Text; + resultRequest.MeasurementType = comboBoxMeasurementType_MR.SelectedItem?.ToString(); + resultRequest.MeasurementResult = comboBoxResult_MR.SelectedItem?.ToString(); + resultRequest.StartTime = Convert.ToDateTime(dateTimePickerStartTime_MR.Value.ToString("D").ToString()); + resultRequest.EndTime = Convert.ToDateTime(dateTimePickerEndTime_MR.Value.AddDays(1).ToString("D").ToString()).AddSeconds(-1); + + var queryData = _measurementUnitResultManager.GetMeasurementUnitResult(resultRequest); + + dataGridView2.AutoGenerateColumns = false; + dataGridView2.DataSource = queryData; + labelTotal_MR.Text = $"鏁伴噺:{recordsRequest.TotalNum} 鎬婚〉鏁�:{recordsRequest.TotalPage}"; + textBoxPageNum_MR.Text = recordsRequest.PageNum.ToString(); } - #endregion + private void ToPageMR(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + resultRequest.PageNum = Convert.ToInt32(textBoxPageNum.Text); + if (resultRequest.PageNum > resultRequest.TotalPage) + { + resultRequest.PageNum = resultRequest.TotalPage == 0 ? 1 : resultRequest.TotalPage; + } + GetMeasurementUnitResult(); + } + } + private void buttonExport_MR_Click(object sender, EventArgs e) + { + try + { + var exportData = GetMeasurementUnitResultAndKeyUnitData(); + if (exportData != null) + { + ExportProductionExcel(exportData); + MessageBox.Show("瀵煎嚭瀹屾垚"); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + private void ExportProductionExcel(ProductionMeasurementUnitResultExportDataSet productionMeasurementUnitResultExportDataSet) + { + ExcelExportSet excelExportDto = new ExcelExportSet(); + excelExportDto.Worksheets = new List<string>() { "鐢熶骇璁板綍", "妫�娴嬬粨鏋�", "鍘熷鏁版嵁" }; + var productionRecordsColumns = new Dictionary<string, string>() + { + {"ProductionCode", "浜у搧缂栫爜"}, + {"ProductionBarcode", "浜у搧鏉$爜"}, + {"ProductionResult", "浜у搧缁撴灉"}, + {"OperationStartTime", "鎿嶄綔寮�濮嬫椂闂�"}, + {"OperationEndTime", "鎿嶄綔缁撴潫鏃堕棿"} + }; + + var keyUnitColumns = new Dictionary<string, string>() + { + {"ProductionBarcode", "浜у搧鏉$爜"}, + {"Key", "閿�"}, + {"MeasurementItem", "妫�娴嬮」"}, + {"ItemValue", "妫�娴嬪��"} + }; + var measurementUnitResultColumns = new Dictionary<string, string>() + { + {"ProductionBarcode", "浜у搧鏉$爜"}, + {"MeasurementName", "妫�娴嬪悕绉�"}, + {"MeasurementType", "妫�娴嬬被鍨�"}, + {"MeasurementValue", "妫�娴嬪��"}, + {"MeasurementResult", "妫�娴嬬粨鏋�"}, + }; + + excelExportDto.WorksheetColumns[excelExportDto.Worksheets[0]] = productionRecordsColumns; + excelExportDto.WorksheetColumns[excelExportDto.Worksheets[1]] = keyUnitColumns; + excelExportDto.WorksheetColumns[excelExportDto.Worksheets[2]] = measurementUnitResultColumns; + + excelExportDto.WorksheetDataTable[excelExportDto.Worksheets[0]] = ExcelExportHelper.ListToDataTable(productionMeasurementUnitResultExportDataSet.ProductionMeasurementRecordList, productionRecordsColumns); + excelExportDto.WorksheetDataTable[excelExportDto.Worksheets[1]] = ExcelExportHelper.ListToDataTable(productionMeasurementUnitResultExportDataSet.KeyUnitDataList, keyUnitColumns); + excelExportDto.WorksheetDataTable[excelExportDto.Worksheets[2]] = ExcelExportHelper.ListToDataTable(productionMeasurementUnitResultExportDataSet.MeasurementUnitResultList, measurementUnitResultColumns); + + var exportPath = ConfigurationManager.AppSettings["ExportPath"]; + if (!Directory.Exists(exportPath)) + { + Directory.CreateDirectory(exportPath); + } + var fileName = Path.Combine(exportPath, $"ExportData_{DateTime.Now.ToString("HHmmss")}.xlsx"); + + byte[] filecontent = ExcelExportHelper.CreateOrAppendExcel(excelExportDto, fileName); + FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write); + fs.Write(filecontent, 0, filecontent.Length); + fs.Flush(); + fs.Close(); + } + + private ProductionMeasurementUnitResultExportDataSet GetMeasurementUnitResultAndKeyUnitData() + { + ProductionMeasurementUnitResultExportDataSet productionMeasurementUnitResultExportDataSet = new ProductionMeasurementUnitResultExportDataSet(); + try + { + MeasurementUnitResultRequest measurementUnitResultRequest = resultRequest.DeepSerializeClone(); + measurementUnitResultRequest.PageNum = 1; + measurementUnitResultRequest.PageSize = 10000; + productionMeasurementUnitResultExportDataSet = _measurementUnitResultManager.GetProductionMeasurementUnitResultExportDataSet(measurementUnitResultRequest); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + return productionMeasurementUnitResultExportDataSet; + } + + private void buttonToFirstPage_MR_Click(object sender, EventArgs e) + { + resultRequest.PageNum = 1; + GetMeasurementUnitResult(); + } + + private void buttonToBeforePage_MR_Click(object sender, EventArgs e) + { + if (resultRequest.PageNum != 1) + { + resultRequest.PageNum = resultRequest.PageNum - 1; + GetMeasurementUnitResult(); + } + } + + private void buttonToNextPage_MR_Click(object sender, EventArgs e) + { + if (resultRequest.PageNum != resultRequest.TotalPage && resultRequest.TotalPage != 0) + { + resultRequest.PageNum = resultRequest.PageNum + 1; + GetMeasurementUnitResult(); + } + } + + private void buttonToLastPage_MR_Click(object sender, EventArgs e) + { + if (resultRequest.TotalPage != 0) + { + resultRequest.PageNum = resultRequest.TotalPage; + GetMeasurementUnitResult(); + } + } + + #endregion } } diff --git a/src/Bro.M071.Process/UI/M071_DataForm.resx b/src/Bro.M071.Process/UI/M071_DataForm.resx index 859499d..75be4a3 100644 --- a/src/Bro.M071.Process/UI/M071_DataForm.resx +++ b/src/Bro.M071.Process/UI/M071_DataForm.resx @@ -132,6 +132,30 @@ <metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> + <metadata name="ProductionCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ProductionBarcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="MeasurementName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="MeasurementType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="MeasurementValue.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="MeasurementResult.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="OperationStartTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="OperationEndTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> <metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> @@ -147,4 +171,28 @@ <metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> + <metadata name="ProductionCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ProductionBarcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="MeasurementName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="MeasurementType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="MeasurementValue.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="MeasurementResult.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="OperationStartTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="OperationEndTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> </root> \ No newline at end of file diff --git a/src/Bro.UI.Config/App.config b/src/Bro.UI.Config/App.config index b5c8db5..798153c 100644 --- a/src/Bro.UI.Config/App.config +++ b/src/Bro.UI.Config/App.config @@ -41,6 +41,7 @@ <add key="AuthorityCheck" value="False" /> <add key="AuthorityServer" value="192.168.1.255:11001" /> <add key="ClientSettingsProvider.ServiceUri" value="" /> + <add key="ExportPath" value="D:\PROJECTS\M071\Export" /> </appSettings> <system.web> <membership defaultProvider="ClientAuthenticationMembershipProvider"> -- Gitblit v1.8.0