public string GetDate(ExtControlBase controlBase) { string colXtype = controlBase.XType; //掩码是yyyy-mm-dd hh:mm:ss if (controlBase.Format.Length > 11) { colXtype = "ngDateTime"; } sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', name: '{3}', id: '{3}', itemId: '{3}', mustInput: {4}, colspan: {5}, hidden: {6}, readOnly: {7}, x:{8}, y:{9}, width:{10}, value:'{11}', fieldStyle:'color:{12}', labelStyle:'color:{13}' ", colXtype, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue, controlBase.FieldStyle, controlBase.LabelStyle); return(sb); }
//获取二维数组的字段信息 private List <List <ExtControlBase> > GetFieldsRows(Dictionary <int, SortedList <int, PbBaseControlInfo> > dic, FieldSet fset, TableLayoutForm lForm) { List <List <ExtControlBase> > fieldRows = new List <List <ExtControlBase> >(); ExtControlBase extControl = null; foreach (var item in dic) { List <ExtControlBase> list = new List <ExtControlBase>(); foreach (var control in item.Value) { extControl = ControlConverter.ConvertToExtControl(control.Value); list.Add(extControl); if (fset != null) { fset.AllFields.Add(extControl); } if (lForm != null) { lForm.AllFields.Add(extControl); } } if (list.Count > 0) { fieldRows.Add(list); } } return(fieldRows); }
public string GetDisplayField(ExtControlBase controlBase, int ColumnsPerRow) { NGLabel ngLabel = new NGLabel(); ngLabel = controlBase as NGLabel; sb = string.Format(@" xtype: '{0}', value: Lang.{2}||'{1}', name: '{3}', id: '{3}', itemId: '{3}', colspan: {4}, hidden: {5}, x:{6}, y:{7}, width:{8}, fieldStyle:'{9}', labelSeparator: '' ", controlBase.XType, ngLabel.Text, FormTableName + "_" + controlBase.Name, controlBase.Name, ngLabel.IsTitle.Equals(true) && ColumnsPerRow != 0 ? ColumnsPerRow.ToString() : controlBase.ColSpan.ToString(), controlBase.Visible.Equals(true) ? "false" : "true", controlBase.XPos, controlBase.YPos, controlBase.LabelWidth, controlBase.FieldStyle); if (ngLabel.IsTitle) { sb += ",anchor: '100%'"; } return(sb); }
public string GetngTextArea(ExtControlBase controlBase) { sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', name: '{3}', id: '{3}', itemId: '{3}', mustInput: {4}, colspan: {5}, hidden: {6}, readOnly: {7}, x: {8}, y: {9}, width: {10}, height: {11}, value: '{12}', emptyText: '{13}', maxLength: {14}, fieldStyle:'color:{15}', labelStyle:'color:{16}' ", controlBase.XType, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.Height, controlBase.DefaultValue, controlBase.Tag, controlBase.MaxLength == 0 ? "Number.MAX_VALUE" : Convert.ToString(controlBase.MaxLength), controlBase.FieldStyle, controlBase.LabelStyle); return(sb); }
public string GetngNumber(ExtControlBase controlBase) { string showPercent = "false"; //掩码中有% if (controlBase.EditMask.IndexOf("%") >= 0) { showPercent = "true"; } //小数位数 int decimalPrecision = 2; if (string.IsNullOrEmpty(controlBase.EditMask)) { controlBase.EditMask = "0,000"; decimalPrecision = 0; } else if (controlBase.EditMask.IndexOf(".") >= 0) { decimalPrecision = controlBase.EditMask.Split(new string[] { "." }, StringSplitOptions.None)[1].Length; if (controlBase.EditMask.IndexOf("%") >= 0) { decimalPrecision++; } } else { decimalPrecision = 0; } sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', name: '{3}', id: '{3}', itemId: '{3}', mustInput: {4}, colspan: {5}, hidden: {6}, readOnly: {7}, x: {8}, y: {9}, width: {10}, value: '{11}', showPercent: {12}, fieldStyle:'text-align:right;color: {13}', decimalPrecision: {14}, labelStyle:'color:{15}', isMarginRight: false ", controlBase.XType, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue, showPercent, controlBase.FieldStyle, decimalPrecision, controlBase.LabelStyle); return(sb); }
public string GetngRadio(ExtControlBase controlBase) { NGRadio ngRadio = new NGRadio(); ngRadio = controlBase as NGRadio; sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', id: '{3}_code', itemId: '{3}_code', name: '{3}_name', mustInput: {4}, colspan: {5}, hidden: {6}, readOnly: {7}, x:{8}, y:{9}, width:{10}, vertical: true, labelSeparator: '', items:[ ", "radiogroup", controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width); for (int i = 0; i < ngRadio.Items.Count; i++) { //若是必输项,则默认选中第一项 if (controlBase.MustInput && i == 0) { sb += "\t\t\t\t\t\t\t\t{" + ngRadio.Items[i] + ", checked: true" + "}"; } else { sb += "\t\t\t\t\t\t\t\t{" + ngRadio.Items[i] + "}"; } if (i == ngRadio.Items.Count - 1) { sb += "\r\n"; } else { sb += ",\r\n"; } } sb += "\t\t\t\t\t\t\t]\r\n\t\t\t\t\t\t"; return(sb); }
//form列获取 public string GetngCustomFormHelp(ExtControlBase controlBase) { NGCommonHelp commonHelp = new NGCommonHelp(); commonHelp = controlBase as NGCommonHelp; string colXtype = commonHelp.XType; //是多选帮助 if (commonHelp.MultiSelect) { colXtype = "ngCustFormMutilHelp"; } sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', name: '{3}', id: '{3}', itemId: '{3}', mustInput: {4}, colspan: {5}, valueField: '{6}', displayField: '{7}', listFields: '{8}', listHeadTexts: '{9}', helpid: '{10}', hidden: {11}, readOnly: {12}, x: {13}, y: {14}, width: {15}, value: '{16}', fieldStyle:'color:{17}', labelStyle:'color:{18}' ", colXtype, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, commonHelp.ValueField, commonHelp.DisplayField, commonHelp.ListFields, commonHelp.ListHeadTexts, commonHelp.Helpid, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue, controlBase.FieldStyle, controlBase.LabelStyle); return(sb); }
public string GetButton(ExtControlBase controlBase) { NGButton ngButton = new NGButton(); ngButton = controlBase as NGButton; sb = string.Format(@" xtype: '{0}', name: '{1}', id: '{2}', text: Lang.{1}||'{3}', colspan: {4}, hidden: {5}, x:{6}, y:{7}, width:{8} ", controlBase.XType, controlBase.Name, controlBase.Name, ngButton.FieldLabel, '2', controlBase.Visible.Equals(true) ? "false" : "true", controlBase.XPos, controlBase.YPos, controlBase.Width); return(sb); }
public string GetOtherForm(ExtControlBase controlBase) { sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', name: '{3}', id: '{3}', itemId: '{3}', mustInput: {4}, colspan: {5}, hidden: {6}, readOnly: {7}, x: {8}, y: {9}, width: {10}, value: '{11}' ", controlBase.XType, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue); return(sb); }
public string GetngCheckbox(ExtControlBase controlBase) { NGCheckbox ngcheckbox = new NGCheckbox(); ngcheckbox = controlBase as NGCheckbox; sb = string.Format(@" xtype: '{0}', boxLabel: Lang.{2}||'{1}', name: '{3}', id: '{3}', itemId: '{3}', mustInput: {4}, colspan: {5}, readOnly: {6}, x:{7}, y:{8}, width:{9}, inputValue:1 ", ngcheckbox.XType, ngcheckbox.FieldLabel, FormTableName + "_" + ngcheckbox.Name, ngcheckbox.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width); return(sb); }
public static List <ExtGridColumn> GetListColumns(IList <PbBaseTextInfo> pbcontrols) { SortedList <int, PbBaseControlInfo> list = new SortedList <int, PbBaseControlInfo>(); List <ExtGridColumn> columns = new List <ExtGridColumn>(); foreach (PbBaseControlInfo item in pbcontrols) { if (list.ContainsKey(item.XPos)) //如果x坐标重复,则跳过 //0000000038 这里有重复的 { continue; } list.Add(item.XPos, item);//以x坐标排序 } foreach (KeyValuePair <int, PbBaseControlInfo> element in list) { PbBaseTextInfo textInfo = element.Value as PbBaseTextInfo; if (textInfo != null) { ExtGridColumn col = new ExtGridColumn(); col.Header = textInfo.LeftText; col.DataIndex = textInfo.Name; col.Datatype = SqlTypeConverter.ConvertToExtControl(textInfo.ColumnInfo.ColumnDataType); ExtControlBase column = ControlConverter.ConvertToExtControl(textInfo); //转换下xtype的类型; col.editor.XType = column.XType; if (col.editor.XType == "ngRadio") { var temp = column as NGRadio; col.editor.Items = temp.Items; } columns.Add(col); } } return(columns); }
public static ExtControlBase ConvertToExtControl(PbBaseControlInfo pbcontrol) { ExtControlBase extControl = null; switch (pbcontrol.ControlType) { case PbControlType.Label: extControl = GetLabel(pbcontrol); break; case PbControlType.Button: extControl = GetButton(pbcontrol); break; case PbControlType.Checkbox: extControl = GetCheckBox(pbcontrol); break; case PbControlType.ComboBox: extControl = GetCombox(pbcontrol); break; case PbControlType.DateTimeText: extControl = GetDate(pbcontrol); break; case PbControlType.DecimalText: extControl = GetNumber(pbcontrol); break; case PbControlType.IntText: extControl = GetNumber(pbcontrol); break; case PbControlType.Radiobox: extControl = GetRadio(pbcontrol); break; case PbControlType.Text: extControl = GetText(pbcontrol); break; case PbControlType.DataHelpEdit: DataRow[] drs = HelpDac.RichHelpDT.Select("helpid='" + ((PbDataHelpEditInfo)pbcontrol).DataHelpId + "'"); if (drs.Length > 0) { extControl = GetRichHelp(pbcontrol, drs[0]); } else { extControl = GetCustomFormHelp(pbcontrol); } break; default: extControl = GetText(pbcontrol); break; } extControl.XPos = Convert.ToInt32(pbcontrol.XPos * 1.3); extControl.YPos = Convert.ToInt32(pbcontrol.YPos); extControl.Width = Convert.ToInt32(pbcontrol.Width * 1.3); extControl.Height = Convert.ToInt32(pbcontrol.Height); extControl.SingleText = pbcontrol.SingleText; extControl.LabelWidth = Convert.ToInt32(pbcontrol.LabelWidth * 1.3); extControl.DefaultValue = pbcontrol.DefaultValue; extControl.Tag = pbcontrol.Tag; extControl.ColSpan = pbcontrol.ColSpan; extControl.Format = pbcontrol.Format; extControl.EditMask = pbcontrol.EditMask; return(extControl); }
public string GetngRichHelp(ExtControlBase controlBase) { NGCommonHelp richHelp = new NGCommonHelp(); richHelp = controlBase as NGCommonHelp; //是组件类型 if (!string.IsNullOrEmpty(richHelp.CmpName)) { string isValidate = "false"; if (richHelp.CmpName == "WbsHelpField" || richHelp.CmpName == "CbsHelpField") { isValidate = "true"; } sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', name: '{3}', id: '{3}', itemId: '{3}', mustInput: {4}, colspan: {5}, //helpid: '{6}', ORMMode: {7}, hidden: {8}, readOnly: {9}, x: {10}, y: {11}, width: {12}, value: '{13}', fieldStyle: 'color:{14};', labelStyle: 'color:{15}', acceptInput: {16} ", richHelp.CmpName, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, richHelp.Helpid, "true", controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue, controlBase.FieldStyle, controlBase.LabelStyle, isValidate); } else { string colXtype = richHelp.XType; //是多选帮助 if (richHelp.MultiSelect) { colXtype = "ngMultiRichHelp"; } sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', name: '{3}', id: '{3}', itemId: '{3}', mustInput: {4}, colspan: {5}, valueField: '{6}', displayField: '{7}', listFields: '{8}', listHeadTexts: '{9}', helpid: '{10}', ORMMode: {11}, hidden: {12}, readOnly: {13}, x: {14}, y: {15}, width: {16}, value: '{17}', fieldStyle:'color:{18}', labelStyle:'color:{19}' ", colXtype, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, richHelp.ValueField, richHelp.DisplayField, richHelp.ListFields, richHelp.ListHeadTexts, richHelp.Helpid, "false", controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue, controlBase.FieldStyle, controlBase.LabelStyle); } return(sb); }
public string GetngComboBox(ExtControlBase controlBase) { if (controlBase is NGComboBox) { sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', id: '{3}', name: '{3}', mustInput: {4}, colspan: {5}, hidden: {6}, readOnly: {7}, x: {8}, y: {9}, width: {10}, value: '{11}', fieldStyle:'color:{12}', labelStyle:'color:{13}', editable: false, trigger1Cls: 'x-form-clear-trigger', onTrigger1Click: function () {{ this.clearValue(); }}, queryMode: 'local', valueField: 'code', displayField: 'name', data:[ ", "ngComboBox", controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue, controlBase.FieldStyle, controlBase.LabelStyle); NGComboBox ngComboBox = controlBase as NGComboBox; for (int i = 0; i < ngComboBox.Data.Count; i++) { sb += "\t\t\t\t\t\t\t\t{" + ngComboBox.Data[i] + "}"; if (i == ngComboBox.Data.Count - 1) { sb += "\r\n"; } else { sb += ",\r\n"; } } } else if (controlBase is NGCommonHelp) { sb = string.Format(@" xtype: '{0}', fieldLabel: '{1}', name: '{2}', id: '{2}', itemId: '{2}', mustInput: {3}, colspan: {4}, hidden: {5}, readOnly: {6}, x: {7}, y: {8}, width: {9}, editable: false, trigger1Cls: 'x-form-clear-trigger', onTrigger1Click: function () {{ this.clearValue(); }}, queryMode: 'local', valueField: 'code', displayField: 'name', listFields: 'code,name', listHeadTexts: '代码,名称', data:[ ", "ngComboBox", controlBase.FieldLabel, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width); NGCommonHelp commonHelp = controlBase as NGCommonHelp; for (int i = 0; i < commonHelp.Data.Count; i++) { sb += "\t\t\t\t\t\t\t\t{" + commonHelp.Data[i] + "}"; if (i == commonHelp.Data.Count - 1) { sb += "\r\n"; } else { sb += ",\r\n"; } } } sb += "\t\t\t\t\t\t\t]\r\n\t\t\t\t\t\t"; return(sb); }
public static List <ExtGridColumn> GetListColumns(IList <PbBaseTextInfo> pbcontrols) { SortedList <int, PbBaseControlInfo> list = new SortedList <int, PbBaseControlInfo>(); List <ExtGridColumn> columns = new List <ExtGridColumn>(); foreach (PbBaseControlInfo item in pbcontrols) { if (list.ContainsKey(item.XPos)) //如果x坐标重复,则跳过 //0000000038 这里有重复的 { continue; } list.Add(item.XPos, item);//以x坐标排序 } foreach (KeyValuePair <int, PbBaseControlInfo> element in list) { PbBaseTextInfo textInfo = element.Value as PbBaseTextInfo; if (textInfo != null) { ExtGridColumn col = new ExtGridColumn(); if (textInfo.Name.Equals("t_sum")) { continue; } col.Header = textInfo.LeftText; col.DataIndex = textInfo.Name; col.Datatype = SqlTypeConverter.ConvertToExtControl(textInfo.ColumnInfo.ColumnDataType); col.DefaultValue = textInfo.DefaultValue; col.Width = textInfo.Width; //Grid每一列的宽度 col.RgbColor = ControlConverter.GetRgb(textInfo.Color); //grid列的字体颜色 col.BackgroundColor = ControlConverter.GetRgb(textInfo.backgroundColor); //grid列的背景颜色 ExtControlBase column = ControlConverter.ConvertToExtControl(textInfo); //转换下xtype的类型; col.Protect = column.Protect; col.MustInput = column.MustInput; col.Format = column.Format; col.EditMask = column.EditMask; col.editor.XType = column.XType; if (col.editor.XType == "ngCustomFormHelp" || col.editor.XType == "ngRichHelp") { var temp = column as NGHelpBase; if (temp.Helpid == "itemdata") { col.DataIndex = "itemid"; col.Header = "物资"; col.editor.ValueField = "phid"; col.editor.DisplayField = "itemname"; col.editor.ListFields = "itemid,c_name,spec,msname"; col.editor.ListHeadTexts = "编码,名称,规格,单位"; col.editor.Helpid = temp.Helpid; } else { col.editor.ValueField = temp.ValueField; col.editor.DisplayField = temp.DisplayField; col.editor.ListFields = temp.ListFields; col.editor.ListHeadTexts = temp.ListHeadTexts; col.editor.CmpName = temp.CmpName; col.editor.OutFilter = temp.OutFilter; col.editor.Helpid = temp.Helpid; col.editor.MultiSelect = temp.MultiSelect; } } else if (col.editor.XType == "ngComboBox") { if (column is NGComboBox) { NGComboBox temp = column as NGComboBox; col.editor.QueryMode = temp.QueryMode; col.editor.Data = temp.Data; } else if (column is NGCommonHelp) { NGCommonHelp temp = column as NGCommonHelp; col.editor.QueryMode = temp.QueryMode; col.editor.Data = temp.Data; } } else if (col.editor.XType == "ngRadio") { var temp = column as NGRadio; col.editor.Items = temp.Items; } columns.Add(col); } } return(columns); }