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; using Lskj.Control; using Lskj.Business.Impl; using DevExpress.XtraEditors; using Lskj.Model; using Lskj.Core; using Lskj.Control.Model; namespace Lskj.MesPopupButton { public partial class FrmMain : BaseForm { int width = 210, height = 55, left = 30, space = 10, totalHeight = 0; public DynamicPopupButtonModel Model; public FrmMain() { InitializeComponent(); } public void InitButtons() { int top = 22; //DataTable table = BaseModuleImpl.GetBaseGridRightMenus(this.Model.ModuleCode); DataTable table = BaseModuleImpl.GetBaseGridRightMenus("yyyyyhhh"); for (int i = 1; i <= table.Rows.Count; i++) { DataRow item = table.Rows[i - 1]; SimpleButton simpleButton1 = new SimpleButton(); simpleButton1.Name = item["id"] + ""; simpleButton1.Size = new System.Drawing.Size(width, height); simpleButton1.TabIndex = 0; simpleButton1.Tag = item; simpleButton1.Text = item["menuname"] + ""; simpleButton1.Click += new EventHandler(OnButton_Click); //if (i == 1) //{ simpleButton1.Location = new System.Drawing.Point(left, top); //} //else //{ // simpleButton1.Location = new System.Drawing.Point(29, 22); //} if (i == table.Rows.Count) { } top = top + simpleButton1.Height + space; this.Controls.Add(simpleButton1); } totalHeight = top + height + 22; this.Height = totalHeight; } /// /// 说明:打开功能 /// 创建人:龚宇超 /// 创建日期:2019-12-23 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnButton_Click(object sender, EventArgs e) { try { DataRow rowItem = (sender as SimpleButton).Tag as DataRow; CommonMenu menu = new CommonMenu(this.Model, new MyControl()); //menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore); menu.Apply(rowItem); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } /// /// 说明:窗口加载 /// 创建人:龚宇超 /// 创建日期:2019-12-23 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. void OnMainLoad(object sender, EventArgs e) { try { ERPInfo.Instance.UserId = "1"; ERPInfo.Instance.UserName = "管理员"; if (DBConfig.Instance.CreateConnection()) { //Model = new DynamicPopupButtonModel() this.InitButtons(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } finally { Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this); } } } }