From 1fe2c0ff84de0d69d9f1ba608ddce1915ba5f346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Mon, 19 Feb 2024 12:54:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9C=E7=8F=AD=E7=99=BD=E5=A4=A9=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LjReport/DayWhiteEmbryo/GhWuLiaoInitDb.cs | 45 +++++++++++++++---- .../DayWhiteEmbryo/HuYuMiFenInitDb.cs | 40 +++++++++++++---- 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/GhWuLiaoInitDb.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/GhWuLiaoInitDb.cs index 0709f0d..a92ad59 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/GhWuLiaoInitDb.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/GhWuLiaoInitDb.cs @@ -100,25 +100,53 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.DayWhiteEmbryo private void WhiteWork_Click(object sender, EventArgs e) { + dt = GetDefault(); DateTime nowTime = DateTime.Now; - DateTime starttime; - DateTime endtime; + DateTime starttime=DateTime.Now; + DateTime endtime=DateTime.Now; - //如果大于当天8点 就展示当天的白班 否则展示上一个白班 - if (nowTime >= DateTime.Now.Date.AddHours(8)) + if (((Button)sender).Text.Contains("白")) { - starttime = DateTime.Now.Date.AddHours(7).AddMinutes(30); - endtime = DateTime.Now.Date.AddHours(19).AddMinutes(30); + //如果大于当天8点 就展示当天的白班 否则展示上一个白班 + if (nowTime >= DateTime.Now.Date.AddHours(8)) + { + starttime = DateTime.Now.Date.AddHours(7).AddMinutes(30); + endtime = DateTime.Now.Date.AddHours(19).AddMinutes(30); + } + else + { + starttime = DateTime.Now.Date.AddHours(-17).AddMinutes(30); + endtime = DateTime.Now.Date.AddHours(-5).AddMinutes(30); + } } else { - starttime = DateTime.Now.Date.AddHours(-17).AddMinutes(30); - endtime = DateTime.Now.Date.AddHours(-5).AddMinutes(30); + //如果小于当天20点 就展示当天的前一个晚班 + if (nowTime <= DateTime.Now.Date.AddHours(20)) + { + starttime = DateTime.Now.Date.AddHours(-5).AddMinutes(30); + endtime = DateTime.Now.Date.AddHours(7).AddMinutes(30); + } + else + { + starttime = DateTime.Now.Date.AddHours(19).AddMinutes(30); + endtime = DateTime.Now.Date.AddHours(31).AddMinutes(30); + } } + + string statValue = starttime.ToString("yyyy-MM-dd HH:mm:ss"); string endValue = endtime.ToString("yyyy-MM-dd HH:mm:ss"); + + startDate.Value = Convert.ToDateTime(starttime.ToString("yyyy-MM-dd")); + endDate.Value = Convert.ToDateTime(endtime.ToString("yyyy-MM-dd")); + + startTime.Value = Convert.ToDateTime(starttime.ToString("HH:mm:ss")); + endTime.Value = Convert.ToDateTime(endtime.ToString("HH:mm:ss")); + + FillData(statValue, endValue); } @@ -126,6 +154,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.DayWhiteEmbryo private void FillData(string statValue, string endValue) { + DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); list = new List(); diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/HuYuMiFenInitDb.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/HuYuMiFenInitDb.cs index b8e0658..63895e6 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/HuYuMiFenInitDb.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/HuYuMiFenInitDb.cs @@ -89,8 +89,8 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.DayWhiteEmbryo //selectButton.Click += SelectButton_Click; //dataGridView.CellClick += MoreData_Click; //dataGridView.CellValueChanged += MoreData_Click; - //WhiteWork.Click += WhiteWork_Click; - //NightWork.Click += NightWork_Click; + WhiteWork.Click += WhiteWork_Click; + NightWork.Click += WhiteWork_Click; SelectButton_Click(new object(),new EventArgs()); MoreData_Click(new object(), new EventArgs()); @@ -118,18 +118,42 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.DayWhiteEmbryo DateTime starttime; DateTime endtime; - //如果大于当天8点 就展示当天的白班 否则展示上一个白班 - if (nowTime >= DateTime.Now.Date.AddHours(8)) + if (((Button)sender).Text.Contains("白")) { - starttime = DateTime.Now.Date.AddHours(7).AddMinutes(30); - endtime = DateTime.Now.Date.AddHours(19).AddMinutes(30); + //如果大于当天8点 就展示当天的白班 否则展示上一个白班 + if (nowTime >= DateTime.Now.Date.AddHours(8)) + { + starttime = DateTime.Now.Date.AddHours(7).AddMinutes(30); + endtime = DateTime.Now.Date.AddHours(19).AddMinutes(30); + } + else + { + starttime = DateTime.Now.Date.AddHours(-17).AddMinutes(30); + endtime = DateTime.Now.Date.AddHours(-5).AddMinutes(30); + } } else { - starttime = DateTime.Now.Date.AddHours(-17).AddMinutes(30); - endtime = DateTime.Now.Date.AddHours(-5).AddMinutes(30); + //如果小于当天20点 就展示当天的前一个晚班 + if (nowTime <= DateTime.Now.Date.AddHours(20)) + { + starttime = DateTime.Now.Date.AddHours(-5).AddMinutes(30); + endtime = DateTime.Now.Date.AddHours(7).AddMinutes(30); + } + else + { + starttime = DateTime.Now.Date.AddHours(19).AddMinutes(30); + endtime = DateTime.Now.Date.AddHours(31).AddMinutes(30); + } } + + startDate.Value = Convert.ToDateTime(starttime.ToString("yyyy-MM-dd")); + endDate.Value = Convert.ToDateTime(endtime.ToString("yyyy-MM-dd")); + + startTime.Value = Convert.ToDateTime(starttime.ToString("HH:mm:ss")); + endTime.Value = Convert.ToDateTime(endtime.ToString("HH:mm:ss")); + string statValue = starttime.ToString("yyyy-MM-dd HH:mm:ss"); string endValue = endtime.ToString("yyyy-MM-dd HH:mm:ss"); FileData(statValue, endValue);