public ValidateParam(ValidateType type, string text, System.Windows.Forms.Label lb, string Message) { this.type = type; this.text = text; this.lb = lb; this.Message = Message; }
public bool ValidateMobileNo(ValidateType oExpression, string ToValidate) { bool result = false; if (oExpression == ValidateType.PakistanMobileNoLimitCheck) { // Empty if (string.IsNullOrEmpty(ToValidate)) { return(false); } if (!ToValidate.StartsWith("92")) { return(false); } if (ToValidate.Length != 12) { return(false); } result = true; // StartWith } return(result); }
public override bool IsValid(ValidateType type) { switch (type) { case ValidateType.ForDelete: if (Status != StatusType.Completed) { return(true); } return(false); case ValidateType.ForInsert: return(true); case ValidateType.ForUpdate: if (Status == StatusType.New) { return(true); } return(false); default: return(false); } }
public bool Validate(MCBEModel model, ValidateType type = AllTypes) { var errors = new List <string>(); if (type.HasFlag(ValidateType.ModelInfo)) { errors.AddRange(validateModelInfo(model)); } if (type.HasFlag(ValidateType.Descriptions)) { errors.AddRange(validateDescriptions(model)); } if (type.HasFlag(ValidateType.Rules)) { errors.AddRange(validateRules(model)); } if (errors.Count > 0) { Errors = errors; return(false); } return(true); }
/* ------ Button Click ------ */ public IEnumerator DoCheckValidateType() { if (!mCheckState) { EginProgressHUD.Instance.ShowWaitHUD(ZPLocalization.Instance.Get("HttpConnectWait")); WWW www = HttpConnect.Instance.HttpRequestWithSession(ConnectDefine.SAFE_VALIDATE_TYPE_URL, null); yield return(www); HttpResult result = HttpConnect.Instance.BaseResult(www); EginProgressHUD.Instance.HideHUD(); if (HttpResult.ResultType.Sucess == result.resultType) { mCheckState = true; JSONObject resultObj = (JSONObject)result.resultObject; mValidateType = (ValidateType)resultObj["bank_validate"].n; bool isLogin = (resultObj["is_login"].n == 1); UpdateLoginState(isLogin); } else { UpdateLoginState(false); EginProgressHUD.Instance.ShowPromptHUD(result.resultObject as string); } } }
public void SetValidateType(BaseEdit edit, ValidateType _ValidateType) { if (!lst.ContainsKey(edit)) { edit.ErrorIconAlignment = ErrorIconAlignment; lst.Add(edit, new ValidateHepler() { ValidateType = _ValidateType }); } else { lst[edit].ValidateType = _ValidateType; } if (_ValidateType != ValidateType._不判断) { edit.ErrorIconAlignment = ErrorIconAlignment; if (CheckDesingModel.IsDesingMode) { edit.ErrorText = "校验"; //edit.EditValue = "IsDesingMode"; } else { edit.ErrorText = ""; //edit.EditValue = "IsRun"; } } }
private string CreateValidateCode(ValidateType type, int length) { //获得验证码长度;获得验证码来源;随机数; Random rd = new Random(); StringBuilder strBuilder = new StringBuilder(); string[] codes = _codeStr.Split(','); for (int i = 0; i < length; i++) { int rdNum = rd.Next(codes.Length); var rdCode = codes[rdNum]; //判断类型: if (type == ValidateType.AllNumber) //纯数字 { if (!rdCode.IsInt()) { i--; continue; } } else if (type == ValidateType.AllLetter) //纯字母 { if (rdCode.IsInt()) { i--; continue; } } strBuilder.Append(rdCode); } return(strBuilder.ToString()); }
private bool ValidateInt(decimal value, ValidateType Ruler) { bool success = true; switch (Ruler) { case ValidateType.Int不等于0: { success = value != 0; }; break; case ValidateType.Int大于0: { success = value > 0; }; break; case ValidateType.Int大于等于0: { success = value >= 0; }; break; case ValidateType.Int小于0: { success = value < 0; }; break; case ValidateType.Int小于等于0: { success = value <= 0; }; break; } return(success); }
/// <summary> /// Создать валидатор для Control /// </summary> /// <param name="type">Тип валидации</param> /// <param name="control">Control, к которому привязать</param> /// <param name="userfunc">Собственный обработчик</param> public static void SetValidator(Control control, ValidateType type, KeyPressEventHandler userfunc = null) { switch (type) { case ValidateType.OnlyNumbers: { control.KeyPress += ValidNumbers; control.Text = "0"; break; } case ValidateType.OnlyText: { control.KeyPress += ValidText; break; } case ValidateType.UserValidate: { if (userfunc != null) { control.KeyPress += userfunc; } break; } } }
public void CheckIfFuncAllowed(ValidateType sut) { sut.AllowableFunc.IsAllowed(typeof(Class)).Returns(true); sut.Validate(typeof(Class)); sut.Registrations.Items.DidNotReceiveWithAnyArgs().ContainsKey(default !);
private BaseValidationAttribute GetValidator(ValidateType type) { switch (type) { case Validation.ValidateType.Email: return(new EmailAttribute()); case Validation.ValidateType.Interger: return(new IntegerAttribute()); case Validation.ValidateType.IP: return(new IPAddressAttribute()); case Validation.ValidateType.MaxLength: return(new MaxLengthAttribute()); case Validation.ValidateType.Phone: return(new PhoneAttribute()); case Validation.ValidateType.Regex: return(new RegexAttribute()); case Validation.ValidateType.Required: return(new RequiredFieldAttribute()); case Validation.ValidateType.URL: return(new URLAttribute()); case Validation.ValidateType.ZIP: return(new ZipCodeAttribute()); default: return(null); } }
/// <summary> /// 生成短信码 /// </summary> /// <param name="mobile">手机号</param> /// <param name="validateType">验证类型</param> /// <returns></returns> public SMessage Build(string mobile, ValidateType validateType) { var now = DateTime.Now.AddMinutes(-1); // 一分钟内, 无需重新生成, 仍然用原来的 var data = _validateDataRepository.FirstOrDefault(d => d.Mobile == mobile && d.ValidateType == validateType && d.CreationTime >= now); if (data == null) { data = CreateValidateData(mobile, validateType); } data.SendNum += 1; // 生成一次,相当于发送一次了 _validateDataRepository.Update(data); SMessage message = new SMessage() { Mobile = mobile, Content = GenerateContent(data.ValidateCode), CustId = validateType.ToString(), }; CurrentUnitOfWork.SaveChanges(); return(message); }
public override void Add(Game entity) { if (entity.Settings == null || entity.Settings == "" || !ValidateType.IsValidJson(entity.Settings)) { entity.Settings = GlobalConstants.DefaultGameSettings; } base.Add(entity); }
public void Validate(ValidateType type, AttributeBox sender, WeaponData weapon, Vector2 point) { switch (type) { case ValidateType.Injured: ProcessInjuredByWeapon(sender, weapon, this, point); break; } }
public void SendVerifyCode(string mobile, ValidateType verifyType, long?uid, string signName, string ip, string from) { ExceptionHelper.ThrowIfNullOrWhiteSpace(mobile, "mobile", "手机号码不能为空"); ExceptionHelper.ThrowIfTrue(!StringRule.VerifyMobile(mobile), "mobile", "手机号码格式错误"); using (var service = _UserManagerService.NewChannelProvider()) { service.Channel.SendCode(new OAuth2ClientIdentity(), mobile, verifyType, uid, signName, ip, from); } }
public void OnlyProcessesSameTypeOnce(ValidateType sut) { sut.AllowableEnumerable.IsAllowed(typeof(Class)).Returns(true); sut.Validate(typeof(Class)); sut.Validate(typeof(Class)); sut.AllowableEnumerable.Received(1).IsAllowed(typeof(Class)); }
public void Validate(ValidateType type, AttributeBox sender, MissileData missile, Vector2 point) { switch (type) { case ValidateType.Injured: ProcessInjuredByMissile(sender, missile, this, point); break; } }
public void Validate(ValidateType type, AttributeBox sender, SkillData skill, Vector2 point) { switch (type) { case ValidateType.Injured: ProcessInjuredBySkill(sender, skill, this, point); break; } }
public static ListItem GetListItem(ValidateType type, bool selected) { var item = new ListItem(GetText(type), type.Value); if (selected) { item.Selected = true; } return(item); }
public string Verify(string code, string mobile, ValidateType verifyType) { ExceptionHelper.ThrowIfNullOrWhiteSpace(code, "code", "手机验证码不能为空"); ExceptionHelper.ThrowIfNullOrWhiteSpace(mobile, "mobile"); ExceptionHelper.ThrowIfTrue(!StringRule.VerifyMobile(mobile), "mobile", "手机号码格式错误"); var result = String.Empty; result = _VerifyHelper.Verify(mobile, code, verifyType); return(result); }
/// <summary> /// 检查需要验证的函数是否通过 /// </summary> /// <param name="checkType">被检查类型</param> /// <param name="matchType">需要检查的类型</param> /// <param name="func">检查函数</param> /// <param name="errMessage">错误信息</param> /// <returns>Emtpy 验证通过,否则返回错误信息</returns> private static string CheckValidate(ValidateType checkType, ValidateType matchType, Func <bool> func, string errMessage) { if (checkType.HasFlag(matchType)) { if (func()) { return(errMessage); } } return(String.Empty); }
internal string GetCellNoLimitMessage(ValidateType validateType) { string result = ""; if (validateType == ValidateType.PakistanMobileNoLimitCheck) { result = "Mobile no must be of 11 number"; } return(result); }
public static bool Equals(ValidateType type, string typeStr) { if (string.IsNullOrEmpty(typeStr)) { return(false); } if (string.Equals(type.Value.ToLower(), typeStr.ToLower())) { return(true); } return(false); }
public static string GetText(ValidateType type) { if (type == ValidateType.None) { return("无"); } if (type == ValidateType.Chinese) { return("中文"); } if (type == ValidateType.English) { return("英文"); } if (type == ValidateType.Email) { return("Email格式"); } if (type == ValidateType.Url) { return("网址格式"); } if (type == ValidateType.Phone) { return("电话号码"); } if (type == ValidateType.Mobile) { return("手机号码"); } if (type == ValidateType.Integer) { return("整数"); } if (type == ValidateType.Currency) { return("货币格式"); } if (type == ValidateType.Zip) { return("邮政编码"); } if (type == ValidateType.IdCard) { return("身份证号码"); } if (type == ValidateType.RegExp) { return("正则表达式验证"); } throw new Exception(); }
public ValidatePayload ValidateDirect(ValidateType type, AttributeKeys key, AttributeSetTypes setType, float value) { ValidatePayload payload = ValidatePayload.CreateEmpty(type); SubAttribute(key, setType, value); if (type == ValidateType.Injured) { payload.damage = (int)value; } return(payload); }
public string Verify(string mobile, string code, ValidateType type) { var error = ErrorCode.None; ExceptionHelper.ThrowIfNullOrWhiteSpace(mobile, "mobile", "手机号码不能为空"); ExceptionHelper.ThrowIfTrue(!StringRule.VerifyMobile(mobile), "mobile", "手机号码格式错误"); using (var service = _UserManagerService.NewChannelProvider()) { return(service.Channel.Verify(new OAuth2ClientIdentity(), mobile, code, type)); } }
private ValidateData CreateValidateData(string mobile, ValidateType validateType) { var code = Abp.RandomHelper.GetRandom(0, 9999).ToString("0000"); var id = _validateDataRepository.InsertAndGetId(new ValidateData() { Mobile = mobile, ValidateType = validateType, ValidateCode = code, EffectiveTime = DateTime.Now.AddMinutes(ChiMaConfig.SMSTimeOfExistence + 1) }); return(_validateDataRepository.Get(id)); }
public static List <TextBox> ValidateTextBox(this Form form, ValidateType type = ValidateType.NONE, Action method = null, Func <TextBox, bool> predicate = null) { var txtList = new List <TextBox>(); var txtInPanel = GetTextBoxInContainer <Panel>(form); var txtInManyPanel = GetTextBoxInManyContainers <Panel>(form); var txtInGroupBox = GetTextBoxInContainer <GroupBox>(form); var txtInManyGroupBox = GetTextBoxInManyContainers <GroupBox>(form); var txtInSplitContainer = GetTextBoxInSpliContainer(form); var txtInTabControl = GetTextBoxInTabControl(form); var txtInManyTabControl = GetTextBoxInManyTabControl(form); var txtInForm = GetTextBoxInForm(form); txtList.AddRange(txtInGroupBox); txtList.AddRange(txtInManyGroupBox); txtList.AddRange(txtInPanel); txtList.AddRange(txtInManyPanel); txtList.AddRange(txtInTabControl); txtList.AddRange(txtInManyTabControl); txtList.AddRange(txtInSplitContainer); txtList.AddRange(txtInForm); if (type == ValidateType.IS_EMPTY) { txtList = txtList.Where(textBox => string.IsNullOrEmpty(textBox.Text.Trim())).ToList(); } txtList = predicate == null?txtList.OrderBy(t => t.TabIndex).ToList() : txtList.Where(predicate).OrderBy(t => t.TabIndex).ToList(); if (method != null) { method.Invoke(); } form.ActiveControl = txtList.OrderBy(t => t.TabIndex).FirstOrDefault(); return(txtList); }
bool IsNotEmpBaseEdit(BaseEdit edit, string ErrorText, ValidateType Ruler) { if (edit.Visible == false) { return(true); } if (Ruler == ValidateType._不判断) { return(true); } bool Validate = true; switch (Ruler) { case ValidateType.String不等于空: { if (String.IsNullOrEmpty(edit.EditValue.ToString())) { Validate = false; } }; break; case ValidateType.Int不等于0: case ValidateType.Int大于0: case ValidateType.Int大于等于0: case ValidateType.Int小于0: case ValidateType.Int小于等于0: { decimal value; if (Decimal.TryParse(edit.EditValue.ToString(), out value)) { Validate = ValidateInt(value, Ruler); } else { Validate = false; } }; break; } if (Validate == false) { ShowError(edit, ErrorText); } return(Validate); }
/// <summary> /// 发送验证码 /// </summary> /// <param name="codeKey">验证码Key</param> /// <param name="validateType">验证方式</param> /// <param name="codeType">验证码类型</param> /// <param name="sendAction">发送委托</param> /// <returns>业务操作结果</returns> private async Task <OperationResult> SendValidateCode(string codeKey, ValidateType validateType, CodeType codeType, Action <string> sendAction) { codeKey.CheckNotNull("codeKey"); sendAction.CheckNotNull("sendAction"); string validateCode = new ValidateCoder().GetCode(6, ValidateCodeType.Number); var codeEntity = new ValidateCode() { CodeKey = codeKey, Code = validateCode, ValidateType = validateType, CodeType = codeType }; var result = await ValidateCodeRepo.InsertAsync(codeEntity); sendAction(validateCode); return(new OperationResult(OperationResultType.Success, "验证码发送成功", validateCode)); }
public static bool Validate(string text, ValidateType type) { switch (type) { case ValidateType.Number: return IsNumber(text); case ValidateType.EnCode: return IsEnCode(text); case ValidateType.Email: return IsEmail(text); case ValidateType.Phone: return IsPostCode(text); case ValidateType.Mobile: return IsMobile(text); case ValidateType.PostCode: return IsPostCode(text); case ValidateType.IdCard: return IsIdCard(text); case ValidateType.IP: return IsIP(text); } throw new Exception("Not find validate type"); }
/// <summary> /// 发送验证码 /// </summary> /// <param name="codeKey">验证码Key</param> /// <param name="validateType">验证方式</param> /// <param name="codeType">验证码类型</param> /// <param name="sendAction">发送委托</param> /// <returns>业务操作结果</returns> private async Task<OperationResult> SendValidateCode(string codeKey, ValidateType validateType, CodeType codeType, Action<string> sendAction) { codeKey.CheckNotNull("codeKey"); sendAction.CheckNotNull("sendAction"); string validateCode = new ValidateCoder().GetCode(6, ValidateCodeType.Number); var codeEntity = new ValidateCode() { CodeKey = codeKey, Code = validateCode, ValidateType = validateType, CodeType = codeType }; await ValidateCodeRepo.InsertAsync(codeEntity); sendAction(validateCode); return new OperationResult(OperationResultType.Success, "验证码发送成功", ""); }
internal string GenRefValConfig(string fieldName, string labelName, int LabelWidth, string parentID, bool AllowNull, ValidateType validType, string validMethod, string validMsg) { String textBoxID = String.IsNullOrEmpty(fieldName) ? this.ClientID + "TextBox" : fieldName; String labelID = String.IsNullOrEmpty(labelName) ? this.ClientID + "Label" : parentID + labelName; string tpl = this.GenTemplate(); StringBuilder refVal = new StringBuilder(); refVal.Append("layout: 'hbox',"); refVal.AppendFormat("width: {0},", this.Width); //refVal.Append("baseCls: \"x-plain\","); refVal.Append("items: [{"); refVal.AppendFormat("id: '{0}',", labelID); if (!String.IsNullOrEmpty(labelName)) refVal.Append("disabled:true,disabledCls:'info-x-item-disabled',"); refVal.Append("xtype: 'label',"); refVal.AppendFormat("width: {0},", LabelWidth + 5); refVal.AppendFormat("text: '{0}',", labelName); refVal.Append("},{"); refVal.AppendFormat("id: '{0}',", parentID + textBoxID); refVal.AppendFormat("name:'{0}',", textBoxID); if (!AllowNull) refVal.Append("allowBlank:false,"); string message = ""; #region validate switch (validType) { case ValidateType.None: break; case ValidateType.Method: if (!string.IsNullOrEmpty(validMethod)) { if (validMethod.IndexOf('.') != -1) { refVal.AppendFormat("srvValid:'{0}',msg:'{1}',", validMethod, validMsg); } else { refVal.AppendFormat("validator:{0},", validMethod); } } break; case ValidateType.Alpha: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidAlphaMsg", true); } else { message = validMsg; } refVal.AppendFormat("vtype:'alpha',alphaText:'{0}',", message); break; case ValidateType.AlphaNumber: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidAlphaNumMsg", true); } else { message = validMsg; } refVal.AppendFormat("vtype:'alphanum',alphanumText:'{0}',", message); break; case ValidateType.Email: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidEmailMsg", true); } else { message = validMsg; } refVal.AppendFormat("vtype:'email',emailText:'{0}',", message); break; case ValidateType.Url: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidUrlMsg", true); } else { message = validMsg; } refVal.AppendFormat("vtype:'url',urlText:'{0}',", message); break; case ValidateType.Int: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidIntMsg", true); } else { message = validMsg; } refVal.AppendFormat("vtype:'isint',vtypeText:'{0}',", message); break; case ValidateType.Float: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidFloatMsg", true); } else { message = validMsg; } refVal.AppendFormat("vtype:'isfloat',vtypeText:'{0}',", message); break; case ValidateType.IPAddress: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidIPMsg", true); } else { message = validMsg; } refVal.AppendFormat("vtype:'ip',vtypeText:'{0}',", message); break; } #endregion if (!String.IsNullOrEmpty(fieldName)) refVal.Append("disabled:true,disabledCls:'info-x-item-disabled',"); //refVal.Append("disabled:true,hidden:true,disabledCls:'info-x-item-disabled',"); refVal.Append("xtype: 'textfield',"); refVal.Append("hidden: true,"); refVal.Append("flex: 1,"); refVal.Append("listeners:"); refVal.Append("{enable:function(){"); refVal.AppendFormat("Ext.getCmp('{0}').enable();", parentID+ textBoxID + "Button"); refVal.AppendFormat("Ext.getCmp('{0}').enable();", parentID + textBoxID + "_Name"); refVal.AppendFormat("Ext.getCmp('{0}').hide();", parentID + textBoxID + "_Name"); refVal.AppendFormat("Ext.getCmp('{0}').show();", parentID + textBoxID); refVal.Append("},disable:function(){"); refVal.AppendFormat("Ext.getCmp('{0}').disable();",parentID+ textBoxID + "Button"); refVal.AppendFormat("Ext.getCmp('{0}').disable();", parentID + textBoxID + "_Name"); refVal.AppendFormat("Ext.getCmp('{0}').show();", parentID + textBoxID + "_Name"); refVal.AppendFormat("Ext.getCmp('{0}').hide();", parentID + textBoxID ); refVal.Append("},blur:function(obj){"); //text #region showDisplayMember refVal.Append("var param = new setRefvalparam();"); refVal.AppendFormat("param.refvalID = \"{0}\";", this.ClientID); refVal.AppendFormat("param.refTitle = \"{0}\";", this.RefValTitle); refVal.AppendFormat("param.refParentID = \"{0}\";", parentID); refVal.Append("param.refModuleName = \"GLModule\";"); refVal.Append("param.refCommandName = \"cmdRefValUse\";"); refVal.Append("param.refDynamic = \"Y\";"); object o = this.GetObjByID(this.DataSourceID); if (o != null && o is WebDataSource) { WebDataSource wds = o as WebDataSource; if (!string.IsNullOrEmpty(wds.SelectAlias) && !string.IsNullOrEmpty(wds.SelectCommand)) { refVal.AppendFormat("param.refCmdsql = \"{0}\";", wds.SelectCommand); } } refVal.AppendFormat("param.refBindControlID = \"{0}\";", parentID + textBoxID); refVal.AppendFormat("param.refBindValueColumn = \"{0}\";", this.ValueField); refVal.AppendFormat("param.refBindTextColumn = \"{0}\";", this.DisplayField); String strMatchSrcColumnsT = String.Empty; String strMatchDestcontrolIDsT = String.Empty; foreach (ExtColumnMatch column in this.ColumnMatch) { if (strMatchSrcColumnsT != String.Empty) strMatchSrcColumnsT += "|"; if (strMatchDestcontrolIDsT != String.Empty) strMatchDestcontrolIDsT += "|"; strMatchSrcColumnsT += "\'" + column.SrcField + "\'"; strMatchDestcontrolIDsT += "\'" + column.DestField + "\'"; } if (strMatchSrcColumnsT != String.Empty && strMatchDestcontrolIDsT != String.Empty) { refVal.AppendFormat("param.refMatchSrcColumns = [{0}];", strMatchSrcColumnsT); refVal.AppendFormat("param.refMatchDestcontrolIDs = [{0}];", strMatchDestcontrolIDsT); } String strFilterColumns = String.Empty; String strFilterControls = String.Empty; foreach (ExtColumnMatch column in this.ColumnMatch) { if (strFilterColumns != String.Empty) strFilterColumns += "|"; if (strFilterControls != String.Empty) strFilterControls += "|"; strFilterColumns += "\'" + column.SrcField + "\'"; strFilterControls += "\'" + column.DestField + "\'"; } if (strFilterColumns != String.Empty && strFilterControls != String.Empty) { refVal.AppendFormat("param.refFilterColumns = [{0}];", strFilterColumns); refVal.AppendFormat("param.refFilterControls = [{0}];", strFilterControls); } refVal.Append("param.refAutoShow = 'N';"); refVal.Append("var GexRef_ID = createGexRef(param);"); refVal.AppendFormat("GexRef_ID.onblurColumnMatch(obj.value);"); refVal.Append("return GexRef_ID;"); #endregion refVal.Append("},change:function(obj,newValue,oldValue){"); //text #region columnMatchTest refVal.Append("var param = new setRefvalparam();"); refVal.AppendFormat("param.refvalID = \"{0}\";", this.ClientID); refVal.AppendFormat("param.refTitle = \"{0}\";", this.RefValTitle); refVal.AppendFormat("param.refParentID = \"{0}\";", parentID); refVal.Append("param.refModuleName = \"GLModule\";"); refVal.Append("param.refCommandName = \"cmdRefValUse\";"); refVal.Append("param.refDynamic = \"Y\";"); if (o != null && o is WebDataSource) { WebDataSource wds = o as WebDataSource; if (!string.IsNullOrEmpty(wds.SelectAlias) && !string.IsNullOrEmpty(wds.SelectCommand)) { refVal.AppendFormat("param.refCmdsql = \"{0}\";", wds.SelectCommand); } } refVal.AppendFormat("param.refBindControlID = \"{0}\";", parentID + textBoxID); refVal.AppendFormat("param.refBindValueColumn = \"{0}\";", this.ValueField); refVal.AppendFormat("param.refBindTextColumn = \"{0}\";", this.DisplayField); if (strMatchSrcColumnsT != String.Empty && strMatchDestcontrolIDsT != String.Empty) { refVal.AppendFormat("param.refMatchSrcColumns = [{0}];", strMatchSrcColumnsT); refVal.AppendFormat("param.refMatchDestcontrolIDs = [{0}];", strMatchDestcontrolIDsT); } if (strFilterColumns != String.Empty && strFilterControls != String.Empty) { refVal.AppendFormat("param.refFilterColumns = [{0}];", strFilterColumns); refVal.AppendFormat("param.refFilterControls = [{0}];", strFilterControls); } refVal.Append("param.refAutoShow = 'N';"); refVal.Append("var GexRef_ID = createGexRef(param);"); refVal.AppendFormat("GexRef_ID.getRefName(newValue);"); refVal.Append("return GexRef_ID;"); #endregion refVal.Append("}}"); refVal.Append("},{"); refVal.AppendFormat("id: '{0}',", parentID + textBoxID + "_Name"); refVal.AppendFormat("name:'{0}',", textBoxID + "_Name"); if (!String.IsNullOrEmpty(fieldName)) refVal.Append("disabled:true,disabledCls:'info-x-item-disabled',"); refVal.Append("xtype: 'textfield',"); refVal.Append("flex: 1"); refVal.Append("},{"); refVal.AppendFormat("id: '{0}',",parentID + textBoxID + "Button"); if (!String.IsNullOrEmpty(fieldName)) refVal.Append("disabled:true,disabledCls:'info-x-item-disabled',"); refVal.Append("xtype: 'button',"); refVal.Append("iconCls:'ext_refbtn_icon',"); refVal.Append("width: 22,"); refVal.Append("listeners: {"); refVal.Append("'click': function(){"); refVal.Append("var param = new setRefvalparam();"); refVal.AppendFormat("param.refvalID = \"{0}\";", this.ClientID); refVal.AppendFormat("param.refTitle = \"{0}\";", this.RefValTitle); refVal.AppendFormat("param.refParentID = \"{0}\";", parentID); refVal.Append("param.refModuleName = \"GLModule\";"); refVal.Append("param.refCommandName = \"cmdRefValUse\";"); refVal.Append("param.refDynamic = \"Y\";"); //object o = this.GetObjByID(this.DataSourceID); if (o != null && o is WebDataSource) { WebDataSource wds = o as WebDataSource; if (!string.IsNullOrEmpty(wds.SelectAlias) && !string.IsNullOrEmpty(wds.SelectCommand)) { refVal.AppendFormat("param.refCmdsql = \"{0}\";", wds.SelectCommand); } } String ShowFields = String.Empty; String ShowFieldsWidth = String.Empty; String ShowFieldsCaption = String.Empty; foreach (ExtSimpleColumn column in this.Columns) { if (ShowFields != String.Empty) ShowFields += ","; if (ShowFieldsWidth != String.Empty) ShowFieldsWidth += ","; if (ShowFieldsCaption != string.Empty) ShowFieldsCaption += ","; ShowFields += column.DataField; ShowFieldsWidth += column.Width; ShowFieldsCaption += (column.HeaderText == null || column.HeaderText == string.Empty) ? column.DataField : column.HeaderText; } refVal.AppendFormat("param.refShowFields = \"{0}\";", ShowFields); refVal.AppendFormat("param.refShowFieldsWidth = \"{0}\";", ShowFieldsWidth); refVal.AppendFormat("param.refShowFieldsCaption = \"{0}\";", ShowFieldsCaption); refVal.AppendFormat("param.refBindControlID = \"{0}\";", parentID + textBoxID); refVal.AppendFormat("param.refBindValueColumn = \"{0}\";", this.ValueField); refVal.AppendFormat("param.refBindTextColumn = \"{0}\";", this.DisplayField); String strMatchSrcColumns = String.Empty; String strMatchDestcontrolIDs = String.Empty; foreach (ExtColumnMatch column in this.ColumnMatch) { if (strMatchSrcColumns != String.Empty) strMatchSrcColumns += "|"; if (strMatchDestcontrolIDs != String.Empty) strMatchDestcontrolIDs += "|"; strMatchSrcColumns += "\'" + column.SrcField + "\'"; strMatchDestcontrolIDs += "\'" + column.DestField + "\'"; } if (strMatchSrcColumns != String.Empty && strMatchDestcontrolIDs != String.Empty) { refVal.AppendFormat("param.refMatchSrcColumns = [{0}];", strMatchSrcColumns); refVal.AppendFormat("param.refMatchDestcontrolIDs = [{0}];", strMatchDestcontrolIDs); } //String strFilterColumns = String.Empty; //String strFilterControls = String.Empty; //foreach (ExtColumnMatch column in this.ColumnMatch) //{ // if (strFilterColumns != String.Empty) // strFilterColumns += "|"; // if (strFilterControls != String.Empty) // strFilterControls += "|"; // strFilterColumns += "\'" + column.SrcField + "\'"; // strFilterControls += "\'" + column.DestField + "\'"; //} if (strFilterColumns != String.Empty && strFilterControls != String.Empty) { refVal.AppendFormat("param.refFilterColumns = [{0}];", strFilterColumns); refVal.AppendFormat("param.refFilterControls = [{0}];", strFilterControls); } refVal.Append("param.refAutoShow = true;"); refVal.Append("var GexRef_ID = createGexRef(param);"); refVal.Append("return GexRef_ID;"); refVal.Append("}"); refVal.Append("}"); refVal.Append("}]"); return refVal.ToString(); }
public static string GenValidateConfig(bool allowNull, ValidateType validType, string validMethod, string validMsg) { StringBuilder builder = new StringBuilder(); if (!allowNull) { builder.Append("allowBlank:false,"); } string message = ""; switch (validType) { case ValidateType.None: break; case ValidateType.Method: if (!string.IsNullOrEmpty(validMethod)) { if (validMethod.IndexOf('.') != -1) { builder.AppendFormat("srvValid:'{0}',msg:'{1}',", validMethod, validMsg); } else { builder.AppendFormat("validator:{0},", validMethod); } } break; case ValidateType.Alpha: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidAlphaMsg", true); } else { message = validMsg; } builder.AppendFormat("vtype:'alpha',alphaText:'{0}',", message); break; case ValidateType.AlphaNumber: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidAlphaNumMsg", true); } else { message = validMsg; } builder.AppendFormat("vtype:'alphanum',alphanumText:'{0}',", message); break; case ValidateType.Email: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidEmailMsg", true); } else { message = validMsg; } builder.AppendFormat("vtype:'email',emailText:'{0}',", message); break; case ValidateType.Url: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidUrlMsg", true); } else { message = validMsg; } builder.AppendFormat("vtype:'url',urlText:'{0}',", message); break; case ValidateType.Int: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidIntMsg", true); } else { message = validMsg; } builder.AppendFormat("vtype:'isint',vtypeText:'{0}',", message); break; case ValidateType.Float: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidFloatMsg", true); } else { message = validMsg; } builder.AppendFormat("vtype:'isfloat',vtypeText:'{0}',", message); break; case ValidateType.IPAddress: if (string.IsNullOrEmpty(validMsg)) { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "AjaxTools", "ExtGrid", "ValidIPMsg", true); } else { message = validMsg; } builder.AppendFormat("vtype:'ip',vtypeText:'{0}',", message); break; } if (builder.ToString().EndsWith(",")) { builder.Remove(builder.Length - 1, 1); } return builder.ToString(); }