|
I have a table which has columns like this
EmpID | Hours | Date
1 | 7.5 | 20110105
1 | 7.5 | 20110106
1 | 7.5 | 20110107
1 | 7.5 | 20110108
1 | 7.5 | 20110208
date means 2011-01-05
Now i want to get consolidated record of employees like this
EmpID | Hours | Date
1 | 30 | 01
1 | 7.5 | 02
for this i am using this in linq [of course some joins]
from lev in db.TimeTables
where lev.ActualDate.Contains(Year) &&
lev.PRJ_InternalID.Equals(36)
join
emp in db.Employees on lev.EMP_InternalID equals emp.InternalID
join
prj in db.Projects on lev.PRJ_InternalID equals prj.InternalID
select new LastYearVacationDetail
{
EmployeeID = lev.EMP_InternalID,
LeaveDays = lev.Hours,
Month = lev.ActualDate.Substring(5, 2)
}).ToList();
Now i am not getting Sum and not able to group.
Any help is appreciated
|
|
|
|
|
You could post this in the Linq forum[^]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hello,
I have an application that is composed of 2 forms. The first page launches the second page. On Page 2, I have a "Save As" button that launches a SaveFileDialog box, which works perfectly to save a file. However, whether I save or cancel, after it is done, the application closes Page 2 and restarts on Page 1. I want to application to simply return me to Page 2 where the Save As button is. I have tried several variations but have been unable to make it work that way. I am looking for a piece of code that will allow a new instruction when either Cancel or Save is selected from the SaveFileDialog box. I am including the save dialog code that I am using.
string savedFile = string.Empty;
SaveFileDialog saveFD = new SaveFileDialog();
saveFD.Filter = "Text Files|*.txt|All Files|*.*";
saveFD.Title = "Save a Text File";
if (saveFD.ShowDialog() != DialogResult.Cancel)
{
savedFile = saveFD.FileName;
richTextBoxSql.SaveFile(savedFile, RichTextBoxStreamType.PlainText);
}
else
{
}
Any suggestions are gratefully appreciated. Thank You..Pat
|
|
|
|
|
The code you have provided is fine and will not cause the form that calls this code to close. You must have this save as button set as the Accept or Cancel button for the form, or the button click handler contains the formname.close call.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Great Call Marcus....definitely a case of not being able to see the forest through the trees! I have this very poor habit of copying controls rather than making new one's, caused by my laziness when it comes to having to format. I may have done that with this button (or something else as foolish) and somehow managed to assign it the Cancel event. I gratefully gave you a fast five for this one. Best to all that replied. I truly do appreciate it. Luc...thank you for your input. Nice to see you replying to me again...Pat
|
|
|
|
|
I tried pasting your code into a form, and displaying the form via both Show and ShowDialog. Even with an AcceptButton and a CancelButton defined, I could not make it close the form by closing the SaveFileDialog with the mouse on either button, or with the ENTER or ESC keys.
In short - I cannot duplicate your problem from the information you have given. What are you doing that I am not? Have you tried removing code until it does work, then putting it back until it stops again?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
OriginalGriff wrote: Have you tried ... putting it back until it stops again?
Now why would he want to do that?
Seriously, removing code to deal with a bug is fine, most bugs are in code you don't really need anyway; putting the bugs back in is a bit weird though.
|
|
|
|
|
Take away in huge chunks: problem goes away. Put back smaller chunks: problem comes back. Your bug is now in a smaller bit of code, so repeat the process until you have a manageable code size that demonstrates the problem.
I do like to be able to replicate bugs before I try to fix them...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Got my five on this one, which I think deserves posterity via some "idiom."
My suggestion: "kill code until live: resurrect code until death."
Actually it's a technique I use quite often to isolate bugs, along with trying to reproduce the bug "outside" the original context by creating a special test-case mini-app, or replacement class, or whatever.
best, Bill
"Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill
|
|
|
|
|
How are you implementing your pages? are you using a tab control? On which pade is the rich text box?
|
|
|
|
|
Hello everybody, and sorry for my bad English, I'm trying to draw Wave forms from a wave file.
I know that in .Wav files data are codified by the PCM technique, and that i have 16 it for each amplitude coded.
So I came up with this code:
private void Plot()
{
int Num = 0;
WaveChart.Series.FindByName("WaveSerie").Points.Clear();
Double Dx = 1 / Ws.CurrentHeader.SampleRate;
for (int i = 0; i < Ws.CurrentBuffer.Length; i += 2)
{
Num = ((Ws.CurrentBuffer[i + 1] * 256) + Ws.CurrentBuffer[i]);
WaveChart.Series.FindByName("WaveSerie").Points.AddXY(Dx * i, Num);
}
}
It just take the 2 bytes read form the .Wav file, and merge them in order to make a 16 bit number, then It tries to draw the point obtained.
But it don't work, because I get an incorent drawing:
http://postimage.org/image/q647gboon/[^]
The correct Wave form is this [From Audacity]:
http://postimage.org/image/9bbrgrwcb/[^]
Ws is just a Class which read a .Wav file and puts in CurrentHeader the file header and in CurrentBuffer the Wave data.
Num is the number obtained by merging the 2 bytes from current buffer, it is the wave amplitude.
Where is the mistake ? Thank you, and sorry again for my English.
|
|
|
|
|
Hi,
in C# int and short are signed, however byte is unsigned by default.
I bet you're using an unsigned byte array, in which case your two-byte to integer conversion is wrong.
A simple if(x>=0x8000) x-=0x10000; could fix it.
|
|
|
|
|
Oh, such a stupid error ! It works ! Thank you very much !
|
|
|
|
|
You're welcome.
|
|
|
|
|
I want to import data from excel to sql server 2005. I am using C# for this purpose. I successfully exported the data of general format
to varchar. But, the problem arises while exporting the data of date type.
I have used date format in excel and want to export it in sql server 2005's datetime field.
The code that I have used is:-
SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
sqlBulk.DestinationTableName = "Data_Master_Inventory";
sqlBulk.ColumnMappings.Add("VendorRegistrationNo", "VendorRegistrationNo");
sqlBulk.ColumnMappings.Add("ProductCode", "ProductCode");
sqlBulk.ColumnMappings.Add("SerialNo", "SerialNo");
sqlBulk.ColumnMappings.Add("VendorProvidedSerialNo", "VendorProvidedSerialNo");
sqlBulk.ColumnMappings.Add("ModelName", "ModelName");
sqlBulk.ColumnMappings.Add("ProductCategoryCode", "ProductCategoryCode");
sqlBulk.ColumnMappings.Add("InventoryDate", "InventoryDate");
sqlBulk.WriteToServer(dReader);
Please provide me necessary solution.
|
|
|
|
|
Hi Rahul
U can refer these links
http://www.sqlteam.com/article/use-sqlbulkcopy-to-quickly-load-data-from-your-client-to-sql-server
http://www.codeproject.com/KB/database/SqlBulkCopy.aspx
http://www.codeproject.com/KB/database/TransferUsingSQLBulkCopy.aspx
http://stackoverflow.com/questions/2238328/sqlbulkcopy-writetoserver-example-what-am-i-doing-wrong
Thanks
Ravindra
|
|
|
|
|
Please use the appropriate editor buttons to make your links clickable.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
It's gonna be one of those kinds of days...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
No change there then.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
hey! Please convert Url to Hyperlink! because it provide better readability and accessibility to other user.
|
|
|
|
|
Always wrap your code in "pre" tag.
|
|
|
|
|
How to take picture from camera(directx.capture)? (please help me)
|
|
|
|
|
Don't post the same question in both Q&A and the forums - is duplicates work and annoys people.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Compensated for 1-voting 'tard...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
And then he 1-voted my post that called him a 'tard...
Some people... SHEESH!
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|