Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

C# Change content if login succeeded.

$
0
0
Hi.
I'm building a admin control panel there the admin can update accounts. Anyway.. I have built the login part but I want if the login success then the content of the form should change and show the account management tools without opening a new form. Everyhing should happend in the same form. So my question is how do I do this?

<Window x:Class="AdminCP.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" WindowStartupLocation="CenterScreen">
    <Grid>   
        <TextBox Name="textBox1" Height="25" Margin="161,100,161,0" TextWrapping="Wrap" VerticalAlignment="Top"/>
        <PasswordBox Name="textBox2" Margin="161,151,161,0" VerticalAlignment="Top" Height="25"/>
        <Label Content="Username:" HorizontalAlignment="Left" Margin="161,74,0,0" VerticalAlignment="Top"/>
        <Label Content="Password:" HorizontalAlignment="Left" Margin="161,125,0,0" VerticalAlignment="Top"/>
        <Button Content="Login" HorizontalAlignment="Left" Margin="274,187,0,0" VerticalAlignment="Top" Width="75" Height="25" Click="Button_Click_1"/>
    </Grid>
    
</Window>



namespace AdminCP
{
    /// <summary>
    /// Interaction logic for Mainwindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {            
            ServiceReference1.Service1Client ACPservice = new ServiceReference1.Service1Client();

            string username = textBox1.Text.Trim();
            string password = textBox2.Password.Trim(); 
            string auth = ACPservice.Login(username, password);

            if (!String.IsNullOrEmpty(textBox1.Text) || (!String.IsNullOrEmpty(textBox2.Password)))
            {
                if (auth == Properties.Resources.Autentication)
                {
                    MessageBox.Show("Success");
                }
                else
                {
                    MessageBox.Show("Invaild username or password.");
                }
            }
            else
            {
                MessageBox.Show(Properties.Resources.Validationerror);
                
            }
        }
    }
}



Any help would be appreciated.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>