This commit is contained in:
gongxh
2022-05-13 10:27:55 +08:00
parent 33ce865577
commit 617a205527
8 changed files with 289 additions and 52 deletions

View File

@@ -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 一般方法
/// <summary>
/// 存在
/// </summary>
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 });
}
}
/// <summary>
/// 添加一个数据
/// </summary>
public bool Add(CleanMachine.Model.CM.DayWorkTime model)
{
return new DayWorkTimeDAL().Add(model);
}
/// <summary>
/// 更新一个数据
/// </summary>
public bool Update(CleanMachine.Model.CM.DayWorkTime model)
{
return new DayWorkTimeDAL().Update(model);
}
/// <summary>
/// 删除一个数据
/// </summary>
public bool Delete(string strWhere, object Params = null)
{
return new DayWorkTimeDAL().Delete(strWhere, Params);
}
/// <summary>
/// 删除一个数据
/// </summary>
public bool Delete(DateTime Date)
{
return new DayWorkTimeDAL().Delete(Date);
}
/// <summary>
/// 获得数据列表
/// </summary>
public IEnumerable<CleanMachine.Model.CM.DayWorkTime> GetList(string strWhere, object Params = null)
{
return new DayWorkTimeDAL().GetList(strWhere, Params);
}
/// <summary>
/// 获取一个对象
/// </summary>
public CleanMachine.Model.CM.DayWorkTime GetModel(DateTime Date)
{
return new DayWorkTimeDAL().GetModel(Date);
}
#endregion
}
}

View File

@@ -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 一般方法
/// <summary>
/// 存在
/// </summary>
public bool Exists(DateTime Date)
{
string strSql = @"SELECT count(1) from CM_DayWorkTime WHERE Date=@Date ";
return LeadDbHelperSQLite.ExecuteScalar<int>(strSql, new { Date }) > 0;
}
/// <summary>
/// 添加一个数据
/// </summary>
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;
}
/// <summary>
/// 更新一个数据
/// </summary>
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;
}
/// <summary>
/// 更新一个数据
/// </summary>
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;
}
/// <summary>
/// 删除一个数据
/// </summary>
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;
}
/// <summary>
/// 删除一个数据
/// </summary>
public bool Delete(DateTime Date)
{
return this.Delete("Date=@Date ", new { Date });
}
/// <summary>
/// 获得数据列表
/// </summary>
public IEnumerable<CleanMachine.Model.CM.DayWorkTime> GetList(string strWhere, object Params = null)
{
string strSql = $@"SELECT * FROM CM_DayWorkTime ";
if (strWhere.Trim() != "")
{
strSql += $" WHERE {strWhere}";
}
return LeadDbHelperSQLite.Query<CleanMachine.Model.CM.DayWorkTime>(strSql, Params);
}
/// <summary>
/// 获取一个对象
/// </summary>
public CleanMachine.Model.CM.DayWorkTime GetModel(DateTime Date)
{
return this.GetList("Date=@Date", new { Date }).FirstOrDefault();
}
#endregion
}
}

View File

@@ -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;
/// <summary>
///
/// </summary>
public DateTime Date
{
get { return this.date; }
set { this.date = value; }
}
/// <summary>
///
/// </summary>
public int StartValue
{
get { return this.startValue; }
set { this.startValue = value; }
}
/// <summary>
///
/// </summary>
public int EndValue
{
get { return this.endValue; }
set { this.endValue = value; }
}
}
}

Binary file not shown.

View File

@@ -1,5 +1,5 @@
//#define NewFun #define NewFun
using CleanMachineHMI.Domain.Enums; using CleanMachineHMI.Domain.Enums;
using CleanMachineHMI.Utils; using CleanMachineHMI.Utils;

View File

@@ -32,17 +32,17 @@ namespace CleanMachineHMI.FrmUserControl
this.kryptonPanel2 = new Krypton.Toolkit.KryptonPanel(); this.kryptonPanel2 = new Krypton.Toolkit.KryptonPanel();
this.kryptonGroupBox3 = new Krypton.Toolkit.KryptonGroupBox(); this.kryptonGroupBox3 = new Krypton.Toolkit.KryptonGroupBox();
this.kryptonDataGridView1 = new Krypton.Toolkit.KryptonDataGridView(); 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.kryptonGroupBox4 = new Krypton.Toolkit.KryptonGroupBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.kbt_Reset = new Krypton.Toolkit.KryptonButton(); this.kbt_Reset = new Krypton.Toolkit.KryptonButton();
this.kbt_Query = new Krypton.Toolkit.KryptonButton(); this.kbt_Query = new Krypton.Toolkit.KryptonButton();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 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.kryptonLabel2 = new Krypton.Toolkit.KryptonLabel();
this.kdtp_CreateStartTime = new Krypton.Toolkit.KryptonDateTimePicker();
this.kryptonLabel5 = new Krypton.Toolkit.KryptonLabel(); this.kryptonLabel5 = new Krypton.Toolkit.KryptonLabel();
this.DateTime = new Krypton.Toolkit.KryptonDataGridViewDateTimePickerColumn(); this.kdtp_CreateEndTime = new Krypton.Toolkit.KryptonDateTimePicker();
this.ColCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.kryptonPanel2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel2)).BeginInit();
this.kryptonPanel2.SuspendLayout(); this.kryptonPanel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox3)).BeginInit();
@@ -106,6 +106,23 @@ namespace CleanMachineHMI.FrmUserControl
this.kryptonDataGridView1.Size = new System.Drawing.Size(1020, 500); this.kryptonDataGridView1.Size = new System.Drawing.Size(1020, 500);
this.kryptonDataGridView1.TabIndex = 3; 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 // kryptonGroupBox4
// //
this.kryptonGroupBox4.CaptionOverlap = 0D; 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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel2.BackColor = System.Drawing.Color.Transparent; this.tableLayoutPanel2.BackColor = System.Drawing.Color.Transparent;
this.tableLayoutPanel2.ColumnCount = 4; this.tableLayoutPanel2.ColumnCount = 3;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 160F));
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.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.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.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.Controls.Add(this.kbt_Query, 2, 0); this.tableLayoutPanel2.Controls.Add(this.kbt_Reset, 2, 0);
this.tableLayoutPanel2.Location = new System.Drawing.Point(604, 48); this.tableLayoutPanel2.Controls.Add(this.kbt_Query, 1, 0);
this.tableLayoutPanel2.Location = new System.Drawing.Point(727, 48);
this.tableLayoutPanel2.Name = "tableLayoutPanel2"; this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1; this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); 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; this.tableLayoutPanel2.TabIndex = 6;
// //
// kbt_Reset // 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) 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.Left)
| System.Windows.Forms.AnchorStyles.Right))); | 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.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.TabIndex = 0;
this.kbt_Reset.Tag = "show"; this.kbt_Reset.Tag = "show";
this.kbt_Reset.Values.Text = "重置条件"; 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) 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.Left)
| System.Windows.Forms.AnchorStyles.Right))); | 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.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.TabIndex = 0;
this.kbt_Query.Tag = "show"; this.kbt_Query.Tag = "show";
this.kbt_Query.Values.Text = "查询"; this.kbt_Query.Values.Text = "查询";
@@ -182,20 +199,18 @@ namespace CleanMachineHMI.FrmUserControl
this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1; 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.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.Size = new System.Drawing.Size(1020, 42);
this.tableLayoutPanel1.TabIndex = 5; this.tableLayoutPanel1.TabIndex = 5;
// //
// kdtp_CreateEndTime // kryptonLabel2
// //
this.kdtp_CreateEndTime.Anchor = System.Windows.Forms.AnchorStyles.None; this.kryptonLabel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.kdtp_CreateEndTime.CustomFormat = "yyyy-MM-dd HH:mm:ss"; this.kryptonLabel2.Location = new System.Drawing.Point(3, 3);
this.kdtp_CreateEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; this.kryptonLabel2.Name = "kryptonLabel2";
this.kdtp_CreateEndTime.Location = new System.Drawing.Point(702, 10); this.kryptonLabel2.Size = new System.Drawing.Size(114, 36);
this.kdtp_CreateEndTime.Name = "kdtp_CreateEndTime"; this.kryptonLabel2.TabIndex = 4;
this.kdtp_CreateEndTime.ShowCheckBox = true; this.kryptonLabel2.Values.Text = "重置时间";
this.kdtp_CreateEndTime.Size = new System.Drawing.Size(246, 21);
this.kdtp_CreateEndTime.TabIndex = 7;
// //
// kdtp_CreateStartTime // kdtp_CreateStartTime
// //
@@ -208,15 +223,6 @@ namespace CleanMachineHMI.FrmUserControl
this.kdtp_CreateStartTime.Size = new System.Drawing.Size(246, 21); this.kdtp_CreateStartTime.Size = new System.Drawing.Size(246, 21);
this.kdtp_CreateStartTime.TabIndex = 7; 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 // kryptonLabel5
// //
this.kryptonLabel5.Anchor = System.Windows.Forms.AnchorStyles.None; this.kryptonLabel5.Anchor = System.Windows.Forms.AnchorStyles.None;
@@ -226,22 +232,16 @@ namespace CleanMachineHMI.FrmUserControl
this.kryptonLabel5.TabIndex = 4; this.kryptonLabel5.TabIndex = 4;
this.kryptonLabel5.Values.Text = "至"; this.kryptonLabel5.Values.Text = "至";
// //
// DateTime // kdtp_CreateEndTime
// //
this.DateTime.Checked = false; this.kdtp_CreateEndTime.Anchor = System.Windows.Forms.AnchorStyles.None;
this.DateTime.DataPropertyName = "DateTime"; this.kdtp_CreateEndTime.CustomFormat = "yyyy-MM-dd HH:mm:ss";
this.DateTime.HeaderText = "ResetTime"; this.kdtp_CreateEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.DateTime.Name = "DateTime"; this.kdtp_CreateEndTime.Location = new System.Drawing.Point(702, 10);
this.DateTime.ReadOnly = true; this.kdtp_CreateEndTime.Name = "kdtp_CreateEndTime";
this.DateTime.Width = 71; this.kdtp_CreateEndTime.ShowCheckBox = true;
// this.kdtp_CreateEndTime.Size = new System.Drawing.Size(246, 21);
// ColCount this.kdtp_CreateEndTime.TabIndex = 7;
//
this.ColCount.DataPropertyName = "Count";
this.ColCount.HeaderText = "Count";
this.ColCount.Name = "ColCount";
this.ColCount.ReadOnly = true;
this.ColCount.Width = 69;
// //
// frmShiftCountRecord // frmShiftCountRecord
// //

View File

@@ -120,7 +120,4 @@
<metadata name="ColCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="ColCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="ColCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View File

@@ -575,6 +575,10 @@ namespace CleanMachineHMI
int SysRunTime = (int)PlcOperationHelper.Instance.ReadPlcItem("SysRuningTime", PlcItemTypeDesc.D); int SysRunTime = (int)PlcOperationHelper.Instance.ReadPlcItem("SysRuningTime", PlcItemTypeDesc.D);
new CleanMachine.BLL.CM.DayWorkTimeBLL().UpdateTime(DateTime.Today, SysRunTime);
int Minutes = SysRunTime / 60; int Minutes = SysRunTime / 60;
BeginInvoke(new Action(() => BeginInvoke(new Action(() =>
{ {