Example #1
0
 public ReceiptModule()
 {
     this.CurrentModuleName     = "Receipt";
     CurrentModuleEntity        = new ReceiptEntities();
     CurrentModuleEntity.Module = this;
     InitializeModule();
 }
Example #2
0
        public void ChangeReceiptProductLotNo()
        {
            DialogResult rs = MessageBox.Show("Bạn có muốn thay đổi mã lô hàng cho toàn bộ sản phẩm không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (rs != DialogResult.Yes)
            {
                return;
            }

            ReceiptEntities      entity                = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptsInfo       mainobject            = (ICReceiptsInfo)CurrentModuleEntity.MainObject;
            ICProductsController objProductsController = new ICProductsController();
            ICProductsInfo       objProductsInfo       = new ICProductsInfo();

            entity.ReceiptItemsList.ForEach(o =>
            {
                objProductsInfo = (ICProductsInfo)objProductsController.GetObjectByID(o.FK_ICProductID);
                if (objProductsInfo == null)
                {
                    return;
                }

                if (objProductsInfo.ICPriceCalculationMethodType != PriceCalculationMethod.Specific)
                {
                    return;
                }

                o.ICReceiptItemStockLotNo = mainobject.ICReceiptProductLotNo;
            });
            entity.ReceiptItemsList.GridControl.RefreshDataSource();
        }
Example #3
0
        public override void InitGridControlDataSource()
        {
            ReceiptEntities entity = (ReceiptEntities)((BaseModuleERP)Screen.Module).CurrentModuleEntity;
            BindingSource   bds    = new BindingSource();

            bds.DataSource  = entity.ReceiptItemsList;
            this.DataSource = bds;
        }
Example #4
0
        public override void ActionComplete()
        {
            base.ActionComplete();
            ReceiptEntities entity     = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptsInfo  mainobject = (ICReceiptsInfo)CurrentModuleEntity.MainObject;

            mainobject.ICReceiptStatus = ReceiptStatus.Complete;
            entity.UpdateMainObject();
            ActionPosted();
        }
Example #5
0
        public void DeleteItemFromReceiptItemList()
        {
            if (Toolbar.IsNullOrNoneAction())
            {
                return;
            }

            ReceiptEntities entity = (ReceiptEntities)CurrentModuleEntity;

            entity.ReceiptItemsList.RemoveSelectedRowObjectFromList();
            entity.UpdateTotalAmount();
        }
Example #6
0
        public void ChangeCurrency(int currencyID)
        {
            ReceiptEntities entity     = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptsInfo  mainObject = (ICReceiptsInfo)entity.MainObject;

            mainObject.FK_GECurrencyID = currencyID;
            GECurrenciesInfo objCurrenciesInfo = VinaApp.CurrencyList.Where(o => o.GECurrencyID == currencyID).FirstOrDefault();

            mainObject.ICReceiptExchangeRate = objCurrenciesInfo == null ? 1 : objCurrenciesInfo.GECurrencyTransferRate;
            ChangeExchangeRate();
            entity.UpdateMainObjectBindingSource();
        }
Example #7
0
        public void ChangeTaxAmount()
        {
            ReceiptEntities entity     = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptsInfo  mainObject = (ICReceiptsInfo)entity.MainObject;

            if (mainObject.ICReceiptSubTotalAmount - mainObject.ICReceiptDiscountAmount != 0)
            {
                mainObject.ICReceiptTaxPercent = 100 * mainObject.ICReceiptTaxAmount / (mainObject.ICReceiptSubTotalAmount - mainObject.ICReceiptDiscountAmount);
            }
            else
            {
                mainObject.ICReceiptTaxPercent = 0;
            }
            mainObject.ICReceiptTaxPercent = Math.Round(mainObject.ICReceiptTaxPercent, 2, MidpointRounding.AwayFromZero);
            entity.UpdateTotalAmount();
        }
Example #8
0
        public void ChangeItemFromReceiptItemsList(ICReceiptItemsInfo objReceiptItemsInfo)
        {
            ReceiptEntities entity = (ReceiptEntities)CurrentModuleEntity;

            if (objReceiptItemsInfo == null)
            {
                return;
            }

            objReceiptItemsInfo.ICReceiptItemProductExchangeQty = objReceiptItemsInfo.ICReceiptItemProductQty * objReceiptItemsInfo.ICReceiptItemProductFactor;
            objReceiptItemsInfo.ICReceiptItemDiscountAmount     = (objReceiptItemsInfo.ICReceiptItemDiscountPercent / 100) * (objReceiptItemsInfo.ICReceiptItemProductExchangeQty * objReceiptItemsInfo.ICReceiptItemProductUnitPrice);
            objReceiptItemsInfo.ICReceiptItemTaxAmount          = (objReceiptItemsInfo.ICReceiptItemTaxPercent / 100) * (objReceiptItemsInfo.ICReceiptItemProductExchangeQty * objReceiptItemsInfo.ICReceiptItemProductUnitPrice - objReceiptItemsInfo.ICReceiptItemDiscountAmount);
            objReceiptItemsInfo.ICReceiptItemTotalAmount        = objReceiptItemsInfo.ICReceiptItemProductExchangeQty * objReceiptItemsInfo.ICReceiptItemProductUnitPrice - objReceiptItemsInfo.ICReceiptItemDiscountAmount + objReceiptItemsInfo.ICReceiptItemTaxAmount;
            entity.ReceiptItemsList.GridControl.RefreshDataSource();
            entity.UpdateTotalAmount();
        }
Example #9
0
        public void ChangeItemMeasureUnit()
        {
            ReceiptEntities    entity = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptItemsInfo objReceiptItemsInfo = entity.ReceiptItemsList[entity.ReceiptItemsList.CurrentIndex];

            if (objReceiptItemsInfo == null)
            {
                return;
            }

            ICProductMeasureUnitsController controller  = new ICProductMeasureUnitsController();
            ICProductMeasureUnitsInfo       measureUnit = controller.GetProductMeasureUnitByProductIDAndMeasureUnitID(objReceiptItemsInfo.FK_ICProductID, objReceiptItemsInfo.FK_ICMeasureUnitID);

            objReceiptItemsInfo.ICReceiptItemProductFactor      = measureUnit.ICProductMeasureUnitFactor;
            objReceiptItemsInfo.ICReceiptItemProductExchangeQty = objReceiptItemsInfo.ICReceiptItemProductQty * objReceiptItemsInfo.ICReceiptItemProductFactor;
            entity.ReceiptItemsList.GridControl.RefreshDataSource();
        }
Example #10
0
        public override int ActionSave()
        {
            ReceiptEntities entity     = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptsInfo  mainobject = (ICReceiptsInfo)CurrentModuleEntity.MainObject;

            entity.ReceiptItemsList.EndCurrentEdit();
            entity.UpdateTotalAmount();
            List <string> errorMessages = new List <string>();

            if (mainobject.FK_ICStockID == 0)
            {
                errorMessages.Add("Kho không được bỏ trống!");
            }
            if (mainobject.FK_GECurrencyID == 0 || mainobject.ICReceiptExchangeRate == 0)
            {
                errorMessages.Add("Vui lòng chọn loại tiền tề và tỷ giá!");
            }
            ICProductsController objProductsController = new ICProductsController();
            ICProductsInfo       objProductsInfo       = new ICProductsInfo();

            entity.ReceiptItemsList.ForEach(o =>
            {
                objProductsInfo = (ICProductsInfo)objProductsController.GetObjectByID(o.FK_ICProductID);
                if (objProductsInfo.ICPriceCalculationMethodType == PriceCalculationMethod.Specific && string.IsNullOrWhiteSpace(o.ICReceiptItemStockLotNo))
                {
                    errorMessages.Add("Vui lòng nhập mã lô cho sản phẩm: " + o.ICReceiptItemProductNo);
                }
            });
            if (errorMessages.Count() > 0)
            {
                GuiErrorMessage guiError = new GuiErrorMessage(errorMessages);
                guiError.Module = this;
                guiError.ShowDialog();
                return(0);
            }
            int iObjectID = base.ActionSave();

            if (iObjectID > 0)
            {
                this.ActionComplete();
            }
            return(iObjectID);
        }
Example #11
0
        public void AddItemToReceiptItemsList(int productID)
        {
            ReceiptEntities entity     = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptsInfo  mainobject = (ICReceiptsInfo)CurrentModuleEntity.MainObject;

            ICProductsController objProductsController = new ICProductsController();
            ICProductsInfo       objProductsInfo       = (ICProductsInfo)objProductsController.GetObjectByID(productID);

            if (objProductsInfo == null)
            {
                return;
            }

            ICReceiptItemsInfo objReceiptItemsInfo = objProductsInfo.ToReceiptItem();

            entity.ReceiptItemsList.Add(objReceiptItemsInfo);
            entity.ReceiptItemsList.GridControl.RefreshDataSource();
            entity.UpdateTotalAmount();
            entity.UpdateMainObjectBindingSource();
        }
Example #12
0
        public void ChangeItemDiscountAmount()
        {
            ReceiptEntities    entity = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptItemsInfo objReceiptItemsInfo = entity.ReceiptItemsList[entity.ReceiptItemsList.CurrentIndex];

            if (objReceiptItemsInfo == null)
            {
                return;
            }

            if (objReceiptItemsInfo.ICReceiptItemDiscountAmount != 0 && (objReceiptItemsInfo.ICReceiptItemProductExchangeQty * objReceiptItemsInfo.ICReceiptItemProductUnitPrice) != 0)
            {
                objReceiptItemsInfo.ICReceiptItemDiscountPercent = 100 * objReceiptItemsInfo.ICReceiptItemDiscountAmount / (objReceiptItemsInfo.ICReceiptItemProductExchangeQty * objReceiptItemsInfo.ICReceiptItemProductUnitPrice);
            }
            else
            {
                objReceiptItemsInfo.ICReceiptItemDiscountPercent = 0;
            }
            objReceiptItemsInfo.ICReceiptItemDiscountPercent = Math.Round(objReceiptItemsInfo.ICReceiptItemDiscountPercent, 2, MidpointRounding.AwayFromZero);
            entity.ReceiptItemsList.GridControl.RefreshDataSource();
        }
Example #13
0
        public void ChangeExchangeRate()
        {
            ReceiptEntities entity     = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptsInfo  mainObject = (ICReceiptsInfo)entity.MainObject;

            entity.ReceiptItemsList.ForEach(o =>
            {
                if (mainObject.ICReceiptExchangeRate != 0)
                {
                    o.ICReceiptItemProductUnitPrice = o.ICReceiptItemProductBasicPrice / mainObject.ICReceiptExchangeRate;
                }
                else
                {
                    o.ICReceiptItemProductUnitPrice = 0;
                }

                ChangeItemFromReceiptItemsList(o);
            });
            entity.ReceiptItemsList.GridControl.RefreshDataSource();
            entity.UpdateTotalAmount();
        }
Example #14
0
        public void ChangeStock(int stockID)
        {
            ReceiptEntities entity     = (ReceiptEntities)CurrentModuleEntity;
            ICReceiptsInfo  mainobject = (ICReceiptsInfo)CurrentModuleEntity.MainObject;

            mainobject.FK_ICStockID = stockID;
            entity.UpdateMainObjectBindingSource();
            DialogResult rs = MessageBox.Show("Bạn có muốn thay đổi kho cho toàn bộ sản phẩm không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (rs != DialogResult.Yes)
            {
                return;
            }

            entity.ReceiptItemsList.ForEach(o =>
            {
                o.FK_ICStockID            = stockID;
                o.ICReceiptItemStockLotNo = string.Empty;
            });

            entity.ReceiptItemsList.GridControl.RefreshDataSource();
        }
Example #15
0
        protected override void GridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            base.GridView_CellValueChanged(sender, e);
            ReceiptEntities entity = (ReceiptEntities)(this.Screen.Module as BaseModuleERP).CurrentModuleEntity;

            if (entity.ReceiptItemsList.CurrentIndex >= 0)
            {
                GridView           gridView = (GridView)sender;
                ICReceiptItemsInfo item     = (ICReceiptItemsInfo)gridView.GetRow(gridView.FocusedRowHandle);
                if (e.Column.FieldName == "FK_ICMeasureUnitID")
                {
                    ((ReceiptModule)Screen.Module).ChangeItemMeasureUnit();
                }
                else if (e.Column.FieldName == "ICReceiptItemDiscountAmount")
                {
                    ((ReceiptModule)Screen.Module).ChangeItemDiscountAmount();
                }
                else if (e.Column.FieldName == "ICReceiptItemTaxAmount")
                {
                    ((ReceiptModule)Screen.Module).ChangeItemTaxAmount();
                }
                ((ReceiptModule)Screen.Module).ChangeItemFromReceiptItemsList(item);
            }
        }
Example #16
0
        public void ChangeTaxPercent()
        {
            ReceiptEntities entity = (ReceiptEntities)CurrentModuleEntity;

            entity.UpdateTotalAmount();
        }