|
No, but it's a start
|
|
|
|
|
Michel,
Thanks for the reply. You get me headed in the right direction. I actually needed to have my try/catch in the Service Method that is called in the OnStart. Everything is working like a charm now. I appreciate the help.
Thanks,
Joe Brislin
|
|
|
|
|
Joe Brislin wrote: try/catch in the Service Method
Exactly. Very good.
|
|
|
|
|
Hey everybody, if somebody can help me with this I'd really appreciate it. I'm currently writing a Ticketmaster esque program, in which we have to have a user log-in and out of the program. Well I have a main form, and a log-in form. The user clicks a linked label on the main form to load up the log-in form. Sign in with their credentials and click the log-in button on the log-in form. I have it reading from and checking an access database file to make sure that they have log-in information and that it is correct. What I need now is to be able to pass the [username] from the database that they use on the login form back to the main form, so that the program can recognize if an administrator logs in. Here is my main form code for the log-in button:
private void lnklblLogIn_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
sp.Stop();
frmLogIn LogIn = new frmLogIn();
LogIn.Show();
}
and here is my log-in form code for the log-in button:
private void btnLogIn_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\John\\Desktop\\Database1.mdb");
OleDbCommand com = new OleDbCommand("SELECT UserName, PassWord FROM Table1",con);
OleDbDataReader reader;
bool permit = false;
try
{
con.Open();
reader = com.ExecuteReader();
while (reader.Read())
{
if (txtUserName.Text == (reader["UserName"].ToString()) && mtxtPassWord.Text == reader["PassWord"].ToString())
{
permit = true;
break;
}
}
con.Close();
}
catch
{
MessageBox.Show("File not able to be read");
return;
}
if (permit != true)
MessageBox.Show("Username or Password are not correct.");
else
{
Close();
}
}
So again my issue is being able to get the username logged in with on the "Log-in" form back to the main form so the main form knows who has logged in. If somebody can help me with this I'd really appreciate it
|
|
|
|
|
why not just add an event to the login form. Call it something like "UserLoggedInSuccessfully".
public class MyEventArgs: EventArgs
{
private string _UserName;
public MyEventArgs(string UserName)
{
_UserName = UserName;
}
public string UserName()
{
return _UserName;
}
}
public delegate void myEventHandler(object sender, MyEventArgs e)
public class LoginForm: Form
{
public Event myEventHandler LoginSuccessful;
...
}
Then, when the login is successful you call:
LoginSuccessful(this, new MyEventArgs(UserName));
and hook it on the main form. When the event is raised on the main form, you can check the username to see who it is.
|
|
|
|
|
For this, the best method is probably to set up a public property (called say UserName) in the log in form and then change your main form code to:
private void lnklblLogIn_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
sp.Stop();
myUserName = "";
frmLogIn LogIn = new frmLogIn();
if (LogIn.ShowDialog() == DialogResult.OK)
{
myUserName = LogIn.UserName;
}
} You may want to take some action (like closedown) if the dialog result is not OK
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I'm having trouble getting the main form to recognize LogIn.UserName, what could I be missing? I tried making the oleDb stuff public but that won't work.
|
|
|
|
|
OriginalGriff wrote: set up a public property (called say UserName) in the log in form
Or did you miss that bit?
for example:
private string userName;
public string UserName
{
get { return userName; }
} Declares a read-only string called UserName that can be accessed outside the login form.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Thank you very much, yeah forgot about that part lol. I was trying to pass the reader and reread from the DB again I guess lol. This makes it a lot eaiser and pushed my project ahead a lot lol. That was the one speed bump I couldn't get over. Thank you again.
|
|
|
|
|
Hi
Im developing a windows CE app. I have inherited user controls which i use as screens which i can switch between. All working fine. One thing i'd like to do is set the system clock on the CE device. To do this i need to do [DllImport("coredll.dll")]. When i do this i can no longer get access to the designer screen and get the following messgae
<html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"><title></title><style>.ErrorStyle { font-family: tahoma; font-size: 11 pt; text-align: left}.DetailsStyle { font-family: tahoma; font-size: 10pt; text-align: left;text-indent: 0; word-spacing: 0; line-height: 100%; float: left; margin-top: 0; margin-bottom: 0}.StackStyleVisible { font-family: tahoma; font-size: 10pt; text-align: left; margin-left: 20; text-indent: 0}.StackStyleHidden { display:none; font-family: tahoma; font-size: 10pt; text-align: left; margin-left: 20; text-indent: 0}</style></head><body><DIV class="DetailsStyle" width="100%"><table border="0" width="100%" id="table1" height="100%" cellspacing="0" cellpadding="0"><tr><td height="40" bgcolor="#FF9999" width="8%" style="letter-spacing: 0" align="center"><img border="0" src="C:\Documents and Settings\Chris Clarke.PIPECOIL\Local Settings\Temp\13113A5.tmp" width="35" height="35" alt="ErrorImage" ></td><td height="40" bgcolor="#FF9999" width="91%" style="vertical-align: top; letter-spacing: 0" align="left"><b><font size="2" face="Arial" fontsize="70%">One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.</font><font size="2" face="Arial"></font></b></td></tr><tr><td colspan="2" align="left" valign="top"><DIV id="div1" class="ErrorStyle" width="100%"><span style="font-weight: 600"><br>The type 'Microsoft.CompactFramework.Design.UnsafeUserControl' has no property named 'Colour'. </span><br><a href="" id="details0">Hide</a><font color="#0000FF">  </font><a href="" id="task0">Edit</a><font color="#0000FF"></font></span></DIV> </td> </tr> <tr><td colspan="2" align="left" valign="top"><DIV id="div20" class="StackStyleVisible" width="100%"><br> at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)<br> at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertyAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement, CodePropertyReferenceExpression propertyReferenceEx, Boolean reportError)<br> at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)<br> at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)</DIV></td></tr></table></div></body></html>
When i run the project on the device it works fine. all the screens work and i can even set the time.
Anybody got any ideas about this error? been pulling my hair out for a bit now.
Thanks
Chris
Chris
|
|
|
|
|
Are you compiling with the /unsafe target?
|
|
|
|
|
kevinnicol
I'm compiling it to a windows CE device. but even in visula studio the user controls are not visible
Chris
|
|
|
|
|
Hi all,
I've been looking for a way to write data to a CSV file based on a timer event, without success. Is there a standard .NET class that will do this?
Thanks.
|
|
|
|
|
There are timer classes and there are classes to perform file I/O. Were you expecting specialized support beyond this? If so, what kind?
/ravi
|
|
|
|
|
What I would like to do is write a variable value to a csv file dynamically at a certain interval (timer tick). Each tick would result in a new line in the csv file.
|
|
|
|
|
OK, that's fair.
One way to do this would be to open the file (for update) when your application starts, set up a timer to fire at a specific interval, and in the timer tick handler, write a line to the open file (and flush the file). When your program terminates (either normally or abnormally), close the file.
See the Timer and File classes for more information.
/ravi
|
|
|
|
|
This works, but it seems a bit flakey. Also, does anyone know how to limit the file size?
using (StreamWriter writer = new StreamWriter("C:\\log.csv", true))
{
writer.WriteLine(textBox1.Text + "," + System.DateTime.Now);
}
|
|
|
|
|
mprice214 wrote: This works, but it seems a bit flakey.
Define "flakey".
Remember, a Timer is only one way to go. You could also use a background thread. In this case, be sure to handle concurrent access of UI (and other) data.
/ravi
|
|
|
|
|
|
Luc Pattyn wrote: No problem[^].
Come again?
|
|
|
|
|
Luc is just having some fun at our expense.
/ravi
|
|
|
|
|
OT: I wished I lived in Belgium. It's a collector's haven for Dinky Toys.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: collector's haven for Dinky Toys
is it? I wasn't aware, I haven't seen one for ages.
I am a model railroad enthusiast myself (N gauge, i.e. scale 1:160).
|
|
|
|
|
Luc Pattyn wrote: I haven't seen one for ages.
You can relive some childhood memories here[^].
/ravi
|
|
|
|
|
Great.
The very first image[^] I looked at has a bill board for a shop in Ghent that is still there; I have bought some locs there once. Normally I go shopping in Germany...
PS: may I suggest you add some navigation to your catalogs, moving to the next/previous page would increase the
"user experience".
|
|
|
|