public List <PurchasePolicy> GetAllPolicies() { List <int> listOfIDs = new List <int>(); List <PurchasePolicy> result = new List <PurchasePolicy>(); using (var dbReader = dbConnection.SelectFromTableWithCondition("ComplexPolicies", "*", "Root = 'true'")) { while (dbReader.Read()) { listOfIDs.Add(dbReader.GetInt32(0)); int id = dbReader.GetInt32(0); PolicyType type = PurchasePolicy.GetEnumFromStringValue(dbReader.GetString(2)); string subject = dbReader.GetString(3); PurchasePolicy policy = FindComplexPolicy(id, type, subject, true); policy.IsRoot = true; result.Add(policy); } } using (var dbReader = dbConnection.SelectFromTableWithCondition("SimplePolicies", "*", "Root = 'true'")) { while (dbReader.Read()) { int id = dbReader.GetInt32(0); PolicyType type = PurchasePolicy.GetEnumFromStringValue(dbReader.GetString(2)); string subject = dbReader.GetString(3); PurchasePolicy policy = FindSimplePolicy(id, type, subject, true); policy.IsRoot = true; result.Add(policy); } } return(result); }
public bool IsUserExist(string userName) { dbConnection.CheckInput(userName); using (var dbReader = dbConnection.SelectFromTableWithCondition("Users", "*", "Name = '" + userName + "'")) { return(dbReader.Read()); } }
public int[] GetUserIds() { var userIds = new List <int>(); using (var dbReader = dbConnection.SelectFromTableWithCondition("Users", "SystemID", "Name IS NOT NULL")) { while (dbReader.Read()) { userIds.Add(dbReader.GetInt32(0)); } } return(userIds.ToArray()); }
public SqlDataReader SelectFromTableWithCondition(string table, string toSelect, string condition) { try { return(realMarketDB.SelectFromTableWithCondition(table, toSelect, condition)); } catch (InvalidOperationException e) { if (!IsConnected(e.Message) || MarketDB.ToDisable) { throw new DataException(); } throw; } catch (SqlException e) { if (!IsConnected(e.Message) || MarketDB.ToDisable) { throw new DataException(); } throw; } }
public Order FindOrder(int orderId) { Order order = null; using (var dbReader = dbConnection.SelectFromTableWithCondition("Orders", "*", "OrderID = " + orderId + "")) { while (dbReader.Read()) { if (dbReader.GetValue(0) != null) { order = new Order(dbReader.GetInt32(0), dbReader.GetString(1), dbReader.GetString(2), dbReader.GetDouble(3) , dbReader.GetString(4), GetAllItems(orderId)); } } } return(order); }
public Store GetStorebyName(string storeName) { dbConnection.CheckInput(storeName); using (var dbReader = dbConnection.SelectFromTableWithCondition("Store", "*", "Name = '" + storeName + "'")) { while (dbReader.Read()) { return(new Store(dbReader.GetString(0), dbReader.GetString(1), dbReader.GetString(2), dbReader.GetString(3))); } return(null); } }