You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
144 lines
5.2 KiB
C#
144 lines
5.2 KiB
C#
using DevExpress.Xpo.Helpers;
|
|
|
|
using FastReport.Dialog;
|
|
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb;
|
|
using Mesnac.Codd.Session;
|
|
using Mesnac.Controls.Default;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjReport.DayWhiteEmbryo
|
|
{
|
|
public class DayWhiteEmbryoInitDb : ChemicalWeighingAction, IAction
|
|
{
|
|
|
|
//BtnOk MCDateTimePicker1 MCDataGridView1
|
|
private RuntimeParameter _runtime;
|
|
MCButton btnOk;
|
|
MCButton selectButton;
|
|
MCDateTimePicker mCDateTimePicker;
|
|
MCDateTimePicker startDate;
|
|
MCDateTimePicker startTime;
|
|
MCDateTimePicker endDate;
|
|
MCDateTimePicker endTime;
|
|
MCDataGridView dataGridView;
|
|
MCDataGridView moreData;
|
|
DataTable dt;
|
|
DataTable MoreDataTable;
|
|
List<DayWhiteEmbryoEntity> list;
|
|
List<DayWhiteEmbryoEntity> listMore;
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime); //必须调用
|
|
this._runtime = runtime;
|
|
var control = GetAllControls();
|
|
|
|
mCDateTimePicker = control.FirstOrDefault(x => x.Name == "MCDateTimePicker1") as MCDateTimePicker;
|
|
btnOk = control.FirstOrDefault(x => x.Name == "MCButton1") as MCButton;
|
|
dataGridView = control.FirstOrDefault(x => x.Name == "MCDataGridView1") as MCDataGridView;
|
|
selectButton = control.FirstOrDefault(x => x.Name == "SelectButton") as MCButton;
|
|
moreData = control.FirstOrDefault(x => x.Name == "MoreData") as MCDataGridView;
|
|
startDate = control.FirstOrDefault(x => x.Name == "startDate") as MCDateTimePicker;
|
|
startTime = control.FirstOrDefault(x => x.Name == "startTime") as MCDateTimePicker;
|
|
endDate = control.FirstOrDefault(x => x.Name == "endDate") as MCDateTimePicker;
|
|
endTime = control.FirstOrDefault(x => x.Name == "endTime") as MCDateTimePicker;
|
|
dataGridView.AutoGenerateColumns = true;
|
|
mCDateTimePicker.Value = DateTime.Now.AddDays(0);
|
|
startDate.Value = DateTime.Now.AddDays(-3);
|
|
|
|
dt = new DataTable();
|
|
dt.Columns.Add("机台", typeof(string));
|
|
dt.Columns.Add("总量", typeof(string));
|
|
|
|
MoreDataTable = new DataTable();
|
|
MoreDataTable.Columns.Add("重量", typeof(string));
|
|
MoreDataTable.Columns.Add("时间", typeof(string));
|
|
|
|
btnOk.Click += BtnOk_Click;
|
|
selectButton.Click += SelectButton_Click;
|
|
dataGridView.CellClick += MoreData_Click;
|
|
|
|
}
|
|
|
|
private void BtnOk_Click(object sender, EventArgs e)
|
|
{
|
|
dt.Rows.Clear();
|
|
string time = mCDateTimePicker.Value.ToString("yyyyMMdd");
|
|
list = FreeSqlUnit.Instance.Select<DayWhiteEmbryoEntity>().Where(x => x.CreateDate == time).ToList();
|
|
|
|
for (int i = 1; i <= 8; i++)
|
|
{
|
|
var dr = dt.NewRow();
|
|
dr[0] = "糊化机" + i;
|
|
var totalWeight = list.Where(x => x.DeviceId == i).Sum(x => x.Weight);
|
|
dr[1] = totalWeight.ToString();
|
|
|
|
dt.Rows.Add(dr);
|
|
}
|
|
|
|
dataGridView.DataSource = null;
|
|
dataGridView.DataSource = dt;
|
|
|
|
}
|
|
|
|
private void SelectButton_Click(object sender, EventArgs e)
|
|
{
|
|
dt.Rows.Clear();
|
|
DateTime starttime = startDate.Value.Date.AddHours(startTime.Value.Hour);
|
|
starttime.AddMinutes(startTime.Value.Minute);
|
|
starttime.AddSeconds(startTime.Value.Second);
|
|
DateTime endtime = endDate.Value.Date.AddHours(endTime.Value.Hour);
|
|
endtime.AddMinutes(endTime.Value.Minute);
|
|
endtime.AddSeconds(endTime.Value.Second);
|
|
|
|
list = FreeSqlUnit.Instance.Select<DayWhiteEmbryoEntity>().Where(x => (x.CreateTime >= starttime && x.CreateTime <= endtime)).ToList();
|
|
|
|
for(int i = 1; i <= 8; i++)
|
|
{
|
|
var dr = dt.NewRow();
|
|
dr[0] = "糊化机" + i;
|
|
var totalWeight = list.Where(x => x.DeviceId == i).Sum(x => x.Weight);
|
|
dr[1] = totalWeight.ToString();
|
|
|
|
dt.Rows.Add(dr);
|
|
}
|
|
|
|
dataGridView.DataSource = null;
|
|
dataGridView.DataSource = dt;
|
|
}
|
|
|
|
private void MoreData_Click(object sender, EventArgs e)
|
|
{
|
|
MoreDataTable.Rows.Clear();
|
|
|
|
string dID = dataGridView.SelectedRows[0].Cells["机台"].Value as string;
|
|
|
|
char[] a = dID.ToCharArray();
|
|
char chr = a[3];
|
|
int num = int.Parse(chr.ToString());
|
|
listMore = list.Where(x => x.DeviceId == num).ToList();
|
|
|
|
for (int i = 0; i < listMore.Count; i++)
|
|
{
|
|
var dr = MoreDataTable.NewRow();
|
|
dr[0] = listMore[i].Weight;
|
|
dr[1] = listMore[i].CreateTime;
|
|
MoreDataTable.Rows.Add(dr);
|
|
}
|
|
|
|
moreData.DataSource = null;
|
|
moreData.DataSource = MoreDataTable;
|
|
|
|
}
|
|
}
|
|
}
|