internal void Override(Tk5FieldInfoEx item, OverrideExtensionConfig ovExt) { if (!string.IsNullOrEmpty(ovExt.CheckValue)) { CheckValue = ovExt.CheckValue; } if (!string.IsNullOrEmpty(ovExt.UnCheckValue)) { UnCheckValue = ovExt.UnCheckValue; } if (!string.IsNullOrEmpty(ovExt.Expression)) { Expression = ovExt.Expression; item.ResetExpression(); } if (!string.IsNullOrEmpty(ovExt.Format)) { Format = ovExt.Format; } if (ovExt.Align.HasValue) { Align = ovExt.Align.Value; } if (!string.IsNullOrEmpty(ovExt.EmptyTitle)) { EmptyTitle = ovExt.EmptyTitle; } }
private ICellStyle BorderAndFontSetting(IWorkbook wb, Tk5FieldInfoEx metaInfo, Model model) { ICellStyle cellStyle = wb.CreateCellStyle(); if (fUseBorder) { cellStyle.BorderTop = BorderStyle.Thin; cellStyle.BorderRight = BorderStyle.Thin; cellStyle.BorderBottom = BorderStyle.Thin; cellStyle.BorderLeft = BorderStyle.Thin; } if (model == Model.Content) { IFont fontContent = ExcelUtil.FontSetting(wb, fContent); cellStyle.SetFont(fontContent); if (metaInfo.Extension != null) { ExcelUtil.AlignSetting(metaInfo.Extension.Align, cellStyle); } else { ExcelUtil.AlignSetting(fContent.Align, cellStyle); } } else { ExcelUtil.AlignSetting(fHeader.Align, cellStyle); IFont fontHeader = ExcelUtil.FontSetting(wb, fHeader); cellStyle.SetFont(fontHeader); } return cellStyle; }
private static IDisplay GetDisplay(Tk5FieldInfoEx field, IPageData pageData) { switch (pageData.Style.Style) { case PageStyle.Insert: case PageStyle.Update: return(field.Edit.Display.CreateObject()); case PageStyle.Detail: return(field.ListDetail.DetailDisplay.CreateObject()); case PageStyle.List: return(field.ListDetail.ListDisplay.CreateObject()); default: if (MetaDataUtil.StartsWith(pageData.Style, "DetailList")) { return(field.ListDetail.ListDisplay.CreateObject()); } TkDebug.ThrowToolkitException( string.Format(ObjectUtil.SysCulture, "当前页面类型是{0},没有可用的Display,请不要使用这种PageMaker", PageStyleClass.FromStyle(pageData.Style)), field); return(null); } }
string CreateHeadAttrs(IFieldInfoEx field, int index, int sortField, DataRow sortRow) { HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); Tk5FieldInfoEx tk5Field = field.Convert <Tk5FieldInfoEx>(); if (tk5Field.DataType == TkDataType.Text || (tk5Field.ListDetail != null && tk5Field.ListDetail.TextHead)) { builder.Add("class", "text-left text-nowrap"); } else { builder.Add("data-sort", index.ToString()); string order = sortRow.GetString("Order"); string sortClass = string.Empty; if (index == sortField) { order = order == "DESC" ? "ASC" : "DESC"; sortClass = "sort-" + order; } builder.Add("data-order", order); builder.Add("class", HtmlUtil.MergeClass("text-left text-nowrap", sortClass.ToLower())); } return(builder.CreateAttribute()); }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue, string linkedValue) { if (rowValue == null) { return(linkedValue); } string linkUrl = ResolveRowValue(rowValue, Content); if (string.IsNullOrEmpty(linkUrl)) { return(linkedValue); } else { linkUrl = AppUtil.ResolveUrl(linkUrl); } string target; if (!string.IsNullOrEmpty(Base)) { linkUrl = UriUtil.CombineUri(Base, linkUrl).ToString(); } if (!string.IsNullOrEmpty(Target)) { target = string.Format(ObjectUtil.SysCulture, " target=\"{0}\"", Target); } else { target = string.Empty; } return(string.Format(ObjectUtil.SysCulture, "<a href=\"{0}\"{1}>{2}</a>", StringUtil.EscapeHtmlAttribute(linkUrl), target, StringUtil.EscapeHtml(linkedValue))); }
private ICellStyle BorderAndFontSetting(IWorkbook wb, Tk5FieldInfoEx metaInfo, Model model) { ICellStyle cellStyle = wb.CreateCellStyle(); if (fUseBorder) { cellStyle.BorderTop = BorderStyle.Thin; cellStyle.BorderRight = BorderStyle.Thin; cellStyle.BorderBottom = BorderStyle.Thin; cellStyle.BorderLeft = BorderStyle.Thin; } if (model == Model.Content) { IFont fontContent = ExcelUtil.FontSetting(wb, fContent); cellStyle.SetFont(fontContent); if (metaInfo.Extension != null) { ExcelUtil.AlignSetting(metaInfo.Extension.Align, cellStyle); } else { ExcelUtil.AlignSetting(fContent.Align, cellStyle); } } else { ExcelUtil.AlignSetting(fHeader.Align, cellStyle); IFont fontHeader = ExcelUtil.FontSetting(wb, fHeader); cellStyle.SetFont(fontHeader); } return(cellStyle); }
public static string DisplayValue(this Tk5FieldInfoEx field, IFieldValueProvider row) { object fieldValue = row[field.NickName]; return(DisplayUtil.GetDisplayString(field.ListDetail.ListDisplay, fieldValue, field, row)); //return DisplayValue(field, row, false); }
public static string Detail(this Tk5FieldInfoEx field, IFieldValueProvider row, bool showHint, bool needId) { TkDebug.AssertArgumentNull(field, "field", null); HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); AddNormalAttribute(field, builder, field.NickName, needId, true); object fieldValue = row[field.NickName]; builder.Add("data-value", fieldValue.ToString()); HtmlAttribute classAttr = builder["class"]; if (classAttr == null) { builder.Add("class", "detail-content"); } else { classAttr.Value = HtmlCommonUtil.MergeClass(classAttr.Value, "detail-content"); } string displayValue = DisplayUtil.GetDisplayString(field.ListDetail.DetailDisplay, fieldValue, field, row); return(string.Format(ObjectUtil.SysCulture, "<div {0}>{1}</div>", builder.CreateAttribute(), displayValue)); }
public static string Combo(this Tk5FieldInfoEx field, IFieldValueProvider row, bool needId) { TkDebug.AssertArgumentNull(field, "field", null); TkDebug.AssertArgumentNull(row, "row", null); return(InternalCombo(field, field.NickName, row, needId)); }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue) { if (DisplayUtil.IsNull(value)) { return(string.Empty); } string text = value.ToString(); int len = text.Length; if (len <= MaxLength) { return(StringUtil.EscapeXmlString(text)); } switch (DisplayMode) { case DisplayPosition.Middle: text = string.Format(ObjectUtil.SysCulture, "{0}{1}{2}", text.Substring(0, MaxLength - EndLength), AbbrString, text.Substring(len - EndLength, EndLength)); break; default: text = text.Substring(0, MaxLength) + AbbrString; break; } return(StringUtil.EscapeXmlString(text)); }
private static string InternalCombo(Tk5FieldInfoEx field, string name, DataRow row, DataSet model, bool needId) { HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); AddNormalAttribute(field, builder, name, needId); TkDebug.AssertNotNull(field.Decoder, "Combo控件需要配置Decoder", field); DataTable codeTable = model.Tables[field.Decoder.RegName]; StringBuilder options = new StringBuilder(); if (field.IsEmpty) { string emptyTitle; if (field.Extension != null && field.Extension.EmptyTitle != null) emptyTitle = field.Extension.EmptyTitle; else emptyTitle = string.Empty; options.Append("<option value=\"\">").Append(emptyTitle).AppendLine("</option>"); } string value = row.GetString(name); if (codeTable != null) { foreach (DataRow codeRow in codeTable.Rows) { string codeValue = codeRow.GetString("Value"); options.AppendFormat(ObjectUtil.SysCulture, "<option value=\"{0}\"{1}>{2}</option>\r\n", codeValue, codeValue == value ? " selected" : string.Empty, codeRow.GetString("Name")); } } return string.Format(ObjectUtil.SysCulture, "<select {0}>{1}</select>{2}", builder.CreateAttribute(), options, ERROR_LABEL); }
private static string DateControl(Tk5FieldInfoEx field, string icon, string name, string value, string format, int size, bool needId, bool isSearchCtrl) { HtmlAttributeBuilder groupBuilder = new HtmlAttributeBuilder(); groupBuilder.Add("data-control", field.InternalControl.Control); groupBuilder.Add("data-date-format", format); groupBuilder.Add("data-date", value); HtmlAttributeBuilder inputBuilder = new HtmlAttributeBuilder(); inputBuilder.Add("type", "text"); inputBuilder.Add("size", size); string deletestr; if (!field.ContainAttribute("unreadonly", true)) { inputBuilder.Add((HtmlAttribute)"readonly"); deletestr = Html.DateTimeDelete; } else { deletestr = string.Empty; } AddInputAttribute(field, inputBuilder, isSearchCtrl); AddNormalAttribute(field, inputBuilder, name, needId); inputBuilder.Add("value", value); return(string.Format(ObjectUtil.SysCulture, Html.Datetime, groupBuilder.CreateAttribute(), inputBuilder.CreateAttribute(), icon, ERROR_LABEL, deletestr)); }
private static string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue, IConfigCreator <IDisplay> displayObj) { var display = displayObj.CreateObject(); return(display.DisplayValue(value, field, rowValue)); }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue, string linkedValue) { switch (Style) { case FontStyle.Bold: return(string.Format(ObjectUtil.SysCulture, "<span class='bold'>{0}</span>", linkedValue)); case FontStyle.Italic: return(string.Format(ObjectUtil.SysCulture, "<span class='italic'>{0}</span>", linkedValue)); case FontStyle.Underline: return(string.Format(ObjectUtil.SysCulture, "<span class='underline'>{0}</span>", linkedValue)); case FontStyle.Strikeout: return(string.Format(ObjectUtil.SysCulture, "<span style='text-decoration:line-through;'>{0}</span>", linkedValue)); default: return(linkedValue); } }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue) { if (DisplayUtil.IsNull(value) || string.IsNullOrEmpty(value.ToString())) { return(string.Empty); } DateTime today = DateTime.Today; DateTime dateValue = value.Value <DateTime>(); if (today == dateValue) { return(TkWebApp.Today); } else if (today.AddDays(1) == dateValue) { return(TkWebApp.Tomorrow); } else if (today.AddDays(-1) == dateValue) { return(TkWebApp.Yesterday); } else { DateTime weekDate = today.AddDays(-6); if (dateValue > weekDate && dateValue < today) { return(dateValue.ToString("dddd", ObjectUtil.SysCulture)); } else { return(dateValue.ToString(Format, ObjectUtil.SysCulture)); } } }
private static string InternalInput(this Tk5FieldInfoEx field, string name, string value, bool needId, bool isSearchCtrl) { TkDebug.AssertArgumentNull(field, "field", null); HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); TkDebug.AssertNotNull(field.InternalControl, "field的InternalControl不能为空", field); builder.Add("type", field.InternalControl.Control); builder.Add("value", value); AddInputAttribute(field, builder, isSearchCtrl); AddNormalAttribute(field, builder, name, needId); if (field.HintPosition == HintPosition.PlaceHolder || string.IsNullOrEmpty(field.Hint)) { return(string.Format(ObjectUtil.SysCulture, "<input {0}/>{1}", builder.CreateAttribute(), ERROR_LABEL)); } else { string format; if (field.HintPosition == HintPosition.Front) { format = Html.InputHintBefore; } else { format = Html.InputHintAfter; } return(string.Format(ObjectUtil.SysCulture, format, builder.CreateAttribute(), ERROR_LABEL, field.Hint)); } }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue, string linkedValue) { string text = Expression.Execute(this); return(string.Format(ObjectUtil.SysCulture, text, linkedValue)); }
private static string EasySearch(this Tk5FieldInfoEx field, IFieldValueProvider row, bool needId, bool isSearchCtrl) { TkDebug.AssertArgumentNull(field, "field", null); return(InternalEasySearch(field, field.NickName, row, needId, isSearchCtrl)); }
private static string Time(this Tk5FieldInfoEx field, IFieldValueProvider row, bool needId, bool isSearchCtrl) { TkDebug.AssertArgumentNull(field, "field", null); return(DateControl(field, "time", field.NickName, string.Empty, "hh:ii", 5, needId, isSearchCtrl)); }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue) { IDisplay display = CoreDisplay.CreateObject(); if (display == null) { return(string.Empty); } string linkValue = display.DisplayValue(value, field, rowValue); if (DecorateDisplays == null) { return(linkValue); } foreach (var item in DecorateDisplays) { var decorateDisplay = item.CreateObject(); if (decorateDisplay == null) { continue; } linkValue = decorateDisplay.DisplayValue(value, field, rowValue, linkValue); } return(linkValue); }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue) { TkDebug.AssertArgumentNull(field, "field", this); if (DisplayUtil.IsNull(value)) { return(string.Empty); } if (field.Upload != null) { Tk5UploadConfig upload = field.AssertUpload(); IUploadProcessor2 processor = upload.CreateUploadProcessor2(); //IFieldValueProvider provider = new DataRowFieldValueProvider(row, row.Table.DataSet); string url = processor.Display(upload, rowValue); HtmlAttribute cssAttr = string.IsNullOrEmpty(CssClass) ? null : new HtmlAttribute("class", CssClass); HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); builder.Add("src", url); builder.Add(cssAttr); return(string.Format(ObjectUtil.SysCulture, "<img {0} />", builder.CreateAttribute())); } return(string.Empty); }
private static string InputEnd(Tk5FieldInfoEx field, DataRow row) { TkDebug.AssertArgumentNull(field, "field", null); string name = GetSearchEndName(field); string value = FormatNumber(field, name, row); return InternalInput(field, name, value, true); }
public static string Switcher(this Tk5FieldInfoEx field, IFieldValueProvider row, bool needId) { TkDebug.AssertArgumentNull(field, "field", null); HtmlAttributeBuilder builder = InternalCheckBox(field, row, needId); return(string.Format(ObjectUtil.SysCulture, Html.Switcher, builder.CreateAttribute())); }
internal static string DateTimeEnd(Tk5FieldInfoEx field, IFieldValueProvider row) { string name = GetSearchEndName(field); object fieldValue = row[name + "END"]; string value = DisplayUtil.GetDisplayString(field.Edit.Display, fieldValue, field, row); return(DateControl(field, "th", name, value, "yyyy-mm-dd hh:ii", 16, true, true)); }
private static string DisplayValue(Tk5FieldInfoEx field, ObjectContainer container, bool showHint) { TkDebug.AssertArgumentNull(field, "field", null); //if (field.Upload != null) // return DisplayUpload(field, row); object receiver = container.MainObject; string displayValue = string.Empty; string value = string.Empty; try { value = receiver.MemberValue(field.NickName).ConvertToString(); if (field.Decoder == null || field.Decoder.Type == DecoderType.None) displayValue = FormatNumber(field, field.NickName, receiver); else displayValue = container.Decoder.GetNameString(field.NickName); } catch { displayValue = value; } if (showHint) { if (!string.IsNullOrEmpty(field.Hint)) displayValue += " " + field.Hint; } if (field.ListDetail != null && field.ListDetail.Link != null) { var link = field.ListDetail.Link; string linkUrl = string.Empty; string target = string.Empty; switch (link.RefType) { case LinkRefType.Href: linkUrl = HtmlUtil.ParseLinkUrl(receiver, link.Content); linkUrl = WebUtil.ResolveUrl(linkUrl); if (!string.IsNullOrEmpty(link.Base)) linkUrl = UriUtil.CombineUri(link.Base, linkUrl).ToString(); if (!string.IsNullOrEmpty(link.Target)) target = string.Format(ObjectUtil.SysCulture, " target=\"{0}\"", link.Target); break; case LinkRefType.Http: if (!value.StartsWith("http", StringComparison.OrdinalIgnoreCase)) linkUrl = "http://"; linkUrl += value; target = " target=\"_blank\""; break; case LinkRefType.Email: linkUrl = "mailto:" + value; target = " target=\"_blank\""; break; } return string.Format(ObjectUtil.SysCulture, "<a href=\"{0}\"{1}>{2}</a>", StringUtil.EscapeHtmlAttribute(linkUrl), target, StringUtil.EscapeHtml(displayValue)); } return displayValue; }
public static String ControlHtml(this Tk5FieldInfoEx field, IFieldValueProvider provider, bool needId) { string ctrl = field.ControlName; BasePlugInFactory factroy = BaseGlobalVariable.Current .FactoryManager.GetCodeFactory(ControlHtmlPlugInFactory.REG_NAME); return(GetCtrlHtml(field, provider, ctrl, factroy, needId)); }
public string GetHtml(Tk5FieldInfoEx field, IFieldValueProvider provider, bool needId) { TkDebug.AssertArgumentNull(field, "field", this); string startHtml = field.EasySearch(provider, true); string endHtml = HtmlCommonExtension.EasySearchEnd(field, provider); return(HtmlCommonUtil.GetRangeCtrl(startHtml, endHtml)); }
private static string Input(this Tk5FieldInfoEx field, IFieldValueProvider row, bool needId, bool isSearchCtrl) { TkDebug.AssertArgumentNull(field, "field", null); object fieldValue = row[field.NickName]; // DisplayUtil.GetValue(field.NickName, row); string value = DisplayUtil.GetDisplayString(field.Edit.Display, fieldValue, field, row); return(InternalInput(field, field.NickName, value, needId, isSearchCtrl)); }
internal static string InputEnd(Tk5FieldInfoEx field, IFieldValueProvider row) { TkDebug.AssertArgumentNull(field, "field", null); string name = GetSearchEndName(field); object fieldValue = row[name]; // DisplayUtil.GetValue(name, row); string value = DisplayUtil.GetDisplayString(field.Edit.Display, fieldValue, field, row); return(InternalInput(field, name, value, true, true)); }
public static string DisplayUpload(this Tk5FieldInfoEx field, IFieldValueProvider row) { TkDebug.AssertArgumentNull(field, "field", null); Tk5UploadConfig upload = field.AssertUpload(); IUploadProcessor2 processor = upload.CreateUploadProcessor2(); return(processor.Display(upload, row)); }
public static string GetDisplayString(IConfigCreator <IDisplay> display, object value, Tk5FieldInfoEx field, IFieldValueProvider row) { TkDebug.AssertArgumentNull(display, "display", null); TkDebug.AssertArgumentNull(field, "field", null); var displayObj = display.CreateObject(); return(displayObj.DisplayValue(value, field, row)); }
private static string DateTime(this Tk5FieldInfoEx field, IFieldValueProvider row, bool needId, bool isSearchCtrl) { TkDebug.AssertArgumentNull(field, "field", null); object fieldValue = row[field.NickName]; string value = DisplayUtil.GetDisplayString(field.Edit.Display, fieldValue, field, row); return(DateControl(field, "th", field.NickName, value, "yyyy-mm-dd hh:ii", 16, needId, isSearchCtrl)); }
private static string InternalHidden(Tk5FieldInfoEx field, string value, bool needId) { HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); builder.Add("type", "hidden"); builder.Add("value", value); AddNormalAttribute(field, builder, field.NickName, needId, true); return(string.Format(ObjectUtil.SysCulture, "<input {0}/>", builder.CreateAttribute())); }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue) { if (string.IsNullOrEmpty(Content)) { return(string.Empty); } return(EvaluatorUtil.Execute <string>(Content, ("value", value), ("row", rowValue))); }
private static string FormatNumber(Tk5FieldInfoEx field, string fieldName, DataRow row) { object value = null; try { value = row[fieldName]; } catch { } return InternalFormatNumber(field, value); }
private static string InternalTextArea(Tk5FieldInfoEx field, DataRow row, HtmlAttribute addition, bool needId) { TkDebug.AssertArgumentNull(field, "field", null); HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); AddInputAttribute(field, builder); AddNormalAttribute(field, builder, field.NickName, needId); builder.Add(addition); return string.Format(ObjectUtil.SysCulture, "<textarea {0}>{1}</textarea>{2}", builder.CreateAttribute(), StringUtil.EscapeHtml(row.GetString(field.NickName)), ERROR_LABEL); }
public static int GetColWidth(Tk5FieldInfoEx fieldInfo) { int columnWith = 0; // 汉字宽度与excel字符宽度的转换 int titleLength = fieldInfo.DisplayName.Length * 2 + 4; if (fieldInfo.ListDetail != null && fieldInfo.ListDetail.ListWidth > 0) columnWith = fieldInfo.ListDetail.ListWidth / 7 + 4; else { if (fieldInfo.InternalControl != null && fieldInfo.InternalControl.SrcControl == ControlType.CheckBox) columnWith = 6; else { switch (fieldInfo.DataType) { case TkDataType.Date: columnWith = 14; break; case TkDataType.DateTime: columnWith = 20; break; case TkDataType.Long: case TkDataType.Int: case TkDataType.Double: case TkDataType.Decimal: case TkDataType.Text: case TkDataType.Guid: case TkDataType.Xml: if (fieldInfo.Length > 0 && fieldInfo.Length < 12) columnWith = fieldInfo.Length + 4; else if (fieldInfo.Length >= 12) columnWith = 16; break; case TkDataType.Short: case TkDataType.Byte: columnWith = 8; break; case TkDataType.String: if (fieldInfo.Length > 0) columnWith = ((fieldInfo.Length / 3) > 70) ? 70 : (fieldInfo.Length / 3); else columnWith = 16; break; } } } return ((columnWith > titleLength) ? columnWith : titleLength); }
public static void CellPadding(string value, ICell cell, Tk5FieldInfoEx fieldInfo) { Tk5ExtensionConfig exConfig = fieldInfo.Extension; if (exConfig != null && exConfig.Format != null) { string strformat = string.Format(ObjectUtil.SysCulture, "{{0:{0}}}", exConfig.Format); string result = string.Format(ObjectUtil.SysCulture, strformat, value); cell.SetCellValue(result); } else { switch (fieldInfo.DataType) { case TkDataType.Long: case TkDataType.Int: case TkDataType.Short: case TkDataType.Byte: case TkDataType.Double: case TkDataType.Decimal: case TkDataType.Money: double number = value.Value<double>(); cell.SetCellValue(number); break; case TkDataType.String: case TkDataType.Text: case TkDataType.Guid: case TkDataType.Xml: cell.SetCellValue(value); break; case TkDataType.DateTime: case TkDataType.Date: DateTime dt = value.Value<DateTime>(); cell.SetCellValue(dt); break; } } }
private static string InternalMultiEasySearch(Tk5FieldInfoEx field, string nickName, DataRow row, bool needId) { HtmlAttributeBuilder textBuilder = new HtmlAttributeBuilder(); textBuilder.Add("type", "text"); textBuilder.Add("data-regName", field.Decoder.RegName); AddInputAttribute(field, textBuilder); AddNormalAttribute(field, textBuilder, nickName, needId); StringBuilder multiItems = new StringBuilder(); string decodeValue = row.GetString(nickName + "_Name"); if (string.IsNullOrEmpty(decodeValue)) multiItems.AppendFormat(Html.MultiEasySearchItem, "hidden", string.Empty, string.Empty); else { MultipleDecoderData data = MultipleDecoderData.ReadFromString(decodeValue); HtmlAttributeBuilder decodeBuilder = new HtmlAttributeBuilder(); foreach (var item in data) { decodeBuilder.Clear(); decodeBuilder.Add("data-id", item.Value); decodeBuilder.Add("data-name", item.Name); multiItems.AppendFormat(Html.MultiEasySearchItem, "multi-item", item.Name, decodeBuilder.CreateAttribute()); } } string easyUrl = "Library/WebModuleContentPage.tkx?Source=EasySearch&useSource=true".AppVirutalPath(); string dialogUrl = ("Library/WebModuleRedirectPage.tkx?Source=EasySearchRedirect&useSource=true&RegName=" + field.Decoder.RegName).AppVirutalPath(); return string.Format(ObjectUtil.SysCulture, Html.MultipleEasySearch, multiItems, textBuilder.CreateAttribute(), ERROR_LABEL, StringUtil.EscapeHtmlAttribute(easyUrl), StringUtil.EscapeHtmlAttribute(dialogUrl)); }
private static string ComboEnd(Tk5FieldInfoEx field, DataRow row, DataSet model) { string name = GetSearchEndName(field); return InternalCombo(field, name, row, model, true); }
private static string FormatNumber(Tk5FieldInfoEx field, string fieldName, object receiver) { object value = MemberValue(fieldName, receiver); return InternalFormatNumber(field, value); }
private static string DisplayValue(Tk5FieldInfoEx field, DataRow row, bool showHint) { TkDebug.AssertArgumentNull(field, "field", null); if (field.Upload != null) return DisplayUpload(field, row); string displayValue = string.Empty; string value = string.Empty; try { value = row[field.NickName].ToString(); if (field.Decoder == null || field.Decoder.Type == DecoderType.None) displayValue = FormatNumber(field, field.NickName, row); else { ControlType ctrlType = field.InternalControl.SrcControl; string rowValue = row[field.NickName + "_Name"].ToString(); if (ctrlType == ControlType.CheckBoxList || ctrlType == ControlType.MultipleEasySearch) { MultipleDecoderData data = MultipleDecoderData.ReadFromString(rowValue); displayValue = string.Join(", ", data); } else displayValue = rowValue; } } catch { displayValue = value; } if (showHint) { if (!string.IsNullOrEmpty(field.Hint)) displayValue += " " + field.Hint; } if (field.ListDetail != null && field.ListDetail.Link != null) { var link = field.ListDetail.Link; string linkUrl = string.Empty; string target = string.Empty; switch (link.RefType) { case LinkRefType.Href: linkUrl = HtmlUtil.ParseLinkUrl(row, link.Content); linkUrl = WebUtil.ResolveUrl(linkUrl); if (!string.IsNullOrEmpty(link.Base)) linkUrl = UriUtil.CombineUri(link.Base, linkUrl).ToString(); if (!string.IsNullOrEmpty(link.Target)) target = string.Format(ObjectUtil.SysCulture, " target=\"{0}\"", link.Target); break; case LinkRefType.Http: if (!value.StartsWith("http", StringComparison.OrdinalIgnoreCase)) linkUrl = "http://"; linkUrl += value; target = " target=\"_blank\""; break; case LinkRefType.Email: linkUrl = "mailto:" + value; target = " target=\"_blank\""; break; } return string.Format(ObjectUtil.SysCulture, "<a href=\"{0}\"{1}>{2}</a>", StringUtil.EscapeHtmlAttribute(linkUrl), target, StringUtil.EscapeHtml(displayValue)); } return displayValue; }
// 导出checkbox下拉菜单选项 private static IEnumerable<IDecoderItem> GetDecoderItem(Tk5FieldInfoEx fieldInfo) { CodeTableContainer ctContainer = new CodeTableContainer(); string regName = fieldInfo.Decoder.RegName; CodeTable codeTable = PlugInFactoryManager.CreateInstance<CodeTable>( CodeTableConfigFactory.REG_NAME, regName); codeTable.Fill(ctContainer); IEnumerable<IDecoderItem> data = ctContainer[regName]; return data; }
private static HtmlAttributeBuilder InternalCheckBox(Tk5FieldInfoEx field, DataRow row, bool needId) { string checkValue; string uncheckValue; GetCheckValue(field, out checkValue, out uncheckValue); HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); builder.Add("type", "checkbox"); builder.Add("value", checkValue); builder.Add("data-uncheck-value", uncheckValue); if (row.GetString(field.NickName) == checkValue) builder.Add((HtmlAttribute)"checked"); AddNormalAttribute(field, builder, field.NickName, needId, true); return builder; }
private static string InternalEasySearch(Tk5FieldInfoEx field, string nickName, DataRow row, bool needId) { HtmlAttributeBuilder hiddenBuilder = new HtmlAttributeBuilder(); hiddenBuilder.Add("type", "hidden"); hiddenBuilder.Add("value", row.GetString(nickName)); string hiddenName = "hd" + nickName; if (needId) hiddenBuilder.Add("id", hiddenName); hiddenBuilder.Add("name", hiddenName); HtmlAttributeBuilder textBuilder = new HtmlAttributeBuilder(); textBuilder.Add("type", "text"); textBuilder.Add("data-regName", field.Decoder.RegName); AddInputAttribute(field, textBuilder); AddNormalAttribute(field, textBuilder, nickName, needId); textBuilder.Add("value", row.GetString(nickName + "_Name")); string easyUrl = "Library/WebModuleContentPage.tkx?Source=EasySearch&useSource=true".AppVirutalPath(); string dialogUrl = ("Library/WebModuleRedirectPage.tkx?Source=EasySearchRedirect&useSource=true&RegName=" + field.Decoder.RegName).AppVirutalPath(); return string.Format(ObjectUtil.SysCulture, Html.EasySearch, hiddenBuilder.CreateAttribute(), textBuilder.CreateAttribute(), ERROR_LABEL, StringUtil.EscapeHtmlAttribute(easyUrl), StringUtil.EscapeHtmlAttribute(dialogUrl)); }
private static string DateTimeEnd(Tk5FieldInfoEx field, DataRow row) { string name = GetSearchEndName(field); string value = row.GetDateTime(name, "yyyy-MM-dd hh:mm"); return DateControl(field, "th", name, value, "yyyy-mm-dd hh:ii", 16, true); }
private static string EasySearchEnd(Tk5FieldInfoEx field, DataRow row) { string name = GetSearchEndName(field); return InternalEasySearch(field, name, row, true); }
private static string InternalCombo(Tk5FieldInfoEx field, string name, ObjectContainer container, CodeTableContainer codeTables, bool needId) { HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); AddNormalAttribute(field, builder, name, needId); TkDebug.AssertNotNull(field.Decoder, "Combo控件需要配置Decoder", field); IEnumerable<IDecoderItem> codeTable = codeTables == null ? null : codeTables[field.Decoder.RegName]; StringBuilder options = new StringBuilder(); if (field.IsEmpty) { string emptyTitle; if (field.Extension != null && field.Extension.EmptyTitle != null) emptyTitle = field.Extension.EmptyTitle; else emptyTitle = string.Empty; options.Append("<option value=\"\">").Append(emptyTitle).AppendLine("</option>"); } string value = MemberValue(field.NickName, container.MainObject).ConvertToString(); if (codeTable != null) { foreach (IDecoderItem codeRow in codeTable) { string codeValue = codeRow.Value; options.AppendFormat(ObjectUtil.SysCulture, "<option value=\"{0}\"{1}>{2}</option>\r\n", codeValue, codeValue == value ? " selected" : string.Empty, codeRow.Name); } } return string.Format(ObjectUtil.SysCulture, "<select {0}>{1}</select>{2}", builder.CreateAttribute(), options, ERROR_LABEL); }
internal static ICellStyle BorderAndFontSetting(IWorkbook workbook, ExportExcelPageMaker configData, Tk5FieldInfoEx metaInfo, Model model) { ICellStyle cellStyle = workbook.CreateCellStyle(); if (configData.UserBorder) { cellStyle.BorderTop = BorderStyle.Thin; cellStyle.BorderRight = BorderStyle.Thin; cellStyle.BorderBottom = BorderStyle.Thin; cellStyle.BorderLeft = BorderStyle.Thin; } if (model == Model.Content) { IFont fontContent = FontSetting(workbook, configData.Content); cellStyle.SetFont(fontContent); if (metaInfo.Extension != null) { AlignSetting(metaInfo.Extension.Align, cellStyle); } else { AlignSetting(configData.Content.Align, cellStyle); } } else { AlignSetting(configData.Header.Align, cellStyle); IFont fontHeader = FontSetting(workbook, configData.Header); cellStyle.SetFont(fontHeader); } return cellStyle; }
//数据有效性以及下拉框的设置 private static HSSFDataValidation CreateDataValidation(int index, Tk5FieldInfoEx fieldInfo) { CellRangeAddressList region = new CellRangeAddressList(1, 65535, index, index); DVConstraint constraint = null; HSSFDataValidation dataValidate = null; if (fieldInfo.Decoder != null && fieldInfo.Decoder.Type == DecoderType.CodeTable) { IEnumerable<IDecoderItem> data = GetDecoderItem(fieldInfo); if (data != null) { List<string> optionList = new List<string>(); foreach (IDecoderItem item in data) { if (item != null) { TkDebug.AssertArgumentNullOrEmpty(item.Name, "item.Name", null); optionList.Add(item.Name); } } constraint = DVConstraint.CreateExplicitListConstraint(optionList.ToArray()); } } else { if (fieldInfo.InternalControl != null && fieldInfo.InternalControl.SrcControl == ControlType.CheckBox) { constraint = DVConstraint.CreateExplicitListConstraint(new string[] { "√", "" }); } else { switch (fieldInfo.DataType) { case TkDataType.DateTime: case TkDataType.Date: constraint = DVConstraint.CreateDateConstraint(6, "1900-01-01", null, "yyyy-MM-dd"); break; case TkDataType.Double: case TkDataType.Decimal: case TkDataType.Money: constraint = DVConstraint.CreateNumericConstraint(2, 1, "1", "0"); break; case TkDataType.Long: case TkDataType.Int: case TkDataType.Short: case TkDataType.Byte: case TkDataType.Bit: constraint = DVConstraint.CreateNumericConstraint(1, 1, "1", "0"); break; default: break; } } } if (constraint != null) { dataValidate = new HSSFDataValidation(region, constraint); dataValidate.CreateErrorBox("error", "You must input a valid value!"); } return dataValidate; }
internal static int GetColWidth(Tk5FieldInfoEx fieldInfo) { int columnWith = 0; // 汉字宽度与excel字符个数转换 int length = fieldInfo.DisplayName.Length * 2 + 1; if (fieldInfo.ListDetail != null && fieldInfo.ListDetail.ListWidth > 0) columnWith = fieldInfo.ListDetail.ListWidth / 7 + 1; else { if (fieldInfo.InternalControl != null && fieldInfo.InternalControl.SrcControl == ControlType.CheckBox) columnWith = 2; else { switch (fieldInfo.DataType) { case TkDataType.Date: columnWith = 12; break; case TkDataType.DateTime: columnWith = 18; break; case TkDataType.Long: case TkDataType.Int: case TkDataType.Double: case TkDataType.Decimal: case TkDataType.String: case TkDataType.Text: case TkDataType.Guid: case TkDataType.Xml: if (fieldInfo.Length > 0 && fieldInfo.Length < 10) { columnWith = fieldInfo.Length; } else columnWith = 10; break; case TkDataType.Short: case TkDataType.Byte: columnWith = 6; break; } } } return ((columnWith > length) ? columnWith : length); }
//数据有效性以及下拉框的设置 public static HSSFDataValidation CreateDataValidation(int index, Tk5FieldInfoEx fieldInfo, ICellStyle styleContent, HSSFWorkbook workbook) { IDataFormat format = workbook.CreateDataFormat(); CellRangeAddressList region = new CellRangeAddressList(1, 65535, index, index); DVConstraint constraint = null; HSSFDataValidation dataValidation = null; if (fieldInfo.Decoder != null && fieldInfo.Decoder.Type == DecoderType.CodeTable) { IEnumerable<IDecoderItem> data = GetDecoderItem(fieldInfo); if (data != null) { List<string> optionList = new List<string>(); foreach (IDecoderItem item in data) { if (item != null) { TkDebug.AssertArgumentNullOrEmpty(item.Name, "item.Name", null); optionList.Add(item.Name); } } constraint = DVConstraint.CreateExplicitListConstraint(optionList.ToArray()); dataValidation = DisplayMsg(region, constraint, "请从下拉框选项中选择"); } } else { if (fieldInfo.InternalControl != null && fieldInfo.InternalControl.SrcControl == ControlType.CheckBox) { constraint = DVConstraint.CreateExplicitListConstraint(new string[] { "√" }); dataValidation = DisplayMsg(region, constraint, "请在下拉框选项中进行选择"); } else { switch (fieldInfo.DataType) { case TkDataType.DateTime: case TkDataType.Date: if (fieldInfo.DataType == TkDataType.DateTime) styleContent.DataFormat = format.GetFormat("yyyy-MM-dd HH:mm"); else styleContent.DataFormat = format.GetFormat("yyyy-MM-dd"); constraint = DVConstraint.CreateDateConstraint(6, "1900-01-01", null, "yyyy-MM-dd"); dataValidation = DisplayMsg(region, constraint, "请输入一个日期类型的值"); break; case TkDataType.Double: case TkDataType.Decimal: case TkDataType.Money: constraint = DVConstraint.CreateNumericConstraint(2, 1, "1", "0"); dataValidation = DisplayMsg(region, constraint, "请输入数值类型的值"); styleContent.DataFormat = format.GetFormat("0"); break; case TkDataType.Long: case TkDataType.Int: case TkDataType.Short: case TkDataType.Byte: case TkDataType.Bit: constraint = DVConstraint.CreateNumericConstraint(1, 1, "1", "0"); dataValidation = DisplayMsg(region, constraint, "请输入一个整数"); styleContent.DataFormat = format.GetFormat("0"); break; default: styleContent.DataFormat = format.GetFormat("@"); break; } } } return dataValidation; }