예제 #1
0
 private void AddOrderForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (SpisokDiskov != null && !orderadded)
     {
         pp_dbEntities db    = new pp_dbEntities();
         string        s     = SpisokDiskov;
         int           id1   = 0;
         int           id2   = 0;
         String[]      words = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
         for (int i = 0; i < words.Length - 1; i += 2)
         {
             int[] array  = words[i].Where(x => char.IsNumber(x)).Select(x => x - 48).ToArray();
             int[] array2 = words[i + 1].Where(x => char.IsNumber(x)).Select(x => x - 48).ToArray();
             for (int j = 0; j < array.Length; j++)
             {
                 id1 = id1 * 10 + array[j];
             }
             for (int j = 0; j < array2.Length; j++)
             {
                 id2 = id2 * 10 + array2[j];
             }
             movies mv = db.movies.Where(c => c.Id == id1).FirstOrDefault();
             mv.count          += id2;
             db.Entry(mv).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
 }
예제 #2
0
        private void cmbxDisk_SelectedIndexChanged(object sender, EventArgs e) //Показывает кол-во доступных дисков в label'ах, при выборе из combobox'а.
        {
            pp_dbEntities db  = new pp_dbEntities();
            int           ID  = Convert.ToInt32(cmbxDisk.SelectedValue.ToString());
            movies        dsk = db.movies.Where(c => c.Id == ID).FirstOrDefault();

            lbldskcount.Text    = dsk.count.ToString();
            lbldskcount.Visible = true;
            label8.Text         = "Дисков в наличии:";
        }
예제 #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtboxName.Text == "" || txtboxPrice.Text == "" || txtboxCount.Text == "")
                MessageBox.Show("Название диска, его цена и количество обязательны к заполнению");
            else
            {
                using (pp_dbEntities db = new pp_dbEntities())
                {

                    movies mv = new movies
                    {
                        name = txtboxName.Text,
                        synopsis = rTxtBoxSynopsis.Text,
                        genres = cmbxGenre.Text,
                        director = txtboxDirector.Text,
                        year = txtboxYear.Text,
                        agerating = cmbxAgerating.Text,
                        country = cmbxCounrty.Text,
                        price = Convert.ToInt32(txtboxPrice.Text),
                        count = Convert.ToInt32(txtboxCount.Text),
                    };
                    try
                    {
                        if (!add_or_edit)
                        {
                            db.movies.Add(mv);
                            db.SaveChanges();
                        }
                        else
                        {
                            movies mv2 = db.movies.Where(c => c.name == name2).FirstOrDefault();
                            mv2.name = txtboxName.Text;
                            mv2.synopsis = rTxtBoxSynopsis.Text;
                            mv2.genres = cmbxGenre.Text;
                            mv2.director = txtboxDirector.Text;
                            mv2.year = txtboxYear.Text;
                            mv2.agerating = cmbxAgerating.Text;
                            mv2.country = cmbxCounrty.Text;
                            mv2.price = Convert.ToInt32(txtboxPrice.Text);
                            mv2.count = Convert.ToInt32(txtboxCount.Text);

                            db.Entry(mv2).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                        return;
                    }
                }
                this.Close();
            }
        }
예제 #4
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            pp_dbEntities db   = new pp_dbEntities();
            int           ID   = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[6].Value.ToString());
            int           CLID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[8].Value.ToString());
            orders        or   = db.orders.Find(ID);
            clients       cl   = db.clients.Where(c => c.id == CLID).FirstOrDefault();



            string dl  = "";
            string s   = or.disklist.ToString();
            bool   a   = true;
            int    id3 = 0;

            String[] words = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < words.Length; i++)
            {
                int[] array = words[i].Where(x => char.IsNumber(x)).Select(x => x - 48).ToArray();
                for (int j = 0; j < array.Length; j++)
                {
                    id3 = id3 * 10 + array[j];
                }
                if (a)
                {
                    movies mv = db.movies.Where(c => c.Id == id3).FirstOrDefault();
                    dl  = dl + mv.name.ToString() + " ";
                    id3 = 0;
                    a   = false;
                }
                else
                {
                    dl  = dl + id3.ToString() + " шт ";
                    id3 = 0;
                    a   = true;
                }
            }



            OrderCloseForm close_form = new OrderCloseForm();

            close_form.lblcl.Text      = or.client.ToString();
            close_form.lblContact.Text = cl.contact.ToString();
            close_form.lblAddress.Text = cl.address.ToString();
            close_form.lbldsk.Text     = dl.ToString();
            close_form.lbldeposit.Text = or.deposit.ToString();
            close_form.lblrent.Text    = or.rent.ToString();
            close_form.lblid.Text      = or.id.ToString();
            close_form.ShowDialog();
            zapis();
        }
예제 #5
0
        private void btnRemoveDisk_Click(object sender, EventArgs e)
        {
            pp_dbEntities db = new pp_dbEntities();

            try
            {
                int    id          = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[9].Value.ToString());
                movies delete_item = db.movies.Find(id);
                db.movies.Remove(delete_item);
                db.SaveChanges();
                zapis();
            }
            catch (Exception ex)
            {
                return;
            }
        }
예제 #6
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            pp_dbEntities db = new pp_dbEntities();
            int           id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[9].Value.ToString());
            movies        mv = db.movies.Find(id);

            AddDiskForm edit_form = new AddDiskForm();

            edit_form.txtboxName.Text      = mv.name;
            edit_form.rTxtBoxSynopsis.Text = mv.synopsis;
            edit_form.cmbxGenre.Text       = mv.genres;
            edit_form.txtboxDirector.Text  = mv.director;
            edit_form.txtboxYear.Text      = mv.year;
            edit_form.cmbxAgerating.Text   = mv.agerating;
            edit_form.cmbxCounrty.Text     = mv.country;
            edit_form.txtboxPrice.Text     = Convert.ToString(mv.price);
            edit_form.txtboxCount.Text     = Convert.ToString(mv.count);

            edit_form.ShowDialog();
            zapis();
        }
예제 #7
0
        public void btnAddDisk_Click(object sender, EventArgs e) // Добавление дисков в заказ
        {
            if (txtboxDiskCount.Text == "" || Convert.ToInt32(txtboxDiskCount.Text) == 0)
            {
                lbldsk.Visible = true;
            }
            else
            {
                lbldsklst.Text = "";
                dobavlen       = true;
                lbldsk.Visible = false;
                pp_dbEntities db  = new pp_dbEntities();
                movies        mv  = db.movies.Where(c => c.name == cmbxDisk.Text).FirstOrDefault();
                int           cnt = Convert.ToInt32((txtboxDiskCount.Text));

                if (mv.count < cnt)
                {
                    lbldskcount.Visible = false;
                    label8.Text         = "Закажите не более " + lbldskcount.Text + " дисков";
                }

                else
                {
                    mv.count           = mv.count - cnt;
                    db.Entry(mv).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    int    ID  = Convert.ToInt32(cmbxDisk.SelectedValue.ToString());
                    movies dsk = db.movies.Where(c => c.Id == ID).FirstOrDefault();
                    lbldskcount.Text    = dsk.count.ToString();
                    lbldskcount.Visible = true;
                    label8.Text         = "Дисков в наличии:";
                    bool UsheEst = false;
                    for (int j = 0; j < i; j++)
                    {
                        if (DiskList[j] == dsk.Id)
                        {
                            DiskCount[j] = DiskCount[j] + cnt;
                            UsheEst      = true;
                            price        = price + dsk.price * cnt;
                            break;
                        }
                    }
                    if (!UsheEst)
                    {
                        DiskList[i]  = dsk.Id;
                        DiskCount[i] = cnt;
                        price        = price + dsk.price * cnt;
                        i++;
                    }
                }
                if (txtboxRent.Text != "")
                {
                    lblPrice.Text = (price / 20 * Convert.ToDouble(txtboxRent.Text)).ToString();
                }
                else
                {
                    lblPrice.Text = (price / 20).ToString();
                }
                lblDeposit.Text = price.ToString();

                SpisokDiskov = "";
                for (int j = 0; j < i; j++)
                {
                    SpisokDiskov = SpisokDiskov + DiskList[j].ToString() + " " + DiskCount[j].ToString() + " ";
                }
                string   dl    = "";
                string   s     = SpisokDiskov;
                bool     a     = true;
                int      id3   = 0;
                String[] words = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < words.Length; i++)
                {
                    int[] array = words[i].Where(x => char.IsNumber(x)).Select(x => x - 48).ToArray();
                    for (int j = 0; j < array.Length; j++)
                    {
                        id3 = id3 * 10 + array[j];
                    }
                    if (a)
                    {
                        dl = "";
                        movies mv3 = db.movies.Where(c => c.Id == id3).FirstOrDefault();
                        dl  = dl + mv3.name.ToString() + " ";
                        id3 = 0;
                        a   = false;
                    }
                    else
                    {
                        dl             = dl + id3.ToString() + " шт ";
                        id3            = 0;
                        a              = true;
                        lbldsklst.Text = lbldsklst.Text + '\n' + dl;
                    }
                }
            }
        }