Files
lserp_cs_6.0/插件库/Lskj.Main/Control/SubItemForm.cs
T
cyf ab56a9bcf7 基线 SVN r240
SVN-Revision: r240
2025-02-06 06:46:06 +00:00

145 lines
4.6 KiB
C#

/***********************
* 说明:子系统快捷窗口
* 创建人:龚宇超
* 创建日期:
* 修改人:
* 修改日期:
* 修改备注:
* 版本: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.Main.Control
{
public partial class SubItemForm : UserControl
{
public SubItemForm()
{
InitializeComponent();
this.Hide();
}
/// <summary>
/// 控件状态
/// </summary>
public bool _isFocus = false;
/// <summary>
/// 子系统按钮点击回调
/// </summary>
public EventHandler OnbtnSubItemClick;
/// <summary>
/// <para>说明:数据填充排布</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-08-02 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
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;
}
/// <summary>
/// <para>说明:套账填充排布</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-08-02 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
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;
}
/// <summary>
/// <para>说明:点击子系统</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-08-03 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
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);
}
}
}
}