Example #1
0
 //单例模式
 public static SampleOrderSQLManagement GetInstance()
 {
     if (instance == null)
     {
         instance = new SampleOrderSQLManagement();
     }
     return(instance);
 }
Example #2
0
        public App()
        {
            InitializeComponent();
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            EnteredBackground += App_EnteredBackground;
            var instance = SampleDataService.GetInstance();
            var mySQL    = SampleOrderSQLManagement.GetInstance();

            // get all elements in sql
            mySQL.GetAll();
            if (instance.allItems.Count != 0)
            {
                instance.allItems.Clear();
            }
            for (int i = 0; i < mySQL.allItems.Count; i++)
            {
                instance.allItems.Add(mySQL.allItems[i]);
            }

            // Deferred execution until used. Check https://msdn.microsoft.com/library/dd642331(v=vs.110).aspx for further info on Lazy<T> class.
            _activationService = new Lazy <ActivationService>(CreateActivationService);
        }
Example #3
0
 //得到全部
 public void GetAll()
 {
     this.allItems.Clear();
     using (var statement = mySQL.Prepare(SQL_ALL_VALUE_DISTINCT)) {
         while (SQLiteResult.ROW == statement.Step())
         {
             int getOrderId = int.Parse((string)statement[0]);
             using (var statement3 = mySQL.Prepare(SQL_ACCURATE_QUERY_VALUE_LIMIT)) {
                 statement3.Bind(1, getOrderId);
                 statement3.Step();
                 int       getUserNum = int.Parse((string)statement3[1]);
                 int       getTable   = int.Parse((string)statement3[2]);
                 int       getPepper  = int.Parse((string)statement3[3]);
                 float     getPrice   = float.Parse((string)statement3[4]);
                 string    getDetails = (string)statement3[5];
                 UserOrder newOne     = new UserOrder {
                     OrderId = getOrderId,
                     UserNum = getUserNum,
                     Table   = getTable,
                     Pepper  = getPepper,
                     Price   = getPrice,
                     Details = getDetails
                 };
                 using (var statement2 = mySQL.Prepare(SQL_ACCURATE_QUERY_VALUE)) {
                     statement2.Bind(1, newOne.OrderId.ToString());
                     while (SQLiteResult.ROW == statement2.Step())
                     {
                         int         sampleOrderID = int.Parse((string)statement2[6]);
                         int         num           = Convert.ToInt32(statement2[7]);
                         SampleOrder temp          = SampleOrderSQLManagement.GetInstance().accurateQueryItem(sampleOrderID.ToString());
                         temp.Ordered = num;
                         newOne.SampleItems.Add(temp);
                     }
                 }
                 allItems.Add(newOne);
             }
         }
     }
 }