protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e) { try { e.Cancel = true; SelectedKey = null; BBQueryController cont = new BBQueryController(); cont.BBQueryUpdate(provider, connectionString, updCommand, e.Keys, e.NewValues); } catch (Exception exc) { //Exceptions.ProcessModuleLoadException(exc.Message, this, exc); DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, exc.Message, ModuleMessage.ModuleMessageType.RedError); } }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { try { e.Cancel = true; SelectedKey = null; BBQueryController cont = new BBQueryController(); cont.BBQueryInsert(provider, connectionString, insCommand, e.Values); DetailsView1.ChangeMode(DetailsViewMode.Edit); } catch (Exception exc) { //Exceptions.ProcessModuleLoadException(exc.Message,this, exc); DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, exc.Message, ModuleMessage.ModuleMessageType.RedError); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { e.Cancel = true; SelectedKey = null; BBQueryController cont = new BBQueryController(); cont.BBQueryDelete(provider, connectionString, delCommand, GridView1.DataKeys[e.RowIndex].Values); //BindData(); } catch (Exception exc) //Module failed to load { //Exceptions.ProcessModuleLoadException(exc.Message,this, exc); DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, exc.Message, ModuleMessage.ModuleMessageType.RedError); } }
public void OnModuleCommunication(object s, ModuleCommunicationEventArgs e) { if (e.Sender=="BBQuery") { int senderModuleID = Convert.ToInt32(e.Text); if (senderModuleID != ModuleId) { List<ParameterInfo> senderParams = (List<ParameterInfo>) e.Value; SearchParameters = new List<ParameterInfo>(); foreach (ParameterInfo senderParam in senderParams) { bool found = false; foreach (ParameterInfo searchParameter in SearchParameters) { if (searchParameter.FieldName == senderParam.FieldName) { searchParameter.Value = senderParam.Value; found = true; } } if (!found) { BBQueryController cont = new BBQueryController(); List<ParameterInfo> parameters = cont.GetParameters(TabModuleId, false); foreach (ParameterInfo parameter in parameters) { if (parameter.FieldName == senderParam.FieldName) { parameter.Value = senderParam.Value; SearchParameters.Add(parameter); } } } } } } }
private void BindData() { try { BBQueryController cont = new BBQueryController(); string orderby = (String.IsNullOrEmpty(Order) ? "" : " ORDER BY " + Order + " " + SortedDirection); if (SelectedKey != null) { pnlEditMode.Visible = true; DetailsView1.DataBind(); pnlBrowseMode.Visible = false; } else { string selCmd = cont.GetSelect(sqlCommand + " {WHERE} " + orderby, SearchParameters); txtSql.Text = cont.ReplaceParameters(selCmd,SearchParameters); GridView1.DataSource = cont.BBQuerySelect(provider, connectionString, selCmd, SearchParameters); GridView1.DataBind(); pnlBrowseMode.Visible = true; pnlEditMode.Visible = false; cmdInsert.Visible = allowInserts; imgInsert.Visible = allowInserts; GridView1.Columns[0].Visible = allowEdits; GridView1.Columns[1].Visible = allowDeletes; } pnlShowSql.Visible = pnlBrowseMode.Visible && Settings["ShowSql"] != null && Convert.ToBoolean(Settings["ShowSql"]); ctrlSearch.Visible = pnlBrowseMode.Visible; } catch (Exception exc) { //Exceptions.ProcessModuleLoadException(this, exc); DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, exc.Message, ModuleMessage.ModuleMessageType.RedError); } }
/// <summary> /// Runs when the control is loaded /// </summary> private void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) SearchParameters = new List<ParameterInfo>(); // First check if we had querystring parameters BBQueryController cont = new BBQueryController(); List<ParameterInfo> parameters = cont.GetParameters(TabModuleId, false); foreach (ParameterInfo parameter in parameters) { if (Request.QueryString[parameter.FieldName] != null) { bool found = false; foreach (ParameterInfo searchParameter in SearchParameters) { if (searchParameter.FieldName == parameter.FieldName) { searchParameter.Value = ParameterInfo.GetTypedValue(HttpUtility.HtmlDecode(Request.QueryString[parameter.FieldName]), parameter.DataType); found = true; } } if (!found) { parameter.Value = ParameterInfo.GetTypedValue(HttpUtility.HtmlDecode(Request.QueryString[parameter.FieldName]),parameter.DataType); SearchParameters.Add(parameter); } } } UserInfo user = UserController.GetCurrentUserInfo(); if (Settings["AllowInserts"] != null && Settings["RoleAllowInserts"] != null && Request.IsAuthenticated && Convert.ToBoolean(Settings["AllowInserts"]) && user.IsInRole((string)Settings["RoleAllowInserts"])) { allowInserts = true; } else { cmdInsert.Visible = false; imgInsert.Visible = false; } if (Settings["AllowEdits"] != null && Settings["RoleAllowEdits"] != null && Request.IsAuthenticated && Convert.ToBoolean(Settings["AllowEdits"]) && user.IsInRole((string)Settings["RoleAllowEdits"])) { allowEdits = true; } if (Settings["AllowDeletes"] != null && Settings["RoleAllowDeletes"] != null && Request.IsAuthenticated && Convert.ToBoolean(Settings["AllowDeletes"]) && user.IsInRole((string)Settings["RoleAllowDeletes"])) { allowDeletes = true; } if (!IsPostBack) { pnlShowSql.Visible = Settings["ShowSql"] != null && Convert.ToBoolean(Settings["ShowSql"]); } bool needsKey = allowInserts || allowEdits || allowDeletes; if (Settings["SelectCommand"] != null && Settings["Provider"] != null && (!needsKey || needsKey && Settings["Key"] != null )) { sqlCommand = (string)Settings["SelectCommand"]; if (String.IsNullOrEmpty((string) Settings["ConnectionString"])) connectionString = ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString; else connectionString = (string) Settings["ConnectionString"]; key = (string)Settings["Key"]; provider = (string) Settings["Provider"]; updCommand = (string) Settings["UpdateCommand"]; delCommand = (string)Settings["DeleteCommand"]; insCommand = (string)Settings["InsertCommand"]; if (!Page.IsPostBack) { if (!String.IsNullOrEmpty(key)) GridView1.DataKeyNames = key.Split(','); GridView1.AllowPaging = true; GridView1.PageSize = 10; GridView1.AllowSorting = true; if (!String.IsNullOrEmpty(key)) DetailsView1.DataKeyNames = key.Split(','); } } else { string message = Localization.GetString("Configure.Message", this.LocalResourceFile); DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, message, ModuleMessage.ModuleMessageType.YellowWarning); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }