2b2d109132
SVN-Revision: r1230
380 lines
15 KiB
C#
380 lines
15 KiB
C#
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.Control.Model;
|
|
using Lskj.Business.Impl;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
public partial class LabelGridSelectEdit : BaseUserControl
|
|
{
|
|
private string editValue;
|
|
/// <summary>
|
|
/// 文本控件
|
|
/// </summary>
|
|
public TextEdit TextEdit { get { return txtEdit; } }
|
|
/// <summary>
|
|
/// 数据源
|
|
/// </summary>
|
|
public DataTable table = new DataTable();
|
|
public LabelGridSelectEdit()
|
|
{
|
|
InitializeComponent();
|
|
|
|
if (Business.Impl.LanguageTranslation.Translatable)
|
|
{
|
|
simpleButton1.Text = Business.Impl.LanguageTranslation.GetTranslatedText(simpleButton1.Text);
|
|
simpleButton4.Text = Business.Impl.LanguageTranslation.GetTranslatedText(simpleButton4.Text);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 隐藏值
|
|
/// </summary>
|
|
/// <value>The value.</value>
|
|
public string EditValue
|
|
{
|
|
get
|
|
{
|
|
BaseUserControl control = null;
|
|
if (this.Model != null) control = ControlObj.FindControl(this.Model.FieldName);
|
|
if (this.Model != null && (this.Model.FieldType == ControlType.LabGridPopupValue || this.Model.FieldType == ControlType.LabGridPopupMutilValue))
|
|
{
|
|
this.table = BaseImpl.GetDataTableResult(ControlObj.ReplaceControlValue(this.Model.SourceSql));
|
|
if (!string.IsNullOrEmpty(editValue))
|
|
{
|
|
return editValue;
|
|
}
|
|
else
|
|
{
|
|
// 存在名称并且没有value值则
|
|
if (control != null && !string.IsNullOrEmpty(control.EditText))
|
|
{
|
|
if (table != null && table is DataTable)
|
|
{
|
|
String[] strRating = control.EditText.Split(',');
|
|
string textEditValue = string.Empty;
|
|
string textEditText = string.Empty;
|
|
foreach (string strrating in strRating)
|
|
{
|
|
DataRow rowItem = table.Select("1=1").FirstOrDefault(x => strrating == x[this.Model.TextMember] + "");
|
|
DataRow rowValueItem = table.Select("1=1").FirstOrDefault(x => strrating == x[this.Model.ValueMember] + "");
|
|
if (rowItem != null)
|
|
{
|
|
textEditText += rowItem[this.Model.TextMember] + "";
|
|
textEditValue += rowItem[this.Model.ValueMember] + "";
|
|
}
|
|
else if (rowValueItem != null)
|
|
{
|
|
textEditText += rowItem[this.Model.TextMember] + "";
|
|
textEditValue += rowItem[this.Model.ValueMember] + "";
|
|
}
|
|
}
|
|
this.TextEdit.Text = textEditText.TrimEnd(',');
|
|
return textEditValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
set
|
|
{
|
|
// this.Model.SourceSql = "select cltm as 编码,cltm 原纸条码 from WMS_BillOutUsedByPlanTab where #planlistid={planlistid}# and issn=1";
|
|
this.table = BaseImpl.GetDataTableResult(ControlObj.ReplaceControlValue(this.Model.SourceSql));
|
|
if (this.table != null && this.table is DataTable)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(value))
|
|
{
|
|
String[] strRating = value.Split(',');
|
|
string textEditValue = string.Empty;
|
|
string textEditText = string.Empty;
|
|
if (strRating.Length > 0)
|
|
{
|
|
foreach (string strrating in strRating)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(strrating))
|
|
{
|
|
DataRow rowItem = table.Select("1=1").FirstOrDefault(x => strrating == x[this.Model.ValueMember] + "");
|
|
if (rowItem != null)
|
|
{
|
|
textEditValue += rowItem[this.Model.ValueMember] + ",";
|
|
textEditText += rowItem[this.Model.TextMember] + ",";
|
|
|
|
}
|
|
else
|
|
{
|
|
rowItem = table.Select("1=1").FirstOrDefault(x => strrating == x[this.Model.TextMember] + "");
|
|
if (rowItem != null)
|
|
{
|
|
textEditValue += rowItem[this.Model.ValueMember] + ",";
|
|
textEditText += rowItem[this.Model.TextMember] + ",";
|
|
}
|
|
else
|
|
{
|
|
|
|
this.TextEdit.EditValue = string.Empty;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(textEditText)) textEditText = textEditText.Remove(textEditText.LastIndexOf(","), 1);
|
|
//if (!string.IsNullOrWhiteSpace(editValue)) editValue = editValue.Remove(editValue.LastIndexOf(","), 1);
|
|
|
|
this.TextEdit.Text = textEditText.TrimEnd(',');
|
|
this.editValue = textEditValue.TrimEnd(',');
|
|
this.TextEdit.SelectionStart = this.Text.Length;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.TextEdit.EditValue = string.Empty;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.TextEdit.EditValue = string.Empty;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件显示文本</para>
|
|
/// <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();
|
|
this.simpleButton4.Width = this.simpleButton1.Width = this.Model.Size.Height + 10;
|
|
|
|
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.EditValue = value;
|
|
}
|
|
}
|
|
/// <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.txtEdit.Properties.ReadOnly = true;
|
|
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>说明:弹出框</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-01-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void ShowPopup()
|
|
{
|
|
FrmGridSelectPopup popup = new FrmGridSelectPopup(this.Model, ControlObj,this.editValue,this.EditText);
|
|
DialogResult result = popup.ShowDialog();
|
|
if (result == DialogResult.OK)
|
|
{
|
|
this.editValue = popup.ShowValue;
|
|
this.EditText = popup.ShowText;
|
|
}
|
|
else
|
|
{
|
|
this.editValue = this.EditText = "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-07 </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>
|
|
private void txtEdit_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.ShowPopup();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.ShowPopup();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
private void simpleButton4_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.EditText = this.editValue = "";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
public Control.Model.MyControl ControlObj { get; set; }
|
|
|
|
/// <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;
|
|
}
|