I must to insert records in DETAILVIEWS or DETAILVIEWS_FIELDS tables????
Another question....
I must to create the SP in the SqlProcs class
but Can you tell me if the code below it's OK? (I've modified it)
Accounts.ascx.cs
/********************************************************************************************************************** * The contents of this file are subject to the SugarCRM Public License Version 1.1.3 ("License"); You may not use this * file except in compliance with the License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the License for the specific language governing rights and limitations under the License. * * All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * (iii) the SplendidCRM copyright notice * in the same form as they appear in the distribution. See full license for requirements. * * The Original Code is: SplendidCRM Open Source * The Initial Developer of the Original Code is SplendidCRM Software, Inc. * Portions created by SplendidCRM Software are Copyright (C) 2005 SplendidCRM Software, Inc. All Rights Reserved. * Contributor(s): ______________________________________. *********************************************************************************************************************/using System;using System.Data;using System.Data.Common;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using System.Diagnostics;//using Microsoft.VisualBasic;
namespace SplendidCRM.Campaigns{ /// <summary> /// Summary description for ProspectLists. /// </summary> public class Accounts : SplendidControl { protected Guid gID ; protected DataView vwMain ; protected SplendidGrid grdMain ; protected Label lblError ; protected HtmlInputHidden txtACCOUNT_ID;
protected void Page_Command(object sender, CommandEventArgs e) { try { switch ( e.CommandName ) { case "Accounts.Create": Response.Redirect("~/ProspectLists/edit.aspx?PARENT_ID=" + gID.ToString()); break; case "Accounts.Edit": { Guid gACCOUNT_ID = Sql.ToGuid(e.CommandArgument); Response.Redirect("~/ProspectLists/edit.aspx?ID=" + gACCOUNT_ID.ToString()); break; } case "Accounts.Remove": { Guid gACCOUNT_ID = Sql.ToGuid(e.CommandArgument); SqlProcs.spPROSPECT_LIST_CAMPAIGNS_Delete(gACCOUNT_ID, gID); Response.Redirect("view.aspx?ID=" + gID.ToString()); break; } default: throw(new Exception("Unknown command: " + e.CommandName)); } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { gID = Sql.ToGuid(Request["ID"]); Guid gACCOUNT_ID = Sql.ToGuid(txtACCOUNT_ID.Value); if ( !Sql.IsEmptyGuid(gACCOUNT_ID) ) { try { SqlProcs.spPROSPECT_LIST_CAMPAIGNS_Update(gACCOUNT_ID, gID); Response.Redirect("view.aspx?ID=" + gID.ToString()); } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwCAMPAIGNS_PROSPECT_LISTS" + ControlChars.CrLf + " where CAMPAIGN_ID = @CAMPAIGN_ID" + ControlChars.CrLf + " order by DATE_ENTERED asc " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@CAMPAIGN_ID", gID);
if ( bDebug ) RegisterClientScriptBlock("vwCAMPAIGNS_PROSPECT_LISTS", Sql.ClientScriptBlock(cmd));
try { using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; using ( DataTable dt = new DataTable() ) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain ; // 09/05/2005 Paul. LinkButton controls will not fire an event unless the the grid is bound. //if ( !IsPostBack ) { grdMain.ApplySort(); grdMain.DataBind(); } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } } if ( !IsPostBack ) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); // 11/26/2005 Paul. Add fields early so that sort events will get called. grdMain.DynamicColumns("Campaigns.Accounts"); } #endregion }}
Accounts.ascx
<%@ Control CodeBehind="Accounts.ascx.cs" Language="c#" AutoEventWireup="false" Inherits="SplendidCRM.Campaigns.Accounts" %><%/********************************************************************************************************************** * The contents of this file are subject to the SugarCRM Public License Version 1.1.3 ("License"); You may not use this * file except in compliance with the License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the License for the specific language governing rights and limitations under the License. * * All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * (iii) the SplendidCRM copyright notice * in the same form as they appear in the distribution. See full license for requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2005 SugarCRM, Inc. All Rights Reserved. * Portions created by SplendidCRM Software are Copyright (C) 2005 SplendidCRM Software, Inc. All Rights Reserved. * Contributor(s): ______________________________________. *********************************************************************************************************************/%><script type="text/javascript">function ChangeProspectList(sPARENT_ID, sPARENT_NAME){ document.getElementById('<%= txtACCOUNT_ID.ClientID %>').value = sPARENT_ID ; document.forms[0].submit();}function ProspectListPopup(){ return window.open('../ProspectLists/Popup.aspx?ClearDisabled=1','ProspectListPopup','width=600,height=400,resizable=1,scrollbars=1');}</script><div id="divCampaignsAccounts"> <input ID="txtACCOUNT_ID" type="hidden" Runat="server" /> <br> <%@ Register TagPrefix="SplendidCRM" Tagname="ListHeader" Src="~/_controls/ListHeader.ascx" %> <SplendidCRM:ListHeader Title="Accounts.LBL_MODULE_NAME" Runat="Server" /> <table width="100%" border="0" cellpadding="0" cellspacing="0" Visible="<%# !PrintView %>" runat="server"> <tr> <td style="padding-bottom: 2px;"> <asp:Button Visible='<%# SplendidCRM.Security.GetUserAccess("Accounts", "edit") >= 0 %>' CommandName="Accounts.Create" OnCommand="Page_Command" CssClass="button" Text='<%# " " + L10n.Term(".LBL_NEW_BUTTON_LABEL" ) + " " %>' title='<%# L10n.Term(".LBL_NEW_BUTTON_TITLE" ) %>' AccessKey='<%# L10n.AccessKey(".LBL_NEW_BUTTON_KEY" ) %>' Runat="server" /> <input type="button" class="button" onclick="return ProspectListPopup();" title="<%# L10n.Term(".LBL_SELECT_BUTTON_TITLE") %>" accessKey="<%# L10n.Term(".LBL_SELECT_BUTTON_KEY") %>" value="<%# L10n.Term(".LBL_SELECT_BUTTON_LABEL") %>" /> <asp:Label ID="lblError" ForeColor="Red" EnableViewState="false" Runat="server" /> </td> </tr> </table>
<SplendidCRM:SplendidGrid id="grdMain" Width="100%" CssClass="listView" CellPadding="3" CellSpacing="0" border="0" AllowPaging="false" PageSize="20" AllowSorting="false" AutoGenerateColumns="false" EnableViewState="true" runat="server"> <ItemStyle CssClass="oddListRowS1" /> <AlternatingItemStyle CssClass="evenListRowS1" /> <HeaderStyle CssClass="listViewThS1" /> <PagerStyle HorizontalAlign="Right" Mode="NextPrev" PageButtonCount="6" Position="Top" CssClass="listViewPaginationTdS1" PrevPageText=".LNK_LIST_PREVIOUS" NextPageText=".LNK_LIST_NEXT" /> <Columns> <asp:TemplateColumn HeaderText="" ItemStyle-Width="1%" ItemStyle-HorizontalAlign="Left" ItemStyle-Wrap="false"> <ItemTemplate> <asp:ImageButton Visible='<%# SplendidCRM.Security.GetUserAccess("Accounts", "edit", Sql.ToGuid(DataBinder.Eval(Container.DataItem, "ASSIGNED_USER_ID"))) >= 0 %>' CommandName="Accounts.Edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ACCOUNT_ID") %>' OnCommand="Page_Command" CssClass="listViewTdToolsS1" AlternateText='<%# L10n.Term(".LNK_EDIT") %>' ImageUrl='<%# Session["themeURL"] + "images/edit_inline.gif" %>' BorderWidth="0" Width="12" Height="12" ImageAlign="AbsMiddle" Runat="server" /> <asp:LinkButton Visible='<%# SplendidCRM.Security.GetUserAccess("Accounts", "edit", Sql.ToGuid(DataBinder.Eval(Container.DataItem, "ASSIGNED_USER_ID"))) >= 0 %>' CommandName="Accounts.Edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ACCOUNT_ID") %>' OnCommand="Page_Command" CssClass="listViewTdToolsS1" Text='<%# L10n.Term(".LNK_EDIT") %>' Runat="server" /> <span onclick="return confirm('<%= L10n.TermJavaScript("Accounts.PROSPECT_REMOVE_PROSPECT_LISTS_CONFIRM") %>')"> <asp:ImageButton Visible='<%# SplendidCRM.Security.GetUserAccess("Campaigns", "edit", Sql.ToGuid(DataBinder.Eval(Container.DataItem, "CAMPAIGN_ASSIGNED_USER_ID"))) >= 0 %>' CommandName="Accounts.Remove" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ACCOUNT_ID") %>' OnCommand="Page_Command" CssClass="listViewTdToolsS1" AlternateText='<%# L10n.Term(".LNK_REMOVE") %>' ImageUrl='<%# Session["themeURL"] + "images/delete_inline.gif" %>' BorderWidth="0" Width="12" Height="12" ImageAlign="AbsMiddle" Runat="server" /> <asp:LinkButton Visible='<%# SplendidCRM.Security.GetUserAccess("Campaigns", "edit", Sql.ToGuid(DataBinder.Eval(Container.DataItem, "CAMPAIGN_ASSIGNED_USER_ID"))) >= 0 %>' CommandName="Accounts.Remove" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ACCOUNT_ID") %>' OnCommand="Page_Command" CssClass="listViewTdToolsS1" Text='<%# L10n.Term(".LNK_REMOVE") %>' Runat="server" /> </span> </ItemTemplate> </asp:TemplateColumn> </Columns> </SplendidCRM:SplendidGrid></div>
I still see references to ProspectLists and PROSPECT_LISTS. A simply replace all should take care of them.
Oky!!But my chages are OK?????? I would like to know if the changes that I'm doing are right...
antoher question
I haven't to inserted records in DETAILVIEWS or DETAILVIEWS_FIELDS ... It's OK?
Can you be more specific on what things you have changed? I usually use version control to determine what has changed. It is hard to do the same reading text in a forum.
You need to insert records in the GRIDVIEWS_COLUMNS table. These are the columns that will be displayed.
I've changed.... I want to add the accounts in the ProspectList page (Target List area)In the targetlist tab I've inserted an accounts list that allow the user to add new accountI see the list, when I click on the "select" button, the Accounts\PopupMultiSelect.aspx opens the popup but when I select an account I obtain:
Original window has closed. Account cannot be assigned... [guid] [MyAccountName]
Why???
This is my code..... (the pages that I've created)
ProspectLists\Accounts.ascx
<%@ Control CodeBehind="Accounts.ascx.cs" Language="c#" AutoEventWireup="false" Inherits="SplendidCRM.ProspectLists.Accounts" %>
<script type="text/javascript">function ChangeContact(sPARENT_ID, sPARENT_NAME){ document.getElementById('<%= txtACCOUNT_ID.ClientID %>').value = sPARENT_ID ; document.forms[0].submit();}function AccountPopup(){ return window.open('../Accounts/PopupMultiSelect.aspx?ClearDisabled=1','AccountPopup','width=600,height=400,resizable=1,scrollbars=1');}</script><div id="divProspectListsContacts"> <input ID="txtACCOUNT_ID" type="hidden" Runat="server" /> <br> <%@ Register TagPrefix="SplendidCRM" Tagname="ListHeader" Src="~/_controls/ListHeader.ascx" %> <SplendidCRM:ListHeader Title="Accounts.LBL_MODULE_NAME" Runat="Server" /> <table width="100%" border="0" cellpadding="0" cellspacing="0" Visible="<%# !PrintView %>" runat="server"> <tr> <td style="padding-bottom: 2px;"> <input type="button" class="button" onclick="return AccountPopup();" title="<%# L10n.Term(".LBL_SELECT_BUTTON_TITLE") %>" accessKey="<%# L10n.Term(".LBL_SELECT_BUTTON_KEY") %>" value="<%# L10n.Term(".LBL_SELECT_BUTTON_LABEL") %>" /> <asp:Label ID="lblError" ForeColor="Red" EnableViewState="false" Runat="server" /> </td> </tr> </table>
<SplendidCRM:SplendidGrid id="grdMain" Width="100%" CssClass="listView" CellPadding="3" CellSpacing="0" border="0" AllowPaging="false" PageSize="20" AllowSorting="false" AutoGenerateColumns="false" EnableViewState="true" runat="server"> <ItemStyle CssClass="oddListRowS1" /> <AlternatingItemStyle CssClass="evenListRowS1" /> <HeaderStyle CssClass="listViewThS1" /> <PagerStyle HorizontalAlign="Right" Mode="NextPrev" PageButtonCount="6" Position="Top" CssClass="listViewPaginationTdS1" PrevPageText=".LNK_LIST_PREVIOUS" NextPageText=".LNK_LIST_NEXT" /> <Columns> <asp:TemplateColumn HeaderText="" ItemStyle-Width="1%" ItemStyle-HorizontalAlign="Left" ItemStyle-Wrap="false"> <ItemTemplate> <asp:ImageButton Visible='<%# SplendidCRM.Security.GetUserAccess("Contacts", "edit", Sql.ToGuid(DataBinder.Eval(Container.DataItem, "ASSIGNED_USER_ID"))) >= 0 %>' CommandName="Contacts.Edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ACCOUNT_ID") %>' OnCommand="Page_Command" CssClass="listViewTdToolsS1" AlternateText='<%# L10n.Term(".LNK_EDIT") %>' ImageUrl='<%# Session["themeURL"] + "images/edit_inline.gif" %>' BorderWidth="0" Width="12" Height="12" ImageAlign="AbsMiddle" Runat="server" /> <asp:LinkButton Visible='<%# SplendidCRM.Security.GetUserAccess("Contacts", "edit", Sql.ToGuid(DataBinder.Eval(Container.DataItem, "ASSIGNED_USER_ID"))) >= 0 %>' CommandName="Contacts.Edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ACCOUNT_ID") %>' OnCommand="Page_Command" CssClass="listViewTdToolsS1" Text='<%# L10n.Term(".LNK_EDIT") %>' Runat="server" /> <span onclick="return confirm('<%= L10n.TermJavaScript("ProspectLists.CONTACT_REMOVE_PROSPECT_LISTS_CONFIRM") %>')"> <asp:ImageButton Visible='<%# SplendidCRM.Security.GetUserAccess("ProspectLists", "edit", Sql.ToGuid(DataBinder.Eval(Container.DataItem, "PROSPECT_ASSIGNED_USER_ID"))) >= 0 %>' CommandName="Contacts.Remove" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ACCOUNT_ID") %>' OnCommand="Page_Command" CssClass="listViewTdToolsS1" AlternateText='<%# L10n.Term(".LNK_REMOVE") %>' ImageUrl='<%# Session["themeURL"] + "images/delete_inline.gif" %>' BorderWidth="0" Width="12" Height="12" ImageAlign="AbsMiddle" Runat="server" /> <asp:LinkButton Visible='<%# SplendidCRM.Security.GetUserAccess("ProspectLists", "edit", Sql.ToGuid(DataBinder.Eval(Container.DataItem, "PROSPECT_ASSIGNED_USER_ID"))) >= 0 %>' CommandName="Contacts.Remove" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ACCOUNT_ID") %>' OnCommand="Page_Command" CssClass="listViewTdToolsS1" Text='<%# L10n.Term(".LNK_REMOVE") %>' Runat="server" /> </span> </ItemTemplate> </asp:TemplateColumn> </Columns> </SplendidCRM:SplendidGrid></div>
ProspectLists/Accounts.ascx.cs
using System;using System.Data;using System.Data.Common;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using System.Diagnostics;//using Microsoft.VisualBasic;
namespace SplendidCRM.ProspectLists{ /// <summary> /// Summary description for Contacts. /// </summary> public class Accounts : SplendidControl { protected Guid gID ; protected DataView vwMain ; protected SplendidGrid grdMain ; protected Label lblError ; protected HtmlInputHidden txtACCOUNT_ID ;
protected void Page_Command(object sender, CommandEventArgs e) { try { switch ( e.CommandName ) { case "Contacts.Create": Response.Redirect("~/Accounts/edit.aspx?PARENT_ID=" + gID.ToString()); break; case "Contacts.Edit": { Guid gACCOUNT_ID = Sql.ToGuid(e.CommandArgument); Response.Redirect("~/Accounts/edit.aspx?ID=" + gACCOUNT_ID.ToString()); break; } case "Contacts.Remove": { Guid gACCOUNT_ID = Sql.ToGuid(e.CommandArgument); SqlProcs.spPROSPECT_LISTS_CONTACTS_Delete(gID, gACCOUNT_ID); Response.Redirect("view.aspx?ID=" + gID.ToString()); break; } default: throw(new Exception("Unknown command: " + e.CommandName)); } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { gID = Sql.ToGuid(Request["ID"]); if ( !Sql.IsEmptyString(txtACCOUNT_ID.Value) ) { try { // 10/04/2006 Paul. ValidateIDs can throw an exception. string[] arrID = txtACCOUNT_ID.Value.Split(','); string sIDs = Utils.ValidateIDs(arrID); if ( !Sql.IsEmptyString(sIDs) ) { SqlProcs.spPROSPECT_LISTS_CONTACTS_MassUpdate(sIDs, gID); Response.Redirect("view.aspx?ID=" + gID.ToString()); } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwPROSPECT_LISTS_ACCOUNTS " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; // 11/27/2006 Paul. Make sure to filter relationship data based on team access rights. Security.Filter(cmd, m_sMODULE, "list"); cmd.CommandText += " and PROSPECT_LIST_ID = @PROSPECT_LIST_ID" + ControlChars.CrLf; cmd.CommandText += " order by DATE_ENTERED asc " + ControlChars.CrLf; Sql.AddParameter(cmd, "@PROSPECT_LIST_ID", gID);
if ( bDebug ) RegisterClientScriptBlock("vwPROSPECT_LISTS_ACCOUNTS", Sql.ClientScriptBlock(cmd));
try { using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; using ( DataTable dt = new DataTable() ) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain ; // 09/05/2005 Paul. LinkButton controls will not fire an event unless the the grid is bound. //if ( !IsPostBack ) { grdMain.DataBind(); } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } } if ( !IsPostBack ) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); m_sMODULE = "Accounts"; // 11/26/2005 Paul. Add fields early so that sort events will get called. grdMain.DynamicColumns("ProspectLists.Accounts"); } #endregion }}
Another problem .... where Can I find the code that uses che stored procedude for save the accounts in the PROSPECT_LISTS_PROSPECTS?
in the PROSPECT_LISTS_PROSPECTS I Will insert Accounts and Contacts usando Related_type as Contact or Accounts
Thanks for help me!! I hope to resolve this problem!