| @ -0,0 +1,125 @@ | |||||
| using BWP.B3Frameworks.Attributes; | |||||
| using BWP.B3Sale.BO; | |||||
| using BWP.Web.Utils; | |||||
| using Forks.EnterpriseServices.DataForm; | |||||
| using Forks.Utils.TypeDescs; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using TSingSoft.WebControls2; | |||||
| using TSingSoft.WebPluginFramework; | |||||
| namespace BWP.Web.Pages | |||||
| { | |||||
| public class YunKenDFEntityLink : DFControl, IDFFieldEditor | |||||
| { | |||||
| public YunKenDFEntityLink() : base() | |||||
| { | |||||
| } | |||||
| public void InitEntityType(Type type) | |||||
| { | |||||
| mEntityType = type; | |||||
| } | |||||
| Type mEntityType; | |||||
| string mLinkIDField; | |||||
| public YunKenDFEntityLink(Type entityType, string linkIDField ) | |||||
| { | |||||
| mEntityType = entityType; | |||||
| mLinkIDField = linkIDField; | |||||
| } | |||||
| internal string Text | |||||
| { | |||||
| get { return (string)ViewState["Text"]; } | |||||
| set { ViewState["Text"] = value; } | |||||
| } | |||||
| public void ApplyValueToUI(object value) | |||||
| { | |||||
| Text = string.Empty; | |||||
| if (value == null) | |||||
| { | |||||
| return; | |||||
| } | |||||
| var str = value as string; | |||||
| if (string.IsNullOrEmpty(str)) | |||||
| { | |||||
| return; | |||||
| } | |||||
| DFInfo info = DFField.DFInfo as DFInfo; | |||||
| if (info == null) | |||||
| { | |||||
| return; | |||||
| } | |||||
| IDotNetTypeDesc type = info.DFClass as IDotNetTypeDesc; | |||||
| if (type == null) | |||||
| { | |||||
| return; | |||||
| } | |||||
| //+info.DFClass { BWP.B3Sale.BO.SaleOutStore} | |||||
| //Forks.Utils.TypeDescs.ITypeDesc { Forks.Utils.TypeDescs.DotNetTypeDesc} | |||||
| var id = WebBLUtil.GetDmoProperty<object>(type.Type, mLinkIDField, new Tuple<string, object>(DFField.Name, str)); | |||||
| if (id == null) | |||||
| { | |||||
| return; | |||||
| } | |||||
| var url = EditUrlAttribute.GetUrl(mEntityType); | |||||
| if (string.IsNullOrEmpty(url)) | |||||
| { | |||||
| throw new Exception(string.Format("未能得到对象{0}的编辑页面", DFInfo.Get(mEntityType).LogicName)); | |||||
| } | |||||
| url = AspUtil.AddTimeStampToUrl(WpfPageUrl.ToGlobal(url)); | |||||
| url = AspUtil.AddParamToUrl(url, "ID", id.ToString()); | |||||
| Text = string.Format("<a href='#' onclick=\"javascript:OpenUrlInTopTab('{0}')\">{1}</a>", url, value); | |||||
| } | |||||
| public object GetValueFromUI() | |||||
| { | |||||
| return null; | |||||
| } | |||||
| public bool Readonly | |||||
| { | |||||
| get | |||||
| { | |||||
| return true; | |||||
| } | |||||
| set | |||||
| { | |||||
| } | |||||
| } | |||||
| public void ApplyToUI(object dfObject) | |||||
| { | |||||
| ApplyValueToUI(DFField.GetValue(dfObject)); | |||||
| } | |||||
| public void GetFromUI(object dfObject) | |||||
| { | |||||
| } | |||||
| public void ValidInput() | |||||
| { | |||||
| } | |||||
| protected override void Render(System.Web.UI.HtmlTextWriter writer) | |||||
| { | |||||
| writer.Write(Text); | |||||
| } | |||||
| } | |||||
| } | |||||