MajorGeeks Support Forums IOBit Software

Go Back   MajorGeeks Support Forums > Majorgeeks.Com - Support Forums > Programming
Register FAQ Members List Calendar Casino Mark Forums Read

Programming Place to discuss programming including HTML, Java, C++, MySQL and others.


Reply
 
Thread Tools Display Modes
  #1  
Old 04-25-12, 13:07
jcast jcast is offline
Private E-2
 
Join Date: Apr 2012
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default Windows From

Hi I am new to programminh and I am trying to display the whole list of my array into a textbox in windows form:

private void btnLoadCDR_Click(object sender, EventArgs e)
{
string inputString = txtInput.Text;
var inputList = inputString.Split('\n');
var accountSvc = new Shared.Core.Account.AccountSvc();

foreach (string phoneNumber in inputList)
{
var history = accountSvc.GetCallDurationRecords(phoneNumber, DateTime.Parse("01/01/12"), DateTime.Parse("04/14/2012"));
var calledType = history[0].CallType;


txtOut.Text += string.Format("{0}:{1},{2},{3}", phoneNumber, history[31].CalledNumber, history[31].CallType, history[31].Cost) + Environment.NewLine;

}
}

I can get the record of the array 31 for example but how do I get all the records all in one.?
Reply With Quote
Sponsored links
  #2  
Old 04-25-12, 14:13
Wyatt_Earp's Avatar
Wyatt_Earp Wyatt_Earp is offline
Major Geek
 
Join Date: Sep 2002
Location: Powell, OH
Posts: 1,380
Thanks: 3
Thanked 26 Times in 23 Posts
Default Re: Windows From

Since it's hard to tell the structure of your data from the post, I'll give it a shot.

It sounds like you need another loop, e.g.

Code:
// Also don't forget to initialize txtOut.Text
txtOut.Text = string.Empty;

foreach (string phonNumber in inputList)
{
string inputString = txtInput.Text; var inputList = inputString.Split('\n'); var accountSvc = new Shared.Core.Account.AccountSvc(); txtOut.Text += string.Format("{0}:\r\n", phoneNumber); foreach (var histItem in history) {
txtOut.Text += string.Format("- {0},{1},{2}\r\n", histItem.CalledNumber, histItem.CallType, histItem.Cost);
}
}
__________________
"I cannot undertake to lay my finger on that article of
the Constitution which granted a right to Congress of
expending, on the objects of benevolence, the money
of their constituents."

-- James Madison
(1751-1836), Father of the Constitution for the USA,
4th US President
_________________________
AMD Athlon 64 3800+
ABIT KN8 SLI
2 Gb (2x1Gb) PC 3200 Cas 2 Corsair XMS RAM
2x120Gb WD w/ 8Mb cache (RAID 0)
eVGA GeForce 7900GT 256MB
Reply With Quote
  #3  
Old 04-25-12, 17:17
jcast jcast is offline
Private E-2
 
Join Date: Apr 2012
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default Re: Windows From

Thanks Wyatt; The other loop solves the problem, Another question if I want to get the total of my histItem.Cost; how can I add the value of the cost for each record and display a total cost.

you think you can help me with that?
Reply With Quote
  #4  
Old 04-25-12, 20:51
jcast jcast is offline
Private E-2
 
Join Date: Apr 2012
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default Re: Windows From

Here is the code: all the values are displaying fine but I need to get the sum of the cdrRecord.cost in the same txtOut.text.

Please help me.

privatevoid btnLoadCDR_Click(object sender,EventArgs e)

{

string inputString = txtInput.Text;

var inputList = inputString.Split('\n');

var accountSvc = new Shared.Core.Account.AccountSvc();



foreach (string phoneNumberin inputList)

{

var history = accountSvc.GetCallDurationRecords(phoneNumber,DateTime.Parse("01/01/12"),DateTime.Parse("04/14/2012"));



foreach (var cdrRecordin history)

{

if (cdrRecord.CalledNumber == "19402383244" && cdrRecord.Cost > 0)

{

txtOut.Text +=string.Format("- {0},{1},{2}\r\n", cdrRecord.CalledNumber, cdrRecord.CallType, cdrRecord.Cost);



}

else

{



}



}

}

}

Thanks
Reply With Quote
  #5  
Old 04-26-12, 01:18
PC-XT's Avatar
PC-XT PC-XT is offline
Master Sergeant
 
Join Date: Oct 2007
Location: on a farm
Posts: 637
Thanks: 23
Thanked 73 Times in 70 Posts
Post Re: Windows From

It will be best to make another variable, something like this: (untested, but edits commented)
Code:
privatevoid btnLoadCDR_Click(object sender,EventArgs e)

        {

           string inputString = txtInput.Text;

           var inputList = inputString.Split('\n');

           var accountSvc = new Shared.Core.Account.AccountSvc();

           float total;//new variable, which I'll initialize in the loop, use an appropriate name: "total" is really just a placeholder...

           foreach (string phoneNumberin inputList)

            {

               var history = accountSvc.GetCallDurationRecords(phoneNumber,DateTime.Parse("01/01/12"),DateTime.Parse("04/14/2012"));

                total=0.0;//init and reset to 0 for each history

                foreach (var cdrRecordin history)

                {

                   if (cdrRecord.CalledNumber == "19402383244" && cdrRecord.Cost > 0)

                    {

                        txtOut.Text +=string.Format("- {0},{1},{2}\r\n", cdrRecord.CalledNumber, cdrRecord.CallType, cdrRecord.Cost);

                      total+=cdrRecord.Cost;//accumulate the total, assuming cdrRecord.Cost is a number

                    }

                    txtOut.Text+=string.Format("- Total {0}\r\n",total);//put the total at the end

                   else

                    {

 

                    }

 

                }

            }

        }
__________________
I.think(code);
I.eat(code.spaghetti);
Reply With Quote
The Following User Says Thank You to PC-XT For This Useful Post:
jcast (05-02-12)
Sponsored links
  #6  
Old 05-02-12, 14:38
jcast jcast is offline
Private E-2
 
Join Date: Apr 2012
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default Re: Windows From

Hi; I need to make a new post (New question) and I cannot find where to click to create a new thread. Please let me know cause I need to ask a new question.

Thanks
Reply With Quote
  #7  
Old 05-02-12, 15:18
jcast jcast is offline
Private E-2
 
Join Date: Apr 2012
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default Re: Windows From

I figured it out how to make a new post.

Thanks anyways
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows 7 Blue Screen after Windows Logo STOP: C0000135 BSOD kuzya Software 6 01-12-12 14:27
When Disabling Windows Snap in Windows 7, Loose Windows Aero Pointers Scheme? montecarlo1987 Software 1 09-04-10 16:56
Task Manager error: C:\Windows\System32\UTILDLL.dll is not a valid Windows image boom929 Malware Removal 7 01-07-09 18:03
\WINDOWS\SYSTEM32\CONFIG\SYSTEM corrupt, recovery console won't recognize windows dep187 Software 30 08-08-06 21:51
End of support for Windows 98, Windows Me, and Windows XP Service Pack 1 NICK ADSL UK Software 1 07-12-06 05:53


All times are GMT -5. The time now is 00:11.


MajorGeeks.Com Home Page
| Admin Tools | All In One | Anti-Spyware | Anti-Virus | Appearance | Backup | Benchmarking | BIOS | Browsers | Covert Ops |
Data Recovery | Diagnostics | Drive Cleaners | Drive Utilities | Drivers | Driver Tools Ergonomics | Firewalls | Games | Game Tweaks | Graphics | Input Devices | Internet Tools | Macintosh | Mail Utilities | Memory | Messaging | Monitoring | Microsoft | Multimedia | Networking | Office Tools | Process Management | Processor | Registry | Security | System Info | Toys | Video | Miscellaneous
|

-->
Powered by vBulletin® Version 3.8.4
Copyright © 2009 vBulletin Solutions, Inc. All rights reserved.
Ad Management by RedTyger