Exemplo n.º 1
0
        protected override void BeforeUpdate(DataRow row)
        {
            atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)row;
            if (!CanEdit(dr))
            {
                throw new AtriumException(atriumBE.Properties.Resources.CACannotEditAnotherOffice);
            }

            if (dr.IsDisbDateNull())
            {
                this.BeforeChange(DisbursementFields.DisbDate, dr);
            }
            if (dr.IsNull(dr.Table.Columns[DisbursementFields.DisbType]))
            {
                this.BeforeChange(DisbursementFields.DisbType, dr);
            }
            if (dr.IsDisbTaxableNull() && dr.IsDisbTaxExemptNull())
            {
                throw new RequiredException(DisbursementFields.DisbTaxable);
            }
        }
Exemplo n.º 2
0
        protected override void AfterChange(DataColumn dc, DataRow ddr)
        {
            string ObjectName = this.myDisbursementDT.TableName;

            atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)ddr;


            switch (dc.ColumnName)
            {
            case DisbursementFields.DisbTaxable:
            case "TaxRateId":
                if (!dr.Final)
                {
                    if (dr.IsDisbTaxableNull())
                    {
                        dr.SetDisbTaxNull();
                    }
                    else
                    {
                        if (!dr.IsTaxRateIdNull())
                        {
                            appDB.TaxRateRow taxRateRow = myA.AtMng.DB.TaxRate.FindByTaxRateId(dr.TaxRateId);
                            dr.DisbTax = dr.DisbTaxable * taxRateRow.TaxRate;
                        }
                        else
                        {
                            officeDB.OfficeRow drOffice = this.myA.AtMng.GetOffice(dr.OfficeId).CurrentOffice;
                            dr.DisbTax = dr.DisbTaxable * (drOffice.IsTaxRateNull() ? 0 : drOffice.TaxRate);
                        }

                        dr.DisbTax = Math.Round(dr.DisbTax, 2, MidpointRounding.AwayFromZero);
                    }
                    dr.EndEdit();
                }
                break;

            default:
                break;
            }
        }