示例#1
0
        private void lnkSave_Click(object sender, EventArgs e)
        {
            try
            {
                SqlQueryController ctl = new SqlQueryController();
                SqlQuery query = ctl.GetQuery(txtName.Text);
                if (query == null)
                {
                    query = new SqlQuery();
                    query.CreatedByUserId = UserId;
                    query.CreatedOnDate = DateTime.Now;
                }
                query.Name = txtName.Text;
                query.Query = txtQuery.Text;
                query.ConnectionStringName = ddlConnection.SelectedValue;
                query.LastModifiedByUserId = UserId;
                query.LastModifiedOnDate = DateTime.Now;

                if (query.QueryId == 0)
                {
                    ctl.AddQuery(query);
                }
                else
                {
                    ctl.UpdateQuery(query);
                }
                LoadSavedQueries();
                ddlSavedQuery.SelectedValue = query.QueryId.ToString();
                btDelete.Visible = true;

                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, LocalizeString("Saved"), ModuleMessage.ModuleMessageType.GreenSuccess);
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
示例#2
0
        private void btDelete_Click(object sender, EventArgs e)
        {
            try
            {
                SqlQueryController ctl = new SqlQueryController();
                SqlQuery query = ctl.GetQuery(int.Parse(ddlSavedQuery.SelectedValue));
                if (query != null)
                {
                    ctl.DeleteQuery(query);
                    LoadSavedQueries();
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, LocalizeString("Deleted"), ModuleMessage.ModuleMessageType.GreenSuccess);
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }

        }
示例#3
0
 private void ddlSavedQuery_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddlSavedQuery.SelectedValue == "")
     {
         txtQuery.Text = "";
         btDelete.Visible = false;
         ddlConnection.SelectedValue = "SiteSqlServer";
     }
     else
     {
         SqlQueryController ctl = new SqlQueryController();
         SqlQuery query = ctl.GetQuery(int.Parse(ddlSavedQuery.SelectedValue));
         if (query != null)
         {
             txtQuery.Text = query.Query;
             btDelete.Visible = true;
             if (ddlConnection.Items.FindByValue(query.ConnectionStringName) != null)
             {
                 ddlConnection.SelectedValue = query.ConnectionStringName;
             }
             else
             {
                 DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, string.Format(LocalizeString("CnnStringNotFound"), query.ConnectionStringName), ModuleMessage.ModuleMessageType.YellowWarning);
             }
         }
     }
 }