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; } }
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; } }
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; } }
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; } }
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 == "Teams.Delete") { Guid gID = Sql.ToGuid(e.CommandArgument); SqlProcs.spTEAMS_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.spTEAMS_MassDelete(sIDs); Response.Redirect("default.aspx"); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }
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 == "Export") { string[] arrTABLES = Request.Form.GetValues("chkMain"); if (arrTABLES != null) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); int nErrors = 0; MemoryStream stm = new MemoryStream(); XmlTextWriter xw = new XmlTextWriter(stm, Encoding.UTF8); xw.Formatting = Formatting.Indented; xw.IndentChar = ControlChars.Tab; xw.Indentation = 1; xw.WriteStartDocument(); xw.WriteStartElement("splendidcrm"); foreach (string sTABLE_NAME in arrTABLES) { vwMain.RowFilter = "TABLE_NAME = '" + sTABLE_NAME + "'"; if (vwMain.Count > 0) { try { using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = "select * from " + sTABLE_NAME; using (IDataReader rdr = cmd.ExecuteReader()) { int nRecordCount = 0; while (rdr.Read()) { nRecordCount++; xw.WriteStartElement(sTABLE_NAME.ToLower()); for (int nColumn = 0; nColumn < rdr.FieldCount; nColumn++) { xw.WriteStartElement(rdr.GetName(nColumn).ToLower()); if (!rdr.IsDBNull(nColumn)) { switch (rdr.GetFieldType(nColumn).FullName) { case "System.Boolean": xw.WriteString(rdr.GetBoolean(nColumn) ? "1" : "0"); break; case "System.Single": xw.WriteString(rdr.GetDouble(nColumn).ToString()); break; case "System.Double": xw.WriteString(rdr.GetDouble(nColumn).ToString()); break; case "System.Int16": xw.WriteString(rdr.GetInt16(nColumn).ToString()); break; case "System.Int32": xw.WriteString(rdr.GetInt32(nColumn).ToString()); break; case "System.Int64": xw.WriteString(rdr.GetInt64(nColumn).ToString()); break; case "System.Decimal": xw.WriteString(rdr.GetDecimal(nColumn).ToString()); break; case "System.DateTime": xw.WriteString(rdr.GetDateTime(nColumn).ToUniversalTime().ToString(CalendarControl.SqlDateTimeFormat)); break; case "System.Guid": xw.WriteString(rdr.GetGuid(nColumn).ToString().ToUpper()); break; case "System.String": xw.WriteString(rdr.GetString(nColumn)); break; case "System.Byte[]": { Byte[] buffer = rdr.GetValue(nColumn) as Byte[]; xw.WriteBase64(buffer, 0, buffer.Length); break; } default: throw(new Exception("Unsupported field type: " + rdr.GetFieldType(nColumn).FullName)); } } xw.WriteEndElement(); } xw.WriteEndElement(); } vwMain[0]["TABLE_STATUS"] = String.Format(L10n.Term("Export.LBL_RECORDS"), nRecordCount); } } } catch (Exception ex) { nErrors++; vwMain[0]["TABLE_STATUS"] = ex.Message; } } } xw.WriteEndElement(); xw.WriteEndDocument(); xw.Flush(); if (nErrors == 0) { Response.ContentType = "text/xml"; Response.AddHeader("Content-Disposition", "attachment;filename=Export.xml"); stm.WriteTo(Response.OutputStream); Response.End(); } vwMain.RowFilter = null; grdMain.DataBind(); } } } else if (e.CommandName == "Cancel") { Response.Redirect("~/Administration/default.aspx"); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = Server.HtmlEncode(ex.Message); } }