Esempio n. 1
0
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified
        /// along with the details of the child table.
        /// </summary>
        ///
        /// <param name="pk" type="INVProductStockPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class INVProductStockBatchCollection</returns>
        public INVProductStockBatchCollection SelectAllByForeignKeyProductStockID(INVProductStockPrimaryKey pk)
        {
            INVProductStockBatchCollection iNVProductStockBatchCollection = new INVProductStockBatchCollection();

            foreach (POS.DataLayer.INVProductStockBatch _iNVProductStockBatch in POS.DataLayer.INVProductStockBatchBase.SelectAllByForeignKeyProductStockID(new POS.DataLayer.INVProductStockPrimaryKey(pk.ProductStockID)))
            {
                _iNVProductStockBatchWCF = new INVProductStockBatch();
                _iNVProductStockBatchWCF.ProductStockBatchID = _iNVProductStockBatch.ProductStockBatchID;
                _iNVProductStockBatchWCF.ProductStockID      = _iNVProductStockBatch.ProductStockID;
                _iNVProductStockBatchWCF.BatchID             = _iNVProductStockBatch.BatchID;
                _iNVProductStockBatchWCF.Qty = _iNVProductStockBatch.Qty;

                iNVProductStockBatchCollection.Add(_iNVProductStockBatchWCF);
            }
            return(iNVProductStockBatchCollection);
        }
Esempio n. 2
0
        /// <summary>
        /// This method will return an object representing the record matching the primary key information specified.
        /// </summary>
        ///
        /// <param name="pk" type="INVProductStockPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class INVProductStock</returns>
        public INVProductStock SelectOne(INVProductStockPrimaryKey pk)
        {
            _iNVProductStockWCF = new INVProductStock();
            _iNVProductStock    = POS.DataLayer.INVProductStockBase.SelectOne(new POS.DataLayer.INVProductStockPrimaryKey(pk.ProductStockID));

            _iNVProductStockWCF.ProductStockID = _iNVProductStock.ProductStockID;
            _iNVProductStockWCF.ProductID      = _iNVProductStock.ProductID;
            _iNVProductStockWCF.TotalQty       = _iNVProductStock.TotalQty;
            _iNVProductStockWCF.StockTypeID    = _iNVProductStock.StockTypeID;
            _iNVProductStockWCF.OpeningQty     = _iNVProductStock.OpeningQty;
            _iNVProductStockWCF.OpennigDate    = _iNVProductStock.OpennigDate;
            _iNVProductStockWCF.CreateDate     = _iNVProductStock.CreateDate;
            _iNVProductStockWCF.CreatedBy      = _iNVProductStock.CreatedBy;
            _iNVProductStockWCF.UpdateDate     = _iNVProductStock.UpdateDate;
            _iNVProductStockWCF.UpdatedBy      = _iNVProductStock.UpdatedBy;

            return(_iNVProductStockWCF);
        }
Esempio n. 3
0
        new private bool Validate()
        {
            bool isValid = false;
            bool isValidProduct = false;
            int ProductID=0;
            int InvProductID=0;
            int? oldStockTypeId = dgrid_stock.SelectedRows.Count > 0 ? int.Parse(dgrid_stock.SelectedRows[0].Cells["col_StockTypeID"].Value.ToString()) : 0;
            string BatchID = dgrid_batches.SelectedRows.Count > 0 ? dgrid_batches.SelectedRows[0].Cells["col_batch"].Value.ToString() : "";
            DateTime? ExpiryDate = dgrid_batches.SelectedRows.Count > 0 ? Convert.ToDateTime(dgrid_batches.SelectedRows[0].Cells["col_expiry"].Value.ToString()) : (DateTime?)null;
            decimal oldQty = dgrid_batches.SelectedRows.Count > 0 ? Convert.ToDecimal(dgrid_batches.SelectedRows[0].Cells["col_batchQty"].Value.ToString()) : dgrid_stock.SelectedRows.Count>0? Convert.ToDecimal(dgrid_stock.SelectedRows[0].Cells["col_qty"].Value.ToString()):0;
            int AdjustReasonID = 0;
            int StockTypeID = 0;
            int InventoryID = 0;
            decimal Qty = num_Qty.Value;
            if (dgrid_stock.SelectedRows.Count > 0)
                int.TryParse(dgrid_stock.SelectedRows[0].Cells["col_invProductStock"].Value.ToString(), out InvProductID);
            if (cbx_AdjustReason.SelectedValue != null)
                int.TryParse(cbx_AdjustReason.SelectedValue.ToString(), out AdjustReasonID);
            if (cbx_StockTypeTO.SelectedValue != null)
                int.TryParse(cbx_StockTypeTO.SelectedValue.ToString(), out StockTypeID);
            if (cbx_Store.SelectedValue != null)
                int.TryParse(cbx_Store.SelectedValue.ToString(), out InventoryID);

            if (InvProductID > 0)
            {
                isValidProduct = true;

                INVProductStockPrimaryKey ispk = new INVProductStockPrimaryKey();
                ispk.ProductStockID = InvProductID;
                var invPS = _invProductStockWrapper.SelectOne(ispk);
                ProductID = invPS.ProductID.Value;
                BDProductPrimaryKey pk = new BDProductPrimaryKey();
                pk.ProductID = invPS.ProductID;
                if (_ProductWrapper.SelectOne(pk).IsAcceptBatch == true)
                    isValidProduct = (!string.IsNullOrEmpty(BatchID) && ExpiryDate.HasValue);
            }

            if (!isValidProduct || AdjustReasonID == 0 || StockTypeID == 0 || InventoryID == 0 || Qty == 0 || Qty > oldQty || oldStockTypeId == StockTypeID)
                isValid= false;
            else
            {

                isValid = true;

                if (_isEdit)
                {
                    INVAdjustStock _EditNewAdjustStock = _adjustStock;
                    _EditNewAdjustStock.Qty *= -1;
                    _adjustStockCollection.Add(_EditNewAdjustStock);
                    INVAdjustStock _EditOldAdjustStock = _adjustStock;
                    _adjustStock.StockTypeID = _adjustStock.OldStockTypeID;
                    _adjustStockCollection.Add(_EditOldAdjustStock);
                }
                _adjustStock.ProductID = ProductID;
                _adjustStock.AdjustReasonID = AdjustReasonID;
                _adjustStock.AdjustStockID = _adjustStockID;
                _adjustStock.BatchID = null;
                _adjustStock.InventoryID = InventoryID;
                _adjustStock.StockTypeID = StockTypeID;
                _adjustStock.OldStockTypeID = oldStockTypeId;
                _adjustStock.Qty = Qty;
                _adjustStock.BatchNumber = BatchID;
                _adjustStock.ExpiryDate = ExpiryDate;
                if (_isEdit)
                {
                    _adjustStock.UpdateDate = DateTime.Now;
                    _adjustStock.UpdatedBy = GlobalVariables.CurrentUser.UserID;
                }
                else
                {
                    _adjustStock.CredateDate = DateTime.Now;
                    _adjustStock.CreatedBy = GlobalVariables.CurrentUser.UserID;
                }

                _adjustStockCollection.Add(_adjustStock);
                INVAdjustStock _oldAdjustStock = new INVAdjustStock();
                _oldAdjustStock.ProductID = ProductID;
                _oldAdjustStock.AdjustReasonID = AdjustReasonID;
                _oldAdjustStock.AdjustStockID = _adjustStockID;
                _oldAdjustStock.BatchID = null;
                _oldAdjustStock.InventoryID = InventoryID;
                _oldAdjustStock.StockTypeID = oldStockTypeId;
                _oldAdjustStock.Qty = (-1 * Qty);
                _oldAdjustStock.BatchNumber = BatchID;
                _oldAdjustStock.ExpiryDate = ExpiryDate;
                if (_isEdit)
                {
                    _oldAdjustStock.UpdateDate = DateTime.Now;
                    _oldAdjustStock.UpdatedBy = GlobalVariables.CurrentUser.UserID;
                }
                else
                {
                    _oldAdjustStock.CredateDate = DateTime.Now;
                    _oldAdjustStock.CreatedBy = GlobalVariables.CurrentUser.UserID;
                }

                _adjustStockCollection.Add(_oldAdjustStock);
            }
            return isValid;
        }
Esempio n. 4
0
 ///<summary>
 ///This method will Delete the object from the database
 ///</summary>
 ///<param name="pk" type="INVProductStockPrimaryKey">Primary Key information based on which data is to be fetched.</param>
 /// <returns>True if succeeded</returns>
 public bool Delete(INVProductStockPrimaryKey pk)
 {
     return(POS.DataLayer.INVProductStockBase.Delete(new POS.DataLayer.INVProductStockPrimaryKey(pk.ProductStockID)));
 }
Esempio n. 5
0
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified
        /// along with the details of the child table.
        /// </summary>
        ///
        /// <param name="pk" type="INVProductStockPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        /// <param name="pageSize" type="int">Number of records returned.</param>
        /// <param name="skipPages" type="int">The number of missing pages.</param>
        /// <param name="orderByStatement" type="string">The field value to number.</param>
        ///
        /// <returns>object of class INVProductStockBatchCollection</returns>
        public INVProductStockBatchCollection SelectAllByForeignKeyProductStockIDPaged(INVProductStockPrimaryKey pk, int pageSize, int skipPages, string orderByStatement)
        {
            INVProductStockBatchCollection iNVProductStockBatchCollection = new INVProductStockBatchCollection();

            foreach (POS.DataLayer.INVProductStockBatch _iNVProductStockBatch in POS.DataLayer.INVProductStockBatchBase.SelectAllByForeignKeyProductStockIDPaged(new POS.DataLayer.INVProductStockPrimaryKey(pk.ProductStockID), pageSize, skipPages, orderByStatement))
            {
                _iNVProductStockBatchWCF = new INVProductStockBatch();
                _iNVProductStockBatchWCF.ProductStockBatchID = _iNVProductStockBatch.ProductStockBatchID;
                _iNVProductStockBatchWCF.ProductStockID      = _iNVProductStockBatch.ProductStockID;
                _iNVProductStockBatchWCF.BatchID             = _iNVProductStockBatch.BatchID;
                _iNVProductStockBatchWCF.Qty = _iNVProductStockBatch.Qty;

                iNVProductStockBatchCollection.Add(_iNVProductStockBatchWCF);
            }
            return(iNVProductStockBatchCollection);
        }
Esempio n. 6
0
 /// <summary>
 /// This method will delete row(s) from the database using the value of the field specified
 /// along with the details of the child table.
 /// </summary>
 ///
 /// <param name="pk" type="INVProductStockPrimaryKey">Primary Key information based on which data is to be deleted.</param>
 ///
 /// <returns>True if succeeded</returns>
 public bool DeleteAllByForeignKeyProductStockID(INVProductStockPrimaryKey pk)
 {
     return(POS.DataLayer.INVProductStockBatchBase.DeleteAllByForeignKeyProductStockID(new POS.DataLayer.INVProductStockPrimaryKey(pk.ProductStockID)));
 }