Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("wItemId,Name,Description,Manufacturer,Price,Quantity")] wItems wItems)
        {
            if (id != wItems.wItemId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(wItems);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!wItemsExists(wItems.wItemId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(wItems));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("wItemId,Name,Description,Manufacturer,Price,Quantity")] wItems wItems)
        {
            if (ModelState.IsValid)
            {
                _context.Add(wItems);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(wItems));
        }
Exemplo n.º 3
0
        //function to transfer specific item from wholesale to warehouse

        public void OrderSpecificItem(wItems item, int quantity)
        {
            using (wholesaleContext)
            {
                foreach (var i in wholesaleContext.Items.ToList())
                {
                    if (i.Name.Equals(item.Name))
                    {
                        item.Quantity += quantity;
                        // warehouseContext.wItems.Add(item);
                    }
                    warehouseContext.SaveChanges();
                }
            }
        }
Exemplo n.º 4
0
        //function to fill warehouse database based on wholesale database (transfers all items)

        public void OrderItemsForWarehouse(int quantity)
        {
            if (!warehouseContext.wItems.Any())
            {
                using (wholesaleContext)
                {
                    foreach (var item in wholesaleContext.Items)
                    {
                        wItems wItem = new wItems
                        {
                            Name         = " ",
                            Quantity     = 0,
                            Description  = " ",
                            Manufacturer = " ",
                            Price        = 0
                        };
                        // wItem.wItemId = item.ItemId;
                        wItem.Name         = item.Name;
                        wItem.Quantity    += quantity;
                        wItem.Manufacturer = item.Manufacturer;
                        wItem.Price        = item.Price;
                        wItem.Description  = item.Description;
                        // wItem.cathegory.wCathegoryId = item.cathegory.CathegoryId;
                        warehouseContext.wItems.AddAsync(wItem);
                        warehouseContext.SaveChangesAsync();
                    }
                }
            }
            else
            {
                using (warehouseContext)
                {
                    foreach (var w in warehouseContext.wItems.ToList())
                    {
                        w.Quantity += quantity;
                        warehouseContext.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void frmAddItems_Load(object sender, EventArgs e)
        {
            dbItems                         = DB.GetItemsForInvoice(Inv.idInvoice);
            ScanPDFs                        = DB.GetScanPDFs(ActiveOrder.idOrder, Inv.idInvoice, -1);
            lblInvoice.Text                 = Inv.MyNumber + ".  " + Inv.FirmName + " " + Inv.FirmIc;
            txtNrItemsExpected.Text         = Inv.NrItems.ToString();
            txtPriceExpected.Text           = Helper.DoubleToMoney(Inv.Price);
            panel1.AutoScroll               = false;
            panel1.HorizontalScroll.Enabled = false;
            panel1.HorizontalScroll.Visible = false;
            panel1.HorizontalScroll.Maximum = 0;
            panel1.AutoScroll               = true;
            int    LastPosition    = 0;
            int    PocetVyplnenych = 0;
            double PriceDone       = 0;

            for (int i = 0; i < Inv.NrItems; i++)
            {
                wItems   AktItem = dbItems.Find(x => x.InvoiceOrder == (i + 1));
                ctrlItem I       = new ctrlItem();
                if (AktItem == null)
                {
                    I.Mode           = 1;
                    I.NrScan         = ScanPDFs.Select(x => x.ScanIncrement).ToList <int?>();
                    I.InvoiceOrder   = i + 1;
                    I.NrInvoice      = Inv.MyNumber ?? 0;
                    I.Nazev          = "";
                    I.idUnit         = 1;
                    I.idSazbaDPH     = 1;
                    I.idInvoiceItem  = -1;
                    I.BasePriceNoDPH = 0;
                    I.PriceNoDPH     = 0;
                }
                else
                {
                    I.Mode           = 2;
                    I.ScanIncrement  = AktItem.ScanIncrement ?? 0;
                    I.NrScan         = ScanPDFs.Select(x => x.ScanIncrement).ToList <int?>();
                    I.InvoiceOrder   = AktItem.InvoiceOrder ?? 0;
                    I.Nazev          = AktItem.ItemName;
                    I.idUnit         = AktItem.idUnit ?? 0;
                    I.idSazbaDPH     = AktItem.idSazbaDPH ?? 0;
                    I.idInvoiceItem  = AktItem.idInvoiceItem;
                    I.BasePrice      = AktItem.BasePrice ?? 0;
                    I.Price          = AktItem.Price ?? 0;
                    I.Quantity       = AktItem.Quantity ?? 0;
                    I.BasePriceNoDPH = AktItem.BasePriceBezDPH ?? 0;
                    I.PriceNoDPH     = AktItem.PriceBezDPH ?? 0;
                    PriceDone       += I.PriceNoDPH;
                    PocetVyplnenych++;
                }
                I.ctrlItemLeave     += I_ctrlItemLeave;
                I.PriceNoVatChanged += PriceNoVatChanged;
                I.Top = 20 + (I.Height + 2) * i;
                I.myControlChanged += I_myControlChanged;
                panel1.Controls.Add(I);
                LastPosition = 20 + ((I.Height + 2) * i) + I.Height;
                ctrlOneItem.Add(I);
            }
            panel1.Height       = (LastPosition + 30) > 400 ? 400 : (LastPosition + 30);
            this.Height         = 60 + panel1.Top + panel1.Height + 40;
            txtNrItemsDone.Text = PocetVyplnenych.ToString();
            txtPriceDone.Text   = Helper.DoubleToMoney(PriceDone);
            btnSave.Top         = this.ClientSize.Height - 40;
        }