using DevExpress.XtraEditors; using Lskj.Business.Impl; using Lskj.Control; using Lskj.Model; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Lskj.ProductPlatform { public partial class MachineSwitching : UserControl { public MachineSwitching() { InitializeComponent(); } //传入全部机器数据 public void Addmachine(DataTable dataTable) { //设置控件高度 this.panel1.Height = dataTable.Rows.Count * 45; this.Height = dataTable.Rows.Count * 45; foreach (DataRow item in dataTable.Rows) { SimpleButton itemCommon = new SimpleButton(); itemCommon.Text = item["mc"] + ""; itemCommon.Tag = item; itemCommon.Dock = DockStyle.Top; itemCommon.Click += new EventHandler(OnCommonItemClick); itemCommon.Height = 45; itemCommon.Font= new Font("微软雅黑", 20); itemCommon.Appearance.BackColor = Color.Transparent; this.panel1.Controls.Add(itemCommon); } } //点击按钮切换机器 private void OnCommonItemClick(object sender, EventArgs e) { try { SimpleButton simpleButton = sender as SimpleButton; DataRow rowItem = simpleButton.Tag as DataRow; ERPInfo.Instance.WorkJT = rowItem["mc"] + ""; Program.ReStartMain(true); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } } }