public async Task <IActionResult> AddOrEdit([Bind("LocId,LocName,UserName,UserIP,UserDate")] InvLocation invLocation)
        {
            UserDetails();
            if (ModelState.IsValid)
            {
                if (!InvLocationExists(invLocation.LocName))
                {
                    string locname = invLocation.LocName;

                    if (invLocation.LocId == 0)
                    {
                        _context.Add(invLocation);
                        addToast(); // Triggers addToast
                    }
                    else
                    {
                        _context.Update(invLocation);
                        editToast(); // Triggers editToast
                    }
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    warnToast(); // Triggers warnToast
                }
            }
            return(View(invLocation));
        }
Example #2
0
        private static void AddRegion(string region, int xmin, int ymin)
        {
            var number = 1;
            var xmax   = xmin + 29;
            var ymax   = ymin + 18;

            for (var y = ymin; y <= ymax; y++)
            {
                for (var x = xmin; x <= xmax; x++)
                {
                    var h = MakePosition(x, y);
                    var l = MakeRegNum(region, number);
                    var p = new Position {
                        RegNum = l, X = x, Y = y
                    };
                    //InvPosition.Add(l, p);
                    Location.Add(h, p);
                    InvLocation.Add(l, h);
                    number++;
                }
            }
        }
Example #3
0
        internal static string Move(string cur, int dx, int dy)
        {
            if (!InvLocation.ContainsKey(cur))
            {
                return(null);
            }

            var h    = InvLocation[cur];
            var scp  = h.Split(new[] { '/', '_' });
            var ynew = Convert.ToInt32(scp[0], CultureInfo.InvariantCulture) + dy;
            var xnew = Convert.ToInt32(scp[1], CultureInfo.InvariantCulture) + dx;
            var hnew = MakePosition(xnew, ynew);

            if (!Location.ContainsKey(hnew))
            {
                return(null);
            }

            var curnew = Location[hnew].RegNum;

            return(!Cells.ContainsKey(curnew) ? null : curnew);
        }
        void CallJoinTwoWareHouseOrLocation(InvWarehouse fromWareHouse = null, InvWarehouse copyToWareHouse = null, InvLocation fromLocation = null, InvLocation copyToLocation = null)
        {
            DeletePostedJournal delDialog = new DeletePostedJournal(true);

            delDialog.Closed += delegate
            {
                if (delDialog.DialogResult == true)
                {
                    var invApi = new InventoryAPI(crudApi);
                    if (isJoinWareHouse)
                    {
                        JoinResult = invApi.JoinTwoWarehouses(fromWareHouse, copyToWareHouse);
                    }
                    else
                    {
                        JoinResult = invApi.JoinTwoLocations(fromLocation, copyToWareHouse, copyToLocation);
                    }
                    this.DialogResult = true;
                }
            };
            delDialog.Show();
        }