|
hi there,
i made this
<pre>
string[] allLines = System.IO.File.ReadAllLines(@"C:\new.txt");
foreach (string eachRow in allLines)
{
try
{
string[] rowaArray = eachRow.Split(',');
string enrollID = rowaArray[1];
DateTime date1 = DateTime.Now;
DateTime date2 = Convert.ToDateTime(rowaArray[3] + " " + rowaArray[5]);
TimeSpan dtDiff = date1 - date2;
listBox1.Items.Add(dtDiff.Days + " Days " + dtDiff.Hours + " Hours " + dtDiff.Seconds + " Seconds ");
}
catch
(IndexOutOfRangeException ex)
{ }
}
</pre>
i got this output
28 Days 9 Hours 13 Seconds
28 Days 9 Hours 8 Seconds
27 Days 23 Hours 4 Seconds
27 Days 23 Hours 59 Seconds
27 Days 23 Hours 12 Seconds
27 Days 23 Hours 4 Seconds
27 Days 18 Hours 21 Seconds
27 Days 16 Hours 24 Seconds
27 Days 16 Hours 7 Seconds
27 Days 16 Hours 32 Seconds
27 Days 16 Hours 20 Seconds
27 Days 16 Hours 10 Seconds
27 Days 15 Hours 49 Seconds
27 Days 15 Hours 33 Seconds
27 Days 11 Hours 33 Seconds
27 Days 9 Hours 33 Seconds
27 Days 9 Hours 22 Seconds
26 Days 23 Hours 20 Seconds
26 Days 23 Hours 14 Seconds
26 Days 23 Hours 8 Seconds
26 Days 23 Hours 27 Seconds
is this correct? as i feel it's alphabetical.
i want to also ask.if i made a combobox with all employees numbers(enroll no).what event i should use inorder when i select the enroll no.the required number of hours is displayed.
|
|
|
|
|
It's not alphabetical, it is in order of the lines in your file.
I suspect that what you now need to do is tie your enrol no to "check in" and "check out" from your file, and collect the data for display. That bit is over to you, as I do not have the time to do all your homework for you!
The event you are looking for is (predictably enough) "SelectedIndexChanged"
Good luck!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
hi,
i tranced the o/p i have.the output i have isn't logic.
as it's subtract the date/time for today 28/5/2009 from for example:
Enroll No,78,date2,30/4/2009,time2,0:3:43,Check Out
the result is
No:78 Hours 14minutes2 Seconds 34
i should change this
DateTime date1 = DateTime.Now;
to refer to date1 from the file not for DateTime.Now;
but if date1=Convert.ToDateTime(rowaArray[3] + " " + rowaArray[5]); as they are same.
the result will be 0.
have you any idea to change this ?
|
|
|
|
|
Yes. But you will hav eto do the work - it's not that hard!
Look at the data in the file you showed earlier:
Enroll No,194,date2,30/4/2009,time2,0:3:38,Check Out
Enroll No,78,date2,30/4/2009,time2,0:3:43,Check Out
Enroll No,78,date1,30/4/2009,time1,9:44:47,Check In
Enroll No,107,date1,30/4/2009,time1,9:44:52,Check In
Enroll No,108,date1,30/4/2009,time1,9:57:39,Check In
Enroll No,106,date1,30/4/2009,time1,10:40:47,Check In
Enroll No,109,date1,30/4/2009,time1,15:23:30,Check In
Enroll No,107,date2,30/4/2009,time2,17:6:27,Check Out
Enroll No,194,date1,30/4/2009,time1,17:9:44,Check In
Enroll No,132,date1,30/4/2009,time1,17:32:19,Check In
Enroll No,106,date2,30/4/2009,time2,17:35:31,Check Out
Enroll No,78,date2,30/4/2009,time2,17:35:41,Check Out
Enroll No,132,date1,30/4/2009,time1,17:45:2,Check In
Enroll No,108,date2,30/4/2009,time2,18:33:18,Check Out
Enroll No,109,date2,30/4/2009,time2,22:30:18,Check Out
Enroll No,194,date2,1/5/2009,time2,0:4:18,Check Out
Enroll No,132,date2,1/5/2009,time2,0:4:29,Check Out
Each line is a record:
Number 194 Checked out on 30/4/2009 @ 0:3;38
Number 78 Checked out on 30/4/2009 @ 0:3:43
Number 78 Cheked in on 30/4/2009 @ 9:44:47
and so forth...
This means you have to match up the check in with the appropriate check out, and work out the time difference - I am sure this is what the exercise you were set says (and I have never seen the exercise...)
The data you need is not all on one line. Think about what you have been taught in the course so far: I am sure that the structures and loops etc. cover what you need.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
can you suggest me a good book as i'm still a beginner.i take long time to think what the right thing to put.
i was reading visual c# steop by step..but didn't finish it yet.
thanks,
|
|
|
|
|
I can't - there are so many of them, and for a complete beginner I really don't know - I came to C# from C++, and all the way back to assembler, so I started with knowledge you don't have and the books I used presummed that knowledge. Anything called step-by-step is probably a good starting point!
Don't think of it in C# terms: try to think "How would I do this if it was on a piece of paper?"
I would:
Call this "The List":
Enroll No,194,date2,30/4/2009,time2,0:3:38,Check Out
Enroll No,78,date2,30/4/2009,time2,0:3:43,Check Out
Enroll No,78,date1,30/4/2009,time1,9:44:47,Check In
Enroll No,107,date1,30/4/2009,time1,9:44:52,Check In
Enroll No,108,date1,30/4/2009,time1,9:57:39,Check In
Enroll No,106,date1,30/4/2009,time1,10:40:47,Check In
Enroll No,109,date1,30/4/2009,time1,15:23:30,Check In
Enroll No,107,date2,30/4/2009,time2,17:6:27,Check Out
Enroll No,194,date1,30/4/2009,time1,17:9:44,Check In
Enroll No,132,date1,30/4/2009,time1,17:32:19,Check In
Enroll No,106,date2,30/4/2009,time2,17:35:31,Check Out
Enroll No,78,date2,30/4/2009,time2,17:35:41,Check Out
Enroll No,132,date1,30/4/2009,time1,17:45:2,Check In
Enroll No,108,date2,30/4/2009,time2,18:33:18,Check Out
Enroll No,109,date2,30/4/2009,time2,22:30:18,Check Out
Enroll No,194,date2,1/5/2009,time2,0:4:18,Check Out
Enroll No,132,date2,1/5/2009,time2,0:4:29,Check Out
Get a blank sheet of paper, and a pen.
Look at the first line of the list, make a note of the Enroll number (194).
Beside this, I would write the date and time (30/4/2009 @ 0:3:38) and that this was a check out.
Look at the next line, and do the same. If the Enroll number is already on my piece of paper, then I would add the information to that, otherwise note it down separately.
Continue through the list doing all the lines.
I would then have:
Enroll No194 30/4/2009 @ 0: 3:38,Check Out
Enroll No194 30/4/2009 @ 17: 9:44,Check In
Enroll No194 1/5/2009 @ 0: 4:18,Check Out
Enroll No132 30/4/2009 @ 17:32:19,Check In
Enroll No132 30/4/2009 @ 17:45: 2,Check In
Enroll No132 1/5/2009 @ 0: 4:29,Check Out
Enroll No109 30/4/2009 @ 15:23:30,Check In
Enroll No109 30/4/2009 @ 22:30:18,Check Out
Enroll No108 30/4/2009 @ 9:57:39,Check In
Enroll No108 30/4/2009 @ 18:33:18,Check Out
Enroll No107 30/4/2009 @ 9:44:52,Check In
Enroll No107 30/4/2009 @ 17: 6:27,Check Out
Enroll No106 30/4/2009 @ 10:40:47,Check In
Enroll No106 30/4/2009 @ 17:35:31,Check Out
Enroll No 78 30/4/2009 @ 0: 3:43,Check Out
Enroll No 78 30/4/2009 @ 9:44:47,Check In
Enroll No 78 30/4/2009 @ 17:35:41,Check Out
Now it is easy to see that:
No194 Checked in on 30/4/2009 @ 17: 9:44 and out on 1/5/2009 @ 0: 4:18
so he/she was checked in for some 7 hours.
No132 Checked in on 30/4/2009 @ 17:45: 2 and out on 1/5/2009 @ 0: 4:29
so they were in for 6 1/4 hours or so.
All you have to do is translate that into the C# instructions you do know! I can't tell you what those instructions are because I don't know what instructions you do know - please, do not give me a list. Just have a try, it doesn't have to be good (or even work properly to start with) - you obviously know more than you think, since you are correctly using DateTime and TimeSpan structures already!
Post up what you come up with, and I'm sure we can get it working together.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
hi,
sorry to disturb you again.actually i think text file won't be the ideal solution for me.the data you see before is from a finger print device.i can grasp it easily from the machine.i already tried to insert it into database but from the text file by using bulk insert.the problem is i will make update to the txt.file everytime an employee checked out or in.
I'm thinking now to make a database and make update on it or trigger.
I want to as how to grasp the data from the machine and insert into the database directly?
i just need steps...
thanks alot,
emmy,
|
|
|
|
|
OriginalGriff wrote: [edit]left the damn "encode html tags" on again![/edit]
That damned thing makes me sooooooo
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
It's is very handy, but I've always got it the wrong way round - I must remember to use "preview"...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hello,
Do someone know a professional web image viewer providing scan /annotate/.... and can be integrated with c# application. i should not install anything in the client side.
regards
dghdfghdfghdfghdgh
|
|
|
|
|
I have a table from SQL Server. this table have 3 columns name 'ID','Code','Description'.
Department:
ID Code Description
1001 C01 Accounting
1002 C02 Support
1003 T01 Sale&Market
1004 T02 Front Office
1005 T03 Housekeeping Office
My Combobox need:
a. Only show 'Code' and 'Description' 2 columns value and Don'T show 'ID' values when I dropdown in my WinForm, But Combobox1.value return 'ID' value
b. Display Description's valus when input Code's value
Such as: when I choice or inpurt 'C02' , the Combobox Can show 'Support', and
the Combobox1.value equal to 1002
Now, How can I do ? Give me a example for downlod best.
Thank You.
|
|
|
|
|
Good Morning leung
Lets do this step by Step.
leung wrote :
My Combobox need:
a. Only show 'Code' and 'Description' 2 columns value and Don'T show 'ID' values when I dropdown in my WinForm, But Combobox1.value return 'ID' value
Let me see the code that you use to bind your combobox
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
You need to first bind the datatable with the combo box.
It should be something like this:
combobox1.DataSource = dt;
//Then set the datamember and valuemember as follows:
combobox1.DataMember = "Description";
combobox1.ValueMember = "Value";
//This will work...
And if not just write the value member first and then the data member...
|
|
|
|
|
Hi everyone
Pleasae can someone help me. I have created a custom ribbon and am trying to implement it in an ExcaleAddIn and have created all the neccessary xml for it along with it's events as follows:
<pre><?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab idMso="TabAddIns" label="ValueExplorer">
<group id="grpModel" label="Model Manager">
<button id="btnOpenModel" onAction="btnOpenModel_Click" label="Open Model" showImage="false" />
<button id="btnNewModel" onAction="btnNewModel_Click" label="New Model" showImage="false" />
<button id="btnPublish" onAction="btnPublish_Click" label="Publish VXP Model" showImage="false" />
</group>
<group id="grpVersion" label="Version Manager">
<button id="btnNewVersion" onAction="btnNewVersion_Click" label="New Version" showImage="false" />
<button id="btnOpenVersion" onAction="btnOpenVersion_Click" label="Open Version" showImage="false" />
</group>
<group id="grpObject" label="Object Manager">
<button id="btnNewObject" onAction="btnNewObject_Click" label="New Object" showImage="false" />
<button id="btnOpenObject" onAction="btnOpenObject_Click" label="Open Object" showImage="false" />
</group>
<group id="grpUser" label="User Manager">
<button id="btnNewUser" onAction="btnNewUser_Click" label="New User" showImage="false" />
<button id="btnEditUser" onAction="btnEditUser_Click" label="Edit User" showImage="false" />
</group>
<group id="grpScenario" label="Scenario Manager">
<button id="btnNewScenario" onAction="btnNewScenario_Click" label="New Scenario" showImage="false" />
<button id="btnActivate" onAction="btnActivate_Click" label="Activate" showImage="false" />
<button id="btnVarience" onAction="btnVarience_Click" label="Varience Report" showImage="false" />
<separator id="separator1" />
<button id="btnOpenScenario" onAction="btnOpenScenario_Click" label="Open Scenario" showImage="false" />
<button id="btnGroup" onAction="btnGroup_Click" label="Group Scenarios" showImage="false" />
<button id="btnSaveScenario" onAction="btnSaveScenario_Click" label="Save Scenario" showImage="false" />
</group>
<group id="grpSensitivity" label="Sensitivity Manager">
<button id="btnNewSensitivity" onAction="btnNewSensitivity_Click" label="New Sensitivity" showImage="false" />
<button id="btnOpenSensitivity" onAction="btnOpenSensitivity_Click" label="Open Sensitivity" showImage="false" />
<button id="btnSaveSensitivity" onAction="btnSaveSensitivity_Click" label="Save Sensitivity" showImage="false" />
</group>
<group id="grpTracer" label="Tracer">
<button id="btnView" onAction="btnView_Click" label="View" showImage="false" />
</group>
<group id="grpCalc" label="Calculation">
<checkBox id="chkAutoRecalc" onAction="chkAutoRecalc_Click" label="Auto" />
<button id="btnRecalcNow" onAction="btnRecalcNow_Click" label="Recalc Now" showImage="false" />
</group>
<group id="grpConfig" label="Config Manager">
<button id="btnETLConfig" onAction="btnETLConfig_Click" label="ETL Config" showImage="false" />
<button id="btnSysConfig" onAction="btnSysConfig_Click" label="System Config" showImage="false" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I have also created the callbacks for the OnAction event as such:
<pre>public void OnActionCallback(Office.IRibbonControl control, bool isPressed)
{
if (control.Id == "btnNewVersion_Click")
{
//MessageBox.Show("You clicked " + control.Id);
Form frmNewModel = new Form();
frmNewModel.Show();
}
else
{
MessageBox.Show("You clicked a different control.");
}
}
But i still can't get any functionailty out of it. I have successfully added the ribbon to the workbook as a tab but also have some default menu items displaying even after setting the StratFromScratch property to true.
Please help where you can.
Thanks
"Sex is not the answer, it's the question and the answer is yes"
|
|
|
|
|
hello,
I also did the same code but no message box is appearing on my button click in Ribbon, can any one tell me how to code call back method following is the code of my method which i wrote in Ribbon1.cs :
private void button1_Click(object sender, RibbonControlEventArgs e)
{
MessageBox.Show("Hello");
}
i would like to call this so can you tell me how to do it, i exported the ribbon to Xml and also added the "OnAction" attribute to button control in xml. But still not working........????
|
|
|
|
|
Hi,
I have extended the griview to open in edit mode for all of the rows. After changing in few cells (text boxes) in some of the rows, I want to know which row has how many columns changed by the user. If no cell is changed in the row, the row number should not be returned.
Can any one help me to know which are the cells that changed when the Gridview is in edit mode. Any poniters or hints will help.
Thannks in advance!
Reagrds,
Madan
|
|
|
|
|
Hi
I am creating a Student Registration Form in windows application,
i want to generate a Registration Number to the Student after completing the
Form. The Number should be unique.
Thanks in advance
|
|
|
|
|
If you want a unique number, how about using GUID. It's simple and unique.
|
|
|
|
|
Thank u for your answer................
I am not aware of GUID, Can u give idea how to use it
|
|
|
|
|
string myGuid = Guid.NewGuid().ToString();
"myGuid" is always unique.
|
|
|
|
|
HI
I run the code with GUID the value is too long "2d89b36d-39fd-4ac7-9cb4-bf0d3768a1c6"
I need to display and use only Eight Digits.......
pls give some other idea
|
|
|
|
|
How about just increasing the number:
Student 1 : 00000001
Student 2 : 00000002
...
Student 99999999 : 99999999
|
|
|
|
|
If you want to add a new student, just get the record from database.
For example, the last record is number "10".
Then just give number "11" to the new student.
It's so easy.
The right way is to add a number automatically in database. It increase the number automatically
and the number is a primary key. That means the number is unique.
|
|
|
|
|
I would suggest storing the number in a file outside your app and then read that number when processing a form. Once form has been processed just update the number to the next. This is how I currently do it to store version numbers for batch files generated from my apps.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
|