private TagBuilder getTextInputTagBuilder() { var textInput = new TagBuilder("input") { TagRenderMode = TagRenderMode.SelfClosing }; textInput.Attributes.Add("id", _captchaOptions.CaptchaComponent.CaptchaInputName); textInput.Attributes.Add("name", _captchaOptions.CaptchaComponent.CaptchaInputName); textInput.Attributes.Add("autocomplete", "off"); textInput.Attributes.Add("class", TextBoxClass); textInput.Attributes.Add("data-val", "true"); textInput.Attributes.Add("data-val-required", ValidationErrorMessage); textInput.Attributes.Add("required", "required"); textInput.Attributes.Add("data-required-msg", ValidationErrorMessage); textInput.Attributes.Add("placeholder", Placeholder); textInput.Attributes.Add("dir", Dir); textInput.Attributes.Add("type", "text"); textInput.Attributes.Add("value", ""); var textAttr = TextBoxAttribute.Split("|"); textInput.Attributes.Add(textAttr[0], textAttr[1]); return(textInput); }
private Control GetControl(PropertyInfo pi) { object[] attributes = pi.GetCustomAttributes(true); Control _Controls = new Control(); //finding out control attribue int ControlAttributesCount = (from a in attributes where a.GetType().BaseType == typeof(ControlAttribute) || a.GetType().BaseType.BaseType == typeof(ControlAttribute) select a).Count(); if (ControlAttributesCount == 0) { //adding default attributes ArrayList defaultAttributes = new ArrayList(attributes); TextBoxAttribute textbox = new TextBoxAttribute(); defaultAttributes.Add(textbox); string controlName = pi.Name; //String.Format("{0}_TextBoxAttribute", pi.Name); RequiredAttribute vrAtt = new RequiredAttribute(); defaultAttributes.Add(vrAtt); switch (pi.PropertyType.Name) { case "Int32": RegExpAttribute veAtt = new RegExpAttribute(); veAtt.ValidationExpression = @"\d"; defaultAttributes.Add(veAtt); break; case "String": break; default: break; } attributes = defaultAttributes.ToArray(); } foreach (Attribute att in attributes) { //checking validation bool isValidation = false; if (att.GetType().BaseType == typeof(ValidationAttribute)) isValidation = true; /* Begin Validation Controls Geneation */ if (isValidation) { //General Validator Control string ControlType = att.GetType().GetProperty("ControlType").GetValue(att, null).ToString(); Control ValidationControl = (Control)System.Activator.CreateInstance(Type.GetType(ControlType)); //binding BindAttributeFieldsToProperties(ValidationControl, att); if (att.GetType() == typeof(CustomValidatorAttribute)) { string ServerValidationEventName = GetFieldValue(att, "ServerValidationEventName").ToString(); ValidationControl.GetType().GetEvent(ServerValidationEventName).AddEventHandler(ValidationControl, new ServerValidateEventHandler(ServerValidation)); } //Assigning ControlToValidate Property with the propertyName string ControlToValidatePropertyName = GetFieldValue(att, "ControlToValidatePropertyName").ToString(); ValidationControl.GetType().GetProperty(ControlToValidatePropertyName).SetValue(ValidationControl, pi.Name, null); //firing the event OnValidationCreated(ValidationControl, new FieldEventArgs(pi.Name, pi.PropertyType)); _Controls.Controls.Add(ValidationControl); } /* Finish Validation Controls Geneation */ else { // generic control PropertyInfo typePropertyInfo = att.GetType().GetProperty("ControlTypeName"); if (typePropertyInfo != null) { string typeName = typePropertyInfo.GetValue(att, null).ToString(); Control control = (Control)System.Activator.CreateInstance(Type.GetType(typeName)); control.ID = pi.Name;//+ "_" + att.GetType().Name; //binding fields BindAttributeFieldsToProperties(control, att); string bindingPropertyName = att.GetType().GetProperty("BindingProperty").GetValue(att, null).ToString(); PropertyInfo controlBindingProperty = control.GetType().GetProperty(bindingPropertyName); //DataControls bool isDataControl = (bool)att.GetType().GetField("IsDataControl").GetValue(att); if (isDataControl) { bool AutoPostBack = (bool)control.GetType().GetProperty("AutoPostBack").GetValue(control, null); if (AutoPostBack) { string IndexChangeEventName = att.GetType().GetField("IndexChangeEventName").GetValue(att).ToString(); control.GetType().GetEvent(IndexChangeEventName).AddEventHandler(control, new EventHandler(LookupPostback)); } //firing event OnLookupControlCreated(control, new FieldEventArgs(pi.Name, pi.PropertyType)); //seting select value after event if (Mode == Opertion.update) controlBindingProperty.SetValue(control, Convert.ChangeType(pi.GetValue(DataSource, null), control.GetType().GetProperty(bindingPropertyName).PropertyType), null); _Controls.Controls.Add(control); } else { //DirectBinding Property controlBindingProperty.SetValue(control, Convert.ChangeType(pi.GetValue(DataSource, null), control.GetType().GetProperty(bindingPropertyName).PropertyType), null); //firing the event OnControlCreated(control, new FieldEventArgs(pi.Name, pi.PropertyType)); _Controls.Controls.Add(control); } } } } return _Controls; }
private string GetStrCondition() { string condition = "1=1"; string QRcondition = ""; //以下语句为准备查询条件 //物料代码条件 if (TextBoxCode.Text.Trim() != "") { condition = " QROut_MatCode LIKE '%" + TextBoxCode.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxCode", TextBoxCode.GetType().ToString(), TextBoxCode.Text.Trim()); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (DropDownListPlanno.SelectedValue != "1") { QRcondition += " and QROut_MatCode like '%" + TextBoxCode.Text.Trim() + "%'"; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } //物料名称条件 if ((TextBoxName.Text.Trim() != "") && (condition != "")) { condition += " AND " + " MaterialName LIKE '%" + TextBoxName.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxName", TextBoxName.GetType().ToString(), TextBoxName.Text.Trim()); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (DropDownListPlanno.SelectedValue != "1") { QRcondition += " and MaterialName like '%" + TextBoxName.Text.Trim() + "%'"; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } //标识号 if ((TextBoxNO.Text.Trim() != "") && (condition != "")) { condition += " AND " + " CGMODE LIKE '%" + TextBoxNO.Text.Trim().ToUpper() + "%'"; addQueryItem(PageName, "TextBoxNO", TextBoxNO.GetType().ToString(), TextBoxNO.Text.Trim()); } //计划跟踪号条件 if ((TextBoxPTC.Text.Trim() != "") && (condition != "")) { if (TextBoxPTC.Text.Trim() == "备库") { condition += " AND " + " (PTC LIKE '%备库%' or PTC LIKE '%BEIKU%')"; addQueryItem(PageName, "TextBoxPTC", TextBoxPTC.GetType().ToString(), TextBoxPTC.Text.Trim()); } else { condition += " AND " + " PTC LIKE'%" + TextBoxPTC.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxPTC", TextBoxPTC.GetType().ToString(), TextBoxPTC.Text.Trim()); } } //批号条件 if ((TextBoxLotNumber.Text != "") && (condition != "")) { condition += " AND " + " PTC LIKE '%" + TextBoxLotNumber.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxLotNumber", TextBoxLotNumber.GetType().ToString(), TextBoxLotNumber.Text.Trim()); } //型号规格条件 if ((TextBoxStandard.Text != "") && (condition != "")) { condition += " AND " + " Standard LIKE '%" + TextBoxStandard.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxStandard", TextBoxStandard.GetType().ToString(), TextBoxStandard.Text.Trim()); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (DropDownListPlanno.SelectedValue != "1") { QRcondition += " and Standard like '%" + TextBoxStandard.Text.Trim() + "%'"; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } //长度条件 if ((TextBoxLength.Text != "") && (condition != "")) { condition += " AND " + " Length LIKE '%" + TextBoxLength.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxLength", TextBoxLength.GetType().ToString(), TextBoxLength.Text.Trim()); } //宽度条件 if ((TextBoxWidth.Text != "") && (condition != "")) { condition += " AND " + " Width LIKE '%" + TextBoxWidth.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxWidth", TextBoxWidth.GetType().ToString(), TextBoxWidth.Text.Trim()); } //材质条件 if ((TextBoxAttribute.Text != "") && (condition != "")) { condition += " AND " + " Attribute LIKE '%" + TextBoxAttribute.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxAttribute", TextBoxAttribute.GetType().ToString(), TextBoxAttribute.Text.Trim()); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (DropDownListPlanno.SelectedValue != "1") { QRcondition += " and Attribute like '%" + TextBoxAttribute.Text.Trim() + "%'"; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } //是否定尺 if ((TextBoxFixed.Text != "") && (condition != "")) { condition += " AND " + " Fixed LIKE '%" + TextBoxFixed.Text.Trim().ToUpper() + "%'"; addQueryItem(PageName, "TextBoxFixed", TextBoxFixed.GetType().ToString(), TextBoxFixed.Text.Trim()); } //备注条件 if ((TextBoxNote.Text != "") && (condition != "")) { condition += " AND " + " Note LIKE '%" + TextBoxNote.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxNote", TextBoxNote.GetType().ToString(), TextBoxNote.Text.Trim()); } //订单编号条件 if ((TextBoxOrderCode.Text != "") && (condition != "")) { condition += " AND " + " OrderCode LIKE '%" + TextBoxOrderCode.Text.Trim() + "%'"; addQueryItem(PageName, "TextBoxOrderCode", TextBoxOrderCode.GetType().ToString(), TextBoxOrderCode.Text.Trim()); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //是否出库(即是否生成入库单) if ((DropDownListQROutState.SelectedValue != "") && (condition != "")) { condition += " AND " + " QROut_State='" + DropDownListQROutState.SelectedValue + "'"; addQueryItem(PageName, "DropDownListQROutState", DropDownListQROutState.GetType().ToString(), DropDownListQROutState.SelectedValue); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% QRcondition += " and QROut_State='" + DropDownListQROutState.SelectedValue + "'"; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } if ((DropDownListQROutState.SelectedValue == "") && (condition != "")) { condition += " AND " + " (QROut_State='0' or QROut_State='1')"; addQueryItem(PageName, "DropDownListQROutState", DropDownListQROutState.GetType().ToString(), DropDownListQROutState.SelectedValue); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //仓库条件 if ((WarehouseDropDownList.SelectedValue != "0") && (ChildWarehouseDropDownList.SelectedValue != "0")) { if (condition != "") { condition += " AND " + " WarehouseCode='" + ChildWarehouseDropDownList.SelectedValue + "'"; addQueryItem(PageName, "WarehouseDropDownList", WarehouseDropDownList.GetType().ToString(), WarehouseDropDownList.SelectedValue); addQueryItem(PageName, "ChildWarehouseDropDownList", ChildWarehouseDropDownList.GetType().ToString(), ChildWarehouseDropDownList.SelectedValue); } else { condition += " WarehouseCode='" + ChildWarehouseDropDownList.SelectedValue + "'"; addQueryItem(PageName, "WarehouseDropDownList", WarehouseDropDownList.GetType().ToString(), WarehouseDropDownList.SelectedValue); addQueryItem(PageName, "ChildWarehouseDropDownList", ChildWarehouseDropDownList.GetType().ToString(), ChildWarehouseDropDownList.SelectedValue); } } else if ((WarehouseDropDownList.SelectedValue != "0") && (ChildWarehouseDropDownList.SelectedValue == "0")) { if (condition != "") { condition += " AND " + " WarehouseCode LIKE '" + WarehouseDropDownList.SelectedValue + "%'"; addQueryItem(PageName, "WarehouseDropDownList", WarehouseDropDownList.GetType().ToString(), WarehouseDropDownList.SelectedValue); addQueryItem(PageName, "ChildWarehouseDropDownList", ChildWarehouseDropDownList.GetType().ToString(), ChildWarehouseDropDownList.SelectedValue); } else { condition += " WarehouseCode LIKE '" + WarehouseDropDownList.SelectedValue + "%'"; addQueryItem(PageName, "WarehouseDropDownList", WarehouseDropDownList.GetType().ToString(), WarehouseDropDownList.SelectedValue); addQueryItem(PageName, "ChildWarehouseDropDownList", ChildWarehouseDropDownList.GetType().ToString(), ChildWarehouseDropDownList.SelectedValue); } } //物料条件 if ((TypeDropDownList.SelectedValue != "0") && (SubTypeDropDownList.SelectedValue != "0")) { if (condition != "") { condition += " AND " + " QROut_MatCode LIKE '" + SubTypeDropDownList.SelectedValue + "%'"; addQueryItem(PageName, "TypeDropDownList", TypeDropDownList.GetType().ToString(), TypeDropDownList.SelectedValue); addQueryItem(PageName, "SubTypeDropDownList", SubTypeDropDownList.GetType().ToString(), SubTypeDropDownList.SelectedValue); } else { condition += " QROut_MatCode LIKE '" + SubTypeDropDownList.SelectedValue + "%'"; addQueryItem(PageName, "TypeDropDownList", TypeDropDownList.GetType().ToString(), TypeDropDownList.SelectedValue); addQueryItem(PageName, "SubTypeDropDownList", SubTypeDropDownList.GetType().ToString(), SubTypeDropDownList.SelectedValue); } } else if ((TypeDropDownList.SelectedValue != "0") && (SubTypeDropDownList.SelectedValue == "0")) { if (condition != "") { condition += " AND " + " QROut_MatCode LIKE '" + TypeDropDownList.SelectedValue + "%'"; addQueryItem(PageName, "TypeDropDownList", TypeDropDownList.GetType().ToString(), TypeDropDownList.SelectedValue); addQueryItem(PageName, "SubTypeDropDownList", SubTypeDropDownList.GetType().ToString(), SubTypeDropDownList.SelectedValue); } else { condition += " QROut_MatCode LIKE '" + TypeDropDownList.SelectedValue + "%'"; addQueryItem(PageName, "TypeDropDownList", TypeDropDownList.GetType().ToString(), TypeDropDownList.SelectedValue); addQueryItem(PageName, "SubTypeDropDownList", SubTypeDropDownList.GetType().ToString(), SubTypeDropDownList.SelectedValue); } } if (DropDownListPlanno.SelectedValue == "1") { condition = condition; } else { condition = condition + " or ((PTC is null or PTC='')" + QRcondition + ")"; } return(condition); }