public static object GetAllSC() { object res = null; DataTable dt = new DataTable(); using (var context = new PavilionsEntities()) { SqlConnection connection = new SqlConnection(connectionString); string query = $"SELECT SC.SCName, SC.Status, SC.PavilNum, SC.City, SC.Price, SC.FlorNum, SC.CoeOffAddedValue FROM SC"; try { using (connection) { if (connection.State != ConnectionState.Open) { connection.Open(); } dt = GetDataTable(query, connection); } } catch (Exception ex) { // error handling MessageBox.Show(ex.Message); } finally { connection.Close(); } } res = dt; return(res); }
public static object TryAutorize(string login = "", string password = "") { object res = "Неверный логин или пароль"; if (!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(password)) { try { using (var context = new PavilionsEntities()) { var user = context.Planctons.FirstOrDefault(x => x.Login.ToLower() == login); if (user != null && user.Password == password) { res = user; } } } catch (Exception ex) { } } else { res = "Ничего не введено"; } return(res); }