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);