Пример #1
0
        private void cartTable_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 8)
            {
                return;
            }
            var t = sender as DataGridView;

            var id       = (int)(t.Rows[e.RowIndex].Cells[0].Value);
            var quantity = (int)(t.Rows[e.RowIndex].Cells[quantityCol.Name].Value);
            var price    = (decimal)(t.Rows[e.RowIndex].Cells[priceCol.Name].Value);
            var discount = (decimal)(t.Rows[e.RowIndex].Cells[discountCol.Name].Value);

            using (var p = new POSEntities())
            {
                var inventoryItem = p.InventoryItems.FirstOrDefault(x => x.Id == id);
                using (var setup = new ItemSaleSetupForm())
                {
                    setup.SetValues(inventoryItem.Id
                                    , inventoryItem.Product.Item.Barcode,
                                    inventoryItem.SerialNumber,
                                    inventoryItem.Product.Item.Name,
                                    ImageDatabaseConverter.byteArrayToImage(inventoryItem.Product.Item.SampleImage),
                                    price,
                                    inventoryItem.Quantity,
                                    discount,
                                    quantity);

                    setup.OnConfirm += editConfirmed_Callback;
                    setup.ShowDialog();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// handles what happened after one of the boxes is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BoxClicked_Callback(object sender, EventArgs e)
        {
            ItemBoxHolder s                = sender as ItemBoxHolder;
            var           sameRow          = cartTable.Rows.Cast <DataGridViewRow>().FirstOrDefault(x => (int)(x.Cells[0].Value) == s.Id);
            var           isSameRowPresent = sameRow != null;

            decimal currentPrice    = isSameRowPresent ? (decimal)(sameRow.Cells[priceCol.Name].Value) : 0;
            decimal currentDiscount = isSameRowPresent ? (decimal)(sameRow.Cells[discountCol.Name].Value) : 0;

            using (var saleSetup = new ItemSaleSetupForm())
            {
                saleSetup.SetValues(s.Id,
                                    s.Barcode,
                                    s.Serial,
                                    s.ItemName,
                                    s.img,
                                    isSameRowPresent ? currentPrice : s.Price,
                                    s.Quantity,
                                    isSameRowPresent ? currentDiscount : 0,
                                    1,
                                    isSameRowPresent);

                saleSetup.OnConfirm += On_Confirm;
                saleSetup.ShowDialog();
            }
        }