示例#1
0
        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);
        }
示例#2
0
文件: AdminDL.cs 项目: maorRoz/Sadna
 public bool IsUserExist(string userName)
 {
     dbConnection.CheckInput(userName);
     using (var dbReader = dbConnection.SelectFromTableWithCondition("Users", "*", "Name = '" + userName + "'"))
     {
         return(dbReader.Read());
     }
 }
示例#3
0
文件: FeedDL.cs 项目: maorRoz/Sadna
        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());
        }
示例#4
0
        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;
            }
        }
示例#5
0
文件: OrderDL.cs 项目: maorRoz/Sadna
        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);
        }
示例#6
0
        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);
            }
        }