using DevExpress.Xpo.Helpers; using FastReport.Dialog; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.FreeDb; 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; namespace Mesnac.Action.ChemicalWeighing.LjReport.DayWhiteEmbryo { public class DayWhiteEmbryoInitDb : ChemicalWeighingAction, IAction { //BtnOk MCDateTimePicker1 MCDataGridView1 private RuntimeParameter _runtime; MCButton btnOk; MCDateTimePicker mCDateTimePicker; DataGridView dataGridView; DataTable dt; 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 DataGridView; dataGridView.AutoGenerateColumns = true; mCDateTimePicker.Value = DateTime.Now.AddDays(-1); dt=new DataTable(); dt.Columns.Add("机台",typeof(string)); dt.Columns.Add("总量", typeof(string)); btnOk.Click += BtnOk_Click; } private void BtnOk_Click(object sender, EventArgs e) { dt.Rows.Clear(); string time = mCDateTimePicker.Value.ToString("yyyyMMdd"); var list=FreeSqlUnit.Instance.Select().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; } } }