protected override void Archive() { base.Archive(); DB.ORG_Contact orgContact = (DB.ORG_Contact)BindingSource.DataSource; DB.SYS_Person sysPerson = BL.SYS.SYS_Person.Load(orgContact.PersonId, DataContext); sysPerson.Archived = !sysPerson.Archived; btnArchive.Caption = sysPerson.Archived ? "Un-Archive" : "Archive"; try { using (TransactionScope transaction = DataContext.GetTransactionScope()) { DataContext.SaveChangesEntitySystemContext(); DataContext.CompleteTransaction(transaction); } DataContext.EntitySystemContext.AcceptAllChanges(); } catch (Exception ex) { DataContext.EntitySystemContext.RejectChanges(); HasErrors = true; if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }
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; //} }
private void ddlAccountContact_EditValueChanged(object sender, EventArgs e) { if (ddlAccountContact.OldEditValue != null && ddlAccountContact.OldEditValue != DBNull.Value && ddlAccountContact.OldEditValue.GetType() != typeof(System.String) && OldAccountsContact == null && ddlAccountContact.OldEditValue != ddlAccountContact.EditValue && Convert.ToInt64(ddlAccountContact.OldEditValue) != 0) { OldAccountsContact = Convert.ToInt64(ddlAccountContact.OldEditValue); } if (ddlAccountContact.EditValue != DBNull.Value && Convert.ToInt64(ddlAccountContact.EditValue) > 0) { orgAccountsContact = BL.ORG.ORG_Contact.Load((Int64)ddlAccountContact.EditValue, DataContext); } }
/// <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(); orgContact = BL.ORG.ORG_Contact.New; sysContact = BL.SYS.SYS_Person.New; } catch (Exception ex) { if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }
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; } } }
/// <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 { using (new CDS.Client.Desktop.Essential.UTL.WaitCursor()) { base.OpenRecord(Id); orgContact = BL.ORG.ORG_Contact.Load(Id, DataContext); sysContact = BL.SYS.SYS_Person.Load(orgContact.PersonId, DataContext); } } catch (Exception ex) { if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }
//private void clbStatementPreference_ItemChecking(object sender, DevExpress.XtraEditors.Controls.ItemCheckingEventArgs e) //{ // if ((clbStatementPreferenceo.GetItem(e.Index) as DB.ORG_StatementPreference).Id == (byte)BL.ORG.ORG_StatementPreference.Ignore && e.NewValue == CheckState.Checked) // { // clbStatementPreferenceo.UnCheckAll(); // } // else if ((clbStatementPreferenceo.GetItem(e.Index) as DB.ORG_StatementPreference).Id != (byte)BL.ORG.ORG_StatementPreference.Ignore && e.NewValue == CheckState.Checked) // { // for (int i = 0; i < clbStatementPreferenceo.ItemCount; i++) // { // DB.ORG_StatementPreference pref = (clbStatementPreferenceo.GetItem(i) as DB.ORG_StatementPreference); // if (pref.Id == (byte)BL.ORG.ORG_StatementPreference.Ignore && clbStatementPreferenceo.GetItemChecked(i)) // clbStatementPreferenceo.SetItemChecked(i, false); // } // } //} private void ddlSalesContact_Properties_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Tag != null && Convert.ToString(e.Button.Tag).Equals("New")) { Contact.ContactDialogue childform = new Contact.ContactDialogue(); childform.Department = BL.ORG.ORG_Department.Sales; childform.ShowDialog(); if (childform.ORGContact != null) { ServerModeSourceContactSales.QueryableSource = DataContext.ReadonlyContext.VW_Contact.Where(n => (n.CompanyId == null || n.CompanyId == childform.ORGContact.CompanyId) && n.DepartmentId == (byte)BL.ORG.ORG_Department.Sales); ServerModeSourceContactSales.Reload(); if (ddlSalesContact.EditValue != DBNull.Value && Convert.ToInt64(ddlSalesContact.EditValue) > 0) { OldSalesContact = Convert.ToInt64(ddlSalesContact.EditValue); } orgSalesContact = childform.ORGContact; ddlSalesContact.EditValue = childform.ORGContact.Id; } } }