Exemple #1
0
        private void DecrementBook(ListBookClass book)
        {
            Book decrementBook = _db.Books.Where(bk => bk.Id == book.Id).First();

            decrementBook.Count = decrementBook.Count - book.Count;
            _db.SaveChanges();
        }
Exemple #2
0
        private void BtnRemoveList_Click(object sender, EventArgs e)
        {
            int           count = (int)numericCountBook.Value;
            ListBookClass list  = lbOrderBook.SelectedItem as ListBookClass;

            foreach (CMBBookClass item in cmbClientBook.Items)
            {
                try
                {
                    if (item.Id == list.Id)
                    {
                        item.Count += (int)list.Count;
                    }
                }
                catch
                {
                    MessageBox.Show("This list is empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);;
                    return;
                }
            }
            int totalBook = int.Parse(lbCountBook.Text);

            lbCountBook.Text = (totalBook - count).ToString();

            lbOrderBook.Items.Remove(list);
        }
Exemple #3
0
        private void BtnAddList_Click(object sender, EventArgs e)
        {
            CMBBookClass selectBook  = cmbClientBook.SelectedItem as CMBBookClass;
            CMBBookClass selectGenre = cmbClientGenre.SelectedItem as CMBBookClass;
            //  int selectedId = (cmbClientBook.SelectedItem as CMBBookClass).Id;
            int count = (int)numericCountBook.Value;

            if (!this.CheckInput())
            {
                MessageBox.Show("Please filled the input !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            foreach (var item in lbOrderBook.Items)
            {
                if (selectBook.Id == (item as ListBookClass).Id)
                {
                    MessageBox.Show("This book added already", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            if (cmbClientGenre.Text == "" || cmbClientBook.Text == "" || numericCountBook.Value == 0)
            {
                MessageBox.Show("Please filled the input !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            ListBookClass list = new ListBookClass()
            {
                Id    = selectBook.Id,
                Name  = selectBook.Name,
                Price = selectBook.Price,
                Genre = selectGenre.Name,
                Count = count
            };

            lbOrderBook.Items.Add(list);
            cmbClientBook.Text  = "";
            cmbClientGenre.Text = "";

            int totalBook = int.Parse(lbCountBook.Text);

            lbCountBook.Text = (totalBook + count).ToString();

            selectBook.Count      -= count;
            txbBalanceCurrent.Text = (cmbClientGenre.SelectedItem as CMBBookClass).Count.ToString();
            RefreshDGV();
        }