예제 #1
0
 private void BulkEntryChanged()
 {
     //INSTANT C# TODO TASK: The following 'On Error GoTo' statement cannot be converted by Instant C#:
     //On Error GoTo Err
     try
     {
         if (((int.Parse(QtyTextEdit.Text) > 0 && int.Parse(QtyPerPltTextEdit.Text) > 0) || int.Parse(QtyTextEdit.Text) == 0) && LotCodeValidator.ValidateByItemID(Convert.ToInt32(itemLookUpEdit.EditValue), LotTextEdit.Text, true))
         {
             AddLPN_SimpleButton.Enabled  = true;
             AddToLPNSimpleButton.Enabled = int.Parse(QtyTextEdit.Text) <= int.Parse(QtyPerPltTextEdit.Text) && Convert.ToInt32(itemLookUpEdit.EditValue) == m_lastItem;
         }
         else
         {
             //Err:
             AddLPN_SimpleButton.Enabled  = false;
             AddToLPNSimpleButton.Enabled = false;
         }
     }
     catch
     {
         AddLPN_SimpleButton.Enabled  = false;
         AddToLPNSimpleButton.Enabled = false;
     }
 }
예제 #2
0
        public bool ValidateRecord()
        {
            if (itemLookUpEdit.EditValue == null || (itemLookUpEdit.EditValue == null ? null : Convert.ToString(itemLookUpEdit.EditValue)) == itemLookUpEdit.Properties.NullText)
            {
                MessageBox.Show("You must select a Item Code.");
                itemLookUpEdit.Focus();
                return(false);
            }

            if (string.IsNullOrEmpty(newQtyTextEdit.Text) && string.IsNullOrEmpty(newLotTextEdit.Text))
            {
                MessageBox.Show("You must enter a new quantity or lot.");
                newQtyTextEdit.Focus();
                return(false);
            }
            else if (!string.IsNullOrEmpty(newQtyTextEdit.Text) && !string.IsNullOrEmpty(newLotTextEdit.Text))
            {
                if (saveSimpleButton.Tag != null && newQtyTextEdit.Text == "0")
                {
                    newQtyTextEdit.Text = null;
                }
                else
                {
                    MessageBox.Show("You cant update quantity and lot at once.");
                    newQtyTextEdit.Focus();
                    return(false);
                }
            }

            if (originalLotLookUpEdit.EditValue == null && lpnLookUpEdit.EditValue != null)
            {
                MessageBox.Show("You must select a Lot.");
                originalLotLookUpEdit.Focus();
                return(false);
            }

            if (!string.IsNullOrEmpty(newLotTextEdit.Text) && LotCodeValidator.ValidateByItemID(Convert.ToInt32(itemLookUpEdit.GetColumnValue("ItemID")), newLotTextEdit.Text, true) == false)
            {
                MessageBox.Show("Lot code invalid.");
                newLotTextEdit.Focus();
                return(false);
            }

            if (string.IsNullOrEmpty(Convert.ToString(reasonMemoExEdit.EditValue)) == true)
            {
                if (MessageBox.Show(string.Format("The reason field is empty. {0} Do you want to save the record.", Environment.NewLine), "Save Adjustment", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
                {
                    return(false);
                }
                else
                {
                }
            }

            if (locationLookUpEdit.EditValue == null || (locationLookUpEdit.EditValue == null ? null : Convert.ToString(locationLookUpEdit.EditValue)) == locationLookUpEdit.Properties.NullText)
            {
                MessageBox.Show("You must select a Location.");
                locationLookUpEdit.Focus();
                return(false);
            }

            if (saveSimpleButton.Tag == null)
            {
                if (m_AllowAdd == true)
                {
                    saveSimpleButton.Tag = InventoryAdjustmentBLL.GetNewInventoryAdjustmentID();
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #3
0
        private bool ValidateAvailabilityByLine(int i, Dictionary <int, double> totalTransferQuantity)
        {
            double stock            = 0;
            double lotStock         = 0;
            int    transferQuantity = 0;
            Items  item             = null;
            string lot       = null;
            int    LPNNumber = 0;

            lot       = (transferDetailsGridView.GetRowCellValue(i, colTransferLot) == null ? null : Convert.ToString(transferDetailsGridView.GetRowCellValue(i, colTransferLot)));
            item      = Session.DefaultSession.GetObjectByKey <Items>(Convert.ToInt32(transferDetailsGridView.GetRowCellValue(i, transferItemGridColumn)), true);
            LPNNumber = Convert.ToInt32(transferDetailsGridView.GetRowCellValue(i, fullLpnNumberGridColumn));
            if (LPNNumber == 0)
            {
                MessageBox.Show("LPN Number is invalid", "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }

            try
            {
                if (!LotCodeValidator.ValidateByItem(item, lot, false))
                {
                    throw new ApplicationException("Item " + item.ItemCode + " & lot # " + lot + " is invalid" + Environment.NewLine + "You must provide a valid lot.");
                }
            }
            catch (ApplicationException ex)
            {
                MessageBox.Show(ex.Message, "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }

            stock = ItemsBLL.GetQtyOnHandByID(m_TransfersSession, Convert.ToInt32(transferDetailsGridView.GetRowCellValue(i, transferItemGridColumn)), Convert.ToInt32(fromLocationLookUpEdit.EditValue));

            lotStock = ItemsBLL.GetQtyOnHandByIDAndLot(m_TransfersSession, Convert.ToInt32(transferDetailsGridView.GetRowCellValue(i, transferItemGridColumn)), Convert.ToInt32(fromLocationLookUpEdit.EditValue), lot, LPNNumber);

            if (m_TransfersSession.IsNewObject(transferDetailsGridView.GetRow(i)) == false && ((LocationTransferDetails)transferDetailsGridView.GetRow(i)).HasChanges == false)
            {
                return(true);
            }
            else if (m_TransfersSession.IsNewObject(transferDetailsGridView.GetRow(i)) == false)
            {
                transferQuantity = Convert.ToInt32(transferDetailsGridView.GetRowCellValue(i, colTransferQuantity)) - Session.DefaultSession.GetObjectByKey <LocationTransferDetails>(transferDetailsGridView.GetRowCellValue(i, colOid), true).TransferQuantity;
            }
            else
            {
                transferQuantity = Convert.ToInt32(transferDetailsGridView.GetRowCellValue(i, colTransferQuantity));
            }

            if (stock < transferQuantity)
            {
                MessageBox.Show($"{item.ItemCode} does only have {stock} in stock and your shipping {transferQuantity}.{Environment.NewLine}You must enter first the production.", "Stock Verification", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }

            if (lotStock < transferQuantity)
            {
                MessageBox.Show($"{item.ItemCode} lot# {lot} LPN# {LPNNumber} does only have {lotStock} in stock and your shipping {transferQuantity}.{Environment.NewLine}You must enter first the production.", "Stock Verification", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }

            if (totalTransferQuantity.ContainsKey(Convert.ToInt32(transferDetailsGridView.GetRowCellValue(i, transferItemGridColumn))))
            {
                totalTransferQuantity[Convert.ToInt32(transferDetailsGridView.GetRowCellValue(i, transferItemGridColumn))] += transferQuantity;
            }
            else
            {
                totalTransferQuantity.Add(Convert.ToInt32(transferDetailsGridView.GetRowCellValue(i, transferItemGridColumn)), transferQuantity);
            }

            return(true);
        }
예제 #4
0
        public int UpdateReceivingDetails(Session session, int?detailID, int receivingID, int?itemID, string lot, int?quantity, int?units, int?LPN, DateTime?expirationDate)
        {
            if (!itemID.HasValue)
            {
                throw new ApplicationException("You must provide receiving item.");
            }

            if (!quantity.HasValue || !units.HasValue)
            {
                throw new ApplicationException("You must provide the amount of quamtity\\units received.");
            }

            if (LPN == null)
            {
                throw new ApplicationException("LPN is blank.");
            }

            Items item = session.GetObjectByKey <Items>(itemID.Value, true);

            if (!LotCodeValidator.ValidateByItem(item, lot, true))
            {
                throw new ApplicationException("Item " + item.ItemCode + " & lot # " + lot + " is invalid" + Environment.NewLine + "You must provide a valid lot.");
            }


            ReceivingDetail detail = session.GetObjectByKey <ReceivingDetail>(detailID);

            if (detail == null)
            {
                //It is a new Detail
                return(InsertDetails(session, receivingID, item, lot, quantity, units, LPN, expirationDate));
            }

            bool itemChanged = false;

            ReceivingDetail originalDetail = null;
            Cloner          cloner         = new Cloner();

            originalDetail = (ReceivingDetail)cloner.CloneTo(detail, typeof(ReceivingDetail));

            if (itemID.HasValue && originalDetail.ReceivDetItemID.ItemID != itemID)
            {
                itemChanged = true;
            }

            detail.ReceivDetItemID = item;
            detail.intUnits        = units.Value;
            detail.ReceivDetQty    = quantity.Value;
            detail.ExpirationDate  = expirationDate;
            detail.ReceivDetLPN    = LPN;
            detail.ReceivDetLot    = lot;


            if (!(originalDetail == null))
            {
                UpdateAuditTrail(detail, originalDetail);
            }

            session.Save(detail);

            if (!detail.Equals(originalDetail))
            {
                ItemsBLL items      = new ItemsBLL();
                int      locationID = session.GetObjectByKey <Receiving>(receivingID).ReceivingLocation.Oid;
                items.UpdateStock(session, originalDetail.ReceivDetItemID.ItemID, null, originalDetail.ReceivDetQty * -1, false, locationID, originalDetail.ReceivDetLot, LPN);

                items.UpdateStock(session, itemID.Value, quantity.Value, false, locationID, lot, LPN, expirationDate);
            }

            return(detail.ReceivDetID);
        }
예제 #5
0
        private void transferDetailsGridView_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            Items  item      = null;
            string lot       = null;
            int    LPNNumber = 0;

            item = Session.DefaultSession.GetObjectByKey <Items>(Convert.ToInt32(transferDetailsGridView.GetFocusedRowCellValue(transferItemGridColumn)), true);
            lot  = (transferDetailsGridView.GetFocusedRowCellValue(colTransferLot) == null ? null : Convert.ToString(transferDetailsGridView.GetFocusedRowCellValue(colTransferLot)));

            LPNNumber = Convert.ToInt32(transferDetailsGridView.GetFocusedRowCellValue(fullLpnNumberGridColumn));
            if (LPNNumber == 0)
            {
                MessageBox.Show("LPN Number is invalid", "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                e.Valid          = false;
                m_CanSaveDetails = false;
                return;
            }

            try
            {
                if (!LotCodeValidator.ValidateByItem(item, lot, false))
                {
                    throw new ApplicationException("Item " + item.ItemCode + " & lot # " + lot + " is invalid" + Environment.NewLine + "You must provide a valid lot.");
                }
            }
            catch (ApplicationException ex)
            {
                MessageBox.Show(ex.Message, "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                e.Valid          = false;
                m_CanSaveDetails = false;
                return;
            }

            double stock    = Convert.ToDouble(((ViewRecord)itemRepositoryItemLookUpEdit.GetDataSourceRowByKeyValue(transferDetailsGridView.GetFocusedRowCellValue(transferItemGridColumn)))[2]); //QuantityOnHand
            double lotStock = ItemsBLL.GetQtyOnHandByIDAndLot(m_TransfersSession, item.ItemID, Convert.ToInt32(fromLocationLookUpEdit.EditValue), lot, LPNNumber);

            double transferingQuantity = 0;

            if (Convert.ToInt32(transferDetailsGridView.GetRowCellValue(e.RowHandle, colOid)) < 1)
            {
                transferingQuantity = Convert.ToDouble(transferDetailsGridView.GetRowCellValue(e.RowHandle, colTransferQuantity));
            }
            else
            {
                transferingQuantity = Convert.ToDouble(transferDetailsGridView.GetRowCellValue(e.RowHandle, colTransferQuantity)) - Session.DefaultSession.GetObjectByKey <LocationTransferDetails>(transferDetailsGridView.GetRowCellValue(e.RowHandle, colOid), true).TransferQuantity;
            }

            if (stock < transferingQuantity)
            {
                MessageBox.Show(string.Format("{0} does only have {1} in stock and your transfering {2}.", transferDetailsGridView.GetRowCellDisplayText(e.RowHandle, transferItemGridColumn).ToString(), stock.ToString(), transferingQuantity.ToString()), "Stock Verification", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                e.Valid          = false;
                m_CanSaveDetails = false;
            }
            else if (lotStock < transferingQuantity)
            {
                MessageBox.Show($"{item.ItemCode} lot# {lot} LPN# {LPNNumber} does only have {lotStock} in stock and your transfering {transferingQuantity}.", "Stock Verification", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                e.Valid          = false;
                m_CanSaveDetails = false;
            }
            else
            {
                m_CanSaveDetails = true;
            }
        }