コード例 #1
0
ファイル: SQL.ascx.cs プロジェクト: KashbinRepository/Core
        private void LoadSavedQueries()
        {
            SqlQueryController ctl = new SqlQueryController();
            ddlSavedQuery.DataSource = ctl.GetQueries();
            ddlSavedQuery.DataBind();

            ddlSavedQuery.Items.Insert(0, new ListItem(LocalizeString("NewQuery"), ""));
            btDelete.Visible = false;

        }
コード例 #2
0
ファイル: SQL.ascx.cs プロジェクト: KashbinRepository/Core
        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);
            }
        }
コード例 #3
0
ファイル: SQL.ascx.cs プロジェクト: KashbinRepository/Core
        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);
            }

        }
コード例 #4
0
ファイル: SQL.ascx.cs プロジェクト: KashbinRepository/Core
 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);
             }
         }
     }
 }