/*********************** * 说明:子系统快捷窗口 * 创建人:龚宇超 * 创建日期: * 修改人: * 修改日期: * 修改备注: * 版本:1.0.0.0 ***********************/ using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using DevExpress.XtraEditors; using Lskj.Business.Impl; using Lskj.Control; namespace Lskj.Main3.Control { public partial class SubItemForm : UserControl { public SubItemForm() { InitializeComponent(); this.Hide(); } /// /// 控件状态 /// public bool _isFocus = false; /// /// 子系统按钮点击回调 /// public EventHandler OnbtnSubItemClick; /// /// 说明:数据填充排布 /// 创建人:龚宇超 /// 创建日期:2018-08-02 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void SetDataSource(DataRow[] dt) { int index = 1; int height = 0; int x = 0; int formHeight = 0; foreach (DataRow item in dt) { SimpleButton btnSub = new SimpleButton(); btnSub.Width = 96; btnSub.Click += new EventHandler(OnSubItemClick); btnSub.Location = new Point(10 + x, 5 + height); int y = btnSub.Location.Y; x = 96 + 5; if (index % 2 == 0) { height = y + btnSub.Height + 10; x = 0; formHeight = height; } else { formHeight = height + btnSub.Height + 10; } btnSub.Text = item["SubSysName"] + ""; btnSub.Tag = item["SubSysId"] + ""; this.Controls.Add(btnSub); index++; } this.Height = formHeight; this.Width = this.Width + 25; } /// /// 说明:套账填充排布 /// 创建人:龚宇超 /// 创建日期:2018-08-02 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void SetAccountsSource(DataTable dt) { int height = 0; int width = 0; int formWidth = 0; for (int i = dt.Rows.Count; i > 0; i--) { DataRow item = dt.Rows[i - 1]; SimpleButton btnSub = new SimpleButton(); btnSub.Appearance.Options.UseTextOptions = true; btnSub.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near; btnSub.BackColor = Color.Transparent; btnSub.Click += new EventHandler(OnSubItemClick); btnSub.Dock = System.Windows.Forms.DockStyle.Top; btnSub.Text = item["ShowName"] + ""; btnSub.Tag = item; this.Controls.Add(btnSub); height = height + btnSub.Height; if (formWidth < btnSub.Width) { formWidth = btnSub.Width; } } this.Height = height+2; this.Width = formWidth+37; } /// /// 说明:点击子系统 /// 创建人:龚宇超 /// 创建日期:2018-08-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. private void OnSubItemClick(object sender, EventArgs e) { try { if (OnbtnSubItemClick != null) OnbtnSubItemClick(sender, e); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } } }