/ / Check the method (class) of the data in the form (class) to use each control tag property, determine the data type of this control, whether it allows empty (1 is 1 means can't be empty, the bit is 0) Empty, ten digits represent data type; see source code)
If you change to the use of regular expressions, it may be better. // Use: try {checkform controls.tcheckformControls.checkform_data (Object ParentControl);} catch (exception err) {messagebox.show (err.message);}
// Source Namespace CheckformControls {Public Enum Tkhyhdatattype: INT {UNKNOW = 0, Integer = 1, FLOAT = 2, String = 3, Date = 4, DateTime = 5, Time = 6, Number = 7 // It Only Use 0- 9 numbers, for example: 08688122784} ///
private static bool ParseTypeValue (object tag, out TKhyhDataType ofDataType, out string sDataType, out bool bNeedData) {if (tag == null) {ofDataType = TKhyhDataType.Unknow; sDataType = ofDataType.ToString (); bNeedData = false; return false; } Int off {OFTYPEVALUE = Convert.Toint32 (tag.tostring ()); bneeddata = ((OfftyValue% 10) == 1); OffeValue = (OfftyValue- (OFTYPEVALUE% 10)) / 10;
ofDataType = (TKhyhDataType) System.Enum.Parse (typeof (TKhyhDataType), ofTypeValue.ToString ()); sDataType = ofDataType.ToString ();} catch {ofDataType = TKhyhDataType.Unknow; sDataType = ofDataType.ToString (); bNeedData = False; return false;} Return true;} /// For (int i = 0; i IF (! Parstypevalue (Obj.tag, Out OfDataType, Out SDATYPE, OUT BNEEDDATA) Continue; IF (obj.tag == null) Continue; //Messagebox.show (obj.name.tostring ()); //undinue; IF (obj.accessibleDescription == null) objName = ""; else objName = obj.accessibleDescription.toString (); if (objName.length == 0) ObjName = obj.name; if (obj is ListBox) {ListBox lstObj = obj as ListBox; if (bNeedData && lstObj.SelectedItems.Count == 0) {//lstObj.BackColor=Color.Red; throw new Exception (string.Format (SELECT_ITEM, objName) );}} else if (obj is ComboBox) {ComboBox lstObj = obj as ComboBox; if (bNeedData && lstObj.SelectedItem == null) {//lstObj.BackColor=Color.Red; throw new Exception (string.Format (sELECT_ITEM ,}}}}} else if (obj is textbox) {textbox textobj = obj as textbox; string v = textobj.text; if (v.Length == 0) {if (bneeddata) throw new exception (String.Format) (Could_not_empty, objName)); Else Continue;} Switch (OFDATYPE) {CASE TKHYHDATYPE.INTEGER: try {convert.Toint32 (v);} catch {throw new exception (String.Format);} Break;