From 617a20552793a9612997bf2bac0099cbda0ed85c Mon Sep 17 00:00:00 2001 From: gongxh Date: Fri, 13 May 2022 10:27:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CleanMachine.BLL/CM/DayWorkTimeBLL.cs | 90 +++++++++++++++ CleanMachine.DAL/CM/DayWorkTimeDAL.cs | 105 ++++++++++++++++++ CleanMachine.Model/CM/DayWorkTime.cs | 41 +++++++ CleanMachineHMI/DataBase/clearMac.db | Bin 380928 -> 380928 bytes .../FrmUserControl/frmMainDetail.cs | 2 +- .../frmShiftCountRecord.Designer.cs | 96 ++++++++-------- .../FrmUserControl/frmShiftCountRecord.resx | 3 - CleanMachineHMI/frmMainNew.cs | 4 + 8 files changed, 289 insertions(+), 52 deletions(-) create mode 100644 CleanMachine.BLL/CM/DayWorkTimeBLL.cs create mode 100644 CleanMachine.DAL/CM/DayWorkTimeDAL.cs create mode 100644 CleanMachine.Model/CM/DayWorkTime.cs diff --git a/CleanMachine.BLL/CM/DayWorkTimeBLL.cs b/CleanMachine.BLL/CM/DayWorkTimeBLL.cs new file mode 100644 index 0000000..6d101af --- /dev/null +++ b/CleanMachine.BLL/CM/DayWorkTimeBLL.cs @@ -0,0 +1,90 @@ +using CleanMachine.DAL.CM; +using System; +using System.Collections.Generic; +using System.Text; + +namespace CleanMachine.BLL.CM +{ + public class DayWorkTimeBLL + { + public DayWorkTimeBLL() + { + + } + #region 一般方法 + /// + /// 存在 + /// + public bool Exists(DateTime Date) + { + return new DayWorkTimeDAL().Exists(Date); + } + + public bool UpdateTime(DateTime date, int value) + { + var _dal = new DayWorkTimeDAL(); + + if (!_dal.Exists(date)) + { + return _dal.Add(new Model.CM.DayWorkTime() { Date = date, StartValue = value, EndValue = 0 }); + } + else + { + return _dal.UpdateEndValue(new Model.CM.DayWorkTime() { Date = date, StartValue = 0, EndValue = value }); + } + + } + + + + /// + /// 添加一个数据 + /// + public bool Add(CleanMachine.Model.CM.DayWorkTime model) + { + return new DayWorkTimeDAL().Add(model); + } + + /// + /// 更新一个数据 + /// + public bool Update(CleanMachine.Model.CM.DayWorkTime model) + { + return new DayWorkTimeDAL().Update(model); + } + + + /// + /// 删除一个数据 + /// + public bool Delete(string strWhere, object Params = null) + { + return new DayWorkTimeDAL().Delete(strWhere, Params); + } + + /// + /// 删除一个数据 + /// + public bool Delete(DateTime Date) + { + return new DayWorkTimeDAL().Delete(Date); + } + + /// + /// 获得数据列表 + /// + public IEnumerable GetList(string strWhere, object Params = null) + { + return new DayWorkTimeDAL().GetList(strWhere, Params); + } + + /// + /// 获取一个对象 + /// + public CleanMachine.Model.CM.DayWorkTime GetModel(DateTime Date) + { + return new DayWorkTimeDAL().GetModel(Date); + } + #endregion + } +} diff --git a/CleanMachine.DAL/CM/DayWorkTimeDAL.cs b/CleanMachine.DAL/CM/DayWorkTimeDAL.cs new file mode 100644 index 0000000..374e58b --- /dev/null +++ b/CleanMachine.DAL/CM/DayWorkTimeDAL.cs @@ -0,0 +1,105 @@ +using LeadDataBaseUtility; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CleanMachine.DAL.CM +{ + public class DayWorkTimeDAL + { + public DayWorkTimeDAL() + { + + } + #region 一般方法 + /// + /// 存在 + /// + public bool Exists(DateTime Date) + { + string strSql = @"SELECT count(1) from CM_DayWorkTime WHERE Date=@Date "; + return LeadDbHelperSQLite.ExecuteScalar(strSql, new { Date }) > 0; + } + + /// + /// 添加一个数据 + /// + public bool Add(CleanMachine.Model.CM.DayWorkTime model) + { + string strSql = $@"INSERT INTO CM_DayWorkTime + (Date,StartValue,EndValue) + values + (@Date,@StartValue,@EndValue) "; + return LeadDbHelperSQLite.Execute(strSql, model) > 0; + } + + /// + /// 更新一个数据 + /// + public bool Update(CleanMachine.Model.CM.DayWorkTime model) + { + string strSql = $@"UPDATE CM_DayWorkTime SET + StartValue=@StartValue,EndValue=@EndValue + WHERE Date=@Date "; + return LeadDbHelperSQLite.Execute(strSql, model) > 0; + } + + + /// + /// 更新一个数据 + /// + public bool UpdateEndValue(CleanMachine.Model.CM.DayWorkTime model) + { + string strSql = $@"UPDATE CM_DayWorkTime SET + EndValue=@EndValue + WHERE Date=@Date "; + return LeadDbHelperSQLite.Execute(strSql, model) > 0; + } + + + + /// + /// 删除一个数据 + /// + public bool Delete(string strWhere, object Params = null) + { + string strSql = $@"DELETE FROM CM_DayWorkTime "; + if (strWhere.Trim() != "") + { + strSql += $" WHERE {strWhere}"; + } + return LeadDbHelperSQLite.Execute(strSql, Params) > 0; + } + + /// + /// 删除一个数据 + /// + public bool Delete(DateTime Date) + { + return this.Delete("Date=@Date ", new { Date }); + } + + /// + /// 获得数据列表 + /// + public IEnumerable GetList(string strWhere, object Params = null) + { + string strSql = $@"SELECT * FROM CM_DayWorkTime "; + if (strWhere.Trim() != "") + { + strSql += $" WHERE {strWhere}"; + } + return LeadDbHelperSQLite.Query(strSql, Params); + } + + /// + /// 获取一个对象 + /// + public CleanMachine.Model.CM.DayWorkTime GetModel(DateTime Date) + { + return this.GetList("Date=@Date", new { Date }).FirstOrDefault(); + } + #endregion + } +} diff --git a/CleanMachine.Model/CM/DayWorkTime.cs b/CleanMachine.Model/CM/DayWorkTime.cs new file mode 100644 index 0000000..ab69a9d --- /dev/null +++ b/CleanMachine.Model/CM/DayWorkTime.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace CleanMachine.Model.CM +{ + public class DayWorkTime + { + private DateTime date; + private int startValue; + private int endValue; + + /// + /// + /// + public DateTime Date + { + get { return this.date; } + set { this.date = value; } + } + + /// + /// + /// + public int StartValue + { + get { return this.startValue; } + set { this.startValue = value; } + } + + /// + /// + /// + public int EndValue + { + get { return this.endValue; } + set { this.endValue = value; } + } + + } +} diff --git a/CleanMachineHMI/DataBase/clearMac.db b/CleanMachineHMI/DataBase/clearMac.db index 5d32175c4049dd2866845e9041e2359cf088aa50..6c49f5ee0ce73b8e595478b5de1783af52bc08d0 100644 GIT binary patch delta 491 zcmZozAl|S*e1f##N(KgoSRiHwVgVq2J5k4&aplH@9}qhM zu?rBJ1F;zpTLQ5a5L*MW4G{YRvBhQ=g#+>$LcEMZ{P*}z@vrBf%%962!*9xWpYJl? zVtz$l8@`=<^88G^jJ(fzH8<-x=<_o6PoAjI-Td5l`*UAL*&r@P_LmIoFWFx*znthO zzFlyeRY3_= zsgi;QFPDOXl1pMqs*-}sbjN*+Vlu%ciA5!0i8-Y}q0GFJ)b!LM9k43byp-v0?l3BH zgOzLYa%r-ZOuld~b@Bp*(`?p>Y~uc!(;eFO&J{tO|lWu zf!ucV`4Ae7f{h>sg5oHzzZDA(K$ay-Co#rwC135rpAvmIRQ=uC&Zb@DdqS%mzc{?0vMd~|4pfC#uUZlImSB|9Cl-bRTX>W60hRAU-s`@Vro?U94v^hu(Vkok5aB=yje9s_0$%2OXo=D;EHc1nAiy6Xk zVIdhIEyRWQV>jwXdGIWJp06M%uGcM4P{e*r!O84Mi;%){Qt@2EyH)b=9D67U_sa+X z`{d)e0@{tKxP_EKH<$>H0oq1&lbI8Z1BO$753U8rv|%lvexy!PPACC+MBXKPrPGp6 zJSok{4E}JO-1(kR>3RUJyXa^$Sr26ZqlZ5was$S0y9JZ`}%V?S!sWo zO=ci*Q<()S3jU3yu+@{u;5)H`YUKfWyPPL|FKrYriJL`>FQ)@9K$p?W;B9yj=5uvv2;syt9THx88CU(R*jU4d z@;zv6=WG}DK^D1G$JnWxcn@nD!v`d;D*?MdiZ`*0n|NRB>o05LuHL=0dytI&4T>#w AhyVZp diff --git a/CleanMachineHMI/FrmUserControl/frmMainDetail.cs b/CleanMachineHMI/FrmUserControl/frmMainDetail.cs index 0735728..c9caab9 100644 --- a/CleanMachineHMI/FrmUserControl/frmMainDetail.cs +++ b/CleanMachineHMI/FrmUserControl/frmMainDetail.cs @@ -1,5 +1,5 @@  -//#define NewFun +#define NewFun using CleanMachineHMI.Domain.Enums; using CleanMachineHMI.Utils; diff --git a/CleanMachineHMI/FrmUserControl/frmShiftCountRecord.Designer.cs b/CleanMachineHMI/FrmUserControl/frmShiftCountRecord.Designer.cs index 4cb8775..c0daaa2 100644 --- a/CleanMachineHMI/FrmUserControl/frmShiftCountRecord.Designer.cs +++ b/CleanMachineHMI/FrmUserControl/frmShiftCountRecord.Designer.cs @@ -32,17 +32,17 @@ namespace CleanMachineHMI.FrmUserControl this.kryptonPanel2 = new Krypton.Toolkit.KryptonPanel(); this.kryptonGroupBox3 = new Krypton.Toolkit.KryptonGroupBox(); this.kryptonDataGridView1 = new Krypton.Toolkit.KryptonDataGridView(); + this.DateTime = new Krypton.Toolkit.KryptonDataGridViewDateTimePickerColumn(); + this.ColCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.kryptonGroupBox4 = new Krypton.Toolkit.KryptonGroupBox(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.kbt_Reset = new Krypton.Toolkit.KryptonButton(); this.kbt_Query = new Krypton.Toolkit.KryptonButton(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.kdtp_CreateEndTime = new Krypton.Toolkit.KryptonDateTimePicker(); - this.kdtp_CreateStartTime = new Krypton.Toolkit.KryptonDateTimePicker(); this.kryptonLabel2 = new Krypton.Toolkit.KryptonLabel(); + this.kdtp_CreateStartTime = new Krypton.Toolkit.KryptonDateTimePicker(); this.kryptonLabel5 = new Krypton.Toolkit.KryptonLabel(); - this.DateTime = new Krypton.Toolkit.KryptonDataGridViewDateTimePickerColumn(); - this.ColCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.kdtp_CreateEndTime = new Krypton.Toolkit.KryptonDateTimePicker(); ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel2)).BeginInit(); this.kryptonPanel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox3)).BeginInit(); @@ -106,6 +106,23 @@ namespace CleanMachineHMI.FrmUserControl this.kryptonDataGridView1.Size = new System.Drawing.Size(1020, 500); this.kryptonDataGridView1.TabIndex = 3; // + // DateTime + // + this.DateTime.Checked = false; + this.DateTime.DataPropertyName = "DateTime"; + this.DateTime.HeaderText = "ResetTime"; + this.DateTime.Name = "DateTime"; + this.DateTime.ReadOnly = true; + this.DateTime.Width = 71; + // + // ColCount + // + this.ColCount.DataPropertyName = "Count"; + this.ColCount.HeaderText = "Count"; + this.ColCount.Name = "ColCount"; + this.ColCount.ReadOnly = true; + this.ColCount.Width = 69; + // // kryptonGroupBox4 // this.kryptonGroupBox4.CaptionOverlap = 0D; @@ -125,18 +142,18 @@ namespace CleanMachineHMI.FrmUserControl // this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.tableLayoutPanel2.BackColor = System.Drawing.Color.Transparent; - this.tableLayoutPanel2.ColumnCount = 4; - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 160F)); + this.tableLayoutPanel2.ColumnCount = 3; this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33444F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33444F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33112F)); - this.tableLayoutPanel2.Controls.Add(this.kbt_Reset, 3, 0); - this.tableLayoutPanel2.Controls.Add(this.kbt_Query, 2, 0); - this.tableLayoutPanel2.Location = new System.Drawing.Point(604, 48); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel2.Controls.Add(this.kbt_Reset, 2, 0); + this.tableLayoutPanel2.Controls.Add(this.kbt_Query, 1, 0); + this.tableLayoutPanel2.Location = new System.Drawing.Point(727, 48); this.tableLayoutPanel2.Name = "tableLayoutPanel2"; this.tableLayoutPanel2.RowCount = 1; this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(415, 41); + this.tableLayoutPanel2.Size = new System.Drawing.Size(292, 41); this.tableLayoutPanel2.TabIndex = 6; // // kbt_Reset @@ -144,9 +161,9 @@ namespace CleanMachineHMI.FrmUserControl this.kbt_Reset.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.kbt_Reset.Location = new System.Drawing.Point(333, 3); + this.kbt_Reset.Location = new System.Drawing.Point(197, 3); this.kbt_Reset.Name = "kbt_Reset"; - this.kbt_Reset.Size = new System.Drawing.Size(79, 35); + this.kbt_Reset.Size = new System.Drawing.Size(92, 35); this.kbt_Reset.TabIndex = 0; this.kbt_Reset.Tag = "show"; this.kbt_Reset.Values.Text = "重置条件"; @@ -157,9 +174,9 @@ namespace CleanMachineHMI.FrmUserControl this.kbt_Query.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.kbt_Query.Location = new System.Drawing.Point(248, 3); + this.kbt_Query.Location = new System.Drawing.Point(100, 3); this.kbt_Query.Name = "kbt_Query"; - this.kbt_Query.Size = new System.Drawing.Size(79, 35); + this.kbt_Query.Size = new System.Drawing.Size(91, 35); this.kbt_Query.TabIndex = 0; this.kbt_Query.Tag = "show"; this.kbt_Query.Values.Text = "查询"; @@ -182,20 +199,18 @@ namespace CleanMachineHMI.FrmUserControl this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 42F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(1020, 42); this.tableLayoutPanel1.TabIndex = 5; // - // kdtp_CreateEndTime + // kryptonLabel2 // - this.kdtp_CreateEndTime.Anchor = System.Windows.Forms.AnchorStyles.None; - this.kdtp_CreateEndTime.CustomFormat = "yyyy-MM-dd HH:mm:ss"; - this.kdtp_CreateEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; - this.kdtp_CreateEndTime.Location = new System.Drawing.Point(702, 10); - this.kdtp_CreateEndTime.Name = "kdtp_CreateEndTime"; - this.kdtp_CreateEndTime.ShowCheckBox = true; - this.kdtp_CreateEndTime.Size = new System.Drawing.Size(246, 21); - this.kdtp_CreateEndTime.TabIndex = 7; + this.kryptonLabel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.kryptonLabel2.Location = new System.Drawing.Point(3, 3); + this.kryptonLabel2.Name = "kryptonLabel2"; + this.kryptonLabel2.Size = new System.Drawing.Size(114, 36); + this.kryptonLabel2.TabIndex = 4; + this.kryptonLabel2.Values.Text = "重置时间"; // // kdtp_CreateStartTime // @@ -208,15 +223,6 @@ namespace CleanMachineHMI.FrmUserControl this.kdtp_CreateStartTime.Size = new System.Drawing.Size(246, 21); this.kdtp_CreateStartTime.TabIndex = 7; // - // kryptonLabel2 - // - this.kryptonLabel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.kryptonLabel2.Location = new System.Drawing.Point(3, 3); - this.kryptonLabel2.Name = "kryptonLabel2"; - this.kryptonLabel2.Size = new System.Drawing.Size(114, 36); - this.kryptonLabel2.TabIndex = 4; - this.kryptonLabel2.Values.Text = "重置时间"; - // // kryptonLabel5 // this.kryptonLabel5.Anchor = System.Windows.Forms.AnchorStyles.None; @@ -226,22 +232,16 @@ namespace CleanMachineHMI.FrmUserControl this.kryptonLabel5.TabIndex = 4; this.kryptonLabel5.Values.Text = "至"; // - // DateTime + // kdtp_CreateEndTime // - this.DateTime.Checked = false; - this.DateTime.DataPropertyName = "DateTime"; - this.DateTime.HeaderText = "ResetTime"; - this.DateTime.Name = "DateTime"; - this.DateTime.ReadOnly = true; - this.DateTime.Width = 71; - // - // ColCount - // - this.ColCount.DataPropertyName = "Count"; - this.ColCount.HeaderText = "Count"; - this.ColCount.Name = "ColCount"; - this.ColCount.ReadOnly = true; - this.ColCount.Width = 69; + this.kdtp_CreateEndTime.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kdtp_CreateEndTime.CustomFormat = "yyyy-MM-dd HH:mm:ss"; + this.kdtp_CreateEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.kdtp_CreateEndTime.Location = new System.Drawing.Point(702, 10); + this.kdtp_CreateEndTime.Name = "kdtp_CreateEndTime"; + this.kdtp_CreateEndTime.ShowCheckBox = true; + this.kdtp_CreateEndTime.Size = new System.Drawing.Size(246, 21); + this.kdtp_CreateEndTime.TabIndex = 7; // // frmShiftCountRecord // diff --git a/CleanMachineHMI/FrmUserControl/frmShiftCountRecord.resx b/CleanMachineHMI/FrmUserControl/frmShiftCountRecord.resx index 08a6f69..05baf5b 100644 --- a/CleanMachineHMI/FrmUserControl/frmShiftCountRecord.resx +++ b/CleanMachineHMI/FrmUserControl/frmShiftCountRecord.resx @@ -120,7 +120,4 @@ True - - True - \ No newline at end of file diff --git a/CleanMachineHMI/frmMainNew.cs b/CleanMachineHMI/frmMainNew.cs index dae9ddc..2f1d1ce 100644 --- a/CleanMachineHMI/frmMainNew.cs +++ b/CleanMachineHMI/frmMainNew.cs @@ -575,6 +575,10 @@ namespace CleanMachineHMI int SysRunTime = (int)PlcOperationHelper.Instance.ReadPlcItem("SysRuningTime", PlcItemTypeDesc.D); + + new CleanMachine.BLL.CM.DayWorkTimeBLL().UpdateTime(DateTime.Today, SysRunTime); + + int Minutes = SysRunTime / 60; BeginInvoke(new Action(() => {