示例#1
0
        internal void Update(OutputInvoice parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            this.OidFactura = parent.Oid;

            ValidationRules.CheckRules();

            if (!IsValid)
            {
                throw new iQValidationException(Library.Resources.Messages.GENERIC_VALIDATION_ERROR);
            }

            SessionCode = parent.SessionCode;
            OutputInvoiceLineRecord obj = Session().Get <OutputInvoiceLineRecord>(Oid);

            obj.CopyValues(Base.Record);
            Session().Update(obj);

            if (OidPartida == 0)
            {
                OutputDeliveries albaranes = OutputDeliveries.GetList(parent.GetAlbaranes(), true, true, parent.SessionCode);

                OutputDeliveryLine concepto = null;
                OutputDelivery     albaran  = null;

                foreach (OutputDelivery item in albaranes)
                {
                    albaran = item;

                    foreach (OutputDeliveryLine ca in item.Conceptos)
                    {
                        if (ca.Oid == OidConceptoAlbaran)
                        {
                            concepto = ca;
                            break;
                        }
                    }

                    if (concepto != null)
                    {
                        break;
                    }
                }

                if (concepto != null)
                {
                    concepto.CopyFrom(this);
                    albaran.CalculateTotal();
                }
            }

            MarkOld();
        }