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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjClick/InitFormAction.cs

83 lines
2.3 KiB
C#

using DataBlockHelper.DBHelpers;
using Mesnac.Action.Base;
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.LjClick
{
internal class InitFormAction : ChemicalWeighingAction,IAction
{
private RuntimeParameter _runtime;
private DataGridView _materialGridControl = null; //物料列表控件
DataTable dataTable;
MCButton MCButton5;
MCButton MCButton1;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
dataTable = new DataTable("dt");
dataTable.Columns.Add(new DataColumn("名称", typeof(string)));
dataTable.Columns.Add(new DataColumn("点动数", typeof(string)));
var list= this.GetAllControls();
_materialGridControl = (list.FirstOrDefault(x => x.Name == "MCDataGridView1") as DataGridView);
MCButton5 = (list.FirstOrDefault(x => x.Name== "MCButton5") as MCButton);
MCButton1 = (list.FirstOrDefault(x => x.Name == "MCButton1") as MCButton);
MCButton5.Click += MCButton5_Click;
MCButton1.Click += MCButton1_Click;
Init();
}
private void MCButton1_Click(object sender, EventArgs e)
{
Init();
}
private void MCButton5_Click(object sender, EventArgs e)
{
var index= _materialGridControl.CurrentRow.Index;
FormClientManager form=new FormClientManager(index);
form.ShowDialog();
Init();
}
private void Init()
{
var ls= DB2108Helper.GetClickEntities();
dataTable.Rows.Clear();
for (int i = 0; i < 8; i++)
{
int num = i + 1;
DataRow dr = dataTable.NewRow();
dr[0] = "湿混机" + num;
dr[1] = ls[i].ClickValue;
dataTable.Rows.Add(dr);
}
_materialGridControl.AutoGenerateColumns = true;
_materialGridControl.DataSource = null ;
_materialGridControl.DataSource = dataTable;
}
}
}