Example #1
0
        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);
            }
        }