Example #1
0
        private void billingBtnClick(object sender, RoutedEventArgs e)
        {
            BillingDashboard billingWindow = new BillingDashboard();

            billingWindow.Show();
            this.Close();
        }
Example #2
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();
                    }
                }
            }
        }