/// <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); }
/// <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); }
private string GetId(object value) { IComponentReference compRef = value as IComponentReference; if (compRef != null) { return(compRef.Id.ToString()); } return(string.Empty); }
/// <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(); }
private bool CanChangeAddress() { IPersistentEntity parentEntity = GetParentEntity() as IPersistentEntity; IComponentReference parentEntityReference = parentEntity as IComponentReference; 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); }
/// <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> /// 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> /// 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 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() { 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; } } */ }
/// <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 = 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); }