private static Type GetEntityInterfaceTypeFromInstance(IPersistentEntity entity) { return(entity .GetType() .GetInterfaces() .FirstOrDefault(type => type.FullName.StartsWith("Sage.Entity.Interfaces."))); }
void ISDataCrudProvider.Insert(IPersistentEntity entity) { var request = CreateResourceRequest(null); request.Entry = CopyEntityToAtomEntry(entity); request.Create(); }
/// <summary> /// Called when the smartpart has been bound. Derived components should override this method to run code that depends on entity context being set and it not changing. /// </summary> protected override void OnFormBound() { base.OnFormBound(); _parentEntity = GetParentEntity() as IPersistentEntity; _parentEntityReference = _parentEntity as IComponentReference; ClientBindingMgr.RegisterDialogCancelButton(btnCancel); }
private ISDataCrudProvider GetCrudProvider(IPersistentEntity entity) { Type entityIntfType = GetEntityInterfaceTypeFromInstance(entity); Type providerType = typeof(SDataQueryProvider <>).MakeGenericType(entityIntfType); return(Activator.CreateInstance(providerType, _sdataContractUrl, _userName, _password) as ISDataCrudProvider); }
/// <summary> /// Handles the Click event of the btnOK control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnOK_OnClick(object sender, EventArgs e) { UpdatePropertyMappings(SessionMergeArguments.MergeProvider.MergeMaps); string recordOverWrite = Request.Form["rdoRecordOverwrite"]; if (recordOverWrite != null) { SessionMergeArguments.MergeProvider.RecordOverwrite = recordOverWrite.Equals("SourceWins") ? MergeOverwrite.sourceWins : MergeOverwrite.targetWins; } if (Sage.SalesLogix.BusinessRules.BusinessRuleHelper.MergeRecords(SessionMergeArguments)) { using (ISession session = new Sage.Platform.Orm.SessionScopeWrapper(true)) { Type type = SessionMergeArguments.MergeProvider.Target.EntityType; string entityId = SessionMergeArguments.MergeProvider.Source.EntityId; IPersistentEntity source = Sage.Platform.EntityFactory.GetById(type, entityId) as IPersistentEntity; source.Delete(); EntityService.RemoveEntityHistory(type, source); Response.Redirect(String.Format("{0}.aspx", GetEntityName(type))); } } }
/// <summary> /// The given entity is removed from the package. /// </summary> public void RemovedFromPackage(IPersistentEntity entity) { foreach (var iterator in this.Cast <IPackageListener>()) { iterator.RemovedFromPackage(entity); } }
/// <summary> /// The given entity is removed from the package. /// </summary> protected override void RemovedFromPackage(IPersistentEntity entity) { base.RemovedFromPackage(entity); crossingJunctions.RemovedFromPackage(entity); ((IPackageListener)permissions).RemovedFromPackage(entity); enteringDestinationTrigger.RemovedFromPackage(entity); destinationReachedTrigger.RemovedFromPackage(entity); }
/// <summary> /// The given entity is removed from the package. /// </summary> protected override void RemovedFromPackage(IPersistentEntity entity) { base.RemovedFromPackage(entity); if (locs.Contains(entity as Loc)) { locs.Remove((Loc)entity); } }
/// <summary> /// The given entity is removed from the package. /// </summary> protected override void RemovedFromPackage(IPersistentEntity entity) { base.RemovedFromPackage(entity); if (entity.Id == group.Value.Id) { group.Value = null; } }
/// <summary> /// The given entity is removed from the package. /// </summary> protected override void RemovedFromPackage(IPersistentEntity entity) { base.RemovedFromPackage(entity); commandStationRefs.RemovedFromPackage(entity); locRefs.RemovedFromPackage(entity); moduleRefs.RemovedFromPackage(entity); moduleConnections.RemovedFromPackage(entity); locGroups.RemovedFromPackage(entity); }
/// <summary> /// The given entity is removed from the package. /// </summary> public void RemovedFromPackage(IPersistentEntity entity) { var clonedListeners = this.Cast <IPackageListener>().ToList(); foreach (var iterator in clonedListeners) { iterator.RemovedFromPackage(entity); } }
/// <summary> /// Remove a generic file part that belongs to the given entity by it's id. /// </summary> void IPackage.RemoveGenericPart(IPersistentEntity entity, string id) { var uri = CreateGenericPartUri(entity, id); if (parts.Remove(uri)) { OnModified(); } }
/// <summary> /// Handles the ClickAction event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnSave_ClickAction(object sender, EventArgs e) { IPersistentEntity persistentEntity = BindingSource.Current as IPersistentEntity; _parentEntity = GetParentEntity() as IPersistentEntity; _parentEntityReference = _parentEntity as IComponentReference; if (persistentEntity != null) { bool hasContactMatches = false; IAddress address = (IAddress)BindingSource.Current; if (Mode.Value == "ADD") { persistentEntity.Save(); } if (Mode.Value == "UPDATE") { IContact contact = _parentEntityReference as IContact; IAccount account = _parentEntityReference as IAccount; bool hasSalesOrderMatches = (Helpers.HasMatchingSalesOrderAddresses(_parentEntityReference)); if (contact != null) { hasContactMatches = contact.HasAddressChanges(); } else if (account != null) { hasContactMatches = account.HasAddressChanges(); } if ((hasContactMatches || hasSalesOrderMatches) && DialogService != null) { UpdateAddressOptionManager addressOptions = new UpdateAddressOptionManager(); addressOptions.HasContactAddressChanges = hasContactMatches; addressOptions.OldAddressValues = contact != null ? Sage.SalesLogix.Contact.Rules.getOriginalAddressValues( contact) : Sage.SalesLogix.Account.Rules.getOriginalAddressValues( account); addressOptions.HasSalesOrderAddressChanges = hasSalesOrderMatches; addressOptions.ParentEntityReference = _parentEntityReference; addressOptions.IsPrimaryAddress = (address.IsPrimary ?? false); DialogService.SetSpecs(200, 200, 200, 450, contact != null ? "UpdateContactOptions" : "UpdateAccountOptions", "", true); DialogService.EntityType = typeof(IAddress); DialogService.EntityID = address.Id.ToString(); DialogService.DialogParameters.Add("UpdateAddressOptionManager", addressOptions); DialogService.ShowDialog(); } persistentEntity.Save(); } } UpdateFlags(); btnSave_ClickActionBRC(sender, e); }
void ISDataCrudProvider.Delete(IPersistentEntity entity) { var request = CreateResourceRequest((entity as IComponentReference).Id.ToString()); var entry = new AtomEntry(); string etag = ""; _eTagCache.TryGetValue(entity, out etag); entry.SetSDataHttpIfMatch(etag); request.Delete(); }
/// <summary> /// Gets the ID's of all generic parts that belong to the given entity. /// </summary> IEnumerable <string> IPackage.GetGenericPartIDs(IPersistentEntity entity) { var prefix = CreateGenericPartUri(entity, string.Empty).OriginalString; foreach (var uri in parts.Keys.Where(x => x.OriginalString.StartsWith(prefix))) { var id = uri.OriginalString.Substring(prefix.Length); yield return(id); } }
protected void cmdDelete_ClickAction(object sender, EventArgs e) { IPersistentEntity persistentEntity = BindingSource.Current as IPersistentEntity; if (persistentEntity != null) { persistentEntity.Delete(); } CloseParentDialog(true); }
void ISDataCrudProvider.Update(IPersistentEntity entity) { var request = CreateResourceRequest((entity as IComponentReference).Id.ToString()); request.Entry = CopyEntityToAtomEntry(entity); //only get modified properties string etag = ""; _eTagCache.TryGetValue(entity, out etag); request.Entry.SetSDataHttpIfMatch(etag); request.Update(); }
/// <summary> /// Load a generic file part by it's id. /// </summary> /// <returns>Null if not found</returns> Stream IPackage.GetGenericPart(IPersistentEntity entity, string id) { var uri = CreateGenericPartUri(entity, id); byte[] data; if (parts.TryGetValue(uri, out data)) { return(new MemoryStream(data)); } return(null); }
/// <summary> /// Compare the last modification of this entity (from the import source) with the given entity found in /// the target package. /// </summary> /// <param name="target">The equal entity in the target package. Can be null.</param> protected ImportComparison CompareTo(IPersistentEntity target) { if (target == null) { return(ImportComparison.TargetDoesNotExists); } IPersistentEntity source = this; return((source.LastModifiedUtc >= target.LastModifiedUtc) ? ImportComparison.SourceInNewer : ImportComparison.TargetIsNewer); }
/// <summary> /// The given entity is removed from the package. /// </summary> protected override void RemovedFromPackage(IPersistentEntity entity) { base.RemovedFromPackage(entity); blocks.RemovedFromPackage(entity); junctions.RemovedFromPackage(entity); routes.RemovedFromPackage(entity); edges.RemovedFromPackage(entity); sensors.RemovedFromPackage(entity); signals.RemovedFromPackage(entity); outputs.RemovedFromPackage(entity); }
/// <summary> /// Remove this connection is one of the modules is removed. /// </summary> protected override void RemovedFromPackage(IPersistentEntity entity) { base.RemovedFromPackage(entity); IModuleConnection conn = this; if ((entity == conn.ModuleA) || (entity == conn.ModuleB)) { Railway.ModuleConnections.Remove(this); } }
/// <summary> /// Handles the OnCurrentEntitySet event of the BindingSource control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void BindingSource_IntOnCurrentEntitySet(object sender, EventArgs e) { _parentEntity = GetParentEntity() as IPersistentEntity; _task = BindingSource.Current as ICampaignTask; if (DialogService.DialogParameters.Count > 0) { object mode; if (DialogService.DialogParameters.TryGetValue("Mode", out mode)) _mode = mode.ToString(); } LoadView(); }
public void Save(IPersistentEntity entity) { ISDataCrudProvider crudProvider = GetCrudProvider(entity); if ((entity.PersistentState & PersistentState.New) == PersistentState.New) { crudProvider.Insert(entity); } else if ((entity.PersistentState & PersistentState.Modified) == PersistentState.Modified) { crudProvider.Update(entity); } }
/// <summary> /// Remove the given entity from this package /// </summary> void IPackage.Remove(IPersistentEntity entity) { var uri = CreatePartUri(((PersistentEntity)entity).PackageFolder, entity.Id); loadedEntities.Remove(uri); parts.Remove(uri); ((PersistentEntity)entity).Package = null; OnModified(); // Notify all listeners foreach (var iterator in loadedEntities.Values.Cast <IPackageListener>()) { iterator.RemovedFromPackage(entity); } }
/// <summary> /// Handles the OnCurrentEntitySet event of the BindingSource control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void BindingSource_IntOnCurrentEntitySet(object sender, EventArgs e) { _parentEntity = GetParentEntity() as IPersistentEntity; _task = BindingSource.Current as ICampaignTask; if (DialogService.DialogParameters.Count > 0) { object mode; if (DialogService.DialogParameters.TryGetValue("Mode", out mode)) { _mode = mode.ToString(); } } LoadView(); }
/// <summary> /// Connect this property to its context /// </summary> public void SetContext(IPackage package, IPersistentEntity entity) { this.package = package; this.entity = entity; if ((package != null) && (entity != null)) { if (data != null) { // We have cached data, store it package.SetGenericPart(entity, id, new MemoryStream(data)); data = null; id = null; } } }
/// <summary> /// Called when [form bound]. /// </summary> protected override void OnFormBound() { base.OnFormBound(); _parentEntity = GetParentEntity() as IPersistentEntity; _stage = (ICampaignStage)BindingSource.Current; if (DialogService.DialogParameters.Count > 0) { object mode; if (DialogService.DialogParameters.TryGetValue("Mode", out mode)) { _mode = mode.ToString(); } } LoadView(); }
private bool CanChangeAddress() { IPersistentEntity parentEntity = GetParentEntity() as IPersistentEntity; if (parentEntity.PersistentState == PersistentState.Modified) { if (DialogService != null) { string msg = GetLocalResourceObject("SaveChanges").ToString(); DialogService.SetSpecs(100, 100, 25, 100, ""); DialogService.ShowMessage(msg); } return(false); } return(true); }
private void SetEntityProperty(PropertyInfo prop, SDataPayload payload, IPersistentEntity entity) { if (!prop.CanWrite) { return; } if (prop.PropertyType.FullName.StartsWith("Sage.Entity.Interfaces") || prop.PropertyType.FullName.StartsWith("ICollection")) { return; } if (!payload.Values.ContainsKey(prop.Name) || payload.Values[prop.Name] == null) { return; } object convertedValue; if (prop.PropertyType == typeof(bool) || prop.PropertyType == typeof(Nullable <bool>)) { convertedValue = Convert.ToBoolean(payload.Values[prop.Name]); } else if (prop.PropertyType == typeof(DateTime) || prop.PropertyType == typeof(Nullable <DateTime>)) { convertedValue = Convert.ToDateTime(payload.Values[prop.Name]); } else if (prop.PropertyType.IsAssignableFrom(typeof(int))) { convertedValue = Convert.ToInt32(payload.Values[prop.Name]); } else if (prop.PropertyType.IsAssignableFrom(typeof(decimal))) { convertedValue = Convert.ToDecimal(payload.Values[prop.Name]); } else if (prop.PropertyType.IsAssignableFrom(typeof(double))) { convertedValue = Convert.ToDouble(payload.Values[prop.Name]); } else { convertedValue = Convert.ChangeType(payload.Values[prop.Name], prop.PropertyType); } prop.SetValue(entity, convertedValue, null); }
/// <summary> /// Called when [form bound]. /// </summary> protected override void OnFormBound() { base.OnFormBound(); ClientBindingMgr.RegisterDialogCancelButton(cmdCancel); this._parentEntity = GetParentEntity() as Sage.Platform.Orm.Interfaces.IPersistentEntity; this._parentEntityReference = this._parentEntity as Sage.Platform.ComponentModel.IComponentReference; _stage = (ICampaignStage)this.BindingSource.Current; if (DialogService.DialogParameters.Count > 0) { object mode; if (DialogService.DialogParameters.TryGetValue("Mode", out mode)) { _mode = mode.ToString(); } } LoadView(); }
/// <summary> /// Handles the OnClick event of the btnNext control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnNext_OnClick(object sender, EventArgs e) { ContextService.RemoveContext("MergeContactAddressStateInfo"); SessionMergeArguments.MergeProvider.AssignMatchedChildren(SessionMergeArguments.MatchingRecordView); if (Sage.SalesLogix.BusinessRules.BusinessRuleHelper.MergeRecords(SessionMergeArguments)) { using (new Sage.Platform.Orm.SessionScopeWrapper(true)) { Type type = SessionMergeArguments.MergeProvider.Target.EntityType; string entityId = SessionMergeArguments.MergeProvider.Source.EntityId; IPersistentEntity source = EntityFactory.GetById(type, entityId) as IPersistentEntity; source.Delete(); EntityService.RemoveEntityHistory(type, source); Response.Redirect(String.Format("{0}.aspx", GetEntityName(type))); } } }
/// <summary> /// Handles the ClickAction event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnSave_ClickAction(object sender, EventArgs e) { IPersistentEntity persistentEntity = this.BindingSource.Current as IPersistentEntity; this._parentEntity = GetParentEntity() as IPersistentEntity; this._parentEntityReference = this._parentEntity as IComponentReference; if (persistentEntity != null) { IAddress address = (IAddress)this.BindingSource.Current; if (Mode.Value == "ADD") { persistentEntity.Save(); } if (Mode.Value == "UPDATE") { if (((this._parentEntityReference as IContact) != null) || ((this._parentEntityReference as IAccount) != null)) { if (txtUpdateEntityResult.Value == "True") { Sage.SalesLogix.Address.Helpers.UpdateEntityAddresses(address, this._parentEntityReference); } } persistentEntity.Save(); } } btnSave_ClickActionBRC(sender, e); }
public void Delete(IPersistentEntity entity) { }
/// <summary> /// Called when [form bound]. /// </summary> protected override void OnFormBound() { base.OnFormBound(); ClientBindingMgr.RegisterDialogCancelButton(cmdCancel); this._parentEntity = GetParentEntity() as Sage.Platform.Orm.Interfaces.IPersistentEntity; this._parentEntityReference = this._parentEntity as Sage.Platform.ComponentModel.IComponentReference; _stage = (ICampaignStage)this.BindingSource.Current; if (DialogService.DialogParameters.Count > 0) { object mode; if(DialogService.DialogParameters.TryGetValue("Mode", out mode)) { _mode = mode.ToString(); } } LoadView(); }
/// <summary> /// Handles the ClickAction event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnSave_ClickAction(object sender, EventArgs e) { try { IPersistentEntity persistentEntity = BindingSource.Current as IPersistentEntity; _parentEntity = GetParentEntity() as IPersistentEntity; _parentEntityReference = _parentEntity as IComponentReference; if (persistentEntity != null) { bool hasContactMatches = false; IAddress address = (IAddress)BindingSource.Current; if (address.EntityId == null) { address.EntityId = "123123123123"; /*HttpCookie _Latitude = Request.Cookies["Latitude"]; HttpCookie _Logitute = Request.Cookies["Logitute"]; if (_Latitude == null) { address.Latitude = "0"; address.Logitude = "0"; } else { address.Latitude = _Latitude.Value.ToString(); address.Logitude = _Logitute.Value.ToString();*/ address.Latitude = txtLatitude.Text; address.Logitude = txtLogitute.Text; // } } if (Mode.Value == "ADD") { persistentEntity.Save(); Global.ADDRESS_ID = address.Id.ToString(); } if (Mode.Value == "UPDATE") { if (address.EntityId != "123123123123") { IContact contact = _parentEntityReference as IContact; IAccount account = _parentEntityReference as IAccount; bool hasSalesOrderMatches = (Helpers.HasMatchingSalesOrderAddresses(_parentEntityReference)); if (contact != null) hasContactMatches = contact.HasAddressChanges(); else if (account != null) hasContactMatches = account.HasAddressChanges(); if ((hasContactMatches || hasSalesOrderMatches) && DialogService != null) { UpdateAddressOptionManager addressOptions = new UpdateAddressOptionManager(); addressOptions.HasContactAddressChanges = hasContactMatches; addressOptions.OldAddressValues = contact != null ? Sage.SalesLogix.Contact.Rules.getOriginalAddressValues( contact) : Sage.SalesLogix.Account.Rules.getOriginalAddressValues( account); addressOptions.HasSalesOrderAddressChanges = hasSalesOrderMatches; addressOptions.ParentEntityReference = _parentEntityReference; addressOptions.IsPrimaryAddress = (address.IsPrimary ?? false); DialogService.SetSpecs(200, 200, 200, 450, contact != null ? "UpdateContactOptions" : "UpdateAccountOptions", "", true); DialogService.EntityType = typeof(IAddress); DialogService.EntityID = address.Id.ToString(); DialogService.DialogParameters.Add("UpdateAddressOptionManager", addressOptions); DialogService.ShowDialog(); } } persistentEntity.Save(); } } UpdateFlags(); //btnSave_ClickActionBRC(sender, e); } catch (Exception ex) { } }
/// <summary> /// Handles the ClickAction event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnSave_ClickAction(object sender, EventArgs e) { IPersistentEntity persistentEntity = BindingSource.Current as IPersistentEntity; _parentEntity = GetParentEntity() as IPersistentEntity; _parentEntityReference = _parentEntity as IComponentReference; if (persistentEntity != null) { bool hasContactMatches = false; bool hasSalesOrderMatches = false; IAddress address = (IAddress)BindingSource.Current; if (Mode.Value == "ADD") persistentEntity.Save(); if (Mode.Value == "UPDATE") { IContact contact = _parentEntityReference as IContact; IAccount account = _parentEntityReference as IAccount; hasSalesOrderMatches = (Helpers.HasMatchingSalesOrderAddresses(_parentEntityReference)); if (contact != null) hasContactMatches = contact.HasAddressChanges(); else if (account != null) hasContactMatches = account.HasAddressChanges(); if ((hasContactMatches || hasSalesOrderMatches) && DialogService != null) { UpdateAddressOptionManager addressOptions = new UpdateAddressOptionManager(); addressOptions.HasContactAddressChanges = hasContactMatches; if (contact != null) addressOptions.OldAddressValues = Sage.SalesLogix.Contact.Rules.getOriginalAddressValues(contact); else addressOptions.OldAddressValues = Sage.SalesLogix.Account.Rules.getOriginalAddressValues(account); addressOptions.HasSalesOrderAddressChanges = hasSalesOrderMatches; addressOptions.ParentEntityReference = _parentEntityReference; addressOptions.IsPrimaryAddress = (address.IsPrimary.HasValue && (bool)address.IsPrimary); if (contact != null) DialogService.SetSpecs(200, 200, 200, 450, "UpdateContactOptions", "", true); else DialogService.SetSpecs(200, 200, 200, 450, "UpdateAccountOptions", "", true); DialogService.EntityType = typeof(IAddress); DialogService.EntityID = address.Id.ToString(); DialogService.DialogParameters.Add("UpdateAddressOptionManager", addressOptions); DialogService.ShowDialog(); } persistentEntity.Save(); } } btnSave_ClickActionBRC(sender, e); }
/// <summary> /// Handles the OnCurrentEntitySet event of the BindingSource control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void BindingSource_IntOnCurrentEntitySet(object sender, EventArgs e) { this._parentEntity = GetParentEntity() as Sage.Platform.Orm.Interfaces.IPersistentEntity; this._parentEntityReference = this._parentEntity as Sage.Platform.ComponentModel.IComponentReference; _task = this.BindingSource.Current as ICampaignTask; if (DialogService.DialogParameters.Count > 0) { object mode; if (DialogService.DialogParameters.TryGetValue("Mode", out mode)) { _mode = mode.ToString(); } } LoadView(); }
/// <summary> /// Called when the smartpart has been bound. Derived components should override this method to run code that depends on entity context being set and it not changing. /// </summary> protected override void OnFormBound() { ClientBindingMgr.UsePageExitWarning = false; base.OnFormBound(); _parentEntity = GetParentEntity() as IPersistentEntity; _parentEntityReference = _parentEntity as IComponentReference; Sage.SalesLogix.Activity.Event slxEvent = this.BindingSource.Current as Sage.SalesLogix.Activity.Event; if (slxEvent != null) { //Delete.Visible = (slxEvent.Id != null); usrUser.Items.Clear(); foreach (var uc in Sage.SalesLogix.Activity.UserCalendar.GetCurrentUserCalendarList()) { if (uc.AllowAdd == true) { ListItem li = new ListItem(uc.UserName, uc.CalUser.Id.ToString().Trim()); usrUser.Items.Add(li); } } usrUser.SelectedValue = slxEvent.UserId; /* DateTime defaultDate; if (Request.QueryString["startdate"] != null) { defaultDate = Convert.ToDateTime(Server.UrlDecode(Request.QueryString["startdate"])); if (defaultDate != null) { DateTime startDate = new DateTime(defaultDate.Year, defaultDate.Month, defaultDate.Day, 0, 0, 5); slxEvent.StartDate = startDate; slxEvent.EndDate = startDate; } }*/ ((Sage.Platform.WebPortal.EntityPage)Page).TitleBar.Text = System.Web.HttpContext.GetLocalResourceObject(Request.CurrentExecutionFilePath, "PageTitle").ToString(); } }
/// <summary> /// Called when [form bound]. /// </summary> protected override void OnFormBound() { base.OnFormBound(); _parentEntity = GetParentEntity() as IPersistentEntity; _stage = (ICampaignStage)BindingSource.Current; if (DialogService.DialogParameters.Count > 0) { object mode; if(DialogService.DialogParameters.TryGetValue("Mode", out mode)) { _mode = mode.ToString(); } } LoadView(); }
/// <summary> /// Called when the smartpart has been bound. Derived components should override this method to run code that depends on entity context being set and it not changing. /// </summary> protected override void OnFormBound() { base.OnFormBound(); _parentEntity = GetParentEntity() as IPersistentEntity; _parentEntityReference = _parentEntity as IComponentReference; if (_parentEntityReference is IAccount) { ViewState["parentEntityID"] = _parentEntityReference.Id; ViewState["parentEntity"] = "Account"; } if (_parentEntityReference is IContact) { ViewState["parentEntityID"] = _parentEntityReference.Id; ViewState["parentEntity"] = "Contact"; } ClientBindingMgr.RegisterDialogCancelButton(btnCancel); /* string script_FormatNumber = ""; //script_FormatNumber += " function only_required(Address1,pincode,Latitude,Logitute,description,isprimary,addtype,add2,add3,city,state,country,attn) "; script_FormatNumber += " function only_required(Address1,pincode,Latitude,Logitute,add2,add3,city,state,country) "; script_FormatNumber += " {"; script_FormatNumber += " var df = true;"; script_FormatNumber += " if(Address1 == '') { df = false; }"; script_FormatNumber += " if(pincode == '') {df = false; }"; script_FormatNumber += " if(!df) {"; script_FormatNumber += " alert('Please Fill Required fields');"; script_FormatNumber += " return df;} else {"; script_FormatNumber += " var add = Address1 + ', ' + add2 + ', ' + add3 + ', ' + city + ', ' + state + ', ' + country + ', ' + pincode;"; if (ViewState["parentEntity"].ToString() == "Contact") { script_FormatNumber += " document.getElementById('MainContent_InsertContact_txtAccountAddress').value = add;"; } else { script_FormatNumber += " document.getElementById('MainContent_InsertAccount_txtAccountAddress').value = add;"; } script_FormatNumber += " return df;"; // script_FormatNumber += " { document.getElementById('MainContent_InsertContact_txtAccountAddress').value = Address1 + pincode + Latitude + Logitute;"; script_FormatNumber += " }}"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Validate", script_FormatNumber, true); // btnSave.Attributes.Add("onclick", "return only_required(document.getElementById('" + txtAddress1.ClientID + "').value,document.getElementById('" + txtPostalCode.ClientID + "').value,document.getElementById('" + txtLatitude.ClientID + "').value,document.getElementById('" + txtLogitute.ClientID + "').value,document.getElementById('" + txtAddress2.ClientID + "').value,document.getElementById('" + txtAddress3.ClientID + "').value,document.getElementById('" + pklCity.ClientID + "').value,document.getElementById('" + pklState.ClientID + "').value,document.getElementById('" + pklCountry.ClientID + "').value);"); btnSave.Attributes.Add("onclick", "return only_required(document.getElementById('" + txtAddress1.ClientID + "').value,document.getElementById('" + txtPostalCode.ClientID + "').value,document.getElementById('" + txtLatitude.ClientID + "').value,document.getElementById('" + txtLogitute.ClientID + "').value,document.getElementById('" + txtAddress2.ClientID + "').value,document.getElementById('" + txtAddress3.ClientID + "').value,document.getElementById('" + pklCity.ClientID + "_Text').value,document.getElementById('" + pklState.ClientID + "_Text').value,document.getElementById('" + pklCountry.ClientID + "_Text').value);"); if (Session["Addressid"] != null) { string _idname = Session["Addressid"].ToString(); string[] parts = _idname.Split(','); _id = parts[0].ToString(); IAddress curAdd = this.BindingSource.Current as IAddress; Sage.Entity.Interfaces.IAddress objadd = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.IAddress>(_id); if (objadd != null && curAdd.Address1 == null) { curAdd.Address1 = objadd.Address1; curAdd.Address2 = objadd.Address2; curAdd.Address3 = objadd.Address3; curAdd.AddressType = objadd.AddressType; curAdd.City = objadd.City; curAdd.Country = objadd.Country; curAdd.IsPrimary = objadd.IsPrimary; curAdd.Latitude = objadd.Latitude != null ? objadd.Latitude : 0; curAdd.Logitude = objadd.Logitude != null ? objadd.Logitude : 0; curAdd.PostalCode = objadd.PostalCode; curAdd.Salutation = objadd.Salutation; curAdd.State = objadd.State; curAdd.Description = objadd.Description; } } */ }