示例#1
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Receptie).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ReceptieExists(Receptie.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
示例#2
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Produs.Add(Produs);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
示例#3
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            string EanID = Request.Form["LP"].ToString();
            var    data  = (from listaproduse in _context.Produs select listaproduse).ToList();

            ListaProduse = data;
            Stoc objStoc = new Stoc();

            foreach (Produs produs in ListaProduse)
            {
                if (EanID.Equals(produs.ID.ToString()))
                {
                    objStoc.Produs      = produs.Nume;
                    Receptie.EAN        = produs;
                    Receptie.EAN_Produs = produs.EAN;
                    break;
                }
            }

            _context.Receptie.Add(Receptie);
            await _context.SaveChangesAsync();

            objStoc.EAN       = Receptie.EAN;
            objStoc.Cantitate = Receptie.Cantitate;
            objStoc.Furnizor  = Receptie.Furnizor;
            objStoc.SSCC      = Receptie.SSCC;
            objStoc.Adresa    = "În curs de stocare";
            objStoc.Receptie  = Receptie;
            _context.Stoc.Add(objStoc);
            await _context.SaveChangesAsync();

            return(RedirectToPage("../Stocuri/Index"));
        }
示例#4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Stoc = await _context.Stoc.FindAsync(id);

            if (Stoc != null)
            {
                _context.Stoc.Remove(Stoc);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
示例#5
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            // recuperare lista EANuri din bdd
            var datap = (from listaproduse in _context.Produs select listaproduse).ToList();

            ListaProduse = datap;

            var data = (from listastoc in _context.Stoc where listastoc.Comanda == null select listastoc).ToList();

            ListaStoc = data;
            string stocID = Request.Form["LP"].ToString();

            foreach (Stoc stoc in ListaStoc)
            {
                //identificam stocul ales
                if (stocID.Equals(stoc.ID.ToString()))
                {
                    //recuperam produsul stocului
                    foreach (Produs produs in ListaProduse)
                    {
                        if (produs.Nume.Equals(stoc.Produs))
                        {
                            Comanda.EAN = produs;
                            break;
                        }
                    }

                    // modificam stocul care ramane. Daca nu ramane nicio cantitate, stergem
                    // linia
                    decimal cantitate = stoc.Cantitate - Comanda.Cantitate;
                    decimal livrata   = stoc.Cantitate;
                    if (cantitate <= 0)
                    {
                        // s-a consumat tot paletul
                        _context.Stoc.Remove(stoc);
                        await _context.SaveChangesAsync();

                        // setez cantitatea pt rescriere pe comanda - caz comandat>livrat
                        cantitate = stoc.Cantitate;
                    }
                    else
                    {
                        stoc.Cantitate = cantitate;
                        _context.Stoc.Update(stoc);
                        await _context.SaveChangesAsync();

                        // setez cantitatea pt rescriere pe comanda - caz comandat=livrat
                        cantitate = Comanda.Cantitate;
                        livrata   = cantitate;
                    }
                    // scriem comanda
                    Comanda.Livrata = livrata;
                    _context.Comanda.Add(Comanda);
                    await _context.SaveChangesAsync();

                    // scriem stocul comandat. Daca avem o cantitate negativa inseamna
                    // ca nu a fost suficient stocul pt cant comandata. Livram cat este
                    Stoc newStoc = new Stoc();
                    newStoc.EAN       = Comanda.EAN;
                    newStoc.Produs    = stoc.Produs;
                    newStoc.Furnizor  = stoc.Furnizor;
                    newStoc.SSCC      = stoc.SSCC;
                    newStoc.Adresa    = "În curs de expediere";
                    newStoc.Client    = Comanda.Client;
                    newStoc.Receptie  = stoc.Receptie;
                    newStoc.Comanda   = Comanda;
                    newStoc.Cantitate = Comanda.Livrata;
                    _context.Stoc.Add(newStoc);
                    await _context.SaveChangesAsync();

                    break;
                }
            }

            return(RedirectToPage("../Stocuri/Index"));
        }