/// <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="BDProductPrimaryKey">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 PURPurchaseLineCollection</returns>
        public PURPurchaseLineCollection SelectAllByForeignKeyProductIDPaged(BDProductPrimaryKey pk, int pageSize, int skipPages, string orderByStatement)
        {
            PURPurchaseLineCollection pURPurchaseLineCollection = new PURPurchaseLineCollection();

            foreach (POS.DataLayer.PURPurchaseLine _pURPurchaseLine in POS.DataLayer.PURPurchaseLineBase.SelectAllByForeignKeyProductIDPaged(new POS.DataLayer.BDProductPrimaryKey(pk.ProductID), pageSize, skipPages, orderByStatement))
            {
                _pURPurchaseLineWCF = new PURPurchaseLine();
                _pURPurchaseLineWCF.PurchaseLineID   = _pURPurchaseLine.PurchaseLineID;
                _pURPurchaseLineWCF.PurchaseHeaderID = _pURPurchaseLine.PurchaseHeaderID;
                _pURPurchaseLineWCF.ProductID        = _pURPurchaseLine.ProductID;
                _pURPurchaseLineWCF.TotalQty         = _pURPurchaseLine.TotalQty;
                _pURPurchaseLineWCF.BonusQty         = _pURPurchaseLine.BonusQty;
                _pURPurchaseLineWCF.DiscountRatio    = _pURPurchaseLine.DiscountRatio;
                _pURPurchaseLineWCF.DiscountAmount   = _pURPurchaseLine.DiscountAmount;
                _pURPurchaseLineWCF.Unitprice        = _pURPurchaseLine.Unitprice;
                _pURPurchaseLineWCF.CreatedDate      = _pURPurchaseLine.CreatedDate;
                _pURPurchaseLineWCF.CreatedBy        = _pURPurchaseLine.CreatedBy;
                _pURPurchaseLineWCF.UpdateDate       = _pURPurchaseLine.UpdateDate;
                _pURPurchaseLineWCF.UpdatedBy        = _pURPurchaseLine.UpdatedBy;
                _pURPurchaseLineWCF.IsDeleted        = _pURPurchaseLine.IsDeleted;
                _pURPurchaseLineWCF.DeleteDate       = _pURPurchaseLine.DeleteDate;
                _pURPurchaseLineWCF.DeletedBy        = _pURPurchaseLine.DeletedBy;

                pURPurchaseLineCollection.Add(_pURPurchaseLineWCF);
            }
            return(pURPurchaseLineCollection);
        }
Example #2
0
 private void initEntity(int productId)
 {
     try
     {
         BDProductPrimaryKey pk = new BDProductPrimaryKey();
         pk.ProductID = productId;
         _bdProduct = _bdProductWrapper.SelectOne(pk);
         loadUI();
     }
     catch (Exception ex)
     {
         MessageBox.Show("حدث خطأ برجاء تكرار العمليه مره اخرى واذا تكرر الخطا برجاءالاتصال بالشخص المصمم للبرنامج وارسال رسالة الخطا التى ستظهر بعد قليل له");
         MessageBox.Show(ex.Message);
     }
 }
Example #3
0
        /// <summary>
        /// This method will return an object representing the record matching the primary key information specified.
        /// </summary>
        ///
        /// <param name="pk" type="BDProductPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class BDProduct</returns>
        public BDProduct SelectOne(BDProductPrimaryKey pk)
        {
            _bDProductWCF = new BDProduct();
            _bDProduct    = POS.DataLayer.BDProductBase.SelectOne(new POS.DataLayer.BDProductPrimaryKey(pk.ProductID));

            _bDProductWCF.ProductID      = _bDProduct.ProductID;
            _bDProductWCF.ProductName    = _bDProduct.ProductName;
            _bDProductWCF.ProductGroupID = _bDProduct.ProductGroupID;
            _bDProductWCF.ProductCode    = _bDProduct.ProductCode;
            _bDProductWCF.IsAcceptBatch  = _bDProduct.IsAcceptBatch;
            _bDProductWCF.ProductPrice   = _bDProduct.ProductPrice;
            _bDProductWCF.IsFixedPrice   = _bDProduct.IsFixedPrice;
            _bDProductWCF.HasDiscount    = _bDProduct.HasDiscount;
            _bDProductWCF.DiscountAmount = _bDProduct.DiscountAmount;
            _bDProductWCF.DescountRatio  = _bDProduct.DescountRatio;
            _bDProductWCF.IsActive       = _bDProduct.IsActive;
            _bDProductWCF.Notes          = _bDProduct.Notes;

            return(_bDProductWCF);
        }
        /// <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="BDProductPrimaryKey">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 INVAdjustStockCollection</returns>
        public INVAdjustStockCollection SelectAllByForeignKeyProductIDPaged(BDProductPrimaryKey pk, int pageSize, int skipPages, string orderByStatement)
        {
            INVAdjustStockCollection iNVAdjustStockCollection = new INVAdjustStockCollection();

            foreach (POS.DataLayer.INVAdjustStock _iNVAdjustStock in POS.DataLayer.INVAdjustStockBase.SelectAllByForeignKeyProductIDPaged(new POS.DataLayer.BDProductPrimaryKey(pk.ProductID), pageSize, skipPages, orderByStatement))
            {
                _iNVAdjustStockWCF = new INVAdjustStock();
                _iNVAdjustStockWCF.AdjustStockID  = _iNVAdjustStock.AdjustStockID;
                _iNVAdjustStockWCF.ProductID      = _iNVAdjustStock.ProductID;
                _iNVAdjustStockWCF.BatchID        = _iNVAdjustStock.BatchID;
                _iNVAdjustStockWCF.Qty            = _iNVAdjustStock.Qty;
                _iNVAdjustStockWCF.AdjustReasonID = _iNVAdjustStock.AdjustReasonID;
                _iNVAdjustStockWCF.CreatedBy      = _iNVAdjustStock.CreatedBy;
                _iNVAdjustStockWCF.CredateDate    = _iNVAdjustStock.CredateDate;
                _iNVAdjustStockWCF.UpdatedBy      = _iNVAdjustStock.UpdatedBy;
                _iNVAdjustStockWCF.UpdateDate     = _iNVAdjustStock.UpdateDate;

                iNVAdjustStockCollection.Add(_iNVAdjustStockWCF);
            }
            return(iNVAdjustStockCollection);
        }
        /// <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="BDProductPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class INVAdjustStockCollection</returns>
        public INVAdjustStockCollection SelectAllByForeignKeyProductID(BDProductPrimaryKey pk)
        {
            INVAdjustStockCollection iNVAdjustStockCollection = new INVAdjustStockCollection();

            foreach (POS.DataLayer.INVAdjustStock _iNVAdjustStock in POS.DataLayer.INVAdjustStockBase.SelectAllByForeignKeyProductID(new POS.DataLayer.BDProductPrimaryKey(pk.ProductID)))
            {
                _iNVAdjustStockWCF = new INVAdjustStock();
                _iNVAdjustStockWCF.AdjustStockID  = _iNVAdjustStock.AdjustStockID;
                _iNVAdjustStockWCF.ProductID      = _iNVAdjustStock.ProductID;
                _iNVAdjustStockWCF.BatchID        = _iNVAdjustStock.BatchID;
                _iNVAdjustStockWCF.Qty            = _iNVAdjustStock.Qty;
                _iNVAdjustStockWCF.AdjustReasonID = _iNVAdjustStock.AdjustReasonID;
                _iNVAdjustStockWCF.CreatedBy      = _iNVAdjustStock.CreatedBy;
                _iNVAdjustStockWCF.CredateDate    = _iNVAdjustStock.CredateDate;
                _iNVAdjustStockWCF.UpdatedBy      = _iNVAdjustStock.UpdatedBy;
                _iNVAdjustStockWCF.UpdateDate     = _iNVAdjustStock.UpdateDate;

                iNVAdjustStockCollection.Add(_iNVAdjustStockWCF);
            }
            return(iNVAdjustStockCollection);
        }
Example #6
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;
        }
Example #7
0
 ///<summary>
 ///This method will Delete the object from the database
 ///</summary>
 ///<param name="pk" type="BDProductPrimaryKey">Primary Key information based on which data is to be fetched.</param>
 /// <returns>True if succeeded</returns>
 public bool Delete(BDProductPrimaryKey pk)
 {
     return(POS.DataLayer.BDProductBase.Delete(new POS.DataLayer.BDProductPrimaryKey(pk.ProductID)));
 }
Example #8
0
        private void dgrd_OrderLines_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1 && e.ColumnIndex == dgrd_OrderLines.Columns["ProductName"].Index)
            {
                BDProductPrimaryKey pk = new BDProductPrimaryKey();
                pk.ProductID = Convert.ToInt32(dgrd_OrderLines.Rows[e.RowIndex].Cells["ProductName"].Value);
                BDProduct _product = _productWrapper.SelectOne(pk);
                dgrd_OrderLines.Rows[e.RowIndex].Cells["IsAcceptBatch"].Value = _product.IsAcceptBatch;

                if (_product.IsAcceptBatch == true)
                {
                    dgrd_OrderLines.Rows[e.RowIndex].Cells["BatchNumber"].ReadOnly = false;
                    dgrd_OrderLines.Rows[e.RowIndex].Cells["ExpiryDate"].ReadOnly = false;
                }
                else
                {
                    dgrd_OrderLines.Rows[e.RowIndex].Cells["BatchNumber"].ReadOnly = true;
                    dgrd_OrderLines.Rows[e.RowIndex].Cells["ExpiryDate"].ReadOnly = true;
                }
            }

            if (e.RowIndex != -1 && e.ColumnIndex == dgrd_OrderLines.Columns["TotalQty"].Index
                || e.RowIndex != -1 && e.ColumnIndex == dgrd_OrderLines.Columns["PurchasePrice"].Index)
            {
                CalculateTotal();
            }
        }
        private void dgrd_ReturnOrderLines_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {

                var senderGrid = (DataGridView)sender;

                if (e.RowIndex != -1 && (e.ColumnIndex == senderGrid.Columns["TotalQty"].Index /*|| e.ColumnIndex == senderGrid.Columns["UnitPrice"].Index*/) && !string.IsNullOrEmpty(senderGrid.Rows[e.RowIndex].Cells["TotalQty"].Value.ToString()))
                {
                    if (Convert.ToInt32(senderGrid.Rows[e.RowIndex].Cells["ProductName"].Value) == -1)
                    {
                        MessageBox.Show("أختر صنف أولا");
                        return;
                    }
                    if (Convert.ToInt32(senderGrid.Rows[e.RowIndex].Cells["StockType"].Value) == -1)
                    {
                        MessageBox.Show("أختر نوع مرتجع أولا");
                        return;
                    }

                    VSALSalesOrder vSALSalesOrder = vSALSalesOrderCollection.Where(a => a.ProductID == Convert.ToInt32(senderGrid.Rows[e.RowIndex].Cells["ProductName"].Value)).SingleOrDefault();
                    if (Convert.ToInt32(senderGrid.Rows[e.RowIndex].Cells["TotalQty"].Value) > vSALSalesOrder.TotalQty)
                    {
                        MessageBox.Show("الكمية المرتجعه اكبر من الكميه المدخله فى الفاتوره الاصليه");
                        return;
                    }

                    if (senderGrid.Rows[e.RowIndex].Cells["UnitPrice"].Value != null && senderGrid.Rows[e.RowIndex].Cells["TotalQty"].Value != null)
                        tbx_Total.Text = (CalculateTotal(Convert.ToDouble(senderGrid.Rows[e.RowIndex].Cells["UnitPrice"].Value) * Convert.ToDouble(senderGrid.Rows[e.RowIndex].Cells["TotalQty"].Value))).ToString();
                    else
                        return;

                }

                if (e.RowIndex != -1 && e.ColumnIndex == senderGrid.Columns["ProductName"].Index)
                {
                    VSALSalesOrder vSALSalesOrder = vSALSalesOrderCollection.Where(a => a.ProductID == Convert.ToInt32(senderGrid.Rows[e.RowIndex].Cells["ProductName"].Value)).SingleOrDefault();
                    if (vSALSalesOrder == null)
                    {
                        MessageBox.Show("هذا الصنف غير موجود بالفاتورة الاصليه");
                        senderGrid.Rows[e.RowIndex].ErrorText = "هذا الصنف غير موجود بالفاتورة الاصليه";
                        //senderGrid.Rows[e.RowIndex].Cells["ProductName"].Value = null;
                        senderGrid.Rows[e.RowIndex].Cells["ProductName"].Style.BackColor = Color.Red;
                        return;
                    }

                    BDProductPrimaryKey pk = new BDProductPrimaryKey();
                    pk.ProductID = Convert.ToInt32(senderGrid.Rows[e.RowIndex].Cells["ProductName"].Value);

                    BDProduct _product = bDProductWrapper.SelectOne(pk);
                    senderGrid.Rows[e.RowIndex].Cells["IsAcceptBatch"].Value = _product.IsAcceptBatch;

                    if (_product.IsAcceptBatch == true)
                    {
                        senderGrid.Rows[e.RowIndex].Cells["BatchNumber"].ReadOnly = false;
                        senderGrid.Rows[e.RowIndex].Cells["ExpiryDate"].ReadOnly = false;
                    }
                    else
                    {
                        senderGrid.Rows[e.RowIndex].Cells["BatchNumber"].ReadOnly = true;
                        senderGrid.Rows[e.RowIndex].Cells["ExpiryDate"].ReadOnly = true;
                    }
                    senderGrid.Rows[e.RowIndex].Cells["UnitPrice"].Value = vSALSalesOrder.FinalPrice;
                }

                if (e.RowIndex != -1 && e.ColumnIndex == senderGrid.Columns["ExpiryDate"].Index)
                {
                    if (Convert.ToInt32(senderGrid.Rows[e.RowIndex].Cells["ProductName"].Value) == -1)
                    {
                        MessageBox.Show("أختر صنف أولا");
                        return;
                    }
                    DateTime result;
                    if (!DateTime.TryParse(senderGrid.Rows[e.RowIndex].Cells["ExpiryDate"].Value.ToString(), out result))
                    {
                        MessageBox.Show("صيغة تاريخ الصلاحية غير صحيحة لابد ان تكون (يوم -شهر -سنة)");
                        senderGrid.Rows[e.RowIndex].Cells["ExpiryDate"].Style.BackColor = Color.Red;
                        senderGrid.Rows[e.RowIndex].Cells["ExpiryDate"].Value = "";
                    }
                    else
                    {
                        senderGrid.Rows[e.RowIndex].Cells["ExpiryDate"].Style.BackColor = Color.White;
                    }
                }
            }
            catch (Exception ex)
            {

                MessageBox.Show("حدث خطأ برجاء تكرار العمليه مره اخرى واذا تكرر الخطا برجاءالاتصال بالشخص المصمم للبرنامج وارسال رسالة الخطا التى ستظهر بعد قليل له");
                MessageBox.Show(ex.Message);
            }
        }
 /// <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="BDProductPrimaryKey">Primary Key information based on which data is to be deleted.</param>
 ///
 /// <returns>True if succeeded</returns>
 public bool DeleteAllByForeignKeyProductID(BDProductPrimaryKey pk)
 {
     return(POS.DataLayer.PURPurchaseLineBase.DeleteAllByForeignKeyProductID(new POS.DataLayer.BDProductPrimaryKey(pk.ProductID)));
 }
 /// <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="BDProductPrimaryKey">Primary Key information based on which data is to be deleted.</param>
 ///
 /// <returns>True if succeeded</returns>
 public bool DeleteAllByForeignKeyProductID(BDProductPrimaryKey pk)
 {
     return(POS.DataLayer.INVAdjustStockBase.DeleteAllByForeignKeyProductID(new POS.DataLayer.BDProductPrimaryKey(pk.ProductID)));
 }
Example #12
0
 public override void btn_Delete_Click(object sender, EventArgs e)
 {
     int? productID = 0;
     if (dgrid_Result.Rows[dgrid_Result.SelectedCells[0].RowIndex].Cells["ProductID"].Value != null)
     {
         if (MessageBox.Show("هل نت متأكد من حذف الصنف؟", "تحذير", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             productID = Convert.ToInt32(dgrid_Result.Rows[dgrid_Result.SelectedCells[0].RowIndex].Cells["ProductID"].Value);
             BDProductPrimaryKey productPK = new BDProductPrimaryKey();
             productPK.ProductID = productID;
             _bdProductWrapper.Delete(productPK);
         }
         else
         {
             return;
         }
     }
     else
     {
         MessageBox.Show("لابد من اختيار الصنف");
     }
     InitiateGrid();
 }