public override void ActionNew() { base.ActionNew(); CustomerPaymentEntities entity = (CustomerPaymentEntities)CurrentModuleEntity; ARCustomerPaymentsInfo mainObject = (ARCustomerPaymentsInfo)entity.MainObject; ARCustomerPaymentTimePaymentsController objCustomerPaymentTimePaymentsController = new ARCustomerPaymentTimePaymentsController(); List <ARCustomerPaymentTimePaymentsInfo> listCustomerPaymentTimePaymentsInfo = objCustomerPaymentTimePaymentsController.GetDocumentForCustomerPayment(); guiChooseCustomerPaymentTimePayments guiFind = new guiChooseCustomerPaymentTimePayments(listCustomerPaymentTimePaymentsInfo); guiFind.Module = this; DialogResult rs = guiFind.ShowDialog(); if (rs != DialogResult.OK) { ActionCancel(); return; } listCustomerPaymentTimePaymentsInfo = guiFind.SelectedObjects as List <ARCustomerPaymentTimePaymentsInfo>; ARCustomerPaymentTimePaymentsInfo objCustomerPaymentTimePaymentsInfo = listCustomerPaymentTimePaymentsInfo.FirstOrDefault(); mainObject.FK_ARCustomerID = objCustomerPaymentTimePaymentsInfo.FK_ARCustomerID; mainObject.FK_GECurrencyID = objCustomerPaymentTimePaymentsInfo.FK_GECurrencyID; mainObject.ARCustomerPaymentPaymentMethodType = objCustomerPaymentTimePaymentsInfo.ARCustomerPaymentPaymentMethodType; mainObject.ARCustomerPaymentSenderName = objCustomerPaymentTimePaymentsInfo.ARCustomerPaymentSenderName; entity.CustomerPaymentTimePaymentsList.Invalidate(listCustomerPaymentTimePaymentsInfo); UpdateTotalAmount(); entity.UpdateMainObjectBindingSource(); }
public void ChangeCustomer(int customerID) { if (Toolbar.IsNullOrNoneAction() || customerID <= 0) { return; } CustomerPaymentEntities entity = (CustomerPaymentEntities)CurrentModuleEntity; ARCustomerPaymentsInfo mainObject = (ARCustomerPaymentsInfo)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.ARCustomerPaymentSenderName = objCustomersInfo.ARCustomerName; mainObject.ARCustomerPaymentPaymentMethodType = string.IsNullOrEmpty(objCustomersInfo.ARCustomerPaymentMethod) ? string.Empty : objCustomersInfo.ARCustomerPaymentMethod; entity.UpdateMainObjectBindingSource(); }
protected override void GridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { base.GridView_CellValueChanged(sender, e); GridView gridView = (GridView)sender; CustomerPaymentEntities entity = (CustomerPaymentEntities)(this.Screen.Module as BaseModuleERP).CurrentModuleEntity; if (entity.CustomerPaymentTimePaymentsList.CurrentIndex >= 0) { ARCustomerPaymentTimePaymentsInfo item = (ARCustomerPaymentTimePaymentsInfo)gridView.GetRow(gridView.FocusedRowHandle); if (e.Column.FieldName == "ARCustomerPaymentTimePaymentPercent") { item.ARCustomerPaymentTimePaymentAmount = item.ARCustomerPaymentTimePaymentPercent / 100 * item.ARCustomerPaymentTimePaymentTotalAmount; if (item.ARCustomerPaymentTimePaymentAmount > item.ARCustomerPaymentTimePaymentRemainAmount) { decimal oldValue = Convert.ToDecimal(gridView.ActiveEditor.OldEditValue); MessageBox.Show("Số tiền thanh toán vượt quá số tiền còn lại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); item.ARCustomerPaymentTimePaymentPercent = oldValue; item.ARCustomerPaymentTimePaymentAmount = item.ARCustomerPaymentTimePaymentPercent / 100 * item.ARCustomerPaymentTimePaymentTotalAmount; return; } ((CustomerPaymentModule)Screen.Module).UpdateTotalAmount(); } else if (e.Column.FieldName == "ARCustomerPaymentTimePaymentAmount") { ((CustomerPaymentModule)Screen.Module).UpdateTotalAmount(); } } }
public override void InitGridControlDataSource() { CustomerPaymentEntities entity = (CustomerPaymentEntities)((BaseModuleERP)Screen.Module).CurrentModuleEntity; BindingSource bds = new BindingSource(); bds.DataSource = entity.CustomerPaymentTimePaymentsList; this.DataSource = bds; }
public void UpdateTotalAmount() { CustomerPaymentEntities entity = (CustomerPaymentEntities)CurrentModuleEntity; ARCustomerPaymentsInfo mainObject = (ARCustomerPaymentsInfo)CurrentModuleEntity.MainObject; entity.UpdateTotalAmount(); ARCustomerPaymentDetailsGridControl gridControl = (ARCustomerPaymentDetailsGridControl)Controls[CustomerPaymentModule.CustomerPaymentDetailsGridControlName]; gridControl.PaymentAmount = mainObject.ARCustomerPaymentTotalAmount; gridControl.ProposeRemainingAmount(); }
public void ChangeCurrency(int currencyID) { CustomerPaymentEntities entity = (CustomerPaymentEntities)CurrentModuleEntity; ARCustomerPaymentsInfo mainObject = (ARCustomerPaymentsInfo)entity.MainObject; mainObject.FK_GECurrencyID = currencyID; GECurrenciesInfo objCurrenciesInfo = VinaApp.CurrencyList.Where(o => o.GECurrencyID == currencyID).FirstOrDefault(); mainObject.ARCustomerPaymentExchangeRate = objCurrenciesInfo == null ? 1 : objCurrenciesInfo.GECurrencyTransferRate; entity.UpdateMainObjectBindingSource(); ChangeExchangeRate(); }
public void DeleteItemFromCustomerPaymentTimePaymentsList() { if (Toolbar.IsNullOrNoneAction()) { return; } CustomerPaymentEntities entity = (CustomerPaymentEntities)CurrentModuleEntity; entity.CustomerPaymentTimePaymentsList.RemoveSelectedRowObjectFromList(); UpdateTotalAmount(); }
public CustomerPaymentModule() { this.CurrentModuleName = "CustomerPayment"; CurrentModuleEntity = new CustomerPaymentEntities(); CurrentModuleEntity.Module = this; InitializeModule(); CustomerPaymentEntities entity = (CustomerPaymentEntities)CurrentModuleEntity; ARCustomerPaymentDetailsGridControl gridControl = Controls[CustomerPaymentModule.CustomerPaymentDetailsGridControlName] as ARCustomerPaymentDetailsGridControl; gridControl.CustomerPaymentDetailList = entity.CustomerPaymentDetailsList; gridControl.InitGridControlDataSource(); }
public void SetDefaultCustomerPaymentName() { CustomerPaymentEntities entity = (CustomerPaymentEntities)CurrentModuleEntity; ARCustomerPaymentsInfo mainObject = (ARCustomerPaymentsInfo)CurrentModuleEntity.MainObject; if (!String.IsNullOrWhiteSpace(mainObject.ARCustomerPaymentName)) { return; } if (mainObject.FK_ARCustomerID == 0) { return; } mainObject.ARCustomerPaymentName = string.Format("Thu tiền của khách hàng {0}", mainObject.ARCustomerPaymentSenderName); }
public override int ActionSave() { CustomerPaymentEntities entity = (CustomerPaymentEntities)CurrentModuleEntity; ARCustomerPaymentsInfo mainObject = (ARCustomerPaymentsInfo)CurrentModuleEntity.MainObject; SetDefaultCustomerPaymentName(); List <string> errorList = new List <string>(); if (mainObject.FK_ARCustomerID == 0) { errorList.Add("Khách hàng không được để trống!"); } if (string.IsNullOrWhiteSpace(mainObject.ARCustomerPaymentPaymentMethodType)) { errorList.Add("Phương thức thanh toán không được bỏ trống!"); } if (mainObject.FK_GECurrencyID == 0 || mainObject.ARCustomerPaymentExchangeRate == 0) { errorList.Add("Vui lòng chọn loại tiền tề và tỷ giá!"); } entity.CustomerPaymentTimePaymentsList.ForEach(p => { if (p.ARCustomerPaymentTimePaymentAmount > p.ARCustomerPaymentTimePaymentRemainAmount) { errorList.Add("Số tiền thanh toán vượt quá số tiền còn lại!"); } }); if (errorList.Count() > 0) { GuiErrorMessage guiError = new GuiErrorMessage(errorList); guiError.Module = this; guiError.ShowDialog(); return(0); } return(base.ActionSave()); }