Ejemplo n.º 1
0
        private void createNewPrivateEnterprenuer(string identifier)
        {
            var instance = new PrivateEnterprenuer {
                IDName = identifier
            };

            Data.PrivateEnreprenuers.Add(instance);
            Data.Identifiers.Add(identifier);
            Data.Instances.Add(instance);
        }
        internal void SetIdById(string id, string valueId)
        {
/*            var instance = GetInstance(id);*/
            var instanceValue = GetInstance(valueId);

            /*         Instances.Remove(instance);
             *       instance = instanceValue;
             *       Instances.Add(instance);*/

            bool isPrimitive = true;

            string idType = GetIdType(id);

            switch (idType)
            {
            case DataTypes.PRIVATE_ENTERPRENUER_DT:
            {
                PrivateEnterprenuer instance = getPrEntItemByID(id);
                var name = instance.IDName;
                if (instanceValue is PrivateEnterprenuer)
                {
                    PrivateEnterprenuer value = (PrivateEnterprenuer)instanceValue;
                    instance        = value.Clone();
                    instance.IDName = name;
                }
                else
                {
                    showExIdTypesAreDifferent(DataTypes.PRIVATE_ENTERPRENUER_DT, instanceValue);
                }
                changeForNewInstancePrEnt(id, instance);
                isPrimitive = false;
                break;
            }

            case DataTypes.ONE_TAX_PAYER_REPORT_DT:
            {
                var instance = getOneTaxPayerReportItemByID(id);
                var name     = instance.IDName;
                if (instanceValue is OneTaxPayer)
                {
                    OneTaxPayer value = (OneTaxPayer)instanceValue;
                    instance        = value.Clone();
                    instance.IDName = name;
                }
                else
                {
                    showExIdTypesAreDifferent(DataTypes.ONE_TAX_PAYER_REPORT_DT, instanceValue);
                }
                changeForNewInstanceOneTaxPayerReport(id, instance);
                isPrimitive = false;

                break;
            }

            case DataTypes.DF_1_REPORT_DT:
            {
                var instance = getForm1DFReportItemByID(id);
                var name     = instance.IDName;
                if (instanceValue is Form1DF)
                {
                    Form1DF value = (Form1DF)instanceValue;
                    instance        = value.Clone();
                    instance.IDName = name;
                }
                else
                {
                    showExIdTypesAreDifferent(DataTypes.DF_1_REPORT_DT, instanceValue);
                }
                changeForNewInstanceDF1(id, instance);
                isPrimitive = false;

                break;
            }

            case DataTypes.SECTION_1_DF_1_DT:
            {
                var instance = getForm1DFSection1ItemByID(id);
                var name     = instance.IDName;
                if (instanceValue is Form1DF1Section1)
                {
                    Form1DF1Section1 value = (Form1DF1Section1)instanceValue;
                    instance        = value.Clone();
                    instance.IDName = name;
                }
                else
                {
                    showExIdTypesAreDifferent(DataTypes.SECTION_1_DF_1_DT, instanceValue);
                }
                changeForNewInstanceDF1Section1(id, instance);
                isPrimitive = false;

                break;
            }

            case DataTypes.UNIFIED_SOCIAL_TAX_REPORT_DT:
            {
                var instance = getUnifiedSocilTaxReportItemByID(id);
                var name     = instance.IDName;
                if (instanceValue is UnifiedSocialTaxReport)
                {
                    var value = (UnifiedSocialTaxReport)instanceValue;
                    instance        = value.Clone();
                    instance.IDName = name;
                }
                else
                {
                    showExIdTypesAreDifferent(DataTypes.UNIFIED_SOCIAL_TAX_REPORT_DT, instanceValue);
                }
                changeForNewInstanceUnifiedSocialTax(id, instance);
                isPrimitive = false;

                break;
            }

            case DataTypes.TABLE_1_UNIFIED_SOCIL_TAX_DT:
            {
                var instance = getUnifiedSocilTaxTable1ItemByID(id);
                var name     = instance.IDName;
                if (instanceValue is UnifiedSocialTax)
                {
                    var value = (UnifiedSocialTax)instanceValue;
                    instance        = value.Clone();
                    instance.IDName = name;
                }
                else
                {
                    showExIdTypesAreDifferent(DataTypes.TABLE_1_UNIFIED_SOCIL_TAX_DT, instanceValue);
                }
                changeForNewInstanceUnifiedSocialTaxTable1(id, instance);
                isPrimitive = false;

                break;
            }
            }

            if (isPrimitive && instanceValue is PrimitiveType)
            {
                var primitiveInstance = GetPrimitiveInstance(id);
                var curr = (PrimitiveType)instanceValue;
                primitiveInstance.StrValue = curr.StrValue;
                changePrimitives(id, primitiveInstance);
            }
        }
 private void changeForNewInstancePrEnt(string id, PrivateEnterprenuer newInstance)
 {
     PrivateEnreprenuers.Remove(getPrEntItemByID(id));
     PrivateEnreprenuers.Add(newInstance);
 }