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(); }
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(); } } }