Beispiel #1
0
        public bool SaveRecord(int?id, bool IsnewInventory = true)
        {
            if (saveSimpleButton.Tag == null)
            {
                if (m_AllowAdd == true)
                {
                    saveSimpleButton.Tag = InventoryAdjustmentBLL.GetNewInventoryAdjustmentID();
                }
                else
                {
                    return(false);
                }
            }

            if (m_Adjustment.UpdateInventoryAdjustment(Convert.ToInt32(saveSimpleButton.Tag), adjustmentDateEdit.DateTime, Convert.ToInt32(customerLookUpEdit.EditValue), Convert.ToInt32(itemLookUpEdit.EditValue), Convert.ToSingle(originalQtyTextEdit.EditValue), Convert.ToSingle(newQtyTextEdit.EditValue), Convert.ToString(reasonMemoExEdit.EditValue), Convert.ToInt32(locationLookUpEdit.EditValue), Convert.ToString(originalLotLookUpEdit.EditValue), newLotTextEdit.Text, Utilities.ChangeType <int?>(lpnLookUpEdit.EditValue), Utilities.ChangeType <DateTime?>(originalLotLookUpEdit.GetColumnValue("Expr")), IsnewInventory) != true)
            {
                MessageBox.Show("The adjustment record was not updated succesfully.", "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            else if (m_newLpn && !string.IsNullOrEmpty(originalLotLookUpEdit.Text))
            {
                LocationInventoryByLot Lpntodelete = Session.DefaultSession.FindObject <LocationInventoryByLot>(new GroupOperator(GroupOperatorType.And, new BinaryOperator(LocationInventoryByLot.Fields.LPNNumber.PropertyName, (object)Utilities.ChangeType <int?>(lpnLookUpEdit.EditValue), BinaryOperatorType.Equal), new BinaryOperator(LocationInventoryByLot.Fields.QuantityOnHand.PropertyName, 0, BinaryOperatorType.Equal), new BinaryOperator("LocationInventoryLot", "", BinaryOperatorType.Equal)));
                if (Lpntodelete != null)
                {
                    Lpntodelete.Delete();
                    Session.DefaultSession.PurgeDeletedObjects();
                }
            }

            printLpn();

            inventoryXPView.Reload();

            return(true);
        }
Beispiel #2
0
        public static void UpdateStock(Session session, int ItemID, int LocationID, float Quantity, string lot = "", int?LPNNumber = null, DateTime?ExpirationDate = null, bool newInventory = true)
        {
            if (newInventory)
            {
                LocationInventory inventory = session.FindObject <LocationInventory>(new BinaryOperator(LocationInventory.Fields.LocationInventoryItem.ItemID.PropertyName, ItemID, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventory.Fields.Location.Oid.PropertyName, LocationID, BinaryOperatorType.Equal));

                if (inventory == null)
                {
                    inventory = new LocationInventory(session);
                    inventory.LocationInventoryItem = session.GetObjectByKey <Items>(ItemID);
                    inventory.Location       = session.GetObjectByKey <Locations>(LocationID);
                    inventory.QuantityOnHand = Quantity;
                }
                else
                {
                    inventory.QuantityOnHand += Quantity;
                }

                inventory.Save();
            }


            if (((lot == null) || string.IsNullOrEmpty(lot)) && ((LPNNumber == null) || LPNNumber == 0))
            {
                return;
            }

            LocationInventoryByLot inventoryByLot = session.FindObject <LocationInventoryByLot>(new BinaryOperator(LocationInventoryByLot.Fields.LocationInventoryItem.ItemID.PropertyName, ItemID, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventoryByLot.Fields.Location.Oid.PropertyName, LocationID, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventoryByLot.Fields.LocationInventoryLot, lot, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventoryByLot.Fields.LPNNumber, (LPNNumber ?? 0), BinaryOperatorType.Equal));

            if (inventoryByLot == null)
            {
                if (Quantity >= 0)
                {
                    inventoryByLot = new LocationInventoryByLot(session);
                    inventoryByLot.LocationInventoryItem = session.GetObjectByKey <Items>(ItemID);
                    inventoryByLot.Location             = session.GetObjectByKey <Locations>(LocationID);
                    inventoryByLot.LocationInventoryLot = lot;
                    inventoryByLot.LPNNumber            = LPNNumber;
                    inventoryByLot.QuantityOnHand       = Quantity;
                    if (ExpirationDate != null)
                    {
                        inventoryByLot.ExpirationDate = ExpirationDate;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                inventoryByLot.QuantityOnHand += Quantity;
            }

            inventoryByLot.Save();
        }
Beispiel #3
0
        private void cancelSimpleButton_Click(object sender, EventArgs e)
        {
            if (m_newLpn)
            {
                LocationInventoryByLot Lpntodelete = Session.DefaultSession.FindObject <LocationInventoryByLot>(new GroupOperator(GroupOperatorType.And, new BinaryOperator("LPNNumber", (object)Utilities.ChangeType <int?>(lpnLookUpEdit.EditValue), BinaryOperatorType.Equal), new BinaryOperator(LocationInventoryByLot.Fields.QuantityOnHand.PropertyName, 0, BinaryOperatorType.Equal), new BinaryOperator("LocationInventoryLot", "", BinaryOperatorType.Equal)));
                if (Lpntodelete != null)
                {
                    Lpntodelete.Delete();
                    Session.DefaultSession.PurgeDeletedObjects();
                }
            }

            PrepareNewRecord();
        }
Beispiel #4
0
        public static float GetQtyOnHandByIDAndLot(Session session, int?itemID, int locationID, string lot, int?LPNNumber)
        {
            if (itemID.HasValue == false || (LPNNumber == null))
            {
                return(0);
            }

            //If locationID.HasValue = False Then
            //    locationID = UsersBLL.GetUsersLocalLocation(My.Settings.UserName).Oid
            //End If

            try
            {
                if ((lot == null))
                {
                    if (locationID == 0)
                    {
                        return(Convert.ToSingle(session.Evaluate <LocationInventoryByLot>(new AggregateOperand("", LocationInventoryByLot.Fields.QuantityOnHand.PropertyName, Aggregate.Sum), new GroupOperator(GroupOperatorType.And, new BinaryOperator(LocationInventoryByLot.Fields.LocationInventoryItem.ItemID, itemID.Value, BinaryOperatorType.Equal), new BinaryOperator(LocationInventoryByLot.Fields.LPNNumber, LPNNumber.Value, BinaryOperatorType.Equal)))));
                    }
                    else
                    {
                        LocationInventoryByLot quantity = session.FindObject <LocationInventoryByLot>(new GroupOperator(new BinaryOperator(LocationInventoryByLot.Fields.LocationInventoryItem.ItemID, itemID.Value, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventoryByLot.Fields.Location.Oid.PropertyName, locationID, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventoryByLot.Fields.LPNNumber, LPNNumber.Value, BinaryOperatorType.Equal)));
                        //Dim item As Items = Session.DefaultSession.GetObjectByKey(Of Items)(itemID, True)
                        //Return item.s ngQuantityOnHand
                        return(quantity.QuantityOnHand);
                    }
                }
                else
                {
                    if (locationID == 0)
                    {
                        return(Convert.ToSingle(session.Evaluate <LocationInventoryByLot>(new AggregateOperand("", LocationInventoryByLot.Fields.QuantityOnHand.PropertyName, Aggregate.Sum), new GroupOperator(GroupOperatorType.And, new BinaryOperator(LocationInventoryByLot.Fields.LocationInventoryItem.ItemID, itemID.Value, BinaryOperatorType.Equal), new BinaryOperator(LocationInventoryByLot.Fields.LocationInventoryLot, lot, BinaryOperatorType.Equal), new BinaryOperator(LocationInventoryByLot.Fields.LPNNumber, LPNNumber.Value, BinaryOperatorType.Equal)))));
                    }
                    else
                    {
                        LocationInventoryByLot quantity = session.FindObject <LocationInventoryByLot>(new GroupOperator(new BinaryOperator(LocationInventoryByLot.Fields.LocationInventoryItem.ItemID, itemID.Value, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventoryByLot.Fields.Location.Oid.PropertyName, locationID, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventoryByLot.Fields.LocationInventoryLot, lot, BinaryOperatorType.Equal) & new BinaryOperator(LocationInventoryByLot.Fields.LPNNumber, LPNNumber.Value, BinaryOperatorType.Equal)));
                        //Dim item As Items = Session.DefaultSession.GetObjectByKey(Of Items)(itemID, True)
                        //Return item.s ngQuantityOnHand
                        return(quantity.QuantityOnHand);
                    }
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }