Esempio n. 1
0
 private void Show_Table()
 {
     this.button1_Edit.Visible   = false;
     this.button1_Delete.Visible = false;
     this.listView1_Disc.Items.Clear();
     using (MusicEntities2 db = new MusicEntities2())
     {
         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.Pichuri;
             row[2] = VARIABLE.DiskName;
             row[3] = VARIABLE.ColectiveName;
             row[4] = VARIABLE.IzdatelName;
             row[5] = VARIABLE.ColTrec.ToString();
             row[6] = VARIABLE.Genre;
             row[7] = VARIABLE.YearPublishing.ToString("d");
             row[8] = VARIABLE.Cost_price.ToString();
             row[9] = VARIABLE.Price.ToString();
             ListViewItem itm = new ListViewItem(row);
             this.listView1_Disc.Items.Add(itm);
         }
     }
 }
Esempio n. 2
0
 private void Show_Home()
 {
     using (MusicEntities2 db = new MusicEntities2())
     {
         var discs = db.Checkk.Select(z => z).ToList();
         Show(discs);
     }
 }
Esempio n. 3
0
 private void Button1_Dey_Click(object sender, EventArgs e)
 {
     using (MusicEntities2 db = new MusicEntities2())
     {
         var disc = db.Checkk.Where(z => z.DataSale.Day == data.Day).ToList();
         Show(disc);
     }
 }
Esempio n. 4
0
 private void Show_Log()
 {
     using (MusicEntities2 db = new MusicEntities2())
     {
         var log = db.LoginPassword.FirstOrDefault(z => z.Id == 1);
         this.textBox1_Login.Text    = log.Login;
         this.textBox1_Password.Text = log.Password;
     }
 }
Esempio n. 5
0
        private void Button1_Delete_Click(object sender, EventArgs e)
        {
            int  index = this.listView1_Disc.FocusedItem.Index;
            Disc disc  = list[index];

            using (MusicEntities2 db = new MusicEntities2())
            {
                var find = db.Disc.FirstOrDefault(z => z.Id == disc.Id);
                db.Disc.Remove(find);
                db.SaveChanges();
            }
            Show_Table();
        }
Esempio n. 6
0
 private void Serch_DiscName()
 {
     if (this.textBox1_Serch.Text != "")
     {
         start = this.textBox1_Serch.Text;
         this.textBox1_Serch.Text = "";
     }
     using (MusicEntities2 db = new MusicEntities2())
     {
         var disc = db.Disc.Where(z => z.DiskName.StartsWith(start)).OrderBy(z => z.Id).Skip((pagesSerch - 1) * panal_col).Take(panal_col).ToList();
         Show_Serch(disc);
     }
 }
Esempio n. 7
0
        private void List_Korzina(object sender, EventArgs e)
        {
            using (MusicEntities2 db = new MusicEntities2())
            {
                Button button = sender as Button;
                if (button.Name == this.button1_Add1.Name)
                {
                    int id   = Convert.ToInt32(this.label13_Id1.Text);
                    var disc = db.Disc.FirstOrDefault(z => z.Id == id);
                    if (disc != null)
                    {
                        korzina.Add(disc);
                    }
                }
                else if (button.Name == this.button1_Add2.Name)
                {
                    int id   = Convert.ToInt32(this.label13_Id2.Text);
                    var disc = db.Disc.FirstOrDefault(z => z.Id == id);
                    if (disc != null)
                    {
                        korzina.Add(disc);
                    }
                }
                else if (button.Name == this.button1_Add3.Name)
                {
                    int id   = Convert.ToInt32(this.label13_Id3.Text);
                    var disc = db.Disc.FirstOrDefault(z => z.Id == id);
                    if (disc != null)
                    {
                        korzina.Add(disc);
                    }
                }
                else if (button.Name == this.button1_Add4.Name)
                {
                    int id   = Convert.ToInt32(this.label13_Id4.Text);
                    var disc = db.Disc.FirstOrDefault(z => z.Id == id);
                    if (disc != null)
                    {
                        korzina.Add(disc);
                    }
                }
            }

            this.label2_col.Text = korzina.Count.ToString();
        }
Esempio n. 8
0
 private void Button1_Vhod_Click(object sender, EventArgs e)
 {
     using (MusicEntities2 db = new MusicEntities2())
     {
         var Log_Pas = db.LoginPassword.Where(z =>
                                              z.Login == this.textBox1_Login.Text && z.Password == this.textBox1_Password.Text).ToList();
         if (Log_Pas.Count == 0)
         {
             this.textBox1_Login.Text    = null;
             this.textBox1_Password.Text = null;
             this.label4_Error.Visible   = true;
         }
         else
         {
             this.panel2_Zashita.Visible = false;
         }
     }
 }
Esempio n. 9
0
 private void Show_Table()
 {
     this.listView1_Pocupatel.Items.Clear();
     using (MusicEntities2 db = new MusicEntities2())
     {
         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.FersName;
             row[2] = VARIABLE.LastName;
             row[3] = VARIABLE.Col.ToString();
             ListViewItem itm = new ListViewItem(row);
             this.listView1_Pocupatel.Items.Add(itm);
         }
     }
 }
Esempio n. 10
0
 private void Edit_database()
 {
     using (MusicEntities2 db = new MusicEntities2())
     {
         var disc = db.Disc.FirstOrDefault(z => z.Id == disc_disc.Id);
         disc.ColectiveName  = this.textBox1_ColectivName.Text;
         disc.ColTrec        = col;
         disc.Cost_price     = seb_pr;
         disc.DiskName       = this.textBox1_NameDisc.Text;
         disc.Genre          = this.textBox1_Gener.Text;
         disc.IzdatelName    = this.textBox1_Izdatel.Text;
         disc.Pichuri        = this.textBox1_img.Text;
         disc.Price          = pr;
         disc.YearPublishing = date;
         db.Disc.AddOrUpdate(disc);
         db.SaveChanges();
     }
     this.DialogResult = DialogResult.OK;
 }
Esempio n. 11
0
        private void Button1_Edit_Click(object sender, EventArgs e)
        {
            if (this.textBox1_Login.Text == "" || this.textBox1_Password.Text == "")
            {
                MessageBox.Show("Заполните все поля", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            using (MusicEntities2 db = new MusicEntities2())
            {
                var log = db.LoginPassword.FirstOrDefault(z => z.Id == 1);
                log.Login    = this.textBox1_Login.Text;
                log.Password = this.textBox1_Password.Text;
                db.LoginPassword.AddOrUpdate(log);
                db.SaveChanges();
            }

            MessageBox.Show("Данные администратора изменены!", "Оповещение", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
        }
Esempio n. 12
0
        private void Add_database()
        {
            using (MusicEntities2 db = new MusicEntities2())
            {
                Disc disc = new Disc
                {
                    ColectiveName  = this.textBox1_ColectivName.Text,
                    ColTrec        = col,
                    Cost_price     = seb_pr,
                    DiskName       = this.textBox1_NameDisc.Text,
                    Genre          = this.textBox1_Gener.Text,
                    IzdatelName    = this.textBox1_Izdatel.Text,
                    Pichuri        = this.textBox1_img.Text,
                    Price          = pr,
                    YearPublishing = date
                };
                db.Disc.Add(disc);
                db.SaveChanges();
            }

            this.DialogResult = DialogResult.OK;
        }
Esempio n. 13
0
        private void Oformlenie(List <Disc> discs, string lastName, string ferstName)
        {
            using (MusicEntities2 db = new MusicEntities2())
            {
                var user = db.Buyer.Where(z => z.LastName == lastName && z.FersName == ferstName).ToList();
                if (user.Count != 0)
                {
                    foreach (Buyer VARIABLE in user)
                    {
                        int col = VARIABLE.Col;
                        col         += discs.Count;
                        VARIABLE.Col = col;
                        db.Buyer.AddOrUpdate(VARIABLE);
                        db.SaveChanges();
                    }
                }
                else
                {
                    Buyer buyer = new Buyer {
                        Col = discs.Count, LastName = lastName, FersName = ferstName
                    };
                    db.Buyer.Add(buyer);
                    db.SaveChanges();
                }
            }

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

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

                        db.SaveChanges();
                        this.label3_summ.Text   = s.ToString();
                        this.label4_Scidka.Text = nous.ToString();
                    }
                    else
                    {
                        decimal s = 0;
                        this.panel1_NoScidca.Visible = true;
                        foreach (var V in discs)
                        {
                            s += V.Price;
                            Checkk checkk = new Checkk
                            {
                                DataSale = DateTime.Now.Date,
                                IdDisc   = V.Id,
                                IdBuyer  = VARIABLE.Id,
                                Summa    = V.Price
                            };
                            db.Checkk.Add(checkk);
                        }
                        db.SaveChanges();
                        this.label6_NoScidka.Text = s.ToString();
                    }
                }
            }
        }
Esempio n. 14
0
        private void Show_Tovar()
        {
            panel1.Visible      = false;
            panel2.Visible      = false;
            panel3.Visible      = false;
            panel4.Visible      = false;
            panel5_Hit1.Visible = false;
            panel5_Hit2.Visible = false;
            panel6_Hit3.Visible = false;
            panel7_Hit4.Visible = false;
            using (MusicEntities2 db = new MusicEntities2())
            {
                int col_poz = 0;
                var disc    = db.Disc.OrderBy(z => z.Id).Skip((pages - 1) * panal_col).Take(panal_col).ToList();
                if (disc.Count < 4)
                {
                    this.button1_Two.Visible   = false;
                    this.button1_Right.Visible = false;
                }
                else
                {
                    this.button1_Two.Visible   = true;
                    this.button1_Right.Visible = true;
                }
                foreach (var disc1 in disc)
                {
                    if (col_poz == 0)
                    {
                        var hit = db.Checkk.Where(z => z.IdDisc == disc1.Id).ToList();
                        if (hit.Count > 10)
                        {
                            panel5_Hit1.Visible = true;
                        }
                        panel1.Visible = true;
                        try
                        {
                            Bitmap bitmap = new Bitmap(disc1.Pichuri);
                            this.pictureBox2_1.Image = bitmap;
                        }
                        catch (Exception e)
                        {
                            Bitmap bitmap = new Bitmap(@"..\..\imagesMusic\ErrorImg.png");
                            this.pictureBox2_1.Image = bitmap;
                        }
                        this.pictureBox2_1.SizeMode = PictureBoxSizeMode.StretchImage;
                        this.label12_Author1.Text   = disc1.ColectiveName;
                        this.label12_DiscName1.Text = disc1.DiskName;
                        this.label12_Izdatel1.Text  = disc1.IzdatelName;
                        this.label12_Col_Trec1.Text = disc1.ColTrec.ToString();
                        this.label12_Ganr1.Text     = disc1.Genre;
                        this.label12_God1.Text      = disc1.YearPublishing.ToString("d");
                        this.label13_Prise1.Text    = disc1.Price.ToString();
                        this.label13_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)
                        {
                            panel5_Hit2.Visible = true;
                        }
                        panel2.Visible = true;
                        try
                        {
                            Bitmap bitmap = new Bitmap(disc1.Pichuri);
                            this.pictureBox3_2.Image = bitmap;
                        }
                        catch (Exception e)
                        {
                            Bitmap bitmap = new Bitmap(@"..\..\imagesMusic\ErrorImg.png");
                            this.pictureBox3_2.Image = bitmap;
                        }
                        this.pictureBox3_2.SizeMode = PictureBoxSizeMode.StretchImage;
                        this.label12_Author2.Text   = disc1.ColectiveName;
                        this.label12_DiscName2.Text = disc1.DiskName;
                        this.label12_Izdatel2.Text  = disc1.IzdatelName;
                        this.label12_Col_Trec2.Text = disc1.ColTrec.ToString();
                        this.label12_Ganr2.Text     = disc1.Genre;
                        this.label12_God2.Text      = disc1.YearPublishing.ToString("d");
                        this.label13_Prise2.Text    = disc1.Price.ToString();
                        this.label13_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)
                        {
                            panel6_Hit3.Visible = true;
                        }
                        panel3.Visible = true;
                        try
                        {
                            Bitmap bitmap = new Bitmap(disc1.Pichuri);
                            this.pictureBox4_3.Image = bitmap;
                        }
                        catch (Exception e)
                        {
                            Bitmap bitmap = new Bitmap(@"..\..\imagesMusic\ErrorImg.png");
                            this.pictureBox4_3.Image = bitmap;
                        }
                        this.pictureBox4_3.SizeMode = PictureBoxSizeMode.StretchImage;
                        this.label12_Author3.Text   = disc1.ColectiveName;
                        this.label12_DiscName3.Text = disc1.DiskName;
                        this.label12_Izdatel3.Text  = disc1.IzdatelName;
                        this.label12_Col_Trec3.Text = disc1.ColTrec.ToString();
                        this.label12_Ganr3.Text     = disc1.Genre;
                        this.label12_God3.Text      = disc1.YearPublishing.ToString("d");
                        this.label13_Prise3.Text    = disc1.Price.ToString();
                        this.label13_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)
                        {
                            panel7_Hit4.Visible = true;
                        }
                        panel4.Visible = true;
                        try
                        {
                            Bitmap bitmap = new Bitmap(disc1.Pichuri);
                            this.pictureBox5_4.Image = bitmap;
                        }
                        catch (Exception e)
                        {
                            Bitmap bitmap = new Bitmap(@"..\..\imagesMusic\ErrorImg.png");
                            this.pictureBox5_4.Image = bitmap;
                        }
                        this.pictureBox5_4.SizeMode = PictureBoxSizeMode.StretchImage;
                        this.label12_Author4.Text   = disc1.ColectiveName;
                        this.label12_DiscName4.Text = disc1.DiskName;
                        this.label12_Izdatel4.Text  = disc1.IzdatelName;
                        this.label12_Col_Trec4.Text = disc1.ColTrec.ToString();
                        this.label12_Ganr4.Text     = disc1.Genre;
                        this.label12_God4.Text      = disc1.YearPublishing.ToString("d");
                        this.label13_Prise4.Text    = disc1.Price.ToString();
                        this.label13_Id4.Text       = disc1.Id.ToString();
                    }

                    col_poz++;
                }
            }
        }