Exemple #1
0
		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);
								}
							}
						}
					}
				}
			}
		}
Exemple #2
0
		/// <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);
			}
		}