Exemplo n.º 1
0
        //[AllowAnonymous]
        public async Task <IActionResult> Putinva_info([FromRoute] Guid id, [FromBody] inva_info varinva_info)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != varinva_info.inva_infoId)
            {
                return(BadRequest());
            }

            _context.Entry(varinva_info).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!inva_infoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        //[AllowAnonymous]
        public async Task <IActionResult> Postinva_info([FromBody] inva_info varinva_info)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.inva_info.Add(varinva_info);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getinva_info", new { id = varinva_info.inva_infoId }, varinva_info));
        }
Exemplo n.º 3
0
        public async Task <string> Operation_stopinventory(Guid uid, Guid InventoryID)
        {
            string result = "";


            inva_info ia = _context.inva_info.FirstOrDefault(i => i.inva_infoId == InventoryID);

            if (ia == null)
            {
                result = "Не найдена инвентаризация. ";
            }

            string q1 = @"INSERT INTO [dbo].[inva_extra]
                   ([inva_extraid]
                   ,[inva_infoID]
                   ,[storepartid]
                   ,[Qty]
                   ,[locationid]
                   ,[cellid]
                   ,[RFID])

                   select
		           NEWID()
                   ,'" + InventoryID.ToString() + @"'
		           ,r.storepartid
                   ,r.Qty-w.Qty
                   ,r.locationid
                   ,r.cellid
                   ,r.RFID
		           from inva_real r join invw_info w on 
		           r.storepartid = w.storepartid and 
                   r.locationid =w.locationid and
                   r.cellid=w.cellid and
                   r.theStore =w.theStore and
                   r.RFID = w.rFID
		           and r.Qty > w.Qty  where 
		           r.inva_infoID ='"         + InventoryID.ToString() + @"' ";

            _context.DoExec(q1);

            string q2 =
                @"INSERT INTO [dbo].[inva_extra]
           ([inva_extraid]
           ,[inva_infoID]
           ,[storepartid]
           ,[Qty]
           ,[locationid]
           ,[cellid]
           ,[RFID])
           select
		   NEWID()
           ,'" + InventoryID.ToString() + @"'
		   ,r.storepartid
           ,r.Qty
           ,r.locationid
           ,r.cellid
           ,r.RFID
		   from inva_real r   where 
		   r.inva_infoID ='"         + InventoryID.ToString() + @"' and
		   concat(
			   CONVERT(nvarchar(40),storepartid),
			   CONVERT(nvarchar(40),cellid),
			   RFID
		   )
		    not in (
			select 
			concat(
			   CONVERT(nvarchar(40),storepartid),
			   CONVERT(nvarchar(40),cellid),
			   RFID
		    )
		   from invw_info 
		   )"        ;

            _context.DoExec(q2);

            string q3 =
                @"INSERT INTO [dbo].[inva_absnt]
           ([inva_absntid]
           ,[inva_infoID]
           ,[storepartid]
           ,[Qty])
           select
		   NEWID()
           ,'" + InventoryID.ToString() + @"'
		   ,r.storepartid
           ,sum(w.Qty-r.Qty)
		   from inva_real r join invw_info w on 
		   r.storepartid = w.storepartid and 
           r.locationid =w.locationid and
           r.cellid=w.cellid and
           r.theStore =w.theStore and
           r.RFID = w.rFID
		   and r.Qty < w.Qty
           where 
		   r.inva_infoID ='"         + InventoryID.ToString() + @"' 
		   group by  r.storepartid "        ;

            _context.DoExec(q3);


            string q4 = @"INSERT INTO [dbo].[inva_absnt]
           ([inva_absntid]
           ,[inva_infoID]
           ,[storepartid]
           ,[Qty])
     select
		   NEWID()
           ,'" + InventoryID.ToString() + @"'
		   ,r.storepartid
           ,sum(r.Qty)
		    from invw_info r  where 
			   concat(
				   CONVERT(nvarchar(40),storepartid),
				   CONVERT(nvarchar(40),cellid),
				   RFID
			   )
		    not in (
			select 
			concat(
			   CONVERT(nvarchar(40),storepartid),
			   CONVERT(nvarchar(40),cellid),
			   RFID
		    )
		   from inva_real
		   where 
		   inva_infoID ='"         + InventoryID.ToString() + @"' 
		   )
		   group by storepartid"        ;

            _context.DoExec(q4);

            if (ia != null)
            {
                ia.isFinished = enum_YesNo.YesNo_Da;
                await _context.SaveChangesAsync();

                return("OK");
            }
            else
            {
                await _context.SaveChangesAsync();

                return(result);
            }
        }