public void SetDefaultShipmentName() { SaleOrderShipmentEntities entity = CurrentModuleEntity as SaleOrderShipmentEntities; ICShipmentsInfo mainObject = entity.MainObject as ICShipmentsInfo; if (!String.IsNullOrWhiteSpace(mainObject.ICShipmentName)) { return; } if (mainObject.FK_ARSaleOrderID == 0) { return; } ARSaleOrdersController objSaleOrdersController = new ARSaleOrdersController(); ARSaleOrdersInfo objSaleOrdersInfo = objSaleOrdersController.GetObjectByID(mainObject.FK_ARSaleOrderID) as ARSaleOrdersInfo; if (objSaleOrdersInfo == null) { return; } mainObject.ICShipmentName = string.Format("Chứng từ xuất kho của đơn bán hàng {0}", objSaleOrdersInfo.ARSaleOrderNo); }
public bool IsValidInventoryStock() { SaleOrderShipmentEntities entity = (SaleOrderShipmentEntities)CurrentModuleEntity; ICShipmentsInfo mainobject = (ICShipmentsInfo)CurrentModuleEntity.MainObject; List <ICShipmentItemsInfo> mergeList = MergeSaleOrderItemSameProduct(entity.ShipmentItemsList.Select(o => (ICShipmentItemsInfo)o.Clone()).ToList()); ICTransactionsController objTransactionsController = new ICTransactionsController(); decimal inventoryStockQty = 0; List <string> errorMessagesList = new List <string>(); mergeList.ForEach(o => { inventoryStockQty = objTransactionsController.GetAvailabilityQtyForShipment(o.FK_ICProductID, o.FK_ICStockID, o.ICShipmentItemStockLotNo, mainobject.ICShipmentDate); if (inventoryStockQty >= o.ICShipmentItemProductQty) { return; } errorMessagesList.Add(string.Format("Sản phẩm {0} không đủ tồn kho. Vui lòng kiểm tra lại!", o.ICShipmentItemProductNo)); }); if (errorMessagesList.Count() > 0) { GuiErrorMessage guiErrorMessage = new GuiErrorMessage(errorMessagesList); guiErrorMessage.Module = this; guiErrorMessage.ShowDialog(); return(false); } return(true); }
public void InitializeSaleOrderShipmentReport(ICSaleOrderShipment report) { SaleOrderShipmentEntities entity = CurrentModuleEntity as SaleOrderShipmentEntities; ICShipmentsInfo mainObject = entity.MainObject as ICShipmentsInfo; ICShipmentItemsController objShipmentItemsController = new ICShipmentItemsController(); List <ICShipmentItemsInfo> shipmentItemList = objShipmentItemsController.GetShipmentItemForReport(mainObject.ICShipmentID); report.bsICShipmentItems.DataSource = shipmentItemList; }
public void UpdateTotalAmount() { ICShipmentsInfo mainobject = (ICShipmentsInfo)MainObject; mainobject.ICShipmentSubTotalAmount = ShipmentItemsList.Sum(o => o.ICShipmentItemTotalAmount); mainobject.ICShipmentDiscountAmount = mainobject.ICShipmentSubTotalAmount * mainobject.ICShipmentDiscountPercent / 100; mainobject.ICShipmentTaxAmount = (mainobject.ICShipmentSubTotalAmount - mainobject.ICShipmentDiscountAmount) * mainobject.ICShipmentTaxPercent / 100; mainobject.ICShipmentTotalAmount = mainobject.ICShipmentSubTotalAmount - mainobject.ICShipmentDiscountAmount + mainobject.ICShipmentTaxAmount; UpdateMainObjectBindingSource(); }
public virtual void ActionUnPosted() { GLShipmentEntities entity = (GLShipmentEntities)CurrentModuleEntity; ICShipmentsInfo objShipmentsInfo = (ICShipmentsInfo)CurrentModuleEntity.MainObject; objShipmentsInfo.ICShipmentPostedStatus = PostedTransactionStatus.UnPosted.ToString(); entity.UpdateMainObject(); GLHelper.UnPostedTransactions(this.CurrentModuleName, objShipmentsInfo.ICShipmentID, ModulePostingType.Accounting, ModulePostingType.Stock, ModulePostingType.SaleOrder); InvalidateToolbar(); }
public void NewFromSaleOrder() { base.ActionNew(); SaleOrderShipmentEntities entity = CurrentModuleEntity as SaleOrderShipmentEntities; ICShipmentsInfo mainobject = entity.MainObject as ICShipmentsInfo; ARSaleOrderItemsController objSaleOrderItemsController = new ARSaleOrderItemsController(); List <ARSaleOrderItemsInfo> saleOrderItems = objSaleOrderItemsController.GetSaleOrderItemForSaleOrderShipment(); guiChooseSaleOrderItem guiFind = new guiChooseSaleOrderItem(saleOrderItems); guiFind.Module = this; DialogResult rs = guiFind.ShowDialog(); if (rs != DialogResult.OK) { ActionCancel(); return; } saleOrderItems = guiFind.SelectedObjects; ARSaleOrderItemsInfo objSaleOrderItemsInfo = saleOrderItems.FirstOrDefault(); if (objSaleOrderItemsInfo == null) { objSaleOrderItemsInfo = new ARSaleOrderItemsInfo(); } ARSaleOrdersController objSaleOrdersController = new ARSaleOrdersController(); ARSaleOrdersInfo objSaleOrdersInfo = (ARSaleOrdersInfo)objSaleOrdersController.GetObjectByID(objSaleOrderItemsInfo.FK_ARSaleOrderID); if (objSaleOrdersInfo == null) { objSaleOrdersInfo = new ARSaleOrdersInfo(); } mainobject.FK_ARSaleOrderID = objSaleOrdersInfo.ARSaleOrderID; mainobject.FK_ARCustomerID = objSaleOrdersInfo.FK_ARCustomerID; mainobject.ICShipmentDiscountPercent = objSaleOrdersInfo.ARSaleOrderDiscountPercent; mainobject.ICShipmentTaxPercent = objSaleOrdersInfo.ARSaleOrderTaxPercent; mainobject.FK_GECurrencyID = objSaleOrdersInfo.FK_GECurrencyID; mainobject.ICShipmentExchangeRate = objSaleOrdersInfo.ARSaleOrderExchangeRate; mainobject.ICShipmentDeliveryDate = objSaleOrdersInfo.ARSaleOrderDeliveryDate; List <ICShipmentItemsInfo> shipmentItemList = new List <ICShipmentItemsInfo>(); ICShipmentItemsInfo objShipmentItemsInfo = new ICShipmentItemsInfo(); saleOrderItems.ForEach(o => { objShipmentItemsInfo = new ICShipmentItemsInfo(); objShipmentItemsInfo = o.ToShipmentItem(); shipmentItemList.Add(objShipmentItemsInfo); }); entity.ShipmentItemsList.Invalidate(shipmentItemList); entity.UpdateMainObjectBindingSource(); entity.UpdateTotalAmount(); }
public override void SetDefaultMainObject() { base.SetDefaultMainObject(); ICShipmentsInfo mainobject = MainObject as ICShipmentsInfo; mainobject.ICShipmentDate = DateTime.Now; mainobject.ICShipmentDeliveryDate = DateTime.Now; mainobject.FK_HREmployeeID = VinaApp.CurrentUserInfo.FK_HREmployeeID; UpdateMainObjectBindingSource(); }
public void ChangeCurrency(int currencyID) { SaleOrderShipmentEntities entity = (SaleOrderShipmentEntities)CurrentModuleEntity; ICShipmentsInfo mainObject = (ICShipmentsInfo)entity.MainObject; mainObject.FK_GECurrencyID = currencyID; GECurrenciesInfo objCurrenciesInfo = VinaApp.CurrencyList.Where(o => o.GECurrencyID == currencyID).FirstOrDefault(); mainObject.ICShipmentExchangeRate = objCurrenciesInfo == null ? 1 : objCurrenciesInfo.GECurrencyTransferRate; ChangeExchangeRate(); entity.UpdateMainObjectBindingSource(); }
public override void ActionComplete() { base.ActionComplete(); SaleOrderShipmentEntities entity = (SaleOrderShipmentEntities)CurrentModuleEntity; ICShipmentsInfo mainobject = (ICShipmentsInfo)CurrentModuleEntity.MainObject; if (!IsValidInventoryStock()) { return; } mainobject.ICShipmentStatus = ShipmentStatus.Complete; entity.UpdateMainObject(); ActionPosted(); }
public void ChangeTaxAmount() { SaleOrderShipmentEntities entity = (SaleOrderShipmentEntities)CurrentModuleEntity; ICShipmentsInfo mainObject = (ICShipmentsInfo)entity.MainObject; if (mainObject.ICShipmentSubTotalAmount - mainObject.ICShipmentDiscountAmount != 0) { mainObject.ICShipmentTaxPercent = 100 * mainObject.ICShipmentTaxAmount / (mainObject.ICShipmentSubTotalAmount - mainObject.ICShipmentDiscountAmount); } else { mainObject.ICShipmentTaxPercent = 0; } mainObject.ICShipmentTaxPercent = Math.Round(mainObject.ICShipmentTaxPercent, 2, MidpointRounding.AwayFromZero); entity.UpdateTotalAmount(); }
public override void InvalidateToolbar() { SaleOrderShipmentEntities entity = CurrentModuleEntity as SaleOrderShipmentEntities; ICShipmentsInfo mainObject = entity.MainObject as ICShipmentsInfo; base.InvalidateToolbar(); if (mainObject.ICShipmentID > 0) { ParentScreen.SetEnableOfToolbarButton(BaseToolbar.ToolbarButtonEdit, mainObject.ICShipmentPostedStatus != PostedTransactionStatus.Posted.ToString()); if (mainObject.ICShipmentStatus == ShipmentStatus.Complete) { ParentScreen.SetEnableOfToolbarButton(BaseToolbar.ToolbarButtonEdit, false); ParentScreen.SetEnableOfToolbarButton(BaseToolbar.ToolbarButtonComplete, false); } } }
public override void InvalidateToolbar() { ICShipmentsInfo Shipment = (ICShipmentsInfo)CurrentModuleEntity.MainObject; if (Shipment.ICShipmentID > 0) { ParentScreen.SetEnableOfToolbarButton(ToolbarButtons.PostedTransactions, false); ParentScreen.SetEnableOfToolbarButton(ToolbarButtons.UnPostedTransactions, false); if (Shipment.ICShipmentStatus == ShipmentStatus.Complete.ToString()) { ParentScreen.SetEnableOfToolbarButton(ToolbarButtons.PostedTransactions, Shipment.ICShipmentPostedStatus != PostedTransactionStatus.Posted.ToString()); ParentScreen.SetEnableOfToolbarButton(ToolbarButtons.UnPostedTransactions, Shipment.ICShipmentPostedStatus == PostedTransactionStatus.Posted.ToString()); } } base.InvalidateToolbar(); }
public void ChangeExchangeRate() { SaleOrderShipmentEntities entity = (SaleOrderShipmentEntities)CurrentModuleEntity; ICShipmentsInfo mainObject = (ICShipmentsInfo)entity.MainObject; entity.ShipmentItemsList.ForEach(o => { if (mainObject.ICShipmentExchangeRate != 0) { o.ICShipmentItemProductUnitPrice = o.ICShipmentItemProductBasicPrice / mainObject.ICShipmentExchangeRate; } else { o.ICShipmentItemProductUnitPrice = 0; } ChangeItemFromShipmentItemsList(o); }); entity.ShipmentItemsList.GridControl.RefreshDataSource(); entity.UpdateTotalAmount(); }
public void ChangeStock(int stockID) { SaleOrderShipmentEntities entity = (SaleOrderShipmentEntities)CurrentModuleEntity; ICShipmentsInfo mainobject = (ICShipmentsInfo)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.ShipmentItemsList.ForEach(o => { o.FK_ICStockID = stockID; o.ICShipmentItemStockLotNo = string.Empty; }); entity.ShipmentItemsList.GridControl.RefreshDataSource(); }
public override int ActionSave() { SaleOrderShipmentEntities entity = CurrentModuleEntity as SaleOrderShipmentEntities; ICShipmentsInfo mainobject = entity.MainObject as ICShipmentsInfo; entity.ShipmentItemsList.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.ICShipmentExchangeRate == 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.ShipmentItemsList.ForEach(o => { objProductsInfo = (ICProductsInfo)objProductsController.GetObjectByID(o.FK_ICProductID); if (objProductsInfo.ICPriceCalculationMethodType == PriceCalculationMethod.Specific && string.IsNullOrWhiteSpace(o.ICShipmentItemStockLotNo)) { errorMessages.Add("Vui lòng nhập mã lô cho sản phẩm: " + o.ICShipmentItemProductNo); } }); if (errorMessages.Count() > 0) { GuiErrorMessage guiError = new GuiErrorMessage(errorMessages); guiError.Module = this; guiError.ShowDialog(); return(0); } SetDefaultShipmentName(); return(base.ActionSave()); }
public override void InitMainObject() { MainObject = new ICShipmentsInfo(); SearchObject = new ICShipmentsInfo(); }