private void btCancel_Click(object sender, RoutedEventArgs e)
        {
            ManageMusic manageMusic = new ManageMusic();

            manageMusic.Show();
            this.Close();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var ctx = new MusicStoreContext())
            {
                string uName   = tbUserName.Text.Trim();
                string pwd     = tbPassword.Text.Trim();
                bool   isAdmin = rbAdmin.IsChecked ?? false;

                List <User> list1 = ctx.Users.Where(u => u.UserName == uName).ToList();

                if (list1.Count >= 1)
                {
                    User loginUser = ctx.Users.Where(u => u.UserName == uName).FirstOrDefault();
                    loginUserId = loginUser.Id;
                    List <User> list2 = ctx.Users.Where(u => u.UserName == uName && u.PassWord == pwd).ToList();
                    if (list2.Count >= 1)
                    {
                        if (isAdmin == false)
                        {
                            Window1 BuyMusic = new Window1();
                            BuyMusic.loginUserId = loginUserId;
                            this.Close();
                            BuyMusic.Show();
                        }
                        else
                        {
                            ManageMusic manageMusic = new ManageMusic();
                            this.Close();
                            manageMusic.Show();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Either the user name or password entered is incorrect.");
                    }
                }
                else
                {
                    MessageBox.Show("Either the user name or password entered is incorrect.");
                }

                //int howManyUsers = ctx.Users.Count();
                //User u1 = new User() { UserName = "******", PassWord = "******", isAdmin = true };
                //ctx.Users.Add(u1);
                //ctx.SaveChanges();
            }
        }
Example #3
0
 private void btSave_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new MusicStoreContext())
     {
         Music m1 = ctx.Musics.Where(m => m.id == id).FirstOrDefault();
         m1.id        = id;
         m1.musicName = tbName.Text;
         m1.album     = tbAlbum.Text;
         m1.artist    = tbArtist.Text;
         m1.available = bool.Parse(tbAvailable.Text);
         ctx.SaveChanges();
         MessageBox.Show("Edited Successful");
         ManageMusic manageMusic = new ManageMusic();
         manageMusic.Show();
         this.Close();
     }
 }