示例#1
0
        protected override void OnNewRecord()
        {
            base.OnNewRecord();
            orgEntity          = BL.ORG.ORG_Entity.Load(orgEntityId, DataContext, new List <string> {
            });
            orgEntitysysEntity = BL.SYS.SYS_Entity.Load(orgEntity.EntityId, DataContext);
            switch (Type)
            {
            case BL.ORG.ORG_Type.Customer:
            {
                orgCompany            = BL.ORG.ORG_Company.NewCustomerCompany;
                orgCompany.ORG_Entity = orgEntity;
            }
            break;

            case BL.ORG.ORG_Type.Supplier:
            {
                orgCompany            = BL.ORG.ORG_Company.NewSupplierCompany;
                orgCompany.ORG_Entity = orgEntity;
            }
            break;
            }

            if (orgCompany.ORG_Distribution.Count == 0)
            {
                orgDistribution = BL.ORG.ORG_Distribution.New;
                orgCompany.ORG_Distribution.Add(orgDistribution);
            }
            else
            {
                orgDistribution = orgCompany.ORG_Distribution.FirstOrDefault();
            }
            orgBillingAddress  = BL.ORG.ORG_CompanyAddress.NewCompanyBillingAddress;
            orgShippingAddress = BL.ORG.ORG_CompanyAddress.NewCompanyShippingAddress;
            orgCompany.ORG_CompanyAddress.Add(orgBillingAddress);
            orgCompany.ORG_CompanyAddress.Add(orgShippingAddress);
            sysBillingAddress  = BL.SYS.SYS_Address.NewBillingAddress;
            sysShippingAddress = BL.SYS.SYS_Address.NewShippingAddress;
            orgCompany.SiteId  = Convert.ToInt64(BL.ApplicationDataContext.Instance.LoggedInUser.DefaultSiteId);

            if (BL.ORG.ORG_Contact.LoadSalesContact(orgEntitysysEntity.Id, DataContext) != null)
            {
                orgSalesContact = BL.ORG.ORG_Contact.LoadSalesContact(orgEntitysysEntity.Id, DataContext);
            }
            //else
            //{
            //    orgSalesContact = BL.ORG.ORG_Contact.NewSalesContact;
            //}

            if (BL.ORG.ORG_Contact.LoadAccountsContact(orgEntitysysEntity.Id, DataContext) != null)
            {
                orgAccountsContact = BL.ORG.ORG_Contact.LoadAccountsContact(orgEntitysysEntity.Id, DataContext);
            }
            //else
            //{
            //    orgAccountsContact = BL.ORG.ORG_Contact.NewAccountsContact;
            //}
        }
示例#2
0
        public override void OpenRecord(long Id)
        {
            try
            {
                base.OpenRecord(Id);
                orgCompany = BL.ORG.ORG_Company.Load(Id, DataContext, new List <string>()
                {
                    "ORG_Entity"
                });
                orgEntity          = (DB.ORG_Entity)orgCompany.ORG_Entity;
                orgEntitysysEntity = BL.SYS.SYS_Entity.Load(orgEntity.EntityId, DataContext);
                if (BL.ORG.ORG_Contact.LoadSalesContact(orgEntitysysEntity.Id, DataContext) != null)
                {
                    orgSalesContact           = BL.ORG.ORG_Contact.LoadSalesContact(orgEntitysysEntity.Id, DataContext);
                    ddlSalesContact.EditValue = orgSalesContact.Id;
                }
                //else
                //{
                //    orgSalesContact = BL.ORG.ORG_Contact.NewSalesContact;
                //}
                if (BL.ORG.ORG_Contact.LoadAccountsContact(orgEntitysysEntity.Id, DataContext) != null)
                {
                    orgAccountsContact          = BL.ORG.ORG_Contact.LoadAccountsContact(orgEntitysysEntity.Id, DataContext);
                    ddlAccountContact.EditValue = orgAccountsContact.Id;
                }
                //else
                //{
                //    orgAccountsContact = BL.ORG.ORG_Contact.NewAccountsContact;
                //}

                orgDistribution = DataContext.EntityOrganisationContext.ORG_Distribution.FirstOrDefault(n => n.EntityId == orgCompany.Id);
                var          orgCompanyAddress = DataContext.EntityOrganisationContext.ORG_CompanyAddress.Where(n => n.CompanyId == orgCompany.Id && n.AddressId.HasValue == true);
                List <Int64> addressIds        = orgCompanyAddress.Select(l => l.AddressId.Value).ToList();
                var          sysAddress        = DataContext.EntitySystemContext.SYS_Address.Where(n => addressIds.Contains(n.Id)).ToList();
                sysBillingAddress  = sysAddress.FirstOrDefault(n => n.TypeId == (byte)BL.SYS.SYS_Type.BillingAddress);
                orgBillingAddress  = orgCompanyAddress.FirstOrDefault(n => n.AddressId == sysBillingAddress.Id && n.CompanyId == orgCompany.Id);
                sysShippingAddress = sysAddress.FirstOrDefault(n => n.TypeId == (byte)BL.SYS.SYS_Type.ShippingAddress);
                orgShippingAddress = orgCompanyAddress.FirstOrDefault(n => n.AddressId == sysShippingAddress.Id && n.CompanyId == orgCompany.Id);
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
            }
        }