![]() Public static Util.DataColumnInfo GetDataColumnInfo(TransactionContext context, string tableName, string columnName) This code queries a single column, but you can also do the entire table: I but I'm basically just using an IDataReader when you get right down to it. To use a MessagBox, I can do e.description="" to not have an ErrorProvider icon but how to use a MessageBox and sender.focus when the ErrorProvider is managed in the business class and there is a binding between the business class and the controls in the form.Īctually, the ORM makes it a little simpler, but it's not all that difficult. In another words : I want to use for some controls (TextBox) an ErrorProvider and for anothers controls a MessageBox and keep the focus on the control where the rule is broken (with the ErrorProvider the focus go on the following control). ![]() Also I wish, in the UI, the user can't to go to another control until the validation rules are not good on the control (textbox for instance) where the focus is. Now, my first question in this thread, always without answer :ġ) In a winform, when validation rules are not true, the ErrorProvider appear. Without this relation, the properties of the BO can't know the length of the fields in the database unless to pass them in attributes of the properties or other things. I think your code is possible only because you use an ORM, it is to said a relation between the properties in the BO and the fields of the database. New (info.MappedPropertyName, info.ColumnSize)) ![]() New (info.MappedPropertyName, info.MappedFieldName, info.ColumnSize)) PropertyInfo p = GetType().GetProperty(info.MappedPropertyName) CSLA doesn't currently support dynamic properties, so use special rule if property can't be found ValidationRules.AddRule(CommonRules.StringRequired, info.MappedPropertyName) Add rules for all non-nullable string fields not nullable)įoreach (DataColumnInfo info in ColumnInfoCollection.Columns) Add rules for all string columns for maximum length, and whether required (e.g. You might be able to just use the CSLA rule and skip the above: As you can see, sometimes I have to use the special rule above, and sometimes I can just use the built-in CSLA rule. Here is the code that actually adds the rule definitions in my object's AddBusinessRules. If (!String.IsNullOrEmpty(value) & (value.Length > max))Į.Description = String.Format("Field characters", Internal static bool CustomFieldMaxLength(object target, e)ĭecoratedRuleArgs args = (DecoratedRuleArgs)e Public CustomFieldMaxLengthRuleArgs(string propertyName, string fieldName, int nMaxLength) Internal class CustomFieldMaxLengthRuleArgs : It would be easy to change this to reflect directly on the property value and use the MaxLengthRuleArgs directly. It references some things not define here (I'm usign the Wilson ORMapper as a DAL and it provides an IObjectHelper interface for referencing the values of backing fields directly). Rsbaker0 replied on Saturday, October 04, 2008 Is it possible to use these value automaticaly (or automagicaly )) ? Is there a solution to this problem ?ģ) often when we do a, the value we use is the length of a field in the database. Also sometimes the message appears twice. After that, it is not possible this message appear again. net 1.0, there is errors on ErrorProvider : if you put the mouse on the small red icon then the message appear but if you click on this icon or if the mouse stay too long time on it, the message disappears. I wish to replace it by a MessageBox.Īlso I wish, in the UI, the user can't to go to another control until the validation rules are not good on the control (textbox for instance) where the focus is.Ģ) Since. Three questions about validation rules and ErrorProvider :ġ) In a winform, when validation rules are not true, the ErrorProvider appear.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |