public bool CheckFieldNumber(Control control) { bool check = true; // field number if (control.Name == "txtPhone" || control.Name == "txtNumberID" || control.Name == "txtSalary") { rule r = new rule(); if (control.Name == "txtPhone") { if (r.CheckPhone(control.Text) == false) { check = false; this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Red; } else this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Green; } else { if (control.Name == "txtNumberID") { if (r.CheckNumberID(control.Text) == false) { check = false; this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Red; } else this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Green; } else { if (r.CheckNumber(control.Text) == false) { check = false; this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Red; } else this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Green; } } } return check; }