公交车上荫蒂添的好舒服的电影-公用玩物(np双xing总受)-公用小荡货芊芊-公与妇仑乱hd-攻把受做哭边走边肉楼梯play-古装一级淫片a免费播放口

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發文檔 其他文檔  
 
網站管理員

如何將SQL語句進行格式化處理?

admin
2023年9月21日 16:27 本文熱度 1226

先看效果:

直接上代碼:

public Form1()

{

InitializeComponent();

Init();

}

#region 初始化配置

ISqlTokenizer _tokenizer;

ISqlTokenParser _parser;

ISqlTreeFormatter _formatter;

public void Init()

{

    chk_default.Checked = true;

    _tokenizer = new BaiSqlFormatLib.Tokenizers.TSqlStandardTokenizer();

    _parser = new BaiSqlFormatLib.Parsers.TSqlStandardParser();

}

#endregion

#region 格式化

private void textBox1_KeyDown(object sender, KeyEventArgs e)

{

    if (e.KeyData == Keys.F6)

    {

        txt_format.DocumentText = Format(txt_sql.Text);

    }

}


private string Format(string inputSql)

{

    SetFormatter();

    var tokenizedSql = _tokenizer.TokenizeSQL(inputSql, inputSql.Length);

    var parsedSql = _parser.ParseSQL(tokenizedSql);

    string subSqlHtml = _formatter.FormatSQLTree(parsedSql);

    return subSqlHtml;

}

/// <summary>

/// 設置格式化屬性

/// </summary>

private void SetFormatter()

{

ISqlTreeFormatter innerFormatter = new BaiSqlFormatLib.Formatters.TSqlStandardFormatter(new BaiSqlFormatLib.Formatters.TsqlStandardFormatterOptions{

        IndentString = "\\s\\s\\s\\s"//縮進內容

        SpacesPerTab = 4,

        MaxLineWidth = Convert.ToInt32(txt_maxWidth.Text), //單行字符串最大長度

        ExpandCommaLists = !chk_columnNotNewline.Checked,  //false 字段換行

        KeywordAlign = chk_keywordAlign.Checked,     //字段對齊

        TrailingCommas = true,   //true 逗號在字段之后

        SpaceAfterExpandedComma = true,  //true 逗號后追加空格

        ExpandBooleanExpressions = chk_conditionNewline.Checked,  //true 條件換行

        ExpandCaseStatements = chk_expandCase.Checked,      //true case when換行

        ExpandBetweenConditions = chk_expandBetween.Checked,  //true between 換行

        ExpandInLists = chk_expandIn.Checked,   //true in 內容換行

        BreakJoinOnSections = chk_expandOn.Checked, //true join onon 條件換行

        UppercaseKeywords = chk_uppercaseKeywords.Checked, //true 關鍵字大寫

        AllUpper = chk_allUpper.Checked, //true 全部大寫

        HTMLColoring = chk_coloring.Checked, //true HTML顏色標記 默認為true

        KeywordStandardization = true,//true 關鍵字標準化

        NewStatementLineBreaks = 2//新語句換行數

        NewClauseLineBreaks = 1,//遇到關鍵字 換行數

        AllIndent = chk_allIndent.Checked, //整體縮進一個IndentString

        AsAlign = chk_asAlign.Checked, //true as對齊

        KeywordLengthOfAs = Convert.ToInt32(txt_asMaxWidth.Text)//as字段的最大長度

    });

    _formatter = new BaiSqlFormatLib.Formatters.HtmlPageWrapper(innerFormatter);

}

#region 頁面配置

private void chk_default_CheckedChanged(object sender, EventArgs e)

{

    if (chk_default.Checked)

    {

        chk_custom.CheckState = CheckState.Unchecked;
        txt_maxWidth.Text = 
"170";

        chk_columnNotNewline.CheckState = CheckState.Unchecked;

        chk_keywordAlign.CheckState = CheckState.Checked;

        chk_conditionNewline.CheckState = CheckState.Checked;

        chk_expandCase.CheckState = CheckState.Checked;

        chk_expandBetween.CheckState = CheckState.Unchecked;

        chk_expandIn.CheckState = CheckState.Unchecked;

        chk_expandOn.CheckState = CheckState.Checked;

        chk_uppercaseKeywords.CheckState = CheckState.Unchecked;

        chk_allUpper.CheckState = CheckState.Unchecked;

        chk_coloring.CheckState = CheckState.Checked;

        chk_allIndent.CheckState = CheckState.Checked;

        chk_asAlign.CheckState = CheckState.Checked;

        txt_asMaxWidth.Text = "35";

        chk_addSemicolon.CheckState = CheckState.Checked;
        txt_maxWidth.Enabled = 
false;

        chk_columnNotNewline.Enabled = false;

        chk_keywordAlign.Enabled = false;

        chk_conditionNewline.Enabled = false;

        chk_expandCase.Enabled = false;

        chk_expandBetween.Enabled = false;

        chk_expandIn.Enabled = false;

        chk_expandOn.Enabled = false;

        chk_uppercaseKeywords.Enabled = false;

        chk_allUpper.Enabled = false;

        chk_coloring.Enabled = false;

        chk_allIndent.Enabled = false;

        chk_asAlign.Enabled = false;

        txt_asMaxWidth.Enabled = false;

        chk_addSemicolon.Enabled = false;

    }

    else

        chk_custom.CheckState = CheckState.Checked;

}

private void chk_custom_CheckedChanged(object sender, EventArgs e)

{

    if (chk_custom.Checked)

    {

        chk_default.CheckState = CheckState.Unchecked;

        chk_columnNotNewline.Enabled = true;

        chk_keywordAlign.Enabled = true;

        chk_conditionNewline.Enabled = true;

        chk_expandCase.Enabled = true;

        chk_expandBetween.Enabled = true;

        chk_expandIn.Enabled = true;

        chk_expandOn.Enabled = true;

        chk_uppercaseKeywords.Enabled = true;

        chk_allUpper.Enabled = true;

        chk_coloring.Enabled = true;

        chk_allIndent.Enabled = true;

        chk_asAlign.Enabled = true;

        chk_addSemicolon.Enabled = true;

        txt_maxWidth.Enabled = true;

        txt_asMaxWidth.Enabled = true;
    }

    else

        chk_default.CheckState = CheckState.Checked;

}

#endregion

感興趣的小伙伴可以自己研究研究。


該文章在 2023/9/21 16:27:57 編輯過
關鍵字查詢
相關文章
正在查詢...
點晴ERP是一款針對中小制造業的專業生產管理軟件系統,系統成熟度和易用性得到了國內大量中小企業的青睞。
點晴PMS碼頭管理系統主要針對港口碼頭集裝箱與散貨日常運作、調度、堆場、車隊、財務費用、相關報表等業務管理,結合碼頭的業務特點,圍繞調度、堆場作業而開發的。集技術的先進性、管理的有效性于一體,是物流碼頭及其他港口類企業的高效ERP管理信息系統。
點晴WMS倉儲管理系統提供了貨物產品管理,銷售管理,采購管理,倉儲管理,倉庫管理,保質期管理,貨位管理,庫位管理,生產管理,WMS管理系統,標簽打印,條形碼,二維碼管理,批號管理軟件。
點晴免費OA是一款軟件和通用服務都免費,不限功能、不限時間、不限用戶的免費OA協同辦公管理系統。
Copyright 2010-2025 ClickSun All Rights Reserved

主站蜘蛛池模板: 国产精品一区二区av片福利 | 国产尤物视频 | 高潮毛片高清免费视频 | 成人免费va视 | 国产精品一二区 | av无码专区少妇无码专区 | 国产人妖性爱专区 | 国产精品边做奶水狂喷无码 | 国产91精品高清一区二区三区 | 国产在线一区免费国产 | 国产成人无码免费精品果冻传媒 | 国产在线精品一区二区三区 | 国产成人av免费网址 | 国产二区啪啪视频 | 91精品尤物 | 国产盗摄91精品一区 | 国产高清无码黄片亚洲成人毛片 | 精品丰满少妇一区二区 | 丰满少妇人妻久 | 国产亚洲综合一区在线 | 97人妻无码专区 | 国产福利免费怕怕怕视频 | 91香蕉国产亚洲一区二区三区 | 精品国产一区二区三区蜜殿 | 99精品一区| 成人在线视频 | 国产熟女一区二区五月婷 | 国产原创顾美玲剧情在线 | 国产精品无码首页自拍 | 国产毛片情侣视频 | 精品日韩产品在线 | 国产精品探花一区 | 91尤物无码不卡在线 | 国产精品白浆在线观看免费 | 97色精品视频 | 精品无码av毛片一区二区三区 | 国产一区二区三精品久久久无广 | 精品福利一区二区视频 | 丰满多毛的陰户 | 91福利视频合集 | 国产在线观看国自产偷精品产拍 |