Ejemplo n.º 1
0
        internal List <ObservablePhoneBill> GetPhoneBillList()
        {
            List <ObservablePhoneBill> billList = new List <ObservablePhoneBill>();

            using (SQLiteConnection dbConn = new SQLiteConnection(dbPath))
            {
                string sql = @"select * from BillMetaData order by EpochBillDate desc;";
                using (var statement = dbConn.Prepare(sql))
                {
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        PhoneBill phone_bill = new PhoneBill();

                        phone_bill._billNo  = statement[0].ToString();
                        phone_bill.BillType = statement[1].ToString();
                        phone_bill._phoneNo = statement[2].ToString();
                        phone_bill.BillDate = statement[3].ToString();

                        try { phone_bill.FromDate = statement[4].ToString(); }
                        catch (Exception ex) { }

                        try { phone_bill.ToDate = statement[5].ToString(); }
                        catch (Exception ex) { }

                        try { phone_bill.DueDate = statement[6].ToString(); }
                        catch (Exception ex) { }

                        ObservablePhoneBill bill = new ObservablePhoneBill(phone_bill);
                        billList.Add(bill);
                    }
                }
            }

            return(billList);
        }
        public bool DeletePhoneBill(string billNo)
        {
            ObservablePhoneBill old_bill  = GetObservablePhoneBill(billNo);
            List <DBQuery>      queryList = new List <DBQuery>();
            String  sql;                // The query itself
            DBQuery query;              // Query Object

            sql         = @"DELETE FROM BillMetaData WHERE BillNo = ?";
            query       = new DBQuery();
            query.Query = sql;
            query.addQueryData(billNo);
            queryList.Add(query);

            sql         = @"DELETE FROM BillCallDetails WHERE BillNo = ?";
            query       = new DBQuery();
            query.Query = sql;
            query.addQueryData(billNo);
            queryList.Add(query);

            bool success = dbHelper.executeQueries(queryList);

            if (old_bill != null)
            {
                _phoneBillList.Remove(old_bill);
                _phoneBillDictionary.Remove(billNo);
            }

            return(success);
        }
        public void AddBillToList(PhoneBill pb)
        {
            ObservablePhoneBill opb      = new ObservablePhoneBill(pb);
            ObservablePhoneBill old_bill = GetObservablePhoneBill(pb._billNo);

            if (old_bill != null)
            {
                _phoneBillList.Remove(old_bill);
                _phoneBillDictionary.Remove(pb._billNo);
            }


            _phoneBillList.Add(opb);
            _phoneBillDictionary.Add(pb._billNo, opb);
        }