Ejemplo n.º 1
0
        private BooleanPlus CreatePhysicalInventory(string username, string locationName, string locationCode, string shortname)
        {
            BooleanPlus bp = new BooleanPlus();

            DateTime startDate = DateTime.Now;
            string   status    = "In Process";

            bp.ID = entities.IMS_PHYSICAL_INVENTORY.Max(u => (int?)u.PHYSICALINVENTORYID).GetValueOrDefault() + 1;

            entities.IMS_PHYSICAL_INVENTORY.Add(new PI_Domain.IMS_PHYSICAL_INVENTORY()
            {
                PHYSICALINVENTORYID = bp.ID, START_DATE = startDate, STATUS = status, USRNAM = username, LOCATION_NAME = locationName, LOCATIONCODE = locationCode, LOCATION_SHORTNAME = shortname, ORIGSTS = "N"
            });

            try
            {
                entities.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                var fullErrorMessage = string.Join("; ", errorMessages);
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                bp.Errors = exceptionMessage;
            }

            return(bp);
        }
Ejemplo n.º 2
0
        private BooleanPlus CreateShipment(int CustomerID, string ASNNumber, DateTime ShipmentDate, string ReceiveStatus = "Expected")
        {
            BooleanPlus bp = new BooleanPlus();

            string tablename = "IMS_SHIPMENTS";
            string fldname   = "SHIPMENTID";

            int nextID = entities.IMS_SHIPMENTS.Max(x => x.SHIPMENTID);

            nextID += 1;

            entities.IMS_SHIPMENTS.Add(new PI_Domain.IMS_SHIPMENTS
            {
                ORIGSTS                   = "N",
                CUSTOMERID                = CustomerID,
                ASNCREATIONDATE           = DateTime.Now,
                ASNNUMBER                 = ASNNumber,
                RECEIVESTATUS             = ReceiveStatus,
                HAS_SYSTEM_GENERATED_TAGS = "N",
                SHIPMENTDATE              = ShipmentDate,
                SHIPMENTID                = nextID,
                STATUSTIME                = DateTime.Now
            });

            UpdateCounter(nextID, tablename, fldname);

            entities.SaveChanges();

            bp.ID = nextID;

            return(bp);
        }
Ejemplo n.º 3
0
        private BooleanPlus LotNumberExists(string lotnumber)
        {
            BooleanPlus ret = new BooleanPlus();

            var Exists = (from l in entities.IMS_LOTS where l.LOTNUMBER == lotnumber select l).Any();


            if (Exists)
            {
                ret.status = false;

                if (lotnumber.Length < 50)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        var x = LotNumberExists(lotnumber + i.ToString());
                        if (x.status)
                        {
                            ret.value  = lotnumber + i.ToString();
                            ret.status = true;
                            return(ret);
                        }
                    }
                }
            }
            else
            {
                ret.value  = lotnumber;
                ret.status = true;
            }



            return(ret);
        }
Ejemplo n.º 4
0
        public ActionResult HandHeld(Handheld model)
        {
            BooleanPlus bp = new BooleanPlus();

            if (ModelState.IsValid)
            {
                DAL dal   = new DAL();
                var found = dal.GetFoundItems(model);

                foreach (var x in model.locations)
                {
                    if (x.Select && x.Skip != true)
                    {
                        bp = dal.StartPhysicalInventory(x.locationCode);
                        dal.CompletePhysicalInventory(bp.ID, x.locationCode, found);
                    }
                }


                var zz = dal.UpdateCounterPI();
                model = dal.GetHandHeld(10000);
                return(View(model));
            }

            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 5
0
        private BooleanPlus Direct(PurchaseOrder purchaseOrder)
        {
            BooleanPlus ret = new BooleanPlus();

            CreateShipment(purchaseOrder.CustomerID, purchaseOrder.asn.ASNNumber, (DateTime)purchaseOrder.asn.ShipmentDate);

            foreach (var x in purchaseOrder.LineItems)
            {
            }


            return(ret);
        }
Ejemplo n.º 6
0
        private BooleanPlus CreateCurrentInStockRecordSetForPhysicalInventory(string locationCode, int physicalInventoryID)
        {
            //nItemId := ExecFunction("InventoryManagementSolution.GetSequenceId", {"IMS_PHYSICAL_ITEMS", "PHYSICALITEMID"});
            //SqlExecute("INSERT INTO IMS_PHYSICAL_ITEMS (PHYSICALITEMID, SGTIN, PRODUCT_NAME, SUPPLIER_NAME, STATUS, STATUS_TIME, LOTNUMBER, LOTEXPIRATION, PHYSICALINVENTORYID, TAG_GTIN14, TAG_SN)
            //            VALUES (?nItemId?, ?aItems[i][1]?, ?aItems[i][2]?, ?aItems[i][3]?, 'Expected', ?Now()?, ?aItems[i][4]?, ?aItems[i][5]?, ?nSessionId?, ?aItems[i][6]?, ?aItems[i][7]?)");
            BooleanPlus ret = new BooleanPlus();


            // int nextID = entities.IMS_PHYSICAL_ITEMS.Max(u => u.PHYSICALITEMID);

            IEnumerable <InventoryItem> StockItems = from stock in GetInventoryItemsByLocation(locationCode) where (stock.intransit == null || stock.intransit == "N") && (stock.status == "Pending" || stock.status == "Stock") orderby stock.itemID select stock;

            ret.count = StockItems.Count();

            string status = "Expected";

            foreach (var i in StockItems)
            {
                AddPhysicalInventoryItem(physicalInventoryID, status, i);

                try
                {
                    entities.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    var errorMessages = ex.EntityValidationErrors
                                        .SelectMany(x => x.ValidationErrors)
                                        .Select(x => x.ErrorMessage);

                    var fullErrorMessage = string.Join("; ", errorMessages);
                    var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                    ret.Errors = exceptionMessage;
                }
            }



            return(ret);
        }
Ejemplo n.º 7
0
        public BooleanPlus ReceiveASN(PurchaseOrder purchaseOrder, AdvancedShipingNotice asn)
        {
            BooleanPlus bp = new BooleanPlus();

            if (asn.DirectInsert)
            {
            }

            if (asn.XmlFileOutput)
            {
                ASNxml xAsn = XmlOutput(purchaseOrder);

                XmlWriter w = new XmlWriter();
                w.WriteToFile(xAsn);
                XmlFormatter formatter = new XmlFormatter();
                var          zz        = formatter.Serialize <ASNxml>(xAsn);
                bp.value += zz;
            }

            return(bp);
        }
Ejemplo n.º 8
0
        public ActionResult Create(AdvancedShipingNotice model)
        {
            BooleanPlus bp  = new BooleanPlus();
            DAL         dal = new DAL();

            int counter = 0;

            if (ModelState.IsValid)
            {
                dal.CreateSerialNumberDictiony();

                foreach (var po in model.PurchaseOrders.Where(x => x.Select == true))
                {
                    dal.ReceiveASN(po, model);
                    counter++;
                }
            }


            model = new AdvancedShipingNotice();
            model = dal.CreateASN();
            return(View(model));
        }
Ejemplo n.º 9
0
        public BooleanPlus CreateItems(ItemCreation model)
        {
            BooleanPlus bp     = new BooleanPlus();
            string      sn     = "";
            string      epc    = "urn:epc:id:sgtin:{0}.{1}";
            string      sgtin  = "";
            Int32       ItemID = 0;

            Random lotExention = new Random();
            Random random      = new Random();
            long   randnum2;


            model.products.Where(z => z.qty > 0 & z.location != null & z.CostCenterID != "0").ToList().ForEach(z =>
            {
                var verifiedlot = z.lotnumber == null ? "test_" + lotExention.NextDouble().ToString() : z.lotnumber;

                var lotID = CreateLot(verifiedlot, z.lotExpiry, z.ProductID);

                for (int i = 0; i < z.qty; i++)
                {
                    randnum2 = (long)(random.NextDouble() * 9000000000) + 1000000000;
                    sn       = randnum2.ToString();
                    sgtin    = string.Format(epc, z.GTIN, sn);



                    ItemID = GetNextID("IMS_ITEMS", "ITEMID") + 1;
                    entities.IMS_ITEMS.Add(new PI_Domain.IMS_ITEMS()
                    {
                        ORIGSTS              = "N",
                        ITEMID               = ItemID,
                        LOCATIONCODE         = z.location,
                        LOCATIONTIME         = DateTime.Now,
                        SGTIN                = sgtin,
                        PRODUCTID            = z.ProductID,
                        COSTCENTERID         = Convert.ToInt32(z.CostCenterID),
                        STATUS               = "Stock",
                        STATUSTIME           = DateTime.Now,
                        ITEMLOTID            = lotID,
                        TAG_GTIN14           = z.GTIN,
                        TAG_SN               = sn,
                        CONSUMPTION_UNITS    = 1,
                        SYSTEM_GENERATED_TAG = "N",
                        QUARANTINESTATUS     = "Do not Quarantine"
                    });



                    try
                    {
                        entities.SaveChanges();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        var errorMessages = ex.EntityValidationErrors
                                            .SelectMany(x => x.ValidationErrors)
                                            .Select(x => x.ErrorMessage);

                        var fullErrorMessage = string.Join("; ", errorMessages);
                        var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                        bp.Errors = exceptionMessage;
                    }


                    UpdateCounter(ItemID, "IMS_ITEMS", "ITEMID");
                }
            });



            return(bp);
        }