Пример #1
0
        public static ICollection <Inventory> GetLPNInventoryRecords(Session session, string fullLPNNumber, int customerID)
        {
            //Dim LPNNumber As Integer = Integer.Parse(fullLPNNumber.Replace(CustomersBLL.GetLPNPrefix(customerID), ""))

            ICollection <Inventory> result = new Collection <Inventory>();

            result = new XPCollection <Inventory>(session, new BinaryOperator(Inventory.Fields.InventoryItemID.ItemCustomerID.CustomerID.PropertyName, customerID, BinaryOperatorType.Equal) & new BinaryOperator("FullLPNNumber", fullLPNNumber, BinaryOperatorType.Equal));

            if (result.Count() == 0 && !fullLPNNumber.StartsWith(CustomersBLL.GetLPNPrefix(7)))
            {
                //If customerID = 7 Then
                //    Dim locationInventorys As XPCollection(Of LocationInventoryByLot) = New XPCollection(Of LocationInventoryByLot)(session,
                //                                                          New BinaryOperator(LocationInventoryByLot.Fields.LPNNumber.PropertyName, Integer.Parse(fullLPNNumber.Replace(CustomersBLL.GetLPNPrefix(customerID), "")), BinaryOperatorType.Equal))
                //    If locationInventorys.Count < 1 Then Return result
                //    Dim locationInventory As LocationInventoryByLot = locationInventorys(0)
                //    Dim convertToInventory As Inventory = New Inventory(session) With {.InventoryItemID = locationInventory.LocationInventoryItem, .InventoryQuantity = CInt(locationInventory.QuantityOnHand),
                //                                                                .Lot = locationInventory.LocationInventoryLot, .FullLPNNumber = fullLPNNumber, .ExpirationDate = locationInventory.ExpirationDate}
                //    result = New Collection(Of Inventory)
                //    result.Add(convertToInventory)
                //Else
                result = new XPCollection <Inventory>(session, new BinaryOperator(Inventory.Fields.InventoryItemID.ItemCustomerID.CustomerID.PropertyName, customerID, BinaryOperatorType.Equal) & new BinaryOperator("LPNNumber", int.Parse(fullLPNNumber.Replace(CustomersBLL.GetLPNPrefix(customerID), "")), BinaryOperatorType.Equal));
                //End If
            }

            return(result);
        }
Пример #2
0
        public static bool IsLPNShipped(string fullLPNNumber, int customerID, Session DXSession)
        {
            if (!fullLPNNumber.StartsWith(CustomersBLL.GetLPNPrefix(customerID)))
            {
                fullLPNNumber = CustomersBLL.GetLPNPrefix(customerID) + ("0000000000" + fullLPNNumber).Substring(("0000000000" + fullLPNNumber).Length - CustomersBLL.GetCustomer(customerID, DXSession).LastLPNNumber.ToString().Length);
            }

            CriteriaOperatorCollection filter = new CriteriaOperatorCollection();

            filter.Add(new BinaryOperator(ShipDet.Fields.ShipDetMainID.ShipMainCustID.CustomerID.PropertyName, customerID, BinaryOperatorType.Equal));
            filter.Add(new BinaryOperator(ShipDet.Fields.FullLPNNumber.PropertyName, fullLPNNumber, BinaryOperatorType.Equal));

            int?LPNCount = (int?)XpoDefault.Session.Evaluate <ShipDet>(new AggregateOperand("", "FullLPNNumber", Aggregate.Count), new GroupOperator(GroupOperatorType.And, filter));

            if (LPNCount.HasValue && LPNCount.Value >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        private void lpnNumberTextEdit_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (fromLocationLookUpEdit.EditValue != null && lpnNumberTextEdit.Text.Length > 0)
            {
                int LocationID = Convert.ToInt32(fromLocationLookUpEdit.EditValue);

                try
                {
                    int LPN = int.Parse(lpnNumberTextEdit.Text.Replace(CustomersBLL.GetLPNPrefix(7), ""));

                    for (int i = 0; i < transferDetailsGridView.RowCount; i++)
                    {
                        if (transferDetailsGridView.GetDataRow(i) != null && transferDetailsGridView.GetDataRow(i)["FullLpnNumber"].Equals(LPN))
                        {
                            MessageBox.Show("This LPN is already entered.");
                            lpnNumberTextEdit.EditValue = null;
                            return;
                        }
                    }

                    foreach (LocationInventoryByLot record in new XPCollection <LocationInventoryByLot>(m_TransfersSession, new GroupOperator(new BinaryOperator(LocationInventoryByLot.Fields.LPNNumber, LPN, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventoryByLot.Fields.Location.Oid.PropertyName, LocationID, BinaryOperatorType.Equal))))
                    {
                        transferDetailsGridView.AddNewRow();
                        transferDetailsGridView.SetRowCellValue(transferDetailsGridView.FocusedRowHandle, transferItemGridColumn, record.LocationInventoryItem.ItemID);
                        transferDetailsGridView.SetRowCellValue(transferDetailsGridView.FocusedRowHandle, colTransferQuantity, record.QuantityOnHand);
                        transferDetailsGridView.SetRowCellValue(transferDetailsGridView.FocusedRowHandle, colTransferLot, record.LocationInventoryLot);
                        transferDetailsGridView.SetRowCellValue(transferDetailsGridView.FocusedRowHandle, colItemExpirationDate, record.ExpirationDate);
                        transferDetailsGridView.SetRowCellValue(transferDetailsGridView.FocusedRowHandle, fullLpnNumberGridColumn, LPN);
                        transferDetailsGridView.UpdateCurrentRow();
                    }
                }
                catch
                {
                }
                lpnNumberTextEdit.EditValue = null;
            }
        }
Пример #4
0
        public bool DeleteShippingDetail(Session session, int detailID)
        {
            SPG.ShippingDetailsDataTable details = Adapter.GetDetailsByDetailID(detailID);
            int    rowsAffected  = 0;
            int    itemID        = 0;
            int    quantity      = 0;
            int    locationID    = 0;
            string lot           = null;
            string fullLPNNumber = null;

            if (details.Count() == 1)
            {
                SPG.ShippingDetailsRow shippingDetail = (SPG.ShippingDetailsRow)details.Rows[0];
                itemID        = shippingDetail.ShipDetItemID;
                quantity      = shippingDetail.ShipDetDetQty;
                lot           = shippingDetail.ShipDetLot;
                fullLPNNumber = shippingDetail.FullLPNNumber;
                locationID    = session.GetObjectByKey <Shipping>(shippingDetail.ShipDetMainID).ShippingLocation.Oid;
                rowsAffected  = Adapter.Delete(detailID, shippingDetail.ts);
            }

            if (rowsAffected == 1)
            {
                ItemsBLL items = new ItemsBLL();
                if (fullLPNNumber.StartsWith(CustomersBLL.GetLPNPrefix(7)))
                {
                    items.UpdateStock(session, itemID, quantity, false, locationID, lot, int.Parse(fullLPNNumber.Replace(CustomersBLL.GetLPNPrefix(7), "")));
                }
                else
                {
                    items.UpdateStock(session, itemID, quantity, false, locationID);
                }
            }

            //Return true if precisely one row was deleted, otherwise return false.
            return(rowsAffected == 1);
        }
Пример #5
0
        public bool UpdateShippingDetails(Session session, int?detailID, int shippingID, int?itemID, string lot, int?quantity, float?pallets, string note, DateTime?expirationDate, string fullLPNNumber)
        {
            if (!itemID.HasValue)
            {
                throw new ApplicationException("You must provide shipping item.");
            }

            if (!quantity.HasValue)
            {
                throw new ApplicationException("You must provide the Quantity shipped.");
            }

            SPG.ShippingDetailsDataTable details = Adapter.GetDetailsByDetailID(detailID.Value);

            if (details.Count() == 0)
            {
                //It is a new Detail
                return(InsertDetails(session, shippingID, itemID, lot, quantity, pallets, note, expirationDate, fullLPNNumber));
            }

            SPG.ShippingDetailsRow shippingDetail = details[0];
            int  originalItem     = 0;
            int  originalQuantity = 0;
            int  newQuantity      = 0;
            bool itemChanged      = false;

            object[] originalRecord = shippingDetail.ItemArray;

            SPG.ShippingDetailsRow originalDetail = details.NewShippingDetailsRow();
            originalDetail.ItemArray = (object[])originalRecord.Clone();

            originalItem = shippingDetail.ShipDetItemID;
            if (itemID.HasValue && originalItem != itemID.Value)
            {
                itemChanged = true;
            }
            shippingDetail.ShipDetItemID = itemID.Value;
            if (string.IsNullOrEmpty(lot))
            {
                shippingDetail.SetShipDetLotNull();
            }
            else
            {
                shippingDetail.ShipDetLot = lot;
            }
            originalQuantity             = shippingDetail.ShipDetDetQty;
            newQuantity                  = quantity.Value - shippingDetail.ShipDetDetQty;
            shippingDetail.ShipDetDetQty = quantity.Value;
            shippingDetail.SetsngPackagesNull();
            if (!pallets.HasValue)
            {
                shippingDetail.SetsngPalletsNull();
            }
            else
            {
                shippingDetail.sngPallets = pallets.Value;
            }
            if (string.IsNullOrEmpty(note))
            {
                shippingDetail.SetNoteNull();
            }
            else
            {
                shippingDetail.Note = note;
            }
            if (expirationDate.HasValue)
            {
                shippingDetail.ExpirationDate = expirationDate.Value;
            }
            else
            {
                shippingDetail.SetExpirationDateNull();
            }
            if (string.IsNullOrEmpty(fullLPNNumber))
            {
                shippingDetail.SetFullLPNNumberNull();
            }
            else
            {
                shippingDetail.FullLPNNumber = fullLPNNumber;
            }

            if (!(originalRecord == null))
            {
                UpdateAuditTrail(shippingDetail, originalRecord);
            }

            int rowsAffected = Adapter.Update(shippingDetail);

            if (rowsAffected == 1)
            {
                ItemsBLL items      = new ItemsBLL();
                int      locationID = session.GetObjectByKey <Shipping>(shippingID).ShippingLocation.Oid;
                //If itemChanged = True Then
                if (originalDetail.FullLPNNumber.StartsWith(CustomersBLL.GetLPNPrefix(7)))
                {
                    items.UpdateStock(session, originalItem, originalQuantity, false, locationID, originalDetail.ShipDetLot, int.Parse(originalDetail.FullLPNNumber.Replace(CustomersBLL.GetLPNPrefix(7), "")));
                }
                else
                {
                    items.UpdateStock(session, originalItem, originalQuantity, false, locationID);
                }
                if (fullLPNNumber.StartsWith(CustomersBLL.GetLPNPrefix(7)))
                {
                    items.UpdateStock(session, itemID.Value, quantity.Value * -1, false, locationID, lot, int.Parse(fullLPNNumber.Replace(CustomersBLL.GetLPNPrefix(7), "")));
                }
                else
                {
                    items.UpdateStock(session, itemID.Value, quantity.Value * -1, false, locationID);
                }
                //Else
                //    If newQuantity <> 0 Then
                //        items.UpdateStock(session, itemID.Value, newQuantity * -1, False, locationID)
                //    End If
                //End If
            }

            return(rowsAffected == 1);
        }
Пример #6
0
        public bool InsertDetails(Session session, int shippingID, int?itemID, string lot, int?quantity, float?pallets, string note, DateTime?expirationDate, string fullLPNNumber)
        {
            SPG.ShippingDetailsDataTable details        = new SPG.ShippingDetailsDataTable();
            SPG.ShippingDetailsRow       shippingDetail = details.NewShippingDetailsRow();

            shippingDetail.ShipDetMainID = shippingID;
            shippingDetail.ShipDetItemID = itemID.Value;
            if (string.IsNullOrEmpty(lot))
            {
                shippingDetail.SetShipDetLotNull();
            }
            else
            {
                shippingDetail.ShipDetLot = lot;
            }
            shippingDetail.ShipDetDetQty = quantity.Value;
            shippingDetail.SetsngPackagesNull();
            if (!pallets.HasValue)
            {
                shippingDetail.SetsngPalletsNull();
            }
            else
            {
                shippingDetail.sngPallets = pallets.Value;
            }
            if (string.IsNullOrEmpty(note))
            {
                shippingDetail.SetNoteNull();
            }
            else
            {
                shippingDetail.Note = note;
            }
            if (expirationDate.HasValue)
            {
                shippingDetail.ExpirationDate = expirationDate.Value;
            }
            else
            {
                shippingDetail.SetExpirationDateNull();
            }
            if (string.IsNullOrEmpty(fullLPNNumber))
            {
                shippingDetail.SetFullLPNNumberNull();
            }
            else
            {
                shippingDetail.FullLPNNumber = fullLPNNumber;
            }

            details.AddShippingDetailsRow(shippingDetail);
            int rowsAffected = Adapter.Update(details);

            if (rowsAffected == 1)
            {
                ItemsBLL items = new ItemsBLL();
                if (fullLPNNumber.StartsWith(CustomersBLL.GetLPNPrefix(7)))
                {
                    items.UpdateStock(session, itemID.Value, quantity.Value * -1, false, session.GetObjectByKey <Shipping>(shippingID).ShippingLocation.Oid, lot, int.Parse(fullLPNNumber.Replace(CustomersBLL.GetLPNPrefix(7), "")));
                }
                else
                {
                    items.UpdateStock(session, itemID.Value, quantity.Value * -1, false, session.GetObjectByKey <Shipping>(shippingID).ShippingLocation.Oid);
                }
            }

            return(rowsAffected == 1);
        }