예제 #1
0
        //Call Summary methods
        public List <callObject> GetCallList(caller thisCaller)
        {
            List <callObject> callList = new List <callObject>();

            string searchQuery = "SELECT [Call Date],[Duration],[Receiver Name],[Dialled Extension] FROM newSearch AS Calls WHERE [Direction] = 'Outgoing' AND [Caller Number]='" + thisCaller.callerNumber + "'";

            using (IDBManager manager = new DBManager(_provider, _connectionString))
            {
                manager.Open();
                IDataReader callReader = manager.ExecuteReader(CommandType.Text, searchQuery);
                if (callReader != null)
                {
                    string callerName   = thisCaller.callerName;
                    string callerNumber = thisCaller.callerNumber;

                    while (callReader.Read())
                    {
                        string callDate     = callReader.GetValue(0).ToString();
                        string duration     = callReader.GetValue(1).ToString();
                        string receiverName = callReader.GetValue(2).ToString();
                        if (receiverName == String.Empty)
                        {
                            receiverName = "Unknown";
                        }
                        string receiverNumber = callReader.GetValue(3).ToString();

                        string cost = CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol + GetCallCost(callDate, duration, callerNumber, receiverNumber).ToString();
                        callList.Add(new callObject(callDate, receiverName, receiverNumber, duration, cost));
                    }
                }
            }
            return(callList);
        }
예제 #2
0
        public string GetTotalCallerCost(caller thisCaller)
        {
            string searchQuery = "SELECT SUM([Cost]) FROM newSearch WHERE [Caller Number] = '" + thisCaller.callerNumber + "' AND [Direction] = 'Outgoing'";

            using (IDBManager manager = new DBManager(_provider, _connectionString))
            {
                manager.Open();
                IDataReader reader = manager.ExecuteReader(CommandType.Text, searchQuery);

                string costSum = "0.0";
                while (reader.Read())
                {
                    costSum = reader.GetValue(0).ToString();
                }
                return(costSum);
            }
        }