標籤:style blog color os for re c div
/// <summary> /// 檢查非空欄位 /// </summary> /// <param name="IsOk"></param> /// <param name="textboxes"></param> private void CheckTextBoxNotNull(ref bool IsOk, params TextBox[] textboxes) { foreach (TextBox txtBox in textboxes) { txtBox.Background = Brushes.White; if (txtBox.Text.Length <= 0) { IsOk = false; txtBox.Background = Brushes.Red; } else { txtBox.Background = null; } } }
/// <summary> /// 設定控制項 /// </summary> /// <param name="IsEn"></param> /// <param name="IsNull"></param> private void SetControl(bool IsEn ,bool IsNull) { foreach (UIElement c in grd_UserInfo.Children) { if (c is TextBox) { c.IsEnabled = IsEn; if (IsNull) { ((TextBox)c).Text = ""; } } if (c is ComboBox) { c.IsEnabled = IsEn; if (IsNull) { ((ComboBox)c).SelectedIndex = -1; } } if (c is DatePicker) { c.IsEnabled = IsEn; if (IsNull) { ((DatePicker)c).SelectedDate = null; } } } btn_ChoosePhoto.IsEnabled = IsEn; }
/// <summary> /// 驗證郵箱輸入是否合法 /// </summary> /// <param name="strIn"></param> /// <returns></returns> private bool IsValidEmail(string strIn) { return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); }