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.

88 lines
2.6 KiB
C#

using CompressorXN_Service;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CompressorXN_ControlLib
{
public partial class ParaItem : UserControl
{
private static readonly AgreementConfigService _agreementConfigService = new AgreementConfigService();
public ParaItem()
{
InitializeComponent();
}
private void ParaItem_Load(object sender, System.EventArgs e)
{
BindAgreement();
}
/// <summary>
/// 是否只读
/// </summary>
private bool _isReadOnly = false;
[Category("自定义属性"), Description("是否只读")]
public bool IsReadOnly
{
get { return _isReadOnly; }
set
{
_isReadOnly = value;
SetGroupBoxEnabled(!_isReadOnly);
}
}
/// <summary>
/// 设置GroupBox可编辑性
/// </summary>
/// <param name="enabled"></param>
private void SetGroupBoxEnabled(bool enabled = true)
{
cmb_StartType.Enabled = enabled;
cmb_Agreement.Enabled = enabled;
groupBox1.Enabled = enabled;
groupBox2.Enabled = enabled;
groupBox3.Enabled = enabled;
groupBox4.Enabled = enabled;
groupBox5.Enabled = enabled;
groupBox6.Enabled = enabled;
groupBox7.Enabled = enabled;
groupBox8.Enabled = enabled;
groupBox9.Enabled = enabled;
groupBox10.Enabled = enabled;
groupBox11.Enabled = enabled;
}
/// <summary>
/// 绑定协议
/// </summary>
private void BindAgreement()
{
if (string.IsNullOrEmpty(DbContext.ConnStr))
{
return;
}
List<ListItem> list = _agreementConfigService.QueryAgreements()
.Select(m => new ListItem
{
Value = m.AgreementName,
Text = m.AgreementName
}).ToList();
ListItem listItem = new ListItem
{
Value = "",
Text = "--请选择--"
};
list.Insert(0, listItem);
cmb_Agreement.DataSource = list;
cmb_Agreement.ValueMember = "Value";
cmb_Agreement.DisplayMember = "Text";
}
}
}