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, "ACCOUNTS"); if (!Sql.IsEmptyString(sIDs)) { SqlProcs.spACCOUNTS_MassUpdate(sIDs, ctlMassUpdate.ASSIGNED_USER_ID, ctlMassUpdate.ACCOUNT_TYPE, ctlMassUpdate.INDUSTRY); 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, "ACCOUNTS"); if (!Sql.IsEmptyString(sIDs)) { SqlProcs.spACCOUNTS_MassDelete(sIDs); Response.Redirect("default.aspx"); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
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, "ACCOUNTS"); 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); // 09/11/2007 Paul. Mass update of teams is now available. SqlProcs.spACCOUNTS_MassUpdate(sIDs, ctlMassUpdate.ASSIGNED_USER_ID, ctlMassUpdate.ACCOUNT_TYPE, ctlMassUpdate.INDUSTRY, 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, "ACCOUNTS"); 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.spACCOUNTS_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; } }