Example #1
0
        private void RepositoryItemButtonEditAmount_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if ((Screen.Module as BaseModuleERP).IsEditable())
            {
                (Screen.Module as BaseModuleERP).ActionEdit();
            }

            GridView gridView = (GridView)MainView;

            if (gridView.FocusedRowHandle >= 0)
            {
                ARCustomerPaymentDetailsInfo objCustomerPaymentDetailsInfo = (ARCustomerPaymentDetailsInfo)gridView.GetRow(gridView.FocusedRowHandle);
                //guiPaymentCurrency guiPaymentCurrency = new guiPaymentCurrency(objCustomerPaymentDetailsInfo);
                //guiPaymentCurrency.Module = Screen.Module;
                //guiPaymentCurrency.ShowDialog();
            }
        }
Example #2
0
        public void ProposeRemainingAmount()
        {
            GridView gridView = (GridView)MainView;

            if (gridView.FocusedRowHandle >= 0)
            {
                ARCustomerPaymentDetailsInfo currentPayment = null;
                if (!AllowMultiplePayment && !string.IsNullOrEmpty(RequiredMethod))
                {
                    currentPayment = CustomerPaymentDetailList.Where(cpd => cpd.ARCustomerPaymentDetailPaymentMethodType == RequiredMethod).FirstOrDefault();
                }
                else
                {
                    currentPayment = (ARCustomerPaymentDetailsInfo)gridView.GetRow(gridView.FocusedRowHandle);
                }

                if (AllowMultiplePayment)
                {
                    decimal amount = 0;
                    foreach (ARCustomerPaymentDetailsInfo objCustomerPaymentDetailsInfo in CustomerPaymentDetailList)
                    {
                        if (objCustomerPaymentDetailsInfo.ARCustomerPaymentDetailPaymentMethodType != currentPayment.ARCustomerPaymentDetailPaymentMethodType)
                        {
                            amount += objCustomerPaymentDetailsInfo.ARCustomerPaymentDetailAmount;
                        }
                    }

                    if (PaymentAmount >= amount)
                    {
                        currentPayment.ARCustomerPaymentDetailAmount = PaymentAmount - amount;
                    }
                }
                else
                {
                    ARCustomerPaymentDetailsInfo previousPayment = CustomerPaymentDetailList.Where(cpd => cpd.ARCustomerPaymentDetailID > 0 &&
                                                                                                   cpd.ARCustomerPaymentDetailAmount > 0).FirstOrDefault();
                    if (previousPayment != null)
                    {
                        currentPayment = previousPayment;
                    }
                    CustomerPaymentDetailList.ForEach(cpd => cpd.ARCustomerPaymentDetailAmount = 0);
                    currentPayment.ARCustomerPaymentDetailAmount = PaymentAmount;
                }
                this.RefreshDataSource();
            }
        }
Example #3
0
        public static void UpdateCustomerPaymentDetails(ARCustomerPaymentsInfo customerPayment, List <ARCustomerPaymentDetailsInfo> paymentDetails)
        {
            ARCustomerPaymentDetailsController  objCustomerPaymentDetailsController = new ARCustomerPaymentDetailsController();
            List <ARCustomerPaymentDetailsInfo> oldPaymentDetails = objCustomerPaymentDetailsController.GetDetailsByPaymentID(customerPayment.ARCustomerPaymentID);

            foreach (ARCustomerPaymentDetailsInfo oldPaymentDetail in oldPaymentDetails)
            {
                //RollbackRelativeDataOfPaymentDetail((ARCustomerPaymentDetailsInfo)oldPaymentDetail);
            }
            foreach (ARCustomerPaymentDetailsInfo paymentDetail in paymentDetails)
            {
                ARCustomerPaymentDetailsInfo oldPaymentDetail = oldPaymentDetails.Where(pd => pd.ARCustomerPaymentDetailPaymentMethodType == paymentDetail.ARCustomerPaymentDetailPaymentMethodType).FirstOrDefault();
                if (oldPaymentDetail != null)
                {
                    //UpdateRelativeDataOfPaymentDetail(paymentDetail, customerPayment.FK_ARCustomerID);

                    paymentDetail.FK_ARCustomerPaymentID    = oldPaymentDetail.FK_ARCustomerPaymentID;
                    paymentDetail.ARCustomerPaymentDetailID = oldPaymentDetail.ARCustomerPaymentDetailID;
                    objCustomerPaymentDetailsController.UpdateObject(paymentDetail);
                }
            }
        }
Example #4
0
        protected override void GridView_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
        {
            base.GridView_ValidatingEditor(sender, e);

            GridView gridView = (GridView)sender;

            if (gridView.FocusedColumn.FieldName == "ARCustomerPaymentDetailAmount")
            {
                if (e.Value != null)
                {
                    ARCustomerPaymentDetailsInfo currentPayment = (ARCustomerPaymentDetailsInfo)gridView.GetRow(gridView.FocusedRowHandle);
                    if (!AllowMultiplePayment)
                    {
                        if (CustomerPaymentDetailList.Exists(cpd => cpd.ARCustomerPaymentDetailAmount > 0 && cpd.ARCustomerPaymentDetailPaymentMethodType != currentPayment.ARCustomerPaymentDetailPaymentMethodType))
                        {
                            e.ErrorText = "Không thể thực hiện đa thanh toán!";
                            e.Valid     = false;
                            return;
                        }
                    }
                    decimal amount = 0;
                    foreach (ARCustomerPaymentDetailsInfo objDocumentPaymentDetaisInfo in CustomerPaymentDetailList)
                    {
                        if (objDocumentPaymentDetaisInfo.ARCustomerPaymentDetailPaymentMethodType != currentPayment.ARCustomerPaymentDetailPaymentMethodType)
                        {
                            amount += objDocumentPaymentDetaisInfo.ARCustomerPaymentDetailAmount;
                        }
                    }
                    amount += Convert.ToDecimal(e.Value);
                    if (amount > PaymentAmount)
                    {
                        e.ErrorText = "Tổng tiền không được lớn hơn tiền thanh toán!";
                        e.Valid     = false;
                    }
                }
            }
        }