コード例 #1
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         // 12/14/2007 Paul.  We need to capture the sort event from the SearchView.
         else if (e.CommandName == "SortGrid")
         {
             grdMain.SetSortFields(e.CommandArgument as string[]);
         }
         else if (e.CommandName == "Create")
         {
             Response.Redirect("PopupEdit.aspx?CAMPAIGN_ID=" + Sql.ToString(Request["CAMPAIGN_ID"]));
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #2
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "AdvancedSearch")
         {
             Response.Redirect("default.aspx?Advanced=1");
         }
         else if (e.CommandName == "BasicSearch")
         {
             Response.Redirect("default.aspx?Advanced=0");
         }
         else if (e.CommandName == "Clear")
         {
             ctlSearch.ClearForm();
             Server.Transfer("default.aspx?Advanced=" + nAdvanced.ToString());
         }
         else if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
         lblError.Text = ex.Message;
     }
 }
コード例 #3
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "InboundEmail.Delete")
         {
             Guid gID = Sql.ToGuid(e.CommandArgument);
             SqlProcs.spACL_ROLES_Delete(gID);
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
             Response.Redirect("default.aspx");
         }
         else if (e.CommandName == "MassDelete")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     SqlProcs.spACL_ROLES_MassDelete(sIDs);
                     Response.Redirect("default.aspx");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #4
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "AdvancedSearch")
         {
             Response.Redirect("default.aspx?Advanced=1");
         }
         else if (e.CommandName == "BasicSearch")
         {
             Response.Redirect("default.aspx?Advanced=0");
         }
         else if (e.CommandName == "Clear")
         {
             ctlSearch.ClearForm();
             Server.Transfer("default.aspx?Advanced=" + nAdvanced.ToString());
         }
         else if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         else if (e.CommandName == "MassUpdate")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 sIDs = Utils.FilterByACL(m_sMODULE, "edit", arrID, "CAMPAIGNS");
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     // 07/09/2006 Paul.  The date conversion was moved out of the MassUpdate control.
                     SqlProcs.spCAMPAIGNS_MassUpdate(sIDs, ctlMassUpdate.ASSIGNED_USER_ID, T10n.ToServerTime(ctlMassUpdate.START_DATE), T10n.ToServerTime(ctlMassUpdate.END_DATE), ctlMassUpdate.STATUS, ctlMassUpdate.CAMPAIGN_TYPE);
                     Response.Redirect("default.aspx");
                 }
             }
         }
         else if (e.CommandName == "MassDelete")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 sIDs = Utils.FilterByACL(m_sMODULE, "delete", arrID, "CAMPAIGNS");
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     SqlProcs.spCAMPAIGNS_MassDelete(sIDs);
                     Response.Redirect("default.aspx");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
         lblError.Text = ex.Message;
     }
 }
コード例 #5
0
		protected void Page_Command(object sender, CommandEventArgs e)
		{
			try
			{
				switch ( e.CommandName )
				{
					case "Search":
						grdMain.ApplySort();
						grdMain.DataBind();
						break;
					case "Feeds.Add":
					{
						Guid gFEED_ID = Sql.ToGuid(e.CommandArgument);
						SqlProcs.spUSERS_FEEDS_Update(Security.USER_ID, gFEED_ID, 0);
						Response.Redirect("default.aspx");
						break;
					}
					case "Feeds.Delete":
					{
						Guid gFEED_ID = Sql.ToGuid(e.CommandArgument);
						SqlProcs.spUSERS_FEEDS_Delete(Security.USER_ID, gFEED_ID);
						Response.Redirect("default.aspx");
						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;
			}
		}
コード例 #6
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         // 12/14/2007 Paul.  We need to capture the sort event from the SearchView.
         else if (e.CommandName == "SortGrid")
         {
             grdMain.SetSortFields(e.CommandArgument as string[]);
         }
         else if (e.CommandName == "Export")
         {
             // 11/03/2006 Paul.  Apply ACL rules to Export.
             int nACLACCESS = SplendidCRM.Security.GetUserAccess(m_sMODULE, "export");
             if (nACLACCESS >= 0)
             {
                 string[] arrID = Request.Form.GetValues("chkMain");
                 SplendidExport.Export(vwMain, m_sMODULE, ctlExportHeader.ExportFormat, ctlExportHeader.ExportRange, grdMain.CurrentPageIndex, grdMain.PageSize, arrID);
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #7
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         // 12/14/2007 Paul.  We need to capture the sort event from the SearchView.
         else if (e.CommandName == "SortGrid")
         {
             grdMain.SetSortFields(e.CommandArgument as string[]);
         }
         else if (e.CommandName == "Preview.Production")
         {
             ViewState["TEST"] = false;
             CAMPAIGNS_BindData(true);
         }
         else if (e.CommandName == "Preview.Test")
         {
             ViewState["TEST"] = true;
             CAMPAIGNS_BindData(true);
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #8
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         // 12/14/2007 Paul.  We need to capture the sort event from the SearchView.
         else if (e.CommandName == "SortGrid")
         {
             grdMain.SetSortFields(e.CommandArgument as string[]);
         }
         else if (e.CommandName == "MassDelete")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 // 10/26/2007 Paul.  Use a stack to run the update in blocks of under 200 IDs.
                 //string sIDs = Utils.ValidateIDs(arrID);
                 System.Collections.Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "delete", arrID, "EMAIL_TEMPLATES");
                 if (stk.Count > 0)
                 {
                     DbProviderFactory dbf = DbProviderFactories.GetFactory();
                     using (IDbConnection con = dbf.CreateConnection())
                     {
                         con.Open();
                         using (IDbTransaction trn = con.BeginTransaction())
                         {
                             try
                             {
                                 while (stk.Count > 0)
                                 {
                                     string sIDs = Utils.BuildMassIDs(stk);
                                     SqlProcs.spEMAIL_TEMPLATES_MassDelete(sIDs, trn);
                                 }
                                 trn.Commit();
                             }
                             catch (Exception ex)
                             {
                                 trn.Rollback();
                                 throw(new Exception(ex.Message, ex.InnerException));
                             }
                         }
                     }
                     Response.Redirect("default.aspx");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #9
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Clear")
         {
             ctlSearch.ClearForm();
             Server.Transfer("default.aspx");
         }
         else if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         else if (e.CommandName == "ACLRole.MakeDefault")
         {
             // 08/08/2006 Paul.  Update the config value.
             string sNAME     = "default_role";
             string sCATEGORY = "system";
             string sVALUE    = Sql.ToString(e.CommandArgument);
             SqlProcs.spCONFIG_Update(sCATEGORY, sNAME, sVALUE);
             Application["CONFIG." + sNAME] = sVALUE;
             Response.Redirect("default.aspx");
         }
         else if (e.CommandName == "ACLRole.Delete")
         {
             Guid gID = Sql.ToGuid(e.CommandArgument);
             SqlProcs.spACL_ROLES_Delete(gID);
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
             Response.Redirect("default.aspx");
         }
         else if (e.CommandName == "MassDelete")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     SqlProcs.spACL_ROLES_MassDelete(sIDs);
                     Response.Redirect("default.aspx");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #10
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Clear")
         {
             ctlSearch.ClearForm();
             Server.Transfer("default.aspx?Advanced=" + nAdvanced.ToString());
         }
         else if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         else if (e.CommandName == "MassUpdate")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 sIDs = Utils.FilterByACL(m_sMODULE, "edit", arrID, "NOTES");
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     SqlProcs.spNOTES_MassUpdate(sIDs, ctlMassUpdate.PARENT_TYPE, ctlMassUpdate.PARENT_ID, ctlMassUpdate.CONTACT_ID);
                     Response.Redirect("default.aspx");
                 }
             }
         }
         else if (e.CommandName == "MassDelete")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 sIDs = Utils.FilterByACL(m_sMODULE, "delete", arrID, "NOTES");
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     SqlProcs.spNOTES_MassDelete(sIDs);
                     Response.Redirect("default.aspx");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
         lblError.Text = ex.Message;
     }
 }
コード例 #11
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Clear")
         {
             Server.Transfer("default.aspx");
         }
         else if (e.CommandName == "TeamNotices.Delete")
         {
             Guid gID = Sql.ToGuid(e.CommandArgument);
             SqlProcs.spTEAM_NOTICES_Delete(gID);
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
             Response.Redirect("default.aspx");
         }
         else if (e.CommandName == "MassUpdate")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     SqlProcs.spTEAM_NOTICES_MassUpdate(sIDs, T10n.ToServerTime(ctlMassUpdate.DATE_START), T10n.ToServerTime(ctlMassUpdate.DATE_END));
                     Response.Redirect("default.aspx");
                 }
             }
         }
         else if (e.CommandName == "MassDelete")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     SqlProcs.spTEAM_NOTICES_MassDelete(sIDs);
                     Response.Redirect("default.aspx");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #12
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Clear")
         {
             ctlSearch.ClearForm();
             Server.Transfer("default.aspx");
         }
         else if (e.CommandName == "Terminology.Delete")
         {
             Guid gID = Sql.ToGuid(e.CommandArgument);
             SqlProcs.spTERMINOLOGY_Delete(gID);
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         else if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         else if (e.CommandName == "MassDelete")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     //SqlProcs.spTERMINOLOGY_MassDelete(sIDs);
                     Response.Redirect("default.aspx");
                 }
             }
         }
         else if (e.CommandName == "Export")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             SplendidExport.Export(vwMain, m_sMODULE, ctlExportHeader.ExportFormat, ctlExportHeader.ExportRange, grdMain.CurrentPageIndex, grdMain.PageSize, arrID);
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #13
0
        protected void BindGrid()
        {
            Guid gUSER_ID = Sql.ToGuid(lstUSERS.SelectedValue);

            if (Sql.IsEmptyGuid(gUSER_ID))
            {
                ctlAccessView.Visible = false;
                btnSelectRole.Visible = false;
                grdMain.Visible       = false;
                return;
            }
            ctlAccessView.USER_ID = gUSER_ID;
            ctlAccessView.Visible = true;
            btnSelectRole.Visible = true;
            grdMain.Visible       = true;

            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *                 " + ControlChars.CrLf
                       + "  from vwUSERS_ACL_ROLES " + ControlChars.CrLf
                       + " where 1 = 1             " + ControlChars.CrLf;
                using (IDbCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = sSQL;
                    Sql.AppendParameter(cmd, gUSER_ID, "USER_ID");
#if DEBUG
                    Page.RegisterClientScriptBlock("vwUSER_ACL_ROLES", Sql.ClientScriptBlock(cmd));
#endif
                    try
                    {
                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                // 05/03/2006 Paul.  Always bind, so that we don't have to redirect to show changes.
                                //if ( !IsPostBack )
                                {
                                    grdMain.SortColumn = "ROLE_NAME";
                                    grdMain.SortOrder  = "asc";
                                    grdMain.ApplySort();
                                    grdMain.DataBind();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                        lblError.Text = ex.Message;
                    }
                }
            }
        }
コード例 #14
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
            //Page.DataBind();
            string sUnifiedSearch = Sql.ToString(Request["txtUnifiedSearch"]);

            if (!Sql.IsEmptyString(sUnifiedSearch.Trim()))
            {
                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    sSQL = "select *              " + ControlChars.CrLf
                           + "  from vwPROJECTS_List" + ControlChars.CrLf
                           + " where 1 = 1          " + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        SearchBuilder sb = new SearchBuilder(sUnifiedSearch, cmd);
                        cmd.CommandText += sb.BuildQuery("   and ", "NAME");

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("vwPROJECTS_List", 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;
                                    if (!IsPostBack)
                                    {
                                        grdMain.SortColumn = "NAME";
                                        grdMain.SortOrder  = "asc";
                                        grdMain.ApplySort();
                                        grdMain.DataBind();
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                            lblError.Text = ex.Message;
                        }
                    }
                }
                ctlListHeader.Visible = true;
            }
            else
            {
                ctlListHeader.Visible = false;
            }
        }
コード例 #15
0
        private void TERMINOLOGY_BindData(bool bBind)
        {
            bEnableAdd            = true;
            ctlListHeader.Visible = true;

            try
            {
                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    sSQL = "select *                   " + ControlChars.CrLf
                           + "  from vwMODULES_RenameTabs" + ControlChars.CrLf
                           + " where 1 = 1               " + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        // 11/19/2005 Paul.  The language must be initialized before the search clause is applied.
                        if (!IsPostBack)
                        {
                            ctlSearch.LANGUAGE = L10n.NAME;
                        }
                        ctlSearch.SqlSearchClause(cmd);

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                        }

                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;

                                // 12/14/2007 Paul.  Only set the default sort if it is not already set.  It may have been set by SearchView.
                                if (String.IsNullOrEmpty(grdMain.SortColumn))
                                {
                                    grdMain.SortColumn = "TAB_ORDER";
                                    grdMain.SortOrder  = "asc";
                                }
                                grdMain.ApplySort();
                                if (bBind)
                                {
                                    grdMain.DataBind();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }
コード例 #16
0
        protected void Page_Command(object sender, CommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "Clear")
                {
                    ctlSearch.ClearForm();
                    Server.Transfer("default.aspx");
                }
                else if (e.CommandName == "Search")
                {
                    // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
                    grdMain.CurrentPageIndex = 0;
                    grdMain.ApplySort();
                    grdMain.DataBind();
                }
                else if (e.CommandName == "Config.Delete")
                {
                    Guid gID = Sql.ToGuid(e.CommandArgument);
                    DbProviderFactory dbf = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        string sSQL;
                        sSQL = "select *            " + ControlChars.CrLf
                               + "  from vwCONFIG_Edit" + ControlChars.CrLf
                               + " where ID = @ID     " + ControlChars.CrLf;
                        using (IDbCommand cmd = con.CreateCommand())
                        {
                            cmd.CommandText = sSQL;
                            Sql.AddParameter(cmd, "@ID", gID);
                            string sNAME = Sql.ToString(cmd.ExecuteScalar());

                            SqlProcs.spCONFIG_Delete(gID);
                            Application.Remove("CONFIG." + sNAME);
                        }
                    }

                    Response.Redirect("default.aspx");
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }
コード例 #17
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *           " + ControlChars.CrLf
                       + "  from vwTASKS_List" + 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");

                    if (bDebug)
                    {
                        RegisterClientScriptBlock("vwTASKS_List", Sql.ClientScriptBlock(cmd));
                    }

                    try
                    {
                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                // 07/24/2005 Paul.  Since this is not a dynamic grid, we must convert the task status manually.
                                foreach (DataRow row in dt.Rows)
                                {
                                    row["STATUS"] = L10n.Term(".task_status_dom.", row["STATUS"]);
                                }
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                if (!IsPostBack)
                                {
                                    grdMain.SortColumn = "NAME";
                                    grdMain.SortOrder  = "asc";
                                    grdMain.ApplySort();
                                    grdMain.DataBind();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                        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();
            }
        }
コード例 #18
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term("Shippers.LBL_LIST_FORM_TITLE"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            try
            {
                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    sSQL = "select *         " + ControlChars.CrLf
                           + "  from vwSHIPPERS" + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                        }

                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                if (!IsPostBack)
                                {
                                    grdMain.SortColumn = "LIST_ORDER";
                                    grdMain.SortOrder  = "asc";
                                    grdMain.ApplySort();
                                    grdMain.DataBind();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                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();
            }
        }
コード例 #19
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
         lblError.Text = ex.Message;
     }
 }
コード例 #20
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Clear")
         {
             ctlSearch.ClearForm();
             Server.Transfer("default.aspx");
         }
         else if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         else if (e.CommandName == "MassDelete")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 string sIDs = Utils.ValidateIDs(arrID);
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     SqlProcs.spEMAILMAN_MassDelete(sIDs);
                     Response.Redirect("default.aspx");
                 }
             }
         }
         else if (e.CommandName == "SendQueued")
         {
             // 12/20/2007 Paul.  Send all queued emails, regardless of send date.
             EmailUtils.SendQueued(Application, Guid.Empty, Guid.Empty, true);
             Response.Redirect("default.aspx");
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #21
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            gID = Sql.ToGuid(Request["ID"]);
            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *                         " + ControlChars.CrLf
                       + "  from vwCAMPAIGNS_CAMPAIGN_TRKRS" + 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_CAMPAIGN_TRKRS", 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);
                        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();
            }
        }
コード例 #22
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utils.SetPageTitle(Page, L10n.Term(m_sMODULE + ".LBL_LIST_FORM_TITLE"));
            try
            {
                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    sSQL = "select *                 " + ControlChars.CrLf
                           + "  from vwTERMINOLOGY_HELP" + ControlChars.CrLf
                           + " where 1 = 1             " + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                        }

                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                if (!IsPostBack)
                                {
                                    grdMain.SortColumn = "NAME";
                                    grdMain.SortOrder  = "asc";
                                    grdMain.ApplySort();
                                    grdMain.DataBind();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                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();
            }
        }
コード例 #23
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         DropDownList lst = ctlSearchView.FindControl("MODULE_NAME") as DropDownList;
         if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         // 12/14/2007 Paul.  We need to capture the sort event from the SearchView.
         else if (e.CommandName == "SortGrid")
         {
             grdMain.SetSortFields(e.CommandArgument as string[]);
         }
         else if (e.CommandName == "Shortcuts.Delete")
         {
             Guid gID = Sql.ToGuid(e.CommandArgument);
             SqlProcs.spSHORTCUTS_Delete(gID);
             SplendidCache.ClearShortcuts(lst.SelectedValue);
             Response.Redirect("default.aspx");
         }
         else if (e.CommandName == "Shortcuts.Edit")
         {
             Guid gID = Sql.ToGuid(e.CommandArgument);
             Response.Redirect("edit.aspx?ID=" + gID.ToString());
         }
         else if (lst != null)
         {
             Guid gID = Sql.ToGuid(e.CommandArgument);
             if (e.CommandName == "Shortcuts.MoveUp")
             {
                 SqlProcs.spSHORTCUTS_ORDER_MoveUp(gID);
                 SplendidCache.ClearShortcuts(lst.SelectedValue);
                 Response.Redirect("default.aspx");
             }
             else if (e.CommandName == "Shortcuts.MoveDown")
             {
                 SqlProcs.spSHORTCUTS_ORDER_MoveDown(gID);
                 SplendidCache.ClearShortcuts(lst.SelectedValue);
                 Response.Redirect("default.aspx");
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #24
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *                                   " + ControlChars.CrLf
                       + "  from vwCASES_MyList                      " + ControlChars.CrLf
                       + " where ASSIGNED_USER_ID = @ASSIGNED_USER_ID" + ControlChars.CrLf;
                using (IDbCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = sSQL;
                    Sql.AddParameter(cmd, "@ASSIGNED_USER_ID", Security.USER_ID);
#if DEBUG
                    Page.RegisterClientScriptBlock("vwTASKS_List", Sql.ClientScriptBlock(cmd));
#endif
                    try
                    {
                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                if (!IsPostBack)
                                {
                                    grdMain.SortColumn = "PRIORITY";
                                    grdMain.SortOrder  = "asc";
                                    grdMain.ApplySort();
                                }
                                // 09/15/2005 Paul. We must always bind, otherwise a Dashboard refresh will display the grid with empty rows.
                                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();
            }
        }
コード例 #25
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Search")
         {
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         // 12/14/2007 Paul.  We need to capture the sort event from the SearchView.
         else if (e.CommandName == "SortGrid")
         {
             grdMain.SetSortFields(e.CommandArgument as string[]);
         }
         else if (e.CommandName == "Feeds.Add")
         {
             Guid gFEED_ID = Sql.ToGuid(e.CommandArgument);
             SqlProcs.spUSERS_FEEDS_Update(Security.USER_ID, gFEED_ID, 0);
             Response.Redirect("default.aspx");
         }
         // 03/20/2007 Michael.  The command should be Feeds.Remove and not Feeds.Delete.
         else if (e.CommandName == "Feeds.Remove")
         {
             Guid gFEED_ID = Sql.ToGuid(e.CommandArgument);
             SqlProcs.spUSERS_FEEDS_Delete(Security.USER_ID, gFEED_ID);
             Response.Redirect("default.aspx");
         }
         else
         {
             throw(new Exception("Unknown command: " + e.CommandName));
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #26
0
        protected void Bind(bool bBind)
        {
            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *             " + ControlChars.CrLf
                       + "  from vwCALLS_MyList" + ControlChars.CrLf;
                using (IDbCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = sSQL;
                    // 11/24/2006 Paul.  Use new Security.Filter() function to apply Team and ACL security rules.
                    Security.Filter(cmd, m_sMODULE, "list");
                    Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);

                    if (bDebug)
                    {
                        RegisterClientScriptBlock("vwCALLS_List", 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;
                                if (bBind)
                                {
                                    grdMain.SortColumn = "DATE_START";
                                    grdMain.SortOrder  = "asc";
                                    grdMain.ApplySort();
                                }
                                // 09/15/2005 Paul. We must always bind, otherwise a Dashboard refresh will display the grid with empty rows.
                                grdMain.DataBind();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                        lblError.Text = ex.Message;
                    }
                }
            }
        }
コード例 #27
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
            //Page.DataBind();
            string sUnifiedSearch = Sql.ToString(Request["txtUnifiedSearch"]);

            if (!Sql.IsEmptyString(sUnifiedSearch.Trim()))
            {
                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    sSQL = "select *                   " + ControlChars.CrLf
                           + "  from vwOPPORTUNITIES_List" + ControlChars.CrLf
                           + " where 1 = 1               " + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL + UnifiedSearch(sUnifiedSearch, cmd);
#if DEBUG
                        Page.RegisterClientScriptBlock("vwOPPORTUNITIES_List", Sql.ClientScriptBlock(cmd));
#endif
                        try
                        {
                            using (DbDataAdapter da = dbf.CreateDataAdapter())
                            {
                                ((IDbDataAdapter)da).SelectCommand = cmd;
                                using (DataTable dt = new DataTable())
                                {
                                    da.Fill(dt);
                                    // 08/01/2005 Paul.  Convert the term here so that sorting will apply.
                                    foreach (DataRow row in dt.Rows)
                                    {
                                        // 08/17/2005 Paul.  Don't convert if NULL.
                                        row["SALES_STAGE"] = L10n.Term(".sales_stage_dom.", row["SALES_STAGE"]);
                                    }
                                    vwMain             = dt.DefaultView;
                                    grdMain.DataSource = vwMain;
                                    if (!IsPostBack)
                                    {
                                        grdMain.SortColumn = "NAME";
                                        grdMain.SortOrder  = "asc";
                                        grdMain.ApplySort();
                                        grdMain.DataBind();
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                            lblError.Text = ex.Message;
                        }
                    }
                }
                ctlListHeader.Visible = true;
            }
            else
            {
                ctlListHeader.Visible = false;
            }
        }
コード例 #28
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            gID = Sql.ToGuid(Request["ID"]);

            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                // 08/07/2006 Paul.  A contact can have two relationships with a single note, show only one.
                sSQL = "select distinct *                " + ControlChars.CrLf
                       + "  from vwCONTACTS_ACTIVITIES     " + 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.
                    // 12/07/2006 Paul.  This view has an alternate assigned id.
                    Security.Filter(cmd, m_sMODULE, "list", "ACTIVITY_ASSIGNED_USER_ID");
                    cmd.CommandText += "   and CONTACT_ID = @CONTACT_ID  " + ControlChars.CrLf;
                    cmd.CommandText += " order by DATE_DUE desc          " + ControlChars.CrLf;
                    Sql.AddParameter(cmd, "@CONTACT_ID", gID);

                    if (bDebug)
                    {
                        RegisterClientScriptBlock("vwCONTACTS_ACTIVITIES", Sql.ClientScriptBlock(cmd));
                    }

                    try
                    {
                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                // 11/26/2005 Paul.  Convert the term here so that sorting will apply.
                                foreach (DataRow row in dt.Rows)
                                {
                                    // 11/26/2005 Paul.  Status is translated differently for each type.
                                    switch (Sql.ToString(row["ACTIVITY_TYPE"]))
                                    {
                                    // 07/15/2006 Paul.  Translation of Call status remains here because it is more complex than the standard list translation.
                                    case "Calls":  row["STATUS"] = L10n.Term(".call_direction_dom.", row["DIRECTION"]) + " " + L10n.Term(".call_status_dom.", row["STATUS"]);  break;
                                        //case "Meetings":  row["STATUS"] = L10n.Term("Meeting") + " " + L10n.Term(".meeting_status_dom.", row["STATUS"]);  break;
                                        //case "Tasks"   :  row["STATUS"] = L10n.Term("Task"   ) + " " + L10n.Term(".task_status_dom."   , row["STATUS"]);  break;
                                    }
                                }
                                vwOpen             = new DataView(dt);
                                vwOpen.RowFilter   = "IS_OPEN = 1";
                                grdOpen.DataSource = vwOpen;

                                vwHistory             = new DataView(dt);
                                vwHistory.RowFilter   = "IS_OPEN = 0";
                                grdHistory.DataSource = vwHistory;
                                // 09/05/2005 Paul. LinkButton controls will not fire an event unless the the grid is bound.
                                //if ( !IsPostBack )
                                {
                                    grdOpen.SortColumn = "DATE_DUE";
                                    grdOpen.SortOrder  = "desc";
                                    grdOpen.ApplySort();
                                    grdOpen.DataBind();
                                    grdHistory.SortColumn = "DATE_MODIFIED";
                                    grdHistory.SortOrder  = "desc";
                                    grdHistory.ApplySort();
                                    grdHistory.DataBind();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                        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();
            }
        }
コード例 #29
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Search")
         {
             // 10/13/2005 Paul.  Make sure to clear the page index prior to applying search.
             grdMain.CurrentPageIndex = 0;
             grdMain.ApplySort();
             grdMain.DataBind();
         }
         // 12/14/2007 Paul.  We need to capture the sort event from the SearchView.
         else if (e.CommandName == "SortGrid")
         {
             grdMain.SetSortFields(e.CommandArgument as string[]);
         }
         else if (e.CommandName == "MassUpdate")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 // 10/26/2007 Paul.  Use a stack to run the update in blocks of under 200 IDs.
                 //string sIDs = Utils.ValidateIDs(arrID);
                 System.Collections.Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "edit", arrID, "CALLS");
                 if (stk.Count > 0)
                 {
                     DbProviderFactory dbf = DbProviderFactories.GetFactory();
                     using (IDbConnection con = dbf.CreateConnection())
                     {
                         con.Open();
                         using (IDbTransaction trn = con.BeginTransaction())
                         {
                             try
                             {
                                 while (stk.Count > 0)
                                 {
                                     string sIDs = Utils.BuildMassIDs(stk);
                                     // 07/09/2006 Paul.  The date conversion was moved out of the MassUpdate control.
                                     // 09/11/2007 Paul.  Mass update of teams is now available.
                                     SqlProcs.spCALLS_MassUpdate(sIDs, ctlMassUpdate.ASSIGNED_USER_ID, T10n.ToServerTime(ctlMassUpdate.DATE_START), ctlMassUpdate.STATUS, ctlMassUpdate.DIRECTION, ctlMassUpdate.TEAM_ID, trn);
                                 }
                                 trn.Commit();
                             }
                             catch (Exception ex)
                             {
                                 trn.Rollback();
                                 throw(new Exception(ex.Message, ex.InnerException));
                             }
                         }
                     }
                     Response.Redirect("default.aspx");
                 }
             }
         }
         else if (e.CommandName == "MassDelete")
         {
             string[] arrID = Request.Form.GetValues("chkMain");
             if (arrID != null)
             {
                 // 10/26/2007 Paul.  Use a stack to run the update in blocks of under 200 IDs.
                 //string sIDs = Utils.ValidateIDs(arrID);
                 System.Collections.Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "delete", arrID, "CALLS");
                 if (stk.Count > 0)
                 {
                     DbProviderFactory dbf = DbProviderFactories.GetFactory();
                     using (IDbConnection con = dbf.CreateConnection())
                     {
                         con.Open();
                         using (IDbTransaction trn = con.BeginTransaction())
                         {
                             try
                             {
                                 while (stk.Count > 0)
                                 {
                                     string sIDs = Utils.BuildMassIDs(stk);
                                     SqlProcs.spCALLS_MassDelete(sIDs, trn);
                                 }
                                 trn.Commit();
                             }
                             catch (Exception ex)
                             {
                                 trn.Rollback();
                                 throw(new Exception(ex.Message, ex.InnerException));
                             }
                         }
                     }
                     Response.Redirect("default.aspx");
                 }
             }
         }
         else if (e.CommandName == "Export")
         {
             // 11/03/2006 Paul.  Apply ACL rules to Export.
             int nACLACCESS = SplendidCRM.Security.GetUserAccess(m_sMODULE, "export");
             if (nACLACCESS >= 0)
             {
                 if (nACLACCESS == ACL_ACCESS.OWNER)
                 {
                     vwMain.RowFilter = "ASSIGNED_USER_ID = '" + Security.USER_ID.ToString() + "'";
                 }
                 string[] arrID = Request.Form.GetValues("chkMain");
                 SplendidExport.Export(vwMain, m_sMODULE, ctlExportHeader.ExportFormat, ctlExportHeader.ExportRange, grdMain.CurrentPageIndex, grdMain.PageSize, arrID);
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text = ex.Message;
     }
 }
コード例 #30
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 09/09/2006 Paul.  Visibility is already controlled by the ASPX page,
            // but since this control is used on the home page, we need to apply the module specific rules.
            // 11/05/2007 Paul.  Don't show panel if it was manually hidden.
            this.Visible = this.Visible && (SplendidCRM.Security.GetUserAccess(m_sMODULE, "list") >= 0);
            // 09/09/2007 Paul.  We are having trouble dynamically adding user controls to the WebPartZone.
            // Instead, control visibility manually here.  This approach as the added benefit of hiding the
            // control even if the WebPartManager has moved it to an alternate zone.
            if (this.Visible && this.Visible && !Sql.IsEmptyString(sDetailView))
            {
                // 01/17/2008 Paul.  We need to use the sDetailView property and not the hard-coded view name.
                DataView vwFields = new DataView(SplendidCache.DetailViewRelationships(sDetailView));
                vwFields.RowFilter = "CONTROL_NAME = '~/Contacts/MyContacts'";
                this.Visible       = vwFields.Count > 0;
            }
            if (!this.Visible)
            {
                return;
            }

            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *                " + ControlChars.CrLf
                       + "  from vwCONTACTS_MyList" + ControlChars.CrLf;
                using (IDbCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = sSQL;
                    // 11/24/2006 Paul.  Use new Security.Filter() function to apply Team and ACL security rules.
                    Security.Filter(cmd, m_sMODULE, "list");
                    Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);

                    if (bDebug)
                    {
                        RegisterClientScriptBlock("vwCONTACTS_List", 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;
                                if (!IsPostBack)
                                {
                                    grdMain.SortColumn = "DATE_ENTERED";
                                    grdMain.SortOrder  = "desc";
                                    grdMain.ApplySort();
                                }
                                // 09/15/2005 Paul. We must always bind, otherwise a Dashboard refresh will display the grid with empty rows.
                                grdMain.DataBind();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                        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();
            }
        }