Пример #1
0
 private void Show_Table()
 {
     button_EditSinger.Visible   = false;
     button_DeleteSinger.Visible = false;
     listView1_Disc.Items.Clear();
     using (MusicStoreEntities1 db = new MusicStoreEntities1())
     {
         var disc = db.Disc.Select(z => z).ToList();
         list = disc;
         string[] row = new string[10];
         foreach (var VARIABLE in list)
         {
             row[0] = VARIABLE.Id.ToString();
             row[1] = VARIABLE.Cover;
             row[2] = VARIABLE.DiskTitle;
             row[3] = VARIABLE.Singer;
             row[4] = VARIABLE.Publisher;
             row[5] = VARIABLE.Tracks.ToString();
             row[6] = VARIABLE.Genre;
             row[7] = VARIABLE.YearPublishing.ToString("d");
             row[8] = VARIABLE.CostPrice.ToString();
             row[9] = VARIABLE.SellPrice.ToString();
             ListViewItem itm = new ListViewItem(row);
             listView1_Disc.Items.Add(itm);
         }
     }
 }
Пример #2
0
 private void Show_Home()
 {
     using (MusicStoreEntities1 db = new MusicStoreEntities1())
     {
         var discs = db.Checkk.Select(z => z).ToList();
         Show(discs);
     }
 }
Пример #3
0
 private void Button_SellingYear_Click(object sender, EventArgs e)
 {
     using (MusicStoreEntities1 db = new MusicStoreEntities1())
     {
         var disc = db.Checkk.Where(z => z.DataSale.Year == data.Year).ToList();
         Show(disc);
     }
 }
Пример #4
0
 private void Show_Log()
 {
     using (MusicStoreEntities1 db = new MusicStoreEntities1())
     {
         var log = db.LoginPassword.FirstOrDefault(z => z.Id == 1);
         textBox_Login.Text    = log.Login;
         textBox_Password.Text = log.Password;
     }
 }
Пример #5
0
 private void Search_DiscTitle()
 {
     if (textBox_Search.Text != "")
     {
         start = textBox_Search.Text;
         textBox_Search.Text = "";
     }
     using (MusicStoreEntities1 db = new MusicStoreEntities1())
     {
         var disc = db.Disc.Where(z => z.DiskTitle.StartsWith(start)).OrderBy(z => z.Id).Skip((pagesSearch - 1) * panel_col).Take(panel_col).ToList();
         Show_Search(disc);
     }
 }
Пример #6
0
        private void Button_DeleteSinger_Click(object sender, EventArgs e)
        {
            int  index = listView1_Disc.FocusedItem.Index;
            Disc disc  = list[index];

            using (MusicStoreEntities1 db = new MusicStoreEntities1())
            {
                var find = db.Disc.FirstOrDefault(z => z.Id == disc.Id);
                db.Disc.Remove(find);
                db.SaveChanges();
            }
            Show_Table();
        }
Пример #7
0
        private void List_Cart(object sender, EventArgs e)
        {
            using (MusicStoreEntities1 db = new MusicStoreEntities1())
            {
                Button button = sender as Button;
                if (button.Name == button_AddToCart.Name)
                {
                    int id   = Convert.ToInt32(label_Id1.Text);
                    var disc = db.Disc.FirstOrDefault(z => z.Id == id);
                    if (disc != null)
                    {
                        cart.Add(disc);
                    }
                }
                else if (button.Name == button_AddToCart1.Name)
                {
                    int id   = Convert.ToInt32(label_Id2.Text);
                    var disc = db.Disc.FirstOrDefault(z => z.Id == id);
                    if (disc != null)
                    {
                        cart.Add(disc);
                    }
                }
                else if (button.Name == button_AddToCart2.Name)
                {
                    int id   = Convert.ToInt32(label_Id3.Text);
                    var disc = db.Disc.FirstOrDefault(z => z.Id == id);
                    if (disc != null)
                    {
                        cart.Add(disc);
                    }
                }
                else if (button.Name == button_AddToCart3.Name)
                {
                    int id   = Convert.ToInt32(label_Id4.Text);
                    var disc = db.Disc.FirstOrDefault(z => z.Id == id);
                    if (disc != null)
                    {
                        cart.Add(disc);
                    }
                }
            }

            label_CartCounter.Text = cart.Count.ToString();
        }
Пример #8
0
 private void Button_AdminEnter_Click(object sender, EventArgs e)
 {
     using (MusicStoreEntities1 db = new MusicStoreEntities1())
     {
         var Log_Pas = db.LoginPassword.Where(z =>
                                              z.Login == textBox_AdminLogin.Text && z.Password == textBox_AdminPassword.Text).ToList();
         if (Log_Pas.Count == 0)
         {
             textBox_AdminLogin.Text      = null;
             textBox_AdminPassword.Text   = null;
             label_WrongLoginPass.Visible = true;
         }
         else
         {
             panel_Shield.Visible = false;
         }
     }
 }
Пример #9
0
 private void Show_Table()
 {
     listView1_Buyers.Items.Clear();
     using (MusicStoreEntities1 db = new MusicStoreEntities1())
     {
         var      disc = db.Buyer.Select(z => z).ToList();
         string[] row  = new string[4];
         foreach (var VARIABLE in disc)
         {
             row[0] = VARIABLE.Id.ToString();
             row[1] = VARIABLE.FirstName;
             row[2] = VARIABLE.LastName;
             row[3] = VARIABLE.Quantity.ToString();
             ListViewItem itm = new ListViewItem(row);
             listView1_Buyers.Items.Add(itm);
         }
     }
 }
Пример #10
0
 private void Edit_database()
 {
     using (MusicStoreEntities1 db = new MusicStoreEntities1())
     {
         var disc = db.Disc.FirstOrDefault(z => z.Id == disc_disc.Id);
         disc.Singer         = textBox_SingerEdit.Text;
         disc.Tracks         = col;
         disc.CostPrice      = seb_pr;
         disc.DiskTitle      = textBox_AlbumEdit.Text;
         disc.Genre          = textBox_GenreEdit.Text;
         disc.Publisher      = textBox_PublisherEdit.Text;
         disc.Cover          = textBox1_imgEdit.Text;
         disc.SellPrice      = pr;
         disc.YearPublishing = date;
         db.Disc.AddOrUpdate(disc);
         db.SaveChanges();
     }
     DialogResult = DialogResult.OK;
 }
Пример #11
0
        private void Button_LoginEnter_Click(object sender, EventArgs e)
        {
            if (textBox_Login.Text == "" || textBox_Password.Text == "")
            {
                MessageBox.Show("Fill all fields", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            using (MusicStoreEntities1 db = new MusicStoreEntities1())
            {
                var log = db.LoginPassword.FirstOrDefault(z => z.Id == 1);
                log.Login    = textBox_Login.Text;
                log.Password = textBox_Password.Text;
                db.LoginPassword.AddOrUpdate(log);
                db.SaveChanges();
            }

            MessageBox.Show("Admin data has changed!", "Message", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
            DialogResult = DialogResult.OK;
        }
Пример #12
0
        private void Add_database()
        {
            using (MusicStoreEntities1 db = new MusicStoreEntities1())
            {
                Disc disc = new Disc
                {
                    Singer         = textBox_SingerAdd.Text,
                    Tracks         = col,
                    CostPrice      = seb_pr,
                    DiskTitle      = textBox_AlbumAdd.Text,
                    Genre          = textBox_GenreAdd.Text,
                    Publisher      = textBox_PublisherAdd.Text,
                    Cover          = textBox1_img.Text,
                    SellPrice      = pr,
                    YearPublishing = date
                };
                db.Disc.Add(disc);
                db.SaveChanges();
            }

            DialogResult = DialogResult.OK;
        }
Пример #13
0
        private void Show_Search(List <Disc> disc)
        {
            panel1.Visible       = false;
            panel2.Visible       = false;
            panel3.Visible       = false;
            panel4.Visible       = false;
            label_Hot1.Visible   = false;
            label_Hot2.Visible   = false;
            label_Hot3.Visible   = false;
            label_Hot4.Visible   = false;
            panel6_first.Visible = true;
            int col_poz = 0;

            if (disc.Count < 4)
            {
                button_S2_2.Visible    = false;
                button_S2Right.Visible = false;
            }
            else
            {
                button_S2_2.Visible    = true;
                button_S2Right.Visible = true;
            }

            using (MusicStoreEntities1 db = new MusicStoreEntities1())
            {
                foreach (var disc1 in disc)
                {
                    if (col_poz == 0)
                    {
                        var hit = db.Checkk.Where(z => z.IdDisc == disc1.Id).ToList();
                        if (hit.Count > 10)
                        {
                            label_Hot1.Visible = true;
                        }
                        panel1.Visible = true;
                        try
                        {
                            Bitmap bitmap = new Bitmap(disc1.Cover);
                            pictureBox1.Image = bitmap;
                        }
                        catch (Exception e)
                        {
                            Bitmap bitmap = new Bitmap(@"..\..\Covers\default.png");
                            pictureBox1.Image = bitmap;
                        }
                        pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                        label_Singer.Text    = disc1.Singer;
                        label_Disc.Text      = disc1.DiskTitle;
                        label_Publisher.Text = disc1.Publisher;
                        label_Tracks.Text    = disc1.Tracks.ToString();
                        label_Genre.Text     = disc1.Genre;
                        label_Year.Text      = disc1.YearPublishing.ToString("d");
                        label_Price1.Text    = disc1.CostPrice.ToString();
                        label_Id1.Text       = disc1.Id.ToString();
                    }
                    else if (col_poz == 1)
                    {
                        var hit = db.Checkk.Where(z => z.IdDisc == disc1.Id).ToList();
                        if (hit.Count > 10)
                        {
                            label_Hot2.Visible = true;
                        }
                        panel2.Visible = true;
                        try
                        {
                            Bitmap bitmap = new Bitmap(disc1.Cover);
                            pictureBox2.Image = bitmap;
                        }
                        catch (Exception e)
                        {
                            Bitmap bitmap = new Bitmap(@"..\..\Covers\default.png");
                            pictureBox2.Image = bitmap;
                        }
                        pictureBox2.SizeMode  = PictureBoxSizeMode.StretchImage;
                        label_Singer2.Text    = disc1.Singer;
                        label_Disk2.Text      = disc1.DiskTitle;
                        label_Publisher2.Text = disc1.Publisher;
                        label_Tracks2.Text    = disc1.Tracks.ToString();
                        label_Genre2.Text     = disc1.Genre;
                        label_Year2.Text      = disc1.YearPublishing.ToString("d");
                        label_Price2.Text     = disc1.CostPrice.ToString();
                        label_Id2.Text        = disc1.Id.ToString();
                    }
                    else if (col_poz == 2)
                    {
                        var hit = db.Checkk.Where(z => z.IdDisc == disc1.Id).ToList();
                        if (hit.Count > 10)
                        {
                            label_Hot3.Visible = true;
                        }
                        panel3.Visible = true;
                        try
                        {
                            Bitmap bitmap = new Bitmap(disc1.Cover);
                            pictureBox3.Image = bitmap;
                        }
                        catch (Exception e)
                        {
                            Bitmap bitmap = new Bitmap(@"..\..\Covers\default.png");
                            pictureBox3.Image = bitmap;
                        }
                        pictureBox3.SizeMode  = PictureBoxSizeMode.StretchImage;
                        label_Singer3.Text    = disc1.Singer;
                        label_Disk3.Text      = disc1.DiskTitle;
                        label_Publisher3.Text = disc1.Publisher;
                        label_Tracks3.Text    = disc1.Tracks.ToString();
                        label_Genre3.Text     = disc1.Genre;
                        label_Year3.Text      = disc1.YearPublishing.ToString("d");
                        label_Price3.Text     = disc1.CostPrice.ToString();
                        label_Id3.Text        = disc1.Id.ToString();
                    }
                    else if (col_poz == 3)
                    {
                        var hit = db.Checkk.Where(z => z.IdDisc == disc1.Id).ToList();
                        if (hit.Count > 10)
                        {
                            label_Hot4.Visible = true;
                        }
                        panel4.Visible = true;
                        try
                        {
                            Bitmap bitmap = new Bitmap(disc1.Cover);
                            pictureBox4.Image = bitmap;
                        }
                        catch (Exception e)
                        {
                            Bitmap bitmap = new Bitmap(@"..\..\Covers\default.png");
                            pictureBox4.Image = bitmap;
                        }
                        pictureBox4.SizeMode  = PictureBoxSizeMode.StretchImage;
                        label_Singer4.Text    = disc1.Singer;
                        label_Disk4.Text      = disc1.DiskTitle;
                        label_Publisher4.Text = disc1.Publisher;
                        label_Tracks4.Text    = disc1.Tracks.ToString();
                        label_Genre4.Text     = disc1.Genre;
                        label_Year4.Text      = disc1.YearPublishing.ToString("d");
                        label_Price4.Text     = disc1.CostPrice.ToString();
                        label_Id4.Text        = disc1.Id.ToString();
                    }

                    col_poz++;
                }
            }
        }
Пример #14
0
        private void Checkout(List <Disc> discs, string lastName, string firstName)
        {
            using (MusicStoreEntities1 db = new MusicStoreEntities1())
            {
                var user = db.Buyer.Where(z => z.LastName == lastName && z.FirstName == firstName).ToList();
                if (user.Count != 0)
                {
                    foreach (Buyer VARIABLE in user)
                    {
                        int col = VARIABLE.Quantity;
                        col += discs.Count;
                        VARIABLE.Quantity = col;
                        db.Buyer.AddOrUpdate(VARIABLE);
                        db.SaveChanges();
                    }
                }
                else
                {
                    Buyer buyer = new Buyer {
                        Quantity = discs.Count, LastName = lastName, FirstName = firstName
                    };
                    db.Buyer.Add(buyer);
                    db.SaveChanges();
                }
            }

            using (MusicStoreEntities1 db = new MusicStoreEntities1())
            {
                var user = db.Buyer.Where(z => z.LastName == lastName && z.FirstName == firstName).ToList();
                foreach (var VARIABLE in user)
                {
                    var     sumPrise = db.Checkk.Where(z => z.IdBuyer == VARIABLE.Id).Select(z => z.Summ).ToList();
                    decimal sum      = 0;
                    foreach (decimal VAR in sumPrise)
                    {
                        sum += VAR;
                    }

                    if (sum > 1000)
                    {
                        decimal s    = 0;
                        decimal nous = 0;
                        panel_OrderDiscount.Visible = true;
                        foreach (var V in discs)
                        {
                            decimal pr = 0;
                            s   += V.SellPrice;
                            pr   = (V.SellPrice - 15);
                            nous = nous + (V.SellPrice - 15);
                            Checkk checkk = new Checkk
                            {
                                DataSale = DateTime.Now.Date,
                                IdDisc   = V.Id,
                                IdBuyer  = VARIABLE.Id,
                                Summ     = pr
                            };
                            db.Checkk.Add(checkk);
                        }

                        db.SaveChanges();
                        label_TotalDiscount.Text = s.ToString();
                        label_ToPayDiscount.Text = nous.ToString();
                    }
                    else
                    {
                        decimal s = 0;
                        panel_OrderDefault.Visible = true;
                        foreach (var V in discs)
                        {
                            s += V.SellPrice;
                            Checkk checkk = new Checkk
                            {
                                DataSale = DateTime.Now.Date,
                                IdDisc   = V.Id,
                                IdBuyer  = VARIABLE.Id,
                                Summ     = V.SellPrice
                            };
                            db.Checkk.Add(checkk);
                        }
                        db.SaveChanges();
                        label_TotalDefault.Text = s.ToString();
                    }
                }
            }
        }