コード例 #1
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);
        }
コード例 #2
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;
            }
        }