//public int GetTotalCost(string[] phones) //{ // int messageCost = 0; // foreach (string s in phones) // { // messageCost = messageCost + GetMessageCost(s); // } // return messageCost; //} //private int GetMessageCost(string phone) //{ // int intCost = 0; // string code = ""; // string ntwk = ""; // string cost = ""; // if (phone.Trim().StartsWith("0") && phone.Trim().Length == 10) // { // code = phone.Substring(1, 3); // ArrayList phoneCodes = new ArrayList(nCodes.Keys); // if (phoneCodes.Contains(code)) // { // ntwk = nCodes[code].ToString(); // cost = rates[ntwk].ToString(); // intCost = int.Parse(cost); // } // else // { // intCost = 0; // } // } // else if (phone.Trim().StartsWith("256") && phone.Trim().Length == 12) // { // code = phone.Substring(3, 3); // ArrayList phoneCodes = new ArrayList(nCodes.Keys); // if (phoneCodes.Contains(code)) // { // ntwk = nCodes[code].ToString(); // cost = rates[ntwk].ToString(); // intCost = int.Parse(cost); // } // else // { // intCost = 0; // } // } // else // { // intCost = 0; // } // return intCost; //} public string AddCredit(string user_name, string credit, string name) { string output = ""; int credit_toadd = int.Parse(credit); if (credit_toadd.Equals(0)) { output = "Credit to add cannot be zero"; } else if (user_name.Equals("")) { output = "System failed to alocate User details"; } else { string user = HttpContext.Current.Session["Username"].ToString(); data_file.AddCredit(user_name, credit_toadd, user); output = "CREDIT OF " + credit_toadd.ToString("#,##0") + " HAS BEEN ADDED SUCCESSFULLY TO " + name; } return(output); }