Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
0
        protected override void BeforeChange(DataColumn dc, DataRow ddr)
        {
            string ObjectName = this.myDisbursementDT.TableName;

            atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)ddr;
            switch (dc.ColumnName)
            {
            case DisbursementFields.DisbDate:
                if (dr.IsDisbDateNull() || myA.IsEmpty(dr.DisbDate.ToString()))
                {
                    throw new RequiredException(Resources.DisbursementDisbDate);
                }
                this.myA.IsValidDate(Resources.DisbursementDisbDate, dr.DisbDate, false, DateTime.Today.AddMonths(-6), DateTime.Today, Resources.ValidationSixMonthsAgo, Resources.ValidationToday);
                break;

            case DisbursementFields.DisbType:
                if (dr.IsNull(dc) || dr.DisbType.Length == 0)
                {
                    throw new RequiredException(Resources.DisbursementDisbType);
                }
                else if (!myA.CheckDomain(dr.DisbType, myA.Codes("DisbursementType")))
                {
                    throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dr.Table.TableName, "Dsibursement Type");
                }
                break;

            case "TaxRateId":
                if (!dr.IsTaxRateIdNull() && !myA.CheckDomain(dr.TaxRateId, myA.Codes("TaxRate")))
                {
                    throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dc.Table.TableName, "Tax Rate");
                }
                break;

            case "OfficeId":
                if (!myA.CheckDomain(dr.OfficeId, myA.Codes("OfficeList")))
                {
                    throw new AtriumException(atriumBE.Properties.Resources.IsNotValid, dc.ColumnName);
                }
                else if (!myA.CheckDomain(dr.OfficeId, myA.Codes("officelist")))
                {
                    throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dc.Table.TableName, "Office List");
                }
                break;

            case DisbursementFields.IRPId:
            case DisbursementFields.DisbTaxExempt:
            case DisbursementFields.DisbTaxable:
            case DisbursementFields.DisbTax:
            case DisbursementFields.Posted:
            case DisbursementFields.Final:
                if (dr.Final)
                {
                    throw new AtriumException(Resources.DisbNoEditAfterCommit);
                }
                break;

            case DisbursementFields.Taxed:
                if (!dr.Final && dr.Taxed)
                {
                    throw new AtriumException(Resources.DisbNoTaxUnlessCommit);
                }
                break;

            default:
                break;
            }
        }