private void ButtonClick(object sender, RoutedEventArgs e) { if (((Button)sender).Name == "Save") { string error = ""; foreach (TextBox bs in ClassEtcFun.FindVisualChildren <TextBox>(this)) { if (!Valid(bs)) { error += (bs.Name + " incorrect") + Environment.NewLine; } } if (error.Length == 0) { FunctionsService.Click(sender); } else { FunctionsService.ShowMessageTimeList(error); } } else { FunctionsService.Click(sender); } }
/// <summary> /// Открывает соединение. /// </summary> /// <returns>Успешно или нет.</returns> public static bool Connect() { var connection = new SqlConnection(Config.ConnectionString); try { if (connection.State != ConnectionState.Open) { connection.Open(); } return(true); } catch (SqlException odbcEx) { if (connection.State != ConnectionState.Closed) { connection.Close(); } FunctionsService.ShowMessageTimeList(odbcEx.Message); return(false); } }