Example #1
0
 private void Image_MouseLeftButtonDown_two(object sender, MouseButtonEventArgs e)
 {
     if (access == "admin")
     {
         MenuAdmin a = new MenuAdmin();
         a.Show();
         this.Close();
     }
     else
     {
         Menu m = new Menu();
         m.Show();
         this.Close();
     }
 }
Example #2
0
        private void ButtomLog_Click(object sender, RoutedEventArgs e)
        {
            string sqlExpression = "select dbo.AutoValid('" + login.Text + "', '" + passwordBox.Password + "');";
            string take_access   = " select dbo.Take_Access('" + login.Text + "');";

            using (SqlConnection conn = new SqlConnection(SqlConn.ConnectionString.defaultString))
            {
                SqlCommand command = new SqlCommand(sqlExpression, conn);
                conn.Open();
                Int32 number = Convert.ToInt32(command.ExecuteScalar());
                if (number == 0)
                {
                    MessageBox.Show("invalid Data");
                    login.Clear();
                    passwordBox.Clear();
                }
                else if (number == 1)
                {
                    SqlCommand    take_id_ = new SqlCommand(take_access, conn);
                    Int32         id       = Convert.ToInt32(take_id_.ExecuteScalar());
                    SqlConnection conn1    = new SqlConnection(SqlConn.CurrentConnectionString);
                    // SqlConnection conn2 = new SqlConnection(SqlConn.CurrentConnectionString);
                    SqlConnection conn2 = new SqlConnection(SqlConn.UserConnectionString);
                    if (id == 1)
                    {
                        SqlCommand comm    = new SqlCommand(sqlExpression, conn1);
                        int        number1 = command.ExecuteNonQuery();
                        // MessageBox.Show("Complete");
                        Models.MY.login = login.Text;
                        MenuAdmin MenuAdmin = new MenuAdmin();
                        MenuAdmin.Show();
                        this.Close();
                    }
                    else
                    {
                        SqlCommand comm    = new SqlCommand(sqlExpression, conn2);
                        int        number2 = command.ExecuteNonQuery();
                        // MessageBox.Show("Complete");
                        Models.MY.login = login.Text;
                        Menu Menu = new Menu();
                        Menu.Show();
                        this.Close();
                    }
                }
            }
        }