Esempio n. 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;
            //}
        }
Esempio n. 2
0
        /// <summary>
        /// Open an ORG Entity record from the database.
        /// </summary>
        /// <param name="Id">The id (primary key) of the ORG Entity to open.</param>
        /// <remarks>Created: Theo Crous 14/11/2011</remarks>
        public override void OpenRecord(Int64 Id)
        {
            try
            {
                base.OpenRecord(Id);

                orgEntitySYSEntity = BL.SYS.SYS_Entity.Load(Id, DataContext);
                orgEntity = BL.ORG.ORG_Entity.LoadByEntity(Id, DataContext, new List<string>() { "ORG_Company" });
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// The binding source is bound to a new instance of an ORG Entity. This is for the instances where a new record is to be created.
        /// </summary>
        /// <remarks>Created: Theo Crous 17/11/2011</remarks>
        protected override void OnNewRecord()
        {
            try
            {
                base.OnNewRecord();

                orgEntity = BL.ORG.ORG_Entity.New;
                orgEntitySYSEntity = BL.SYS.SYS_Entity.NewCompany;
                orgEntitySYSEntity.CodeSub = "00000";
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; }
            }
        }
Esempio n. 4
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;
                }
            }
        }
Esempio n. 5
0
        protected override void Archive()
        {
            base.Archive();
            throw new Exception("Fix this");
            DB.ORG_Entity org_entity = (DB.ORG_Entity)BindingSource.DataSource;
            DB.SYS_Entity sys_entity = BL.SYS.SYS_Entity.Load(org_entity.EntityId, DataContext);
            if (!sys_entity.Archived)
            {
                try
                {
                    //000 = Archived or Un-Archived
                    //001 = Outstanding Balance
                    //002 = Control Account
                    //003 = Is Parent
                    //004 = Parent is Archived
                    int code = -1;/* Context.Database.SqlQuery<int>(
                    "DECLARE	@return_value int" + Environment.NewLine +
                    "EXEC	@return_value = [dbo].[spArchiveAccount]" + Environment.NewLine +
                    "        @AccountId = " + glxAccount.Id + "," + Environment.NewLine +
                    "        @Archive = 1" + Environment.NewLine +
                    "SELECT	@return_value");
                    */


                    if (code.Equals(0))
                    {
                        sys_entity.Archived = !sys_entity.Archived;
                        btnArchive.Caption = sys_entity.Archived ? "Un-Archive" : "Archive";
                    }
                }
                catch (Exception ex)
                {
                    if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; }
                }
            }
            else
            {
                try
                {
                    //TODO: Find a way to do this
                    //returns 1 if sp was able to unarchive account
                    int code = -1; /* Context.Database.SqlQuery<int>(
                    "DECLARE	@return_value int" + Environment.NewLine +
                    "EXEC	@return_value = [dbo].[spArchiveAccount]" + Environment.NewLine +
                    "        @AccountId = " + glxAccount.Id + "," + Environment.NewLine +
                    "        @Archive = 0" + Environment.NewLine +
                    "SELECT	@return_value");
                    */

                    if (code.Equals(0))
                    {
                        sys_entity.Archived = !sys_entity.Archived;
                        btnArchive.Caption = sys_entity.Archived ? "Un-Archive" : "Archive";
                    }
                    else
                    {
                        Essential.BaseAlert.ShowAlert("Archive", "Entity could not be un-archived.", Essential.BaseAlert.Buttons.Ok, Essential.BaseAlert.Icons.Information);
                    }


                }
                catch (Exception ex)
                {
                    if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; }
                }
            }
        }