⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 labelsqlbuild.aspx.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 3 页
字号:
namespace PowerEasy.WebSite.Admin.Template
{
    using AjaxControlToolkit;
    using CodeEngine.Framework.QueryBuilder;
    using CodeEngine.Framework.QueryBuilder.Enums;
    using PowerEasy.Common;
    using PowerEasy.Components;
    using PowerEasy.Controls;
    using PowerEasy.Enumerations;
    using PowerEasy.Model.TemplateProc;
    using PowerEasy.Templates;
    using PowerEasy.Web.UI;
    using System;
    using System.Configuration;
    using System.Data;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class LabelSqlBuild : AdminPage
    {
        private string action;
        protected Label attlist;
        protected Button BtnClausebilud;
        protected Button BtnNext;
        protected Button BtnPrv;
        protected Button BtnSave;
        protected Button BtnSqlbilud;
        protected CheckBox ChkPage;
        protected HtmlGenericControl CountShow;
        protected ListBox DbFieldDownList;
        protected ListBox DbFieldDownList2;
        protected DropDownList DbFieldList;
        protected DropDownList DbFieldList2;
        protected DropDownList DbTableDownList;
        protected DropDownList DbTableDownList2;
        protected DropDownList Dbtj;
        private string Dbtype;
        protected DropDownList Dbys;
        protected GridView GridView_Clause;
        private string m_LabelLibPath;
        private string m_LabelName;
        protected NumericUpDownExtender NumericUpDownExtender1;
        protected HtmlGenericControl PageShow;
        private SelectQueryBuilder query;
        private SelectQueryBuilder querycount;
        protected ScriptManager ScriptManager1;
        protected ExtendedSiteMapPath SmpNavigator;
        protected HtmlGenericControl Span1;
        protected AjaxControlToolkit.TabPanel TabPanel;
        protected AjaxControlToolkit.TabPanel TabPanel1;
        protected AjaxControlToolkit.TabPanel TabPanel2;
        protected TabContainer Tabs;
        protected TextBox TxtOutNum;
        protected TextBox TxtSqlCount;
        protected TextBox TxtSqlPage;
        protected TextBox TxtSqlstr;
        protected System.Web.UI.UpdatePanel UpdatePanel1;
        private string xmlfilepath;

        protected void BtnClausebilud_Click(object sender, EventArgs e)
        {
            if (this.DbTableDownList.SelectedIndex == 0)
            {
                this.TxtSqlstr.Text = "您尚未选择主表";
            }
            else
            {
                bool flag = true;
                DataTable table = GetDataBaseSchema(this.Dbtype, this.xmlfilepath, this.DbTableDownList.SelectedValue);
                DataTable table2 = table.Clone();
                for (int i = 0; i < this.DbFieldDownList.Items.Count; i++)
                {
                    if (this.DbFieldDownList.Items[i].Selected)
                    {
                        DataRow[] rowArray = table.Select("ColumnName = '" + this.DbFieldDownList.Items[i].Value + "'");
                        for (int k = 0; k < rowArray.Length; k++)
                        {
                            table2.ImportRow(rowArray[k]);
                            flag = false;
                        }
                    }
                }
                if (flag)
                {
                    table2 = table;
                }
                if (this.DbTableDownList2.SelectedIndex > 0)
                {
                    flag = true;
                    table = GetDataBaseSchema(this.Dbtype, this.xmlfilepath, this.DbTableDownList2.SelectedValue);
                    for (int m = 0; m < this.DbFieldDownList2.Items.Count; m++)
                    {
                        if (this.DbFieldDownList2.Items[m].Selected)
                        {
                            DataRow[] rowArray2 = table.Select("ColumnName = '" + this.DbFieldDownList2.Items[m].Value + "'");
                            for (int n = 0; n < rowArray2.Length; n++)
                            {
                                table2.ImportRow(rowArray2[n]);
                                flag = false;
                            }
                        }
                    }
                    if (flag)
                    {
                        for (int num5 = 0; num5 < table.Rows.Count; num5++)
                        {
                            table2.ImportRow(table.Rows[num5]);
                        }
                    }
                }
                this.GridView_Clause.DataSource = table2;
                this.GridView_Clause.DataBind();
                for (int j = 0; j < this.GridView_Clause.Rows.Count; j++)
                {
                    TextBox box = (TextBox) this.GridView_Clause.Rows[j].FindControl("txtbox1");
                    box.Attributes.Add("onmouseup", "dragend(0);");
                }
            }
        }

        protected void BtnNext_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.TxtSqlstr.Text) && (this.TxtSqlstr.Text != "请先建立SQL语句"))
            {
                bool flag = XmlManage.SaveFileNode(this.xmlfilepath, "root", "LabelSqlString", this.TxtSqlstr.Text);
                if (this.ChkPage.Checked)
                {
                    if (!string.IsNullOrEmpty(this.TxtSqlCount.Text) && (this.TxtSqlCount.Text != "请先建立SQL统计语句"))
                    {
                        flag = XmlManage.SaveFileNode(this.xmlfilepath, "root", "LabelSqlCount", this.TxtSqlCount.Text);
                    }
                    else
                    {
                        flag = false;
                        this.TxtSqlCount.Text = "请先建立SQL统计语句";
                    }
                    if ((string.Compare(this.Dbtype.Split(new char[] { '_' })[0], "sql") != 0) && flag)
                    {
                        if (!string.IsNullOrEmpty(this.TxtSqlPage.Text) && (this.TxtSqlPage.Text != "请先建立SQL分页语句"))
                        {
                            flag = XmlManage.SaveFileNode(this.xmlfilepath, "root", "LabelSqlPage", this.TxtSqlPage.Text);
                        }
                        else
                        {
                            flag = false;
                            this.TxtSqlPage.Text = "请先建立SQL分页语句";
                        }
                    }
                }
                if (flag)
                {
                    BasePage.ResponseRedirect("LabelTemplate.aspx?action=" + this.action + "&name=" + base.Server.UrlEncode(this.m_LabelName));
                }
            }
            else
            {
                this.TxtSqlstr.Text = "请先建立SQL语句";
            }
        }

        protected void BtnPrv_Click(object sender, EventArgs e)
        {
            BasePage.ResponseRedirect("LabelProperty.aspx?action=" + this.action + "&name=" + base.Server.UrlEncode(this.m_LabelName));
        }

        protected void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(this.TxtSqlstr.Text) && (this.TxtSqlstr.Text != "请先建立SQL语句"))
                {
                    bool flag = XmlManage.SaveFileNode(this.xmlfilepath, "root", "LabelSqlString", this.TxtSqlstr.Text);
                    if (this.ChkPage.Checked)
                    {
                        if (!string.IsNullOrEmpty(this.TxtSqlCount.Text) && (this.TxtSqlCount.Text != "请先建立SQL统计语句"))
                        {
                            flag = XmlManage.SaveFileNode(this.xmlfilepath, "root", "LabelSqlCount", this.TxtSqlCount.Text);
                        }
                        else
                        {
                            flag = false;
                            this.TxtSqlCount.Text = "请先建立SQL统计语句";
                        }
                        if ((string.Compare(this.Dbtype.Split(new char[] { '_' })[0], "sql") != 0) && flag)
                        {
                            if (!string.IsNullOrEmpty(this.TxtSqlPage.Text) && (this.TxtSqlPage.Text != "请先建立SQL分页语句"))
                            {
                                flag = XmlManage.SaveFileNode(this.xmlfilepath, "root", "LabelSqlPage", this.TxtSqlPage.Text);
                            }
                            else
                            {
                                flag = false;
                                this.TxtSqlPage.Text = "请先建立SQL分页语句";
                            }
                            flag = XmlManage.SaveFileNode(this.xmlfilepath, "root", "LabelSqlPage", this.TxtSqlPage.Text);
                        }
                    }
                    if (flag)
                    {
                        File.Copy(this.xmlfilepath, HttpContext.Current.Server.MapPath(this.m_LabelLibPath) + @"\" + this.m_LabelName + ".config", true);
                        BasePage.ResponseRedirect("LabelManage.aspx");
                    }
                }
                else
                {
                    this.TxtSqlstr.Text = "请先建立SQL语句";
                }
            }
            catch (IOException)
            {
                AdminPage.WriteErrMsg("没有标签目录或临时目录或标签文件的访问权限!", "LabelManage.aspx");
            }
            catch (UnauthorizedAccessException)
            {
                AdminPage.WriteErrMsg("没有标签目录或临时目录或标签文件的访问权限!", "LabelManage.aspx");
            }
        }

        protected void BtnSqlbilud_Click(object sender, EventArgs e)
        {
            this.query = new SelectQueryBuilder();
            this.querycount = new SelectQueryBuilder();
            if (this.DbTableDownList.SelectedIndex > 0)
            {
                bool flag = true;
                bool flag2 = true;
                bool flag3 = false;
                bool flag4 = false;
                if (string.Compare(this.Dbtype, "orc_read", true) == 0)
                {
                    flag3 = true;
                }
                else if ((string.Compare(this.Dbtype, "odbc_read", true) == 0) && Regex.IsMatch(XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelType"), "mysql", RegexOptions.IgnoreCase))
                {
                    flag4 = true;
                }
                string input = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDbPath");
                if ((string.Compare(this.Dbtype, "ole_read", true) == 0) && Regex.IsMatch(input, "xls", RegexOptions.IgnoreCase))
                {
                    this.query.SelectFromTable("[" + this.DbTableDownList.SelectedValue + "]");
                    this.querycount.SelectFromTable("[" + this.DbTableDownList.SelectedValue + "]");
                }
                else
                {
                    this.query.SelectFromTable(this.DbTableDownList.SelectedValue);
                    this.querycount.SelectFromTable(this.DbTableDownList.SelectedValue);
                }
                StringBuilder builder = new StringBuilder();
                if ((this.DbTableDownList2.SelectedIndex <= 0) || (this.DbTableDownList.SelectedIndex == this.DbTableDownList2.SelectedIndex))
                {
                    for (int i = 0; i < this.DbFieldDownList.Items.Count; i++)
                    {
                        if (this.DbFieldDownList.Items[i].Selected)
                        {
                            builder.Append(this.DbFieldDownList.Items[i].Value + ",");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -