Exemplo n.º 1
0
 public DataTable CalculateNetworkCost(DataTable dt)
 {
     //DataTable dt1 = dt;
     try
     {
         dp = new Databasefile();
         Hashtable networkRates = dp.GetNetworkRates();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             DataRow dr           = dt.Rows[i];
             string  network      = dr["Network"].ToString();
             int     networkCount = int.Parse(dr["TotalSms"].ToString());
             int     networkRate  = int.Parse(networkRates[network].ToString());
             int     totalCost    = networkCount * networkRate;
             dr["TotalCost"] = totalCost.ToString("0,0");
             dr["Network"]   = network;
             dr["TotalSms"]  = networkCount.ToString("0,0");
             //dt.Rows.RemoveAt(0);
             //dt.Rows.Add(dr);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(dt);
 }
Exemplo n.º 2
0
    public Hashtable CheckNumbers(ArrayList numbers)
    {
        Hashtable networkCount = new Hashtable();

        try
        {
            dp = new Databasefile();
            Hashtable networkRates = dp.GetNetworkRates();
            Hashtable networkCodes = dp.GetNetworkCodes();
            ArrayList networks     = new ArrayList(networkRates.Keys);
            foreach (string network in networks)
            {
                networkCount.Add(network, 0);
            }
            foreach (string number in numbers)
            {
                string code     = number.Substring(0, 3);
                string network  = networkCodes[code].ToString();
                int    count    = int.Parse(networkCount[network].ToString());
                int    intCount = count + 1;
                networkCount[network] = intCount;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        return(networkCount);
    }