|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
1) What WaitForPendingFinalizers does ?
it suspend the current thread and clear the memory?
2) Why GC.Collect(); called twice when we use GC.WaitForPendingFinalizers(); ?
3) GC.WaitForPendingFinalizers(); slow down the performance of the application....why ?
Thanks
|
|
|
|
|
|
I am trying to find data in xml file using LINQ but my ANY() or WHERE clause found no data. what is the problem in my approach not clear.
I have a xml file which which has been created by Dataset WriteXml() function. that file i am querying by LINQ and data not found occur.
See my XML structure
<?xml version="1.0" standalone="yes"?>
<TER_ViewAll>
<dgvViewAll_Vertical>
<Section_x0020_>ML</Section_x0020_>
<LineItem>BofA Merrill Lynch</LineItem>
<Revise_x0020_Date>01-16-2018</Revise_x0020_Date>
<_x0032_010_x0020_FYA>1608.6500</_x0032_010_x0020_FYA>
<_x0032_011_x0020_FYA>1429.0610</_x0032_011_x0020_FYA>
<_x0032_012_x0020_FYA>1656.7500</_x0032_012_x0020_FYA>
<_x0032_013_x0020_FYA>1427.9330</_x0032_013_x0020_FYA>
<_x0031_Q_x0020_2014A>321.0100</_x0031_Q_x0020_2014A>
<_x0032_Q_x0020_2014A>525.5670</_x0032_Q_x0020_2014A>
<_x0033_Q_x0020_2014A>478.0100</_x0033_Q_x0020_2014A>
<_x0034_Q_x0020_2014A>323.2360</_x0034_Q_x0020_2014A>
<_x0032_014_x0020_FYA>1647.8230</_x0032_014_x0020_FYA>
<_x0031_Q_x0020_2015A>342.4010</_x0031_Q_x0020_2015A>
<_x0032_Q_x0020_2015A>512.7390</_x0032_Q_x0020_2015A>
<_x0033_Q_x0020_2015A>465.9940</_x0033_Q_x0020_2015A>
<_x0034_Q_x0020_2015A>318.4440</_x0034_Q_x0020_2015A>
<_x0032_015_x0020_FYA>1639.5780</_x0032_015_x0020_FYA>
<_x0031_Q_x0020_2016A>430.9940</_x0031_Q_x0020_2016A>
<_x0032_Q_x0020_2016A>531.7920</_x0032_Q_x0020_2016A>
<_x0033_Q_x0020_2016A>410.4750</_x0033_Q_x0020_2016A>
<_x0034_Q_x0020_2016A>379.9890</_x0034_Q_x0020_2016A>
<_x0032_016_x0020_FYA>1753.2500</_x0032_016_x0020_FYA>
<_x0031_Q_x0020_2017A>456.9130</_x0031_Q_x0020_2017A>
<_x0032_Q_x0020_2017A>696.9010</_x0032_Q_x0020_2017A>
<_x0033_Q_x0020_2017A>503.3780</_x0033_Q_x0020_2017A>
<_x0034_Q_x0020_2017A />
<_x0032_017_x0020_FYA />
<_x0031_Q_x0020_2018A />
<_x0032_Q_x0020_2018A />
<_x0033_Q_x0020_2018A />
<_x0034_Q_x0020_2018A />
<_x0032_018_x0020_FYA />
<_x0031_Q_x0020_2019A />
<_x0032_Q_x0020_2019A />
<_x0033_Q_x0020_2019A />
<_x0034_Q_x0020_2019A />
<_x0032_019_x0020_FYA />
<_x0031_Q_x0020_2020A />
<_x0032_Q_x0020_2020A />
<_x0033_Q_x0020_2020A />
<_x0034_Q_x0020_2020A />
<_x0032_020_x0020_FYA />
<_x0031_Q_x0020_2021E />
<_x0032_Q_x0020_2021E />
<_x0033_Q_x0020_2021E />
<_x0034_Q_x0020_2021E />
<_x0032_021_x0020_FYE />
<_x0031_Q_x0020_2022E />
<_x0032_Q_x0020_2022E />
<_x0033_Q_x0020_2022E />
<_x0034_Q_x0020_2022E />
<_x0032_022_x0020_FYE />
<GroupKey>Consensus Model~Net Revenue~TRIN~NBM~~1~ML</GroupKey>
</dgvViewAll_Vertical>
</TER_ViewAll>
the above xml is one records and xml file has many records like above one. i load that xml file by data ser and querying by LINQ. this way i am querying.
private void button1_Click(object sender, EventArgs e)
{
string QCViewPath_savepath = @"C:\RDSS WorkBench_Stage\Data\TER\TER_QC-ViewwAll.xml";
DataSet ds = new DataSet();
ds.ReadXml(QCViewPath_savepath);
if (ds.Tables[0].AsEnumerable().Any(a => a.Field<string>("Section ") == "ML"
&& a.Field<string>("GroupKey").Contains("Consensus Model")
&& a.Field<string>("GroupKey").Contains("Net Revenue")
&& a.Field<string>("GroupKey").Contains("NBM")
&& a.Field<string>("GroupKey").Contains("1")
&& a.Field<string>("GroupKey").Contains("ML")
))
{
ds.Tables[0].AsEnumerable().Where(a => a.Field<string>("Section ") == "ML"
&& a.Field<string>("GroupKey").Split('~')[0].Trim() == "Consensus Model"
&& a.Field<string>("GroupKey").Split('~')[1].Trim() == "Net Revenue"
&& a.Field<string>("GroupKey").Split('~')[3].Trim() == "NBM"
&& a.Field<string>("GroupKey").Split('~')[4].Trim() == "1"
&& a.Field<string>("GroupKey").Split('~')[5].Trim() == "ML"
).ToList<DataRow>()
.ForEach(r =>
{
r["2010 FYA"] = 1200;
});
}
}
My object is to update data table periodical value and save that data at last after all update. after querying data table i am getting Enumeration yielded no results
please help with rectified code. Thanks
modified yesterday.
|
|
|
|
|
You have no field in your XML called "Section ":
if (ds.Tables[0].AsEnumerable().Any(a => a.Field<string>("Section ") == "ML"
&& ...
))
So the first test will always fail.
You have "Section_x0020_" but no "Section " ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Sir xml was created by data table writexml function data looks like & see how Section element looks in xml <section_x0020_>ZB that is why we need to add space end of Section other wise program will throw run time error.
<dgvViewAll_Vertical>
<Section_x0020_>ZB</Section_x0020_>
<LineItem>B. Riley Securities</LineItem>
<Revise_x0020_Date>02-09-2021</Revise_x0020_Date>
<_x0032_010_x0020_FYA />
<_x0032_011_x0020_FYA />
<_x0032_012_x0020_FYA />
<_x0032_013_x0020_FYA />
<_x0031_Q_x0020_2014A />
<_x0032_Q_x0020_2014A />
<_x0033_Q_x0020_2014A />
<_x0034_Q_x0020_2014A />
<_x0032_014_x0020_FYA />
<_x0031_Q_x0020_2015A />
<_x0032_Q_x0020_2015A />
<_x0033_Q_x0020_2015A />
<_x0034_Q_x0020_2015A />
<_x0032_015_x0020_FYA />
<_x0031_Q_x0020_2016A />
<_x0032_Q_x0020_2016A>3333.3865</_x0032_Q_x0020_2016A>
<_x0033_Q_x0020_2016A>3878.1150</_x0033_Q_x0020_2016A>
<_x0034_Q_x0020_2016A>4376.5020</_x0034_Q_x0020_2016A>
<_x0032_016_x0020_FYA />
<_x0031_Q_x0020_2017A>3340.3645</_x0031_Q_x0020_2017A>
<_x0032_Q_x0020_2017A>3711.3744</_x0032_Q_x0020_2017A>
<_x0033_Q_x0020_2017A>4310.8500</_x0033_Q_x0020_2017A>
<_x0034_Q_x0020_2017A>5041.2855</_x0034_Q_x0020_2017A>
<_x0032_017_x0020_FYA>16403.8744</_x0032_017_x0020_FYA>
<_x0031_Q_x0020_2018A>4867.8009</_x0031_Q_x0020_2018A>
<_x0032_Q_x0020_2018A>5167.5060</_x0032_Q_x0020_2018A>
<_x0033_Q_x0020_2018A />
<_x0034_Q_x0020_2018A />
<_x0032_018_x0020_FYA />
<_x0031_Q_x0020_2019A />
<_x0032_Q_x0020_2019A>3545.9127</_x0032_Q_x0020_2019A>
<_x0033_Q_x0020_2019A>3308.1080</_x0033_Q_x0020_2019A>
<_x0034_Q_x0020_2019A>3911.1380</_x0034_Q_x0020_2019A>
<_x0032_019_x0020_FYA />
<_x0031_Q_x0020_2020A>2798.3300</_x0031_Q_x0020_2020A>
<_x0032_Q_x0020_2020A>3054.0900</_x0032_Q_x0020_2020A>
<_x0033_Q_x0020_2020A>$3,851.0000</_x0033_Q_x0020_2020A>
<_x0034_Q_x0020_2020A>4495.1620</_x0034_Q_x0020_2020A>
<_x0032_020_x0020_FYA>14198.5820</_x0032_020_x0020_FYA>
<_x0031_Q_x0020_2021E>4187.6225</_x0031_Q_x0020_2021E>
<_x0032_Q_x0020_2021E>4701.8271</_x0032_Q_x0020_2021E>
<_x0033_Q_x0020_2021E>4902.8013</_x0033_Q_x0020_2021E>
<_x0034_Q_x0020_2021E>4929.6456</_x0034_Q_x0020_2021E>
<_x0032_021_x0020_FYE>18721.8968</_x0032_021_x0020_FYE>
<_x0031_Q_x0020_2022E>4980.5665</_x0031_Q_x0020_2022E>
<_x0032_Q_x0020_2022E>5074.0862</_x0032_Q_x0020_2022E>
<_x0033_Q_x0020_2022E>5281.4401</_x0033_Q_x0020_2022E>
<_x0034_Q_x0020_2022E>5307.0933</_x0034_Q_x0020_2022E>
<_x0032_022_x0020_FYE>20643.1862</_x0032_022_x0020_FYE>
<_x0031_Q_x0020_2023E>4201.8093</_x0031_Q_x0020_2023E>
<_x0032_Q_x0020_2023E>4211.1577</_x0032_Q_x0020_2023E>
<_x0033_Q_x0020_2023E>4220.5062</_x0033_Q_x0020_2023E>
<_x0034_Q_x0020_2023E>4220.5062</_x0034_Q_x0020_2023E>
<_x0032_023_x0020_FYE>16853.9796</_x0032_023_x0020_FYE>
<GroupKey>Consensus Model~Total Revenue~TRIN~NBM~~1~ZB</GroupKey>
</dgvViewAll_Vertical>
|
|
|
|
|
So what? You STILL don't have anything in that XML called "Section".
If this XML is being written incorrectly, I think the problem would come down to the code that generated the original datatable and/or the code that wrote it to the file.
|
|
|
|
|
The underscore character '_' is not a "special character" in XML data - it does not indicate to anything standard that the hex value between a pair of underscores should be treated as a single Unicode character. It's just a valid character in an element name, is all. So an XML element called "Section_x0020_" is not equivalent to a table column called "Section " or even "Section" - it becomes a column named "Section_x0020_" is all.
Even if it was - which it isn't - ending a field or element name with an "invisible character" would be a very poor practice!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Just as a thought, see here: The Naming of Parts[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Yes issue fixed. sharing working code.
string QCViewPath_savepath = @"C:\Test.xml";
DataSet ds = new DataSet();
ds.ReadXml(QCViewPath_savepath);
if (ds.Tables[0].AsEnumerable().Any(a => a.Field<string>("Section ") == "ML"
&& a.Field<string>("GroupKey").Split('~')[0].Trim() == "Consensus Model"
&& a.Field<string>("GroupKey").Split('~')[1].Trim() == "Net Revenue"
&& a.Field<string>("GroupKey").Split('~')[3].Trim() == "NBM"
&& a.Field<string>("GroupKey").Split('~')[5].Trim() == "1"
&& a.Field<string>("GroupKey").Split('~')[6].Trim() == "ML"
))
{
ds.Tables[0].AsEnumerable().Where(a => a.Field<string>("Section ") == "ML"
&& a.Field<string>("GroupKey").Split('~')[0].Trim() == "Consensus Model"
&& a.Field<string>("GroupKey").Split('~')[1].Trim() == "Net Revenue"
&& a.Field<string>("GroupKey").Split('~')[3].Trim() == "NBM"
&& a.Field<string>("GroupKey").Split('~')[5].Trim() == "1"
&& a.Field<string>("GroupKey").Split('~')[6].Trim() == "ML"
).ToList<DataRow>()
.ForEach(r =>
{
r["2010 FYA"] = 1200;
});
}
|
|
|
|
|
Hello
I find on the internet many slider on the internet from 0-10 and so on but I don't find any for hour and minute.
I am trying to make something like this (jquery): https://codepen.io/caseymhunt/pen/kertA
I don't know how I can make in C# winform. I just need to able select beginning and ending of the hour and minute. When moving the slider then increasing and decreasing with 15 minutes.
Is there an open source for this or how I can make this? The design can be basic too, I just need the function to work.
I don't have any idea how to make this possible.
Thank you in advance all of the answers.
|
|
|
|
|
Create a UserControl, and start there.
Give it a fixed height, and add four "points": minimum, maximum, low, high.
These are probably integer values which do not relate in any way directly to hours and minutes, so the control can be flexible.
Handle the Paint event to draw the control and two "handles" that you can move.
Handle the MouseDown, MouseUp, and MouseMove events to let you move the handles.
As they move, update the low and high values.
Provide properties to read the values, and in there translate the integers to hours and minutes - perhaps return a timespan? One digit move could be your fifteen minutes.
Provide an event to indicate "slider changed" so the outside world can react to it.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
put two System.Windows.Forms.TrackBar Controls on a form: tBarHour, tBarMinute. Configure:
// tBarHour
//
this.tBarHour.LargeChange = 4;
this.tBarHour.Location = new System.Drawing.Point(280, 148);
this.tBarHour.Maximum = 23;
this.tBarHour.Name = "tBarHour";
this.tBarHour.Size = new System.Drawing.Size(375, 45);
this.tBarHour.TabIndex = 11;
this.tBarHour.Value = 12;
this.tBarHour.ValueChanged += new System.EventHandler(this.tBarHourMinute_ValueChanged);
//
// tBarMinute
//
this.tBarMinute.LargeChange = 10;
this.tBarMinute.Location = new System.Drawing.Point(280, 200);
this.tBarMinute.Maximum = 59;
this.tBarMinute.Name = "tBarMinute";
this.tBarMinute.Size = new System.Drawing.Size(375, 45);
this.tBarMinute.TabIndex = 12;
this.tBarMinute.ValueChanged += new System.EventHandler(this.tBarHourMinute_ValueChanged); The Minimum TrackBar value is #0 by default.
Set the ValueChanged event handler for both TrackBars to:
private TimeSpan tSpan;
private string tSpanStr;
private void tBarHourMinute_ValueChanged(object sender, EventArgs e)
{
tSpan = new TimeSpan(0, tBarHour.Value, tBarMinute.Value, 0);
tSpanStr = tSpan.ToString());
}
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
modified 2 days ago.
|
|
|
|
|
I have the following query.
There is a one-to-many relationship between Jobs->JobSequenceSheets.
I'm joining to JobSequenceSheets. But what I really want is just the COUNT of the JobSequenceSheets records for each Job record.
I'm not sure how to do this. Can someone help?
var datas = (from j in dc.Jobs
join p in dc.Projects on j.ProjectId equals p.Id
join cty in dc.Cities on p.CityId equals cty.Id
join cl in dc.CompanyLocations on p.LocationId equals cl.Id
let jsdr = dc.JobStartDateRevisions.Where(q => q.JobId == j.Id)
.OrderByDescending(q => q.Revision)
.Take(1)
.FirstOrDefault()
join jss in dc.JobSequenceSheets on j.Id equals jss.JobId
let lots = dc.JobSequenceSheets.Where(q => q.JobId == j.Id).Count()
where (jsdr != null && jsdr.StartDate >= startDate && jsdr.StartDate <= endDate)
select new
{
JobId = j.Id,
JobNumber = j.JobNumber,
Lots = j.Lots,
StartDate = jsdr.StartDate,
ProjectId = p.Id,
ProjectNumber = p.ProjectNumber,
ProjectName = p.ProjectName,
CityId = cty.Id,
City = cty.City1,
LocationId = cl.Id,
Location = cl.Location,
}).OrderBy(x => x.Location)
.ThenBy(x => x.ProjectName)
.ThenBy(x => x.StartDate).ToList();
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Can't you just do that with a GROUP BY?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Probably, but I'm not sure of the syntax
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I've no idea what your DB looks like, but if you have a table containing a foreign key to another, then it's pretty simple.
Assume a Invoices system for simplicity. It contains two tables:
Invoices
ID
InvoiceDate
CustomerID
... InvoiceLines
ID
InvoiceID
ProductID
Quantity
UnitPrice
...
So to get the number of Lines per Invoice it's simple to use a group:
SELECT InvoiceID, COUNT(ID)
FROM InvoiceLines
GROUP BY InvoiceID
So if I issue two invoices:
ID = 1, InvoiceDate = #2021-04-07#, ...
ID = 2, InvoiceDate = #2021-04-08#, ...
ID = 1, InvoiceID = 1, ...
ID = 2, InvoiceID = 1, ...
ID = 3, InvoiceID = 1, ...
ID = 4, InvoiceID = 1, ...
ID = 5, InvoiceID = 2, ...
ID = 6, InvoiceID = 2, ...
ID = 7, InvoiceID = 2, ... Then the query returns:
1, 4
2, 3 Which sounds like what you are looking for.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Good evening everyone, in fact I finished my Point of Sale application on C # .net and SQL server. On the development pc everything is working fine, my concern is to make the application usable in multi-workstation with an Internet connection I have tried everything but to no avail ...
Please if anyone has a solution or an idea to solve this problem.
Thanks for your help
|
|
|
|
|
What problem?
We have no idea what you have done, what you have tried, or even what you are trying to do!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Member 14192216 wrote: Please if anyone has a solution or an idea to solve this problem. It's very easy. The client app needs to be able to access the server app. Usually you install sql server on a machine and then change the connection string to point to that server.
Not to be too critical, but how did you build a POS system without knowing how to change a connection string?
|
|
|
|
|
This connection string can be changed by what? show me please i'm limited by that
|
|
|
|
|
Where did you put it?
It's either hard coded in your code somewhere or it's in your apps app.config file. It's just text in either case.
|
|
|
|
|
Exposing an SQL Server directly to the web is a bad idea.
You should be putting your SQL Server behind a web service that handles all transactions with the SQL database. Your application on client machines should be interacting with this web service with an authenticated and secured connection (think SSL and HTTPS).
It sounds like you have a lot more work to do and your application is indeed NOT finished.
|
|
|
|