private void homeBtn_Click(object sender, RoutedEventArgs e)
        {
            AdminDashbord adminDashbord = new AdminDashbord();

            adminDashbord.Show();
            this.Close();
        }
 private void HomeBtn_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         AdminDashbord adminDashbord = new AdminDashbord();
         adminDashbord.Show();
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Example #3
0
 private void HomeBtn_Click(object sender, RoutedEventArgs e)
 {
     if (UserInfo.User_Type <= 1)
     {
         AdminDashbord adminDashbord = new AdminDashbord();
         adminDashbord.Show();
         this.Close();
     }
     else
     {
         MessageBox.Show("You are not authorized to view this page !", "Warning");
     }
 }
Example #4
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            var res = 0;

            try
            {
                con = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
                con.Open();
                cmd = new SqlCommand("Select * from users where user_name=@UserId", con);
                cmd.Parameters.AddWithValue("@UserId", Username.Text);
                reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    if (reader["password"].ToString().Equals(password.Password, StringComparison.InvariantCulture))
                    {
                        UserInfo.User_Name = Username.Text;
                        UserInfo.User_Id   = int.Parse(reader["user_id"].ToString());
                        UserInfo.User_Type = int.Parse(reader["usertype"].ToString());
                        UserInfo.Login     = true;
                        res = 1;
                    }
                    else
                    {
                        MessageBox.Show("Password is incorrect...!", "Info");
                    }
                }
                else
                {
                    MessageBox.Show("Username is incorrect...!", "Info");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Info");
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                cmd.Dispose();
                con.Close();
                if (res == 1)
                {
                    if (UserInfo.User_Type == 0)
                    {
                        var adminWindow = new AdminDashbord();
                        adminWindow.Show();
                        Close();
                    }
                    else if (UserInfo.User_Type == 1)
                    {
                        AdminDashbord adminDashbord = new AdminDashbord();
                        adminDashbord.Show();
                        this.Close();
                    }
                    else if (UserInfo.User_Type == 2)
                    {
                        BillingDashboard billingDashboard = new BillingDashboard();
                        billingDashboard.Show();
                        this.Close();
                    }
                }
            }
        }