428 lines
14 KiB
C#
428 lines
14 KiB
C#
using DevExpress.XtraEditors;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Data;
|
|
using Lskj.Model;
|
|
using Lskj.Util;
|
|
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.Control
|
|
{
|
|
public partial class LabelBillSourceComboxEdit : BaseUserControl
|
|
{
|
|
public LabelBillSourceComboxEdit()
|
|
{
|
|
InitializeComponent();
|
|
this.TextEdit.Click += new EventHandler(TextEditClick);
|
|
this.btnSource.Click += BtnRefresh_Click;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定ValueMember
|
|
/// </summary>
|
|
public string ValueMember
|
|
{
|
|
get { return txtEdit.ValueMember; }
|
|
set { txtEdit.ValueMember = value; }
|
|
}
|
|
/// <summary>
|
|
/// 隐藏值字段
|
|
/// </summary>
|
|
public string ValueField
|
|
{
|
|
get { return txtEdit.ValueField; }
|
|
set { txtEdit.ValueField = value; }
|
|
}
|
|
/// <summary>
|
|
/// 显示值字段
|
|
/// </summary>
|
|
public string TextField
|
|
{
|
|
get { return txtEdit.TextMember; }
|
|
set { txtEdit.TextMember = value; }
|
|
}
|
|
public string FormKey
|
|
{
|
|
get { return txtEdit.FormKey; }
|
|
set { txtEdit.FormKey = value; }
|
|
}
|
|
/// <summary>
|
|
/// 自动搜索框控件
|
|
/// </summary>
|
|
public AutoGridLookUp TextEdit { get { return txtEdit; } }
|
|
/// <summary>
|
|
/// 文本
|
|
/// </summary>
|
|
/// <value>The label.</value>
|
|
public Label Label { get { return lblText; } }
|
|
/// <summary>
|
|
/// 点击后清空数据
|
|
/// </summary>
|
|
public bool clickAfterEmpty;
|
|
|
|
/// <summary>
|
|
/// 按钮
|
|
/// </summary>
|
|
/// <value>The label.</value>
|
|
public SimpleButton Button { get { return btnSource; } }
|
|
|
|
/// <summary>
|
|
/// 打开来源模块
|
|
/// </summary>
|
|
public event EventHandler OpenDocumentSource;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 按钮点击,打开 单据来源 弹出框
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void BtnRefresh_Click(object sender, EventArgs e)
|
|
{
|
|
if (OpenDocumentSource != null) OpenDocumentSource(this.EditValue, e);
|
|
}
|
|
|
|
|
|
private void TextEditClick(object sender, EventArgs e)
|
|
{
|
|
|
|
if (TextEdit.Enabled && clickAfterEmpty)
|
|
{
|
|
this.EditText = "";
|
|
|
|
this.TextEdit._popup.LookUp.EditValue = "";
|
|
this.TextEdit.ShowPopup();
|
|
SendKeys.Send("{Esc}");
|
|
//this.TextEdit._popup.EditValue = "";
|
|
//TextEdit.Text = "";
|
|
}
|
|
if (SystemInfo.Instance.ControlClickSelectAll)
|
|
{
|
|
//SendKeys.Send("^A");
|
|
TextEdit.SelectAll();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置控件显示文本</pa>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="text">显示Lebel文本</param>
|
|
public override string LabelText
|
|
{
|
|
get
|
|
{
|
|
return this.lblText.Text;
|
|
}
|
|
set
|
|
{
|
|
this.lblText.Text = value;
|
|
if (FontSize > 0)
|
|
{
|
|
this.plLeft.Dock = DockStyle.Left;
|
|
this.plLeft.AutoSize = false;
|
|
this.lblText.AutoSize = false;
|
|
this.lblText.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.lblText.Location = new System.Drawing.Point(0, 0);
|
|
this.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
this.txtEdit.Properties.AutoHeight = false;
|
|
this.plLeft.Width = value.Length * GetCharWidth();
|
|
|
|
GetCharWidthMultilingual(this.lblText, this.lblText.Text, this.plLeft);
|
|
}
|
|
else
|
|
{
|
|
this.plLeft.Width = this.lblText.Width + PaddingLeft;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 字体大小
|
|
/// </summary>
|
|
/// <value>The size of the control.</value>
|
|
public override float FontSize
|
|
{
|
|
get
|
|
{
|
|
return base.FontSize;
|
|
}
|
|
set
|
|
{
|
|
base.FontSize = value;
|
|
if (value > 0)
|
|
{
|
|
this.lblText.Font = new Font(this.lblText.Font.FontFamily, value);
|
|
this.TextEdit.Font = new Font(this.TextEdit.Font.FontFamily, value);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public override string EditText
|
|
{
|
|
get
|
|
{
|
|
return this.txtEdit.Text;
|
|
}
|
|
set
|
|
{
|
|
this.txtEdit.EditValue = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取隐藏值
|
|
/// </summary>
|
|
/// <value>The edit value.</value>
|
|
public string EditValue
|
|
{
|
|
get
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(this.txtEdit.EditValue + "") && this.txtEdit.DataSourceTable != null && this.txtEdit.DataSourceTable.Rows.Count > 0 && Model != null && !string.IsNullOrEmpty(this.txtEdit.Text))
|
|
{
|
|
DataRow[] dataRows = this.txtEdit.DataSourceTable.Select().Where(n => n[Model.TextMember].Equals(this.txtEdit.Text)).ToArray();
|
|
if (dataRows.Count() == 1)
|
|
{
|
|
return dataRows[0][Model.ValueMember] + "";
|
|
}
|
|
}
|
|
return this.txtEdit.EditValue + "";
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return this.txtEdit.EditValue + "";
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件提示文本</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>返回控件值</returns>
|
|
public override string NullText
|
|
{
|
|
get
|
|
{
|
|
return this.txtEdit.Properties.NullValuePrompt;
|
|
}
|
|
set
|
|
{
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
this.TextEdit.Properties.NullValuePromptShowForEmptyValue = true;
|
|
this.TextEdit.Properties.NullValuePrompt = value;
|
|
}
|
|
base.NullText = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 只读文本颜色
|
|
/// </summary>
|
|
/// <value>The color of the read only label.</value>
|
|
public override bool ReadOnly
|
|
{
|
|
get
|
|
{
|
|
return base.ReadOnly;
|
|
}
|
|
set
|
|
{
|
|
base.ReadOnly = value;
|
|
|
|
this.TextEdit.Properties.ReadOnly = value;
|
|
this.lblText.ForeColor = value ? base.ReadOnlyLabelForceColor : Required ? base.RequiredLabelForceColor : base.DefaultLabelForceColor;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 必填文本颜色
|
|
/// </summary>
|
|
/// <value>The color of the required label.</value>
|
|
public override bool Required
|
|
{
|
|
get
|
|
{
|
|
return base.Required;
|
|
}
|
|
set
|
|
{
|
|
base.Required = value;
|
|
if (value)
|
|
{
|
|
this.lblText.ForeColor = base.RequiredLabelForceColor;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:搜索返回ID需要单独验证是否修改</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if this instance is update; otherwise, <c>false</c>.</returns>
|
|
public override bool IsUpdate()
|
|
{
|
|
return !this.Model.Text.Equals(this.EditValue, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
/// <summary>
|
|
/// 控件Model
|
|
/// </summary>
|
|
/// <value>The model.</value>
|
|
public override ControlModel Model
|
|
{
|
|
get { return base.Model; }
|
|
set
|
|
{
|
|
this.TextEdit.Model = base.Model = value;
|
|
if (value != null && !string.IsNullOrEmpty(value.AddModuleId))
|
|
{
|
|
this.TextEdit.Popup.AddVisible = true;
|
|
this.TextEdit.Popup.OnAddMouseClick += new EventHandler(Popup_OnAddMouseClick);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-26 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="dataSource">The data source.</param>
|
|
public void SetDataSource(DataTable dataSource)
|
|
{
|
|
this.txtEdit.DataSource = dataSource;
|
|
this.txtEdit.DataSourceTable = dataSource.Copy();
|
|
// this.txtEdit.DataSourceTable = dataSource;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:添加操作后</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-03 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void Popup_OnAddMouseClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (Model == null) return;
|
|
|
|
string dllName = string.IsNullOrEmpty(this.Model.AddModuleSpec) ? "lskj.pubadd3.dll" : "lskj.pubadd.dll";
|
|
|
|
string AddModuleSpec = "SpeciesNo";
|
|
if (!string.IsNullOrEmpty(this.Model.AddModuleSpec)) AddModuleSpec = this.Model.AddModuleSpec;
|
|
|
|
// 固定传入参数(窗口标题、操作员ID、操作员名称、权限、模版编号)
|
|
string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.LabelText + "-添加", ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "0", this.Model.AddModuleId).Split('~');
|
|
|
|
string[] menuArgs = { string.Format(ModuleArgs.PubAddArgs, ""), "0", "", AddModuleSpec, "默认分类", "", "", "", "", "" };
|
|
string[] args = defaultArgs.Concat(menuArgs).ToArray();
|
|
|
|
IForm form = FormHelper.LoadDllForm(ResourceDynamic.PubAdd, args);
|
|
DialogResult result = form.SubForm.ShowDialog();
|
|
|
|
//if (result == DialogResult.OK)
|
|
//{
|
|
this.SetDataSource(MainImpl.GetDataTableResult(Model.SourceSql));
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 背景颜色
|
|
/// </summary>
|
|
/// <value>The color of the required label.</value>
|
|
public override Color BackgroundColor
|
|
{
|
|
get
|
|
{
|
|
return TextEdit.Properties.Appearance.BackColor;
|
|
}
|
|
set
|
|
{
|
|
TextEdit.Properties.Appearance.BackColor = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 前景颜色
|
|
/// </summary>
|
|
/// <value>The color of the required label.</value>
|
|
public override Color ForeColor
|
|
{
|
|
get
|
|
{
|
|
return TextEdit.Properties.Appearance.ForeColor;
|
|
}
|
|
set
|
|
{
|
|
TextEdit.Properties.Appearance.ForeColor = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 内容加粗
|
|
/// </summary>
|
|
/// <value>The color of the required label.</value>
|
|
public override bool ContentBold
|
|
{
|
|
get
|
|
{
|
|
return TextEdit.Properties.Appearance.Font.Bold;
|
|
}
|
|
set
|
|
{
|
|
Font oldFont = TextEdit.Properties.Appearance.Font;
|
|
TextEdit.Properties.Appearance.Font = new Font(oldFont.FontFamily, oldFont.Size, value ? FontStyle.Bold : FontStyle.Regular);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|