|
Thanks for your concern.My code is working nice now.
Inform1.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace clock
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
getTime();
}
private void timer1_Tick(object sender, EventArgs e)
{
textBox1.Text = DateTime.Now.ToString("HH:mm:ss");
}
public string getTime()
{
string TimeInString = "";
int hour = DateTime.Now.Hour;
int min = DateTime.Now.Minute;
int sec = DateTime.Now.Second;
TimeInString = (hour < 10) ? "0" + hour.ToString() : hour.ToString();
TimeInString += ":" + ((min < 10) ? "0" + min.ToString() : min.ToString());
TimeInString += ":" + ((sec < 10) ? "0" + sec.ToString() : sec.ToString());
return TimeInString;
}
}
}
and
in design of form
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Timer timer1;
working fine
With Regards
Ch.Gayatri
|
|
|
|
|
I'm looking for a tool which can help me to generate specific barcodes like those enumerated in the subject.
I must be able to create this type of barcode, but despite my long googling I never found an open source library who allows me to generate this type of barcodes. I can't also have any source about the way used to generated this kind of barcodes (encoding).
Sorry for my poor english. I wish you will help to find a way...
Thanks.
|
|
|
|
|
Nobody can help me? Is it really too specific?
|
|
|
|
|
I have a collection of controls (many PictureBox es that display a source image) that the user can select.
He can select up to 25 at a time.
Now, I want the user to be able to select them like in Excel (without using the ctrl key).
So, when you hold the mouse button down, you can select up to 5 horizontally and up to 5 vertically.
When the user moves the mouse first down to select more PictureBox es below the first and the moves the mouse up to select more above the first, like in Excel he unselects the previously selected PictureBox es below the first and only select the ones above the first.
Horizontally the same should happen.
Preferrably the user should only be able to select a rectangle, i. e. when selecting 4 PictureBox es down, he shoud not be able to select only 3 PictureBox es in the second column and when he selects 5 PictureBox es down in the second column, the first column should also be extended to 5.
So far I have a Selection class that has a 2 dimensional array of Bitmap s at its core.
But I think this only really works if the user doesn't change selection as mentioned above.
I also check the location of the selected PictureBox es and set an up and left bool to true or false.
But I don't think this is sufficient.
Is there maybe an article about this somewhere?
Thanks a lot.
|
|
|
|
|
Hi,
IMO, assign a unique id or number to each picture box.
declare two variables namely StartPB, and CurrentPB.
in the mouse down event, get the id of the StartPB and in mouse_over event set the CurrentPB with the current id.
now just use general comparison to arrive at your logic....
say you have selcted the nth picture box
then a
b
c
g h i n j k l
d
e
f
you can easily create your required functionality by some simple mathematics with the selectPB and CurrentPB values......
Good Luck and leave a reply if you find some better solution.....
Have a Happy Coding.....
|
|
|
|
|
Hi all,
Can you please help me out or advice on how to solve the following problem.
I'm reading files line by line from a folder and I'm saving the file content into the database. Now, my problem is that some of the lines from the file are the same. I can read the first line and when I reach the other line that has the same name as that first line my 'line' variable becomes empty and nothing got saved in the database (for only those lines that are the same). I need to save all the content of the file into the database, even those lines that are the same (numbering and heading).
my file looks like this (taken some content of the file)
1. This Report Concerns :
an individual
2. Surname :
Nkwanyana
3. First Name :
Nonti
4. Other Initials :
Z
5. Identifying number :
7200506586321
6. Type of Identifier :
_ID Book
7. Country of Residence :
South Africa
1. Transaction was conducted by :
the person referred to in Part D
2. Surname :
Phungo
3. First Name :
Hendrica
4. Other Initials :
M
5. Identifying number :
8695421345789
6. Type of Identifier :
ID book
7. Is there a photograph or other image of the person available?
NO
my code looks like:
if (line != null && line.Contains("2. Surname :"))
{
line = reader.ReadLine();
Surname = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("3. First Name :"))
{
line = reader.ReadLine();
FirstName = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("4. Other Initials :"))
{
line = reader.ReadLine();
OtherInitials = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("5. Identifying number :"))
{
line = reader.ReadLine();
IdentifyingNumber = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("6. Type of Identifier :"))
{
line = reader.ReadLine();
TypeOfIdentifier = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("7. Country of Residence :"))
{
line = reader.ReadLine();
CountryOfResidence = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("2. Surname :"))
{
line = reader.ReadLine();
SecSurname = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("3. First Name :"))
{
line = reader.ReadLine();
SecFirstName = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("4. Other Initials :"))
{
line = reader.ReadLine();
SecOtherInitials = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("5. Identifying number :"))
{
line = reader.ReadLine();
SecIdentifyingNumber = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("6. Type of Identifier :"))
{
line = reader.ReadLine();
SecTypeOfIdentifier = line;
line = reader.ReadLine();
}
Will really appreciate your help.
Thanks.
|
|
|
|
|
If you got a problem with the database it would be helpful if we can see your database-access code...
I guess your line is empty because you are reading the empty line between each record.
I would suggest to refactor your code to read it more like this (pseudo-code):
while( (line = reader.ReadLine()) != null) {
if(line.startsWith("1.") || (line.startsWith("2.") ... {
string sValue = reader.ReadLine();
this.SetValue(line, sValue, oOutput);
}
}
public void SetValue(string sDescriptive, string sValue, MyClass oOutput) {
if(sDescriptive.Contains("2. Surname :")) {
oOutput.Surname = sValue;
} ...
}
Hope this gives you an idea...
Regards
Sebastian
|
|
|
|
|
I don't think the problem is with the database but here is my database code:
cmd.Parameters.Add("@ThisReportConcerns", SqlDbType.VarChar, 50).Value = ReportConcerns;
cmd.Parameters.Add("@Surname", SqlDbType.NVarChar, 50).Value = Surname;
cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 50).Value = FirstName;
cmd.Parameters.Add("@OtherInitials", SqlDbType.NVarChar, 50).Value = OtherInitials;
cmd.Parameters.Add("@IdentifyingNumber", SqlDbType.NVarChar, 50).Value = IdentifyingNumber;
cmd.Parameters.Add("@TypeOfIdentifier", SqlDbType.NVarChar, 50).Value = TypeOfIdentifier;
cmd.Parameters.Add("@CountryOfResidence", SqlDbType.NVarChar, 50).Value = CountryOfResidence;
cmd.Parameters.Add("@Surname2", SqlDbType.NVarChar, 50).Value = SecSurname;
cmd.Parameters.Add("@FirstName2", SqlDbType.NVarChar, 50).Value = SecFirstName;
cmd.Parameters.Add("@OtherInitials2", SqlDbType.NVarChar, 50).Value = SecOtherInitials;
cmd.Parameters.Add("@IdentifyingNumber3", SqlDbType.NVarChar, 50).Value = SecIdentifyingNumber;
cmd.Parameters.Add("@TypeOfIdentifier2", SqlDbType.NVarChar, 50).Value = SecTypeOfIdentifier;
The problem is that the file contains lines that has the same numbering and heading, e.g:
2. Surname:
Mkhwanyana
3. First Name:
Nonti
2. Surname:
Mbambo
3. First Name:
Hendrica
etc.
|
|
|
|
|
Are there empty lines between the values? I think the lines are empty because when you find the first surname you place the cursor (line) on an empty line so that no one of the following if-statements will be fulfilled. Use a loop to read each line according to my suggestion...
Did you refactored your code like I mentioned (reading in a loop)? Try to debug your code step-by-step.
Regards
Sebastian
|
|
|
|
|
Yes, I am reading within the while loop
while ((line = reader.ReadLine()) != null)
{
//read lines from the file
}
|
|
|
|
|
Hi
thanks a lot for your advice. I decided to use a flag in order for my program to read the right line at the right time and now its saving the right values into the database. I really appreciate your help.
Thanks.
|
|
|
|
|
Hi
how I can run any .exe file through WebService that I build ?
thank's in advance
|
|
|
|
|
Have a look at the System.Diagnostics.Process class...
|
|
|
|
|
I try this:
[WebMethod]
public void GO()
{
System.Diagnostics.Process H = new Process();
H.StartInfo.FileName = @"d:\siw.exe";
H.Start();
H.WaitForExit();
}
but still not working
whay ?
|
|
|
|
|
Okay, so what is not working exactly? Do you get an error message?
Btw, calling an exe from an asp.net application can be difficult because of security issues. Check whether the aspnet-process has the rights to see and execute your exe-file.
|
|
|
|
|
Hi there,
Ocassionally, due to malware infection, it is seen that some of the infected or suspicious files or folders can be neither deleted nor renamed and when tried to do so, a messagebox is display something like this: "The file/directory cannot be deleted because it is in use by another program or whatsoever". In such case, we have two options, either format the drive containing the file or continue with it.
However, let me directly come to the point. I have written a program which will create a directory with the following code:
{
System.IO.Directory.CreateDirectory("c:/myfolder");
}
With the above code, I have created a folder "myfolder" in the c: drive. But, this folder can be easily deleted. I want to know that how can I create a process or program associated with it running continuously, such that whenever the user tries to delete the folder, the messageBox "The file/directory cannot be deleted because it is in use by another program" is displayed and the user fails to delete it?
Help me and I assure that your help will be appreciated,
Thanx..... and sorry for my poor english (I am trying to improve),
Rajdeep.NET
|
|
|
|
|
Why you want to do that? What happens if user deleted the directory?
|
|
|
|
|
Well, you could create a file within this directory. Open the file with a stream and let this stream open. This will block the file (and directory) as long as your app is running. If you put the code for this in a windows service the app will run as long as the pc...
Regards
Sebastian
P.S.: By the way, what kind of app are you trying to build?
|
|
|
|
|
Actually,
I am trying to understand the way in which a worm or a freaky virus works. I am creating a removable tool. Thanx for your help
Love u a lot,
Take care,
Rajdeep.NET
|
|
|
|
|
Be sure to tell us when you release this removal tool, so we know when to not download it
|
|
|
|
|
It's the same thing every program does with an open file. You can't delete a file while it's in use, windows won't let you (Or most any other OS for that matter). In order to delete the file you have to stop the process that's using it. In order to delete a file that a virus is using, you have to unload the virus from memory.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
I am not at all sure about your reasons for doing this, but if I wanted to I would start out by researching FileStstemWatcher .
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.”
|
|
|
|
|
Hi Experts.
Pls Help Me How To Make Thread Safe Application in C#.NEt ............
Pls Help Me................
Thank u
Dinesh Sharma
|
|
|
|
|
Sharma Dinesh Kumar wrote: To Make Thread Safe Application in C#.NEt ............
Read the tutorials and comeback with specific questions. This[^] will be a good start.
|
|
|
|
|
Pen p = new Pen(Color.Black,PenWidth);
GraphicsPath gp=new GraphicsPath();
gp.AddLine(StartPoint,EndPoint);
gp.Widen(p);//error:outofmemoryException
|
|
|
|