public void ChangeItemFromProposalItemsList() { if (Toolbar.IsNullOrNoneAction()) { return; } ProposalEntities entity = (ProposalEntities)CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)CurrentModuleEntity.MainObject; if (entity.ProposalItemList.CurrentIndex < 0) { return; } ARProposalItemsInfo objProposalItemsInfo = entity.ProposalItemList[entity.ProposalItemList.CurrentIndex]; if (objProposalItemsInfo == null) { return; } entity.UpdateTotalAmountProposalItemList(mainObject.FK_GECurrencyID); UpdateTotalAmount(); entity.ProposalItemList.GridControl.RefreshDataSource(); entity.UpdateMainObjectBindingSource(); }
public void ChangeCustomer(int customerID) { if (Toolbar.IsNullOrNoneAction() || customerID <= 0) { return; } ProposalEntities entity = (ProposalEntities)CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)CurrentModuleEntity.MainObject; ARCustomersController objCustomersController = new ARCustomersController(); ARCustomersInfo objCustomersInfo = objCustomersController.GetObjectByID(customerID) as ARCustomersInfo; if (objCustomersInfo == null) { return; } if (objCustomersInfo.ARCustomerActiveCheck == false) { MessageBox.Show("Khách hàng này đã bỏ hoạt động!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } mainObject.FK_ARCustomerID = customerID; mainObject.ARProposalCustomerName = objCustomersInfo.ARCustomerName; mainObject.FK_GECurrencyID = objCustomersInfo.FK_GECurrencyID; mainObject.ARProposalPaymentMethod = string.IsNullOrEmpty(objCustomersInfo.ARCustomerPaymentMethod) ? string.Empty : objCustomersInfo.ARCustomerPaymentMethod; entity.UpdateMainObjectBindingSource(); SetDefaultProposalName(); }
public void ActionNewFromProposal() { ActionNew(); SaleOrderEntities entity = (SaleOrderEntities)CurrentModuleEntity; ARSaleOrdersInfo mainObject = (ARSaleOrdersInfo)entity.MainObject; ARProposalsController objProposalsController = new ARProposalsController(); List <ARProposalsInfo> proposalList = objProposalsController.GetAllProposalForOderring(); guichooseProposal guiFind = new guichooseProposal(proposalList); guiFind.Module = this; guiFind.ShowDialog(); if (guiFind.DialogResult != DialogResult.OK) { return; } ARProposalsInfo objProposalsInfo = (ARProposalsInfo)guiFind.SelectedObjects[0]; if (objProposalsInfo != null) { mainObject.FK_ARCustomerID = objProposalsInfo.FK_ARCustomerID; mainObject.FK_ARProposalID = objProposalsInfo.ARProposalID; mainObject.FK_GECurrencyID = objProposalsInfo.FK_GECurrencyID; mainObject.ARSaleOrderDesc = objProposalsInfo.ARProposalDesc; mainObject.ARSaleOrderExchangeRate = objProposalsInfo.ARProposalExchangeRate; mainObject.ARSaleOrderPaymentMethodType = objProposalsInfo.ARProposalPaymentMethod; mainObject.ARSaleOrderSubTotalAmount = objProposalsInfo.ARProposalSubTotalAmount; mainObject.ARSaleOrderDiscountPercent = objProposalsInfo.ARProposalDiscountPerCent; mainObject.ARSaleOrderDiscountAmount = objProposalsInfo.ARProposalDiscountAmount; mainObject.ARSaleOrderTaxPercent = objProposalsInfo.ARProposalTaxPercent; mainObject.ARSaleOrderTaxAmount = objProposalsInfo.ARProposalTaxAmount; mainObject.ARSaleOrderTotalAmount = objProposalsInfo.ARProposalTotalAmount; } proposalList.Clear(); proposalList = (List <ARProposalsInfo>)guiFind.SelectedObjects; proposalList.ForEach(o => { ARProposalItemsController objProposalItemsController = new ARProposalItemsController(); List <ARProposalItemsInfo> proposalItems = objProposalItemsController.GetAllItemByProopsalID(o.ARProposalID); proposalItems.ForEach(p => { ARSaleOrderItemsInfo objSaleOrderItemsInfo = new ARSaleOrderItemsInfo(); objSaleOrderItemsInfo.FK_ICProductID = p.FK_ICProductID; objSaleOrderItemsInfo.FK_ICMeasureUnitID = p.FK_ICMeasureUnitID; objSaleOrderItemsInfo.ARSaleOrderItemProductNo = p.ARProposalItemProductNo; objSaleOrderItemsInfo.ARSaleOrderItemProductName = p.ARProposalItemProductName; objSaleOrderItemsInfo.ARSaleOrderItemProductDesc = p.ARProposalItemDesc; objSaleOrderItemsInfo.ARSaleOrderItemProductUnitPrice = p.ARProposalItemPrice; objSaleOrderItemsInfo.ARSaleOrderItemProductQty = p.ARProposalItemQty; objSaleOrderItemsInfo.ARSaleOrderItemDiscountPercent = p.ARProposalItemDiscountPercent; objSaleOrderItemsInfo.ARSaleOrderItemDiscountAmount = p.ARProposalItemDiscountAmount; objSaleOrderItemsInfo.ARSaleOrderItemTaxPercent = p.ARProposalItemTaxPercent; objSaleOrderItemsInfo.ARSaleOrderItemTaxAmount = p.ARProposalItemTaxAmount; objSaleOrderItemsInfo.ARSaleOrderItemTotalAmount = p.ARProposalItemTotalAmount; entity.SaleOrderItemsList.Add(objSaleOrderItemsInfo); }); }); ChangeCustomer(mainObject.FK_ARCustomerID); entity.UpdateMainObjectBindingSource(); entity.SaleOrderItemsList.GridControl.RefreshDataSource(); }
protected override void GridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { base.GridView_CellValueChanged(sender, e); ProposalEntities entity = (ProposalEntities)(this.Screen.Module as BaseModuleERP).CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)entity.MainObject; if (entity.ProposalItemList.CurrentIndex >= 0) { ARProposalItemsInfo item = entity.ProposalItemList[entity.ProposalItemList.CurrentIndex]; if (item != null) { if (e.Column.FieldName == "ARProposalItemDiscountAmount") { item.ARProposalItemDiscountPercent = item.ARProposalItemDiscountAmount / (item.ARProposalItemPrice * item.ARProposalItemQty) * 100; entity.UpdateTotalAmountProposalItemList(mainObject.FK_GECurrencyID); } else if (e.Column.FieldName == "ARProposalItemTaxAmount") { item.ARProposalItemTaxPercent = item.ARProposalItemTaxAmount / (item.ARProposalItemPrice * item.ARProposalItemQty - item.ARProposalItemDiscountAmount) * 100; entity.UpdateTotalAmountProposalItemList(mainObject.FK_GECurrencyID); } else { ((ProposalModule)Screen.Module).ChangeItemFromProposalItemsList(); } } } }
public void ChangeCurrency(int currencyID) { ProposalEntities entity = (ProposalEntities)CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)entity.MainObject; mainObject.FK_GECurrencyID = currencyID; entity.UpdatePriceBelongCurrency(currencyID); entity.UpdateMainObjectBindingSource(); }
public override void ActionNew() { base.ActionNew(); ProposalEntities entity = (ProposalEntities)CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)CurrentModuleEntity.MainObject; mainObject.ARProposalStatus = ProposalStatus.New; entity.UpdateMainObject(); }
public override void ActionApproved() { ProposalEntities entity = (ProposalEntities)CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)entity.MainObject; ARProposalsController objProposalsController = new ARProposalsController(); mainObject.ARProposalStatus = "Approved"; entity.UpdateMainObject(); InvalidateToolbar(); }
public override void SetDefaultMainObject() { base.SetDefaultMainObject(); ARProposalsInfo mainObject = (ARProposalsInfo)MainObject; mainObject.ARProposalDate = DateTime.Now; mainObject.ARProposalDeliveryDate = DateTime.Now; mainObject.ARProposalValidateDate = DateTime.Now.AddDays(7); mainObject.FK_HREmployeeID = VinaApp.CurrentUserInfo.FK_HREmployeeID; mainObject.ARProposalExchangeRate = 1; mainObject.FK_GECurrencyID = 1; UpdateMainObjectBindingSource(); }
public void ChangeTaxAmount() { if (Toolbar.IsNullOrNoneAction()) { return; } ProposalEntities entity = (ProposalEntities)CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)entity.MainObject; if (mainObject.ARProposalSubTotalAmount > 0) { mainObject.ARProposalDiscountPerCent = mainObject.ARProposalTaxAmount / mainObject.ARProposalSubTotalAmount * 100; } UpdateTotalAmount(); }
public override void InvalidateToolbar() { base.InvalidateToolbar(); ProposalEntities entity = (ProposalEntities)CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)entity.MainObject; ParentScreen.SetEnableOfToolbarButton("Approve", false); if (mainObject.ARProposalID > 0) { ParentScreen.SetEnableOfToolbarButton("Approve", true); if (mainObject.ARProposalStatus == "Approve") { ParentScreen.SetEnableOfToolbarButton(BaseToolbar.ToolbarButtonEdit, false); ParentScreen.SetEnableOfToolbarButton("Approve", false); } } }
public override int ActionSave() { ProposalEntities entity = (ProposalEntities)CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)CurrentModuleEntity.MainObject; if (mainObject.FK_ARCustomerID == 0) { MessageBox.Show("Khách hàng không được để trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(0); } if (string.IsNullOrEmpty(mainObject.ARProposalName)) { MessageBox.Show("Tên báo giá không được để trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(0); } return(base.ActionSave()); }
public void UpdateTotalAmount() { ARProposalsInfo mainObject = (ARProposalsInfo)MainObject; mainObject.ARProposalSubTotalAmount = ProposalItemList.Sum(o => o.ARProposalItemTotalAmount); VinaApp.RoundByCurrency(mainObject, "ARProposalSubTotalAmount", mainObject.FK_GECurrencyID); mainObject.ARProposalDiscountAmount = mainObject.ARProposalDiscountPerCent / 100 * mainObject.ARProposalSubTotalAmount; VinaApp.RoundByCurrency(mainObject, "ARProposalDiscountAmount", mainObject.FK_GECurrencyID); mainObject.ARProposalTaxAmount = mainObject.ARProposalTaxPercent / 100 * (mainObject.ARProposalSubTotalAmount - mainObject.ARProposalDiscountAmount); VinaApp.RoundByCurrency(mainObject, "ARProposalTaxAmount", mainObject.FK_GECurrencyID); mainObject.ARProposalTotalAmount = mainObject.ARProposalSubTotalAmount - mainObject.ARProposalDiscountAmount + mainObject.ARProposalTaxAmount; VinaApp.RoundByCurrency(mainObject, "ARProposalTotalAmount", mainObject.FK_GECurrencyID); UpdateMainObjectBindingSource(); }
public void SetDefaultProposalName() { ProposalEntities entity = (ProposalEntities)CurrentModuleEntity; ARProposalsInfo mainObject = (ARProposalsInfo)CurrentModuleEntity.MainObject; if (!String.IsNullOrWhiteSpace(mainObject.ARProposalName)) { return; } if (mainObject.FK_ARCustomerID == 0) { return; } mainObject.ARProposalName = string.Format("Bán hàng cho {0}", mainObject.ARProposalCustomerName); entity.UpdateMainObjectBindingSource(); }
public void UpdatePriceBelongCurrency(int currencyID) { ARProposalsInfo mainObject = (ARProposalsInfo)MainObject; ProposalItemList.ForEach(o => { if (mainObject.ARProposalExchangeRate != mainObject.ARProposalExchangeRateOld) { o.ARProposalItemProductUnitPrice = o.ARProposalItemProductUnitPrice * mainObject.ARProposalExchangeRate; o.ARProposalItemPrice = o.ARProposalItemPrice * mainObject.ARProposalExchangeRate; } VinaApp.RoundByCurrency(o, "ARProposalItemProductUnitPrice", currencyID); VinaApp.RoundByCurrency(o, "ARProposalItemPrice", currencyID); }); mainObject.ARProposalExchangeRateOld = mainObject.ARProposalExchangeRate; UpdateTotalAmountProposalItemList(currencyID); UpdateTotalAmount(); }
private void Fld_txtARSaleOrderExchangeRate_Validated(object sender, EventArgs e) { ARProposalsInfo mainObject = (ARProposalsInfo)((BaseModuleERP)Module).CurrentModuleEntity.MainObject; ((ProposalModule)Module).ChangeCurrency(mainObject.FK_GECurrencyID); }
public override void InitMainObject() { MainObject = new ARProposalsInfo(); SearchObject = new ARProposalsInfo(); }