public void setUsername(string name) { username = name; ipEntities a = new ipEntities(); string getfname = "Select fname from Users where username='******'"; string getlname = "Select lname from Users where username='******'"; string getemail = "Select email from Users where username='******'"; var fname = a.Database.SqlQuery <string>(getfname).FirstOrDefault(); var lname = a.Database.SqlQuery <string>(getlname).FirstOrDefault(); var email = a.Database.SqlQuery <string>(getemail).FirstOrDefault(); //string abc = string.Empty; if (fname != null && lname != null && email != null) { sfname = fname.ToString(); slname = lname.ToString(); semail = email.ToString(); } }
private void pictureBoxLoginAnim_Click(object sender, EventArgs e) { if (textBoxUsername.Text != "") { if (textBoxPassword.Text != "") { ipEntities a = new ipEntities(); string sequenceMaxQuery = "Select s.username from staff s, Users u where s.Position like '%admin%' and u.password='******' and s.username='******'"; var sequenceQueryResult = a.Database.SqlQuery <string>(sequenceMaxQuery).FirstOrDefault(); string username = string.Empty; if (sequenceQueryResult != null) { //username = sequenceQueryResult.ToString(); //if (username == textBoxUsername.Text) //{ InfoMessages.setMessege("Logging in ..."); ld.Show(); tmr = new Timer(); //set time interval 3 sec tmr.Interval = 3000; //starts the timer tmr.Start(); tmr.Tick += tmr_TickLogOut; LoggedInUser usr = new LoggedInUser(); usr.setUsername(textBoxUsername.Text); //Home b = new Home(); //b.Show(); this.Hide(); //} //else //{ // //wrong // MessageBox.Show("inner messege", "caption", // MessageBoxButtons.OK, // MessageBoxIcon.Question); //} } else { //wrong MessageBox.Show("Wrong Username or Password", "Try again..!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Password box is empty...! Type the Password and continue.", "Type Password", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Username box is empty...! Type the Username and continue.", "Type username", MessageBoxButtons.OK, MessageBoxIcon.Information); } }