public static void Buildrule(NumberRule aRule, string start, string end, string increment) { double result = double.NegativeInfinity; if (double.TryParse(start, out result)) { aRule.Start = result; } else { throw new Exception("Build number rule failed for start field"); } if (double.TryParse(end, out result)) { aRule.End = result; } else { throw new Exception("Build number rule failed for end field"); } if (double.TryParse(increment, out result)) { aRule.Increment = result; } else { throw new Exception("Build number rule failed for increment field"); } }
private void InitComponent() { string productId = NumberRule.NewDataModel(17).GetValue(17); this.txtContractID.Text = productId; DataTable contractCategoryData = XSql.GetDataTable("SELECT * FROM CTR_Category"); this.ddlCategory.DataSource = contractCategoryData; this.ddlCategory.DataValueField = "ID"; this.ddlCategory.DataTextField = "Name"; this.ddlCategory.DataBind(); this.ddlCategory.Items.Insert(0, new ListItem("--请选择--", "")); DataTable projectData = XSql.GetDataTable("SELECT * FROM Pro_Projects"); this.ddlProject.DataSource = projectData; this.ddlProject.DataValueField = "ID"; this.ddlProject.DataTextField = "ProjectName"; this.ddlProject.DataBind(); Dict.BindListCtrl_DeptList(this.ddlDepartment, null, null, null); this.ddlDepartment.Items.Insert(0, new ListItem("--请选择--", "")); this.txtSignedDate.Text = DateTime.Now.ToString("yyyy-M-dd"); this.txtStartDate.Text = DateTime.Now.ToString("yyyy-M-dd"); this.txtEndDate.Text = DateTime.Now.ToString("yyyy-M-dd"); this.txtInputDate.Text = DateTime.Now.ToString("yyyy-M-dd"); this.txtManager.Text = WX.WXUser.GetRealNameByUserID(WX.Authentication.GetUserID()); }
public void GenerateData(NumberRule rule, DataStore store) { Random generateRandom = new Random(); DataColumn aColumn = store.ActualData.Columns[rule.FieldName]; int counter = -1; double range = rule.End - rule.Start; foreach (DataRow aRow in store.ActualData.Rows) { counter++; double result = -1; if (rule.IsRandom) { result = rule.Start + generateRandom.NextDouble() * range; } else { result = rule.Start + counter * rule.Increment; if (result > rule.End) { counter = 0; result = rule.Start; } } if (rule.ConvertToString) { aRow.ItemArray[aColumn.Ordinal] = result.ToString(); } else { aRow.ItemArray[aColumn.Ordinal] = result; } } }
private void InitComponent() { string productId = NumberRule.NewDataModel(15).GetValue(15); this.txtProductID.Text = productId; DataTable unitData = XSql.GetDataTable("SELECT ID,UnitName FROM Ass_Unit"); this.ddlUnit.DataSource = unitData; this.ddlUnit.DataTextField = "UnitName"; this.ddlUnit.DataValueField = "ID"; this.ddlUnit.DataBind(); DataTable suppliersData = XSql.GetDataTable("SELECT SupplierID,CompanyName FROM Ass_Suppliers"); this.ddlSuppliers.DataSource = suppliersData; this.ddlSuppliers.DataTextField = "CompanyName"; this.ddlSuppliers.DataValueField = "SupplierID"; this.ddlSuppliers.DataBind(); DataTable categoryData = XSql.GetDataTable("exec [dbo].[sp_get_tree_table] 'Ass_Category','ID','Name','ParentID','ID',0,1,5"); this.ddlCategory.DataSource = categoryData; this.ddlCategory.DataTextField = "name"; this.ddlCategory.DataValueField = "id"; this.ddlCategory.DataBind(); }
private void InitComponent() { string productId = NumberRule.NewDataModel(16).GetValue(16); this.txtProductID.Text = productId; DataTable categoryData = XSql.GetDataTable("exec [dbo].[sp_get_tree_table] 'PDT_ProductCategory','ID','Name','ParentID','ID',0,1,5"); this.ddlProductCategory.DataSource = categoryData; this.ddlProductCategory.DataTextField = "name"; this.ddlProductCategory.DataValueField = "id"; this.ddlProductCategory.DataBind(); DataTable unitData = XSql.GetDataTable("SELECT * FROM Ass_Unit"); this.ddlUnits.DataSource = unitData; this.ddlUnits.DataValueField = "ID"; this.ddlUnits.DataTextField = "UnitName"; this.ddlUnits.DataBind(); if (WX.Main.GetConfigItem("Product_ISDept") == "1" && WX.Main.GetConfigItem("Product_OneDept") == "1") { BindDropList(); } if (Request["ProductID"] != null && Request["ProductID"] != "") { MenuBar1.Key = "Sale_Product_Edit"; MenuBar1.Param1 = "{Q:ProductID}"; MenuBar1.CurIndex = 2; WX.PDT.Product.MODEL product = WX.Request.rProduct; this.rIsEnable.SelectedValue = product.IsEnable.ToString(); this.txtProductID.Text = product.ProductID.ToString(); this.txtProductName.Text = product.ProductName.ToString(); this.ddlProductCategory.SelectedValue = product.CategoryID.ToString(); this.txtSpecification.Text = product.Specification.ToString(); this.ddlUnits.SelectedValue = product.Units.ToString(); this.txtSalesPrice.Text = product.SalesPrice.ToString(); this.txtDiscountedPrice.Text = product.DiscountedPrice.ToString(); this.txtCostPrice.Text = product.CostPrice.ToString(); this.txtRemark.Text = product.Remark.ToString(); this.txtServices.Text = product.Services.ToString(); if (WX.Main.GetConfigItem("Product_ISDept") == "1" && WX.Main.GetConfigItem("Product_OneDept") == "1") { WX.PDT.ProductDept.MODEL productdept = WX.PDT.ProductDept.GetModel("select top 1 * from PDT_ProductDept where ProductID=" + WX.Request.rProductId + " order by ID desc"); if (productdept != null) { ProductDeptID.SelectedValue = productdept.DeptID.ToString(); MonthFee.Text = productdept.MonthFee.ToString(); Fee.Text = productdept.Fee.ToString(); Feetype1.SelectedValue = productdept.MonthFeeType.ToString(); Feetype2.SelectedValue = productdept.FeeType.ToString(); txtDeptRemarks.Text = productdept.Remarks.ToString(); } } } if (WX.Main.GetConfigItem("Product_ISDept") == "1" && WX.Main.GetConfigItem("Product_OneDept") == "1") { pdept.Visible = true; } }
/// <summary> /// 验证输入是否为数字类型 /// </summary> /// <param name="box">验证框</param> /// <param name="errorMessage">错误提示消息</param> /// <returns></returns> public static ValidBox Number(this ValidBox box, string errorMessage) { var newBox = new NumberRule() { ErrorMessage = errorMessage }.ToValidBox(); return(ValidBox.Merge(box, newBox)); }
private void ExecuteSelectionChangedCommand(NumberRule parameter) { if (SearchKind != 0 || parameter == null) { _showMessage("下拉选项的规则只使用于手机号"); return; } _getNumberByRules(parameter.Pattern); }
public override void EditRule(IDataRule aRule) { base.EditRule(aRule); NumberRule nRule = (NumberRule)aRule; chkConvertToString.Checked = nRule.ConvertToString; rbRandomNumber.Checked = nRule.IsRandom; rbNumberIncrement.Checked = !nRule.IsRandom; txtStart.Text = nRule.Start.ToString(); txtEnd.Text = nRule.End.ToString(); txtNumIncrement.Text = nRule.Increment.ToString(); }
public long Validate(int ruleNumber, int endPattern) { var validRules = 0L; var patterns = this.RulePatterns(endPattern); foreach (var message in this.messages) { var endsWith = patterns.Any(p => message.EndsWith(p)); var rule = new NumberRule(ruleNumber); var valid = rule.Validate(new ValidationContext { Position = 0, Candidate = message, Rules = this.rules, }); validRules += endsWith && valid.Valid && valid.Position == message.Length ? 1 : 0; } return(validRules); }
//生词匹配 private void StrangeWordMacth() { Char c; //将缓冲区填满5个字符 while (Char.GetUnicodeCategory(c = GetNextChar()) == UnicodeCategory.OtherLetter && length < 6) { Push(c); } //对缓冲区中的内容进行生词匹配 int len = StrangeWord.Match(buffer, length); //如果匹配失败则开始大写数字匹配 if (len == 1 && NumberRule.Test(buffer[0])) { for (int i = 1; i < MAX_WORD_LEN; i++) { if (i > length && Char.GetUnicodeCategory(c = GetNextChar()) == UnicodeCategory.OtherLetter) { Push(c); } if (NumberRule.Test(buffer[i])) { len++; } else { break; } } } bufferIndex = bufferIndex - length + len; offset = offset - length + len; length = len; }
/// <summary> /// 验证输入是否为数字类型 /// </summary> /// <param name="box">验证框</param> /// <returns></returns> public static ValidBox Number(this ValidBox box) { var newBox = new NumberRule().ToValidBox(); return(ValidBox.Merge(box, newBox)); }
public static IDataRule InitializeBase(FieldTypes generalType, bool isRandom, String fieldName, String fieldDataType, bool convertToString) { IDataRule result = null; switch (generalType) { case FieldTypes.Date: result = new DateRule(); break; case FieldTypes.Time: result = new TimeRule(); break; case FieldTypes.GUID: result = new GuidRule(); break; case FieldTypes.Imported: //result = new break; case FieldTypes.MultiColumn: result = new MultiFieldDataSourceRule(); break; case FieldTypes.SingleColumn: result = new SingleFieldDataSourceRule(); break; case FieldTypes.Number: result = new NumberRule(); break; case FieldTypes.String: result = new StringRule(); break; case FieldTypes.Bool: result = new BoolRule(); break; case FieldTypes.Dynamic: case FieldTypes.Type: result = new TRule(); break; case FieldTypes.Enumerator: result = new EnumeratorRule(); break; case FieldTypes.MappedSource: result = new MappedSourceRule(); break; case FieldTypes.Collection: result = new CollectionRule(); break; case FieldTypes.Tuple: result = new TupleRule(); break; } result.ConvertToString = convertToString; result.FieldDataType = fieldDataType; result.FieldName = fieldName; result.IsRandom = isRandom; result.RuleType = generalType; return(result); }
public NumberBuilder(string number) { _numberRule = new NumberRule { Number = TerminalNodeBuilder.Of(Token.ConstantNumber, number) }; }