コード例 #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
ファイル: CompanySite.cs プロジェクト: tslekwadi/CDS
 public CompanySite()
 {
     Site            = ApplicationDataContext.Instance.SystemEntityContext.SYS_Site.Include("SYS_Entity").FirstOrDefault(n => n.SYS_Entity.Id == ApplicationDataContext.Instance.LoggedInUser.DefaultSiteId);
     Entity          = Site.SYS_Entity;
     billingAddress  = Site.SYS_Address_BillingAddress;  //dataContext.EntitySystemContext.SYS_Address.FirstOrDefault(n => n.Id == Site.BillingAddress);
     shippingAddress = Site.SYS_Address_ShippingAddress; //dataContext.EntitySystemContext.SYS_Address.FirstOrDefault(n => n.Id == Site.ShippingAddress);
     printerBarcode  = Site.SYS_Printer_Barcode;         //dataContext.EntitySystemContext.SYS_Printer.FirstOrDefault(n => n.Id == Site.PrinterBarcode);
     printerPicker   = Site.SYS_Printer_Picker;          //dataContext.EntitySystemContext.SYS_Printer.FirstOrDefault(n => n.Id == Site.PrinterPicker);
     printerReceipt  = Site.SYS_Printer_Receipt;         //dataContext.EntitySystemContext.SYS_Printer.FirstOrDefault(n => n.Id == Site.PrinterReceipt);
 }
コード例 #3
0
ファイル: SYS_Address.cs プロジェクト: tslekwadi/CDS
        internal static String Save(DB.SYS_Address entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntitySystemContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntitySystemContext.SYS_Address.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                return(dataContext.PackageValidationException());
            }

            return("Success");
        }
コード例 #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;
                }
            }
        }
コード例 #5
0
ファイル: SYS_Address.cs プロジェクト: tslekwadi/CDS
 public static DB.SYS_Address GetPreviousItem(DB.SYS_Address SYS_Address, DataContext dataContext)
 {
     return(dataContext.EntitySystemContext.SYS_Address.OrderByDescending(o => o.Id).FirstOrDefault(n => n.Id < SYS_Address.Id));
 }
コード例 #6
0
ファイル: SYS_Address.cs プロジェクト: tslekwadi/CDS
 public static DB.SYS_Address GetNextItem(DB.SYS_Address SYS_Address, DataContext dataContext)
 {
     return(dataContext.EntitySystemContext.SYS_Address.OrderBy(o => o.Id).FirstOrDefault(n => n.Id > SYS_Address.Id));
 }