|
Wow spammings only spams because you are really scared. Please check me! I am not spammer just I am serious and tell that. If you don't believe than I will leave CodeProject if you say about spam, spam , spam? Hello I am not Facebook user. I am very hostile to Facebook. Why do you always talk about spams - please check users are trusted people and they are not spambots just real human.
Thank you!
|
|
|
|
|
Calm down and get a grip. I didn't accuse you of spam. I said that the automatic spam detectors would have flagged your message for investigation because it contained links and you don't have anywhere near enough reputation on the site to he automatically whitelisted. We get dozens, sometimes hundreds, of spam messages a day and if they weren't flagged they would make the forums unusable. Now, if you want to continue throwing a strop, please feel free. Alternatively you could calm down and realise that your message was let through so the person who reviewed it didn't consider it as spam.
This space for rent
|
|
|
|
|
hi
i have two forms
form1 run with button click and doing a foreach loop
i want to every time need to show form2 in the foreach loop, then pause button click event until i have to select an item from form2.listbox then continue button click event
please help me what should i do?
thanks you dear friends
|
|
|
|
|
Simply disable the control before you start your loop. Or disconnect the event when going into the loop, and reconnect when done. Or in the event, check whether you're looping and exit.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Simple:
Form2 f2 = new Form2();
f2.ShowDialog(); the Form1 code will cease working until Form2 is closed, and then continue from the next line.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If you create a new instance of Form2 inside the 'for loop on Form1 ... where the user makes some choice through direct action ... unless you somehow pass the result of the user action back to Form1 ... then there is no point showing Form2.
I suggest:
1. create one instance of Form2 in Form1
2. create a public delegate (use 'Action) in Form2 that is invoked in the ListBox SelectedValueChanged event handler.
3. in Form1 insert your code for the Action into the instance of Form2.
4. in the for loop on Form1 show Form2 using ShowDialog
Form1
using System;
using System.Windows.Forms;
namespace Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Form2 f2 = new Form2();
string listBoxChoice;
private void Form1_Load(object sender, EventArgs e)
{
f2.SendListBoxChoice += SendListBoxChoice;
}
private void SendListBoxChoice(string choice)
{
listBoxChoice = choice;
}
private void testButton_Click(object sender, EventArgs e)
{
for (int i = 0; i < 2; i++)
{
listBoxChoice = "";
f2.ShowDialog(this);
if (listBoxChoice != "")
{
switch (listBoxChoice)
{
case "1":
break;
}
}
}
}
}
} Form2
using System;
using System.Windows.Forms;
namespace Test
{
public partial class Form2 : Form
{
public Action<string> SendListBoxChoice;
public Form2()
{
InitializeComponent();
}
private void listBox1_SelectedValueChanged(object sender, EventArgs e)
{
if (SendListBoxChoice != null)
{
SendListBoxChoice(listBox1.SelectedItem.ToString());
}
}
}
}
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
i designed real estate management system in c#.net and sql server and then have faced problem coding in part of managimg chegues the idea is that the system must send warning message when the contract going to end for examlpe.
in a litle words: i want help how to write code produce warning message before specific time in in c#.net and sql server.
thanks i hope you help me,please i am my final project
|
|
|
|
|
We can't be specific; we have no idea how your system works, how it's written, or even where you get "contract" information from.
But there are three basic ways:
1) A separate application which is run by the system at scheduled intervals which checks the times and reports.
2) A Timer in your application which does the same thing - runs and the contracts are checked each time the Tick handler is called.
3) A Thread in your application which does the same thing: sleeps for a period, then checks the contract times.
Which is best for your application? No idea!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
ahmedoze wrote: i hope you help me,please i am my final project I never did one of those.
So, assuming you have a list of stuff with dates in SQL Server. When the program runs, you fetch all the mail-adresses that have the date "today". Check with an "if" whether or not to send a mail. What part of that are you stuck on?
For bonus points; if you run the program again, or if it crashes half-way, it may send some mails twice. To be correct, you'd need to remember whom you sent a mail and exclude them when fetching todays stuff.
How much time until your deadline?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: How much time until your deadline? He won't know until he can get his application to post a warning message.
|
|
|
|
|
If this is your final project, you should know by now how to create a specification. You only have the highest level of requirement there. When you say that you want the system to send a warning message, for instance, how do you want that warning to be delivered? Are you sending it to a user logged into your system? Are you sending it to clients via email/text? You need to spend more time working out what your requirements are.
If, for instance, you wanted just to send this to a client via email, then you know that there is a possibility that the client isn't going to be logged into your system at an appropriate point. This tells you that you want to write something that can send updates to people as an unattended operation - in other words, you're probably going to want to write a service. You also need some way to identify that you have already sent a notification, so you probably want to have some attribute in the database, against the client, to identify that the message has been sent.
We aren't going to write your code for you, but we will give you ideas on how to start coming up with your own solution.
This space for rent
|
|
|
|
|
First fall Your application will be used by specific users, IF Yes then, when those users login to your application based on your logic you can write the code and display warning message on the screen.
OR
IF Users not login into your application, and you need to send an emails to your client or customers then you need to write a Service, based on that service you can send an emails/warning messages.
If you can give some more details then it will be easy to figure out the way....
|
|
|
|
|
I wrote a command line program to create a process and run a simulation in the background. This worked fine for many years but IT pushed something to our computers and it no longer works efficiently. I use this program to start 200+ simulation runs and as they queued up, they would use 100% loading all my workstation 40 cores until they finished in about 15 seconds. I am not sure what IT pushed to our computers but now I can only get about a 30% usage of my cores and takes 45 seconds to complete. The program only gets about 12 or so simulations running simultaneously. So I tried using Start-Process in powershell and low and behold, it would queue up enough simulations to run to load all 40 cores to 100%. Can anyone tell my how I can get the Process.start to use all of the processing power. IT does not know what has changed to cause the issue. It is a policy setting as IT did test a clean computer without the required policy settings and the Process.Start was able to load all of the cores.
Here is the code I used to start running a single process in C#.
try
{
Process process = new Process();
if (optionHidden)
{
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
}
process.StartInfo.FileName = application;
process.StartInfo.Arguments = arguments;
process.Start();
if (optionWait)
{
process.WaitForExit();
}
}
catch (Exception e)
{
Console.WriteLine("Failed to launch {0} because of {1}", application, e.Message);
}
The application name is nStart and looks like this to start all of the simulation runs.
nStart /hidden nDOF.exe MM0000.ndof
nStart /hidden nDOF.exe MM0001.ndof
nStart /hidden nDOF.exe MM0002.ndof
nStart /hidden nDOF.exe MM0003.ndof
.
.
.
The powershell script looks like this.
Start-Process .\nDOF.exe -ArgumentList 'MM0000.ndof'
Start-Process .\nDOF.exe -ArgumentList 'MM0001.ndof'
Start-Process .\nDOF.exe -ArgumentList 'MM0002.ndof'
Start-Process .\nDOF.exe -ArgumentList 'MM0003.ndof'
.
.
.
|
|
|
|
|
This has nothing to do with your code.
This is a policy problem. Your IT department is going to have to go back through what they change in policies and installs to figure out what's causing this. You should just have to supply them with the date that you noticed the problem occurring and they should be able to look up what's been changed in their change control system. If they don't have such a system, that's a huge problem and you just uncovered a major hole in their processes.
|
|
|
|
|
Yes it is but I have to find the issue and they may still not allow it to be changed. IT has found one policy that allowed the loading to increase to 70% which was "allow process elevation". This was turned on to prevent bad actors from taking control of the computer. I believed the powershell and C# use the same .NET process and was just trying to figure out why they are handled differently and if I could modify my code to work the same. Thanks for the input.
|
|
|
|
|
This cmdlet is implemented by using the Start method of the System.Diagnostics.Process class.
So, the code that PowerShell uses is similar.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi, I am new in Programming. I am writing a simple app using C# in which i want send data to server, data includes URL with two parameters. When i try to send data to server it just sends the URL but not parameters. Can you help me regarding this.
And i have one more problem that i want to stop send data to server when stop button pressed. What method i can use for it.
Thanks.
What I have tried:
var postData = ("id1="+"123456");
postData += ("&id2="+"0123456789");
var request = (HttpWebRequest)WebRequest.Create("http://abc.xyz.com");
// var postData = "keyid1=id1";
// postData += "&keyid2=id2";
var data = Encoding.ASCII.GetBytes(postData);
Console.WriteLine(data);
request.Method = "POST";
request.ContentType = "multipart/form-data";
Console.WriteLine(request.ContentType);
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
stream.Close();
}
var response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.OK)
{
Console.WriteLine("Status Code not OK");
}
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
if (string.IsNullOrWhiteSpace(responseString))
{
Console.WriteLine("Response string is invalid");
}
else
{
Console.WriteLine("Response: " + responseString);
}
response.Close();
-- modified 19-Apr-18 13:43pm.
|
|
|
|
|
What is the actual text of the POST request that gets sent, and what is the response received from the server?
|
|
|
|
|
Hi Richard,
Thank you very much. Actually the problem was related to Server, It may not be set up to accept a POST at that URL. presently it works fine with Get method. Could you help me how i can stop this request to send to server when stop button pressed.
|
|
|
|
|
A better idea is to have a Send button. That way the send operation does not get executed until the user calls it.
|
|
|
|
|
yeah, i have Activate button. When i press activate button then it sends data to the server but now i have one more STOP button, I want that when i would press STOP button then it should stop to send request to Server. Thank you in advance.
|
|
|
|
|
When you press the Activate button the request will be sent to the server in microseconds at most, so there is no way you could react fast enough to stop it. I don't understand what you think you can achieve with this button.
|
|
|
|
|
Okay, pretty simple question, but I'm struggling in figuring it out. I need a label (that's reading from a text file) to return only certain values from within that same text file. The code I have is below:
private void btnCalculate_Click(object sender, EventArgs e)
{
string name = txtName.Text;
string number = txtNumber.Text;
double hourlyRate = Convert.ToDouble(txtPay.Text);
double hoursWorked = Convert.ToDouble(txtHours.Text);
double grossPay = 0.0;
TextWriter txt = new StreamWriter("employee_information.txt");
if (hoursWorked <= 40)
grossPay = hourlyRate * hoursWorked;
else
grossPay = (hourlyRate * 40) + (hourlyRate * 1.5) * (hoursWorked - 40);
txt.Write("Employee Name: "+ txtName.Text + " " + txtNumber.Text + " " + txtPay.Text + " " + txtHours.Text);
txt.Close();
try
{
using (StreamReader sr = new StreamReader("employee_information.txt" ))
{
string line = sr.ReadToEnd();
lblInformation.Text = line;
}
}
catch (Exception ex)
{
lblInformation.Text = "The file could not be read:";
}
}
I require the lblInformation.Text to read the Name value from the text file, along with the total pay being formatted (in a dollar amount) but it is currently reading all the information from said text file.
Any help or feedback is appreciated,
Thank you
|
|
|
|
|
We can;t help you with that - you need to look at your file and work out exactly how it stores the info you need. The chances are that it's stored by line (judging from your code) but what part of the line is the name and what the salary depend on the data content of each line - if you are lucky, it will be separated, delimited, or structured in order to make it relatively simple. But without the data? We can't even begin to guess.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I see, to answer your question, the data is stored as: name, id, pay, then hours worked. That's the order I have it writing it to the file. Does that help in any way?
|
|
|
|