二、cs文件

using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using BS.EAP.DBAccess;
using System.Data;
using BS.EAP.Authentication;
using BS.EAP.BizMgt.DataQuery;
using System.Web.Security;
using System.Collections;
using BS.EAP.BizMgt.Model;
using System.Text;
using System.Linq;
using System.Web;
using BS.EAP.BizMgt.Action;
using BS.EAP.Account.Model;
using BS.EAP.BizMgt.Common;
using BS.EAP.BizCheck;
using BS.EAP.eForm.Frame;
using BS.EAP.eForm.Web;
using BS.EAP.eForm.Data;
using System.Globalization;
using Oracle.DataAccess.Client;
using Telerik.WebControls;

namespace BS.EAP.Portal.Business.DataQuery
{
    public partial class UpdateMTablesQCols : WebPage
    {
        private IDataBase IDB = DBFactory.GetDBInstance();
        private string appid = "__ALL";
        private string dtid = "__ALL";

protected void Page_Load(object sender, EventArgs e)
        {
            //this.reportDate.InitDateType = (BS.EAP.BizMgt.Common.ReportDateType)Enum.Parse(typeof(BS.EAP.BizMgt.Common.ReportDateType), "月");

if (this.CurrentApplication == null)
            {
                Response.Write(string.Format("<script>top.window.location='{0}'</script>", FormsAuthentication.LoginUrl));
                return;
            }
            this.curBizType = this.CurrentApplication.APPID.ToString();
            this.HtmlCurBizType.Value = this.curBizType;
            // oQuery = new QueryContext(this.curBizType);

if (!this.IsPostBack)
            {
                InitPage();
            }
        }

#region 初始化页面
        /// <summary>
        /// 初始化页面
        /// </summary>
        private void InitPage()
        {
            appid = "__ALL";
            dtid = "__ALL";
            BindDept();
            BindDataTable(appid);
            //根据oQuery绑定curBizType下的表
            BindGV(appid, dtid);

}

private void BindDept()
        {
            drpDept.Items.Clear();

IDataBase oDB = DBFactory.GetDBInstance();
            string sql = "";
            sql = "select app.appid appid, app.appname appname  from sys_application app where app.appid in ('969c388f-b0e2-4571-9876-4312b6a74a54', '3a448698-b695-4a5a-b405-df18f44da86f', '06f74f41-61ff-405a-8c86-bf8edacd945e')";

DataTable dt = oDB.GetDataTable(sql);
            drpDept.Items.Add(new ListItem("全部", "__ALL"));
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    drpDept.Items.Add(new ListItem(dr["appname"].ToString(), dr["appid"].ToString()));
                }

}
        }
        private void BindDataTable(string appid)
        {
            drpTable.Items.Clear();
            IDataBase oDB = DBFactory.GetDBInstance();
            string strSql = "";
            strSql = string.Format(@" select DTName, DTID from Basic_DataTable where  (('__ALL' ='{0}' and
                                       appid in ('969c388f-b0e2-4571-9876-4312b6a74a54',
                                                   '3a448698-b695-4a5a-b405-df18f44da86f',
                                                   '06f74f41-61ff-405a-8c86-bf8edacd945e')) or
                                       ('__ALL' != '{0}' and
                                       appid in ('{0}')))
                    and DTType in ('c544a6c1-e921-448c-8880-0b22cf07cee4', '26a65507-9aec-481f-a5b6-4959a4cc4933') and dtid not in ('35e05ad7-703b-4b8f-b7d1-02eae769dc15',
                   '56d300e1-f91f-44e5-936e-b6b445ea16f8',  '65f31d08-bc1f-43e4-883a-0cfecf4a8282', '2a6005b6-a513-4317-aaca-1049f83dceb1') order by sortno", appid);
            DataTable dt = oDB.GetDataTable(strSql);
            drpTable.Items.Add(new ListItem("全部", "__ALL"));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                drpTable.Items.Add(new ListItem(dt.Rows[i]["DTNAME"].ToString(), dt.Rows[i]["DTID"].ToString()));
            }
        }

private void BindGV(string appid, string dtid)
        {
            string strQuery = "";
            strQuery = string.Format(@"select app.appname appname,
                                       db.dtname   dtname,
                                       t.appid     appid,
                                       t.TABLENAME TABLENAME,
                                       t.colnameen ColNameEN,
                                       t.colnamecn ColNameCN
                                  from tablecolsquery t
                                  left join sys_application app
                                    on app.appid = t.appid
                                  left join basic_datatable db
                                    on upper(db.shortcode) = upper(t.tablename)
                                   and db.status = 0
                                 where (('__ALL' = '{0}' and
                                       t.appid in ('969c388f-b0e2-4571-9876-4312b6a74a54',
                                                     '3a448698-b695-4a5a-b405-df18f44da86f',
                                                     '06f74f41-61ff-405a-8c86-bf8edacd945e')) or
                                       t.appid = '{0}')
                                   and (db.dtid = '{1}' or '__ALL' = '{1}')
                                 order by t.appid, db.sortno, t.TABLENAME, t.COLUMNID asc", appid, dtid);
            IDataBase idb = DBFactory.GetDBInstance();
            DataTable dtQueryResult = idb.GetDataTable(strQuery);
            Session.Remove("QueryResult");
            Session.Add("QueryResult", dtQueryResult);
            if (dtQueryResult.Rows.Count <= 0)
            {
                dtQueryResult = idb.GetDataTable("select '没有数据!' dtname from dual");
                this.gvMutiQueResult.Columns.Clear();
                this.gvMutiQueResult.Columns.Add(new BoundField() { DataField = "dtname", HeaderText = "表" });
                this.gvMutiQueResult.DataSource = dtQueryResult;
                this.gvMutiQueResult.DataBind();
            }
            else
            {

this.gvMutiQueResult.Attributes.Clear();
                this.gvMutiQueResult.Attributes.Add("style", "word-break:keep-all");
                this.gvMutiQueResult.Columns.Clear();
                this.gvMutiQueResult.Columns.Add(new BoundField() { DataField = "appname", HeaderText = "业务" });
                this.gvMutiQueResult.Columns.Add(new BoundField() { DataField = "dtname", HeaderText = "表名" });
                this.gvMutiQueResult.Columns.Add(new BoundField() { DataField = "TABLENAME", HeaderText = "物理表" });
                this.gvMutiQueResult.Columns.Add(new BoundField() { DataField = "ColNameEN", HeaderText = "列名" });
                this.gvMutiQueResult.Columns.Add(new BoundField() { DataField = "ColNameCN", HeaderText = "Comments" });
                this.gvMutiQueResult.DataSource = dtQueryResult;
                this.gvMutiQueResult.DataBind();
            }

}

#endregion

/// <summary>
        /// 存储过程(处理多表查询物理表列字段)
        /// </summary>
        /// <returns></returns>
        private void GetProcedureG(string Reportdate)
        {
            BS.EAP.DBAccess.IDataBase sDB = BS.EAP.DBAccess.DBFactory.GetDBInstance();
            Oracle.DataAccess.Client.OracleParameter[] dataParams = new Oracle.DataAccess.Client.OracleParameter[1];
            dataParams[0] = new Oracle.DataAccess.Client.OracleParameter("v_ReportDate", Oracle.DataAccess.Client.OracleDbType.Varchar2, ParameterDirection.Input);
            dataParams[0].Value = Reportdate;
            sDB.GetDataTableBySPInTran("UPDATETABLECOLS", dataParams);
        }

#region 事件

protected void BtnUpdate_Click(object sender, EventArgs e)
        {
            //this.queryBtn.Attributes.Add("onclick", "return confirm('您确定要更新多表查询列吗?');");
            string Reportdate;
            Reportdate = System.DateTime.Now.ToString("yyyyMMdd");
            GetProcedureG(Reportdate);
            ClientScript.RegisterStartupScript(this.GetType(), "refresh", "<script language=\"javascript\">alert('更新成功!');</script>");
            appid = this.drpDept.SelectedValue.ToString();
            dtid = this.drpTable.SelectedValue.ToString();
            BindGV(appid, dtid);
        }
        protected void BtnQuery_Click(object sender, EventArgs e)
        {
            appid = this.drpDept.SelectedValue.ToString();
            dtid = this.drpTable.SelectedValue.ToString();
            BindGV(appid, dtid);
        }
        protected void gvMutiQueResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            appid = this.drpDept.SelectedValue.ToString();
            dtid = this.drpTable.SelectedValue.ToString();
            this.gvMutiQueResult.PageIndex = e.NewPageIndex;
            if (Session["QueryResult"] != null)
            {
                this.gvMutiQueResult.DataSource = (DataTable)Session["QueryResult"];
                this.gvMutiQueResult.DataBind();
            }
            else
            {
                BindGV(appid, dtid);
            }
        }

protected void drpDept_SelectedIndexChanged(object sender, EventArgs e)
        {
            appid = this.drpDept.SelectedValue.ToString();
            dtid = "__ALL";
            BindDataTable(appid);
            BindGV(appid, dtid);
        }

protected void drpTable_SelectedIndexChanged(object sender, EventArgs e)
        {
            appid = this.drpDept.SelectedValue.ToString();
            dtid = this.drpTable.SelectedValue.ToString();
            BindGV(appid, dtid);
        }

public override void VerifyRenderingInServerForm(Control control)
        {
            //base.VerifyRenderingInServerForm(control);
        }
        #endregion

}
}

.net简单页面后台绑定下拉框,按钮,分页 后台cs文件的更多相关文章

  1. .net简单页面后台绑定下拉框,按钮,分页 前台aspx页面

    一.aspx页面 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Updat ...

  2. WPF AutoGeneratingColumn 绑定下拉框

    WPF自动产生列,前台代码: <DataGrid x:Name="Dg" AutoGenerateColumns="True" CanUserAddRow ...

  3. ASP.NET MVC中的cshtml页面中的下拉框的使用

    ASP.NET MVC中的cshtml页面中的下拉框的使用 用上@Html.DropDownList 先记下来..以做备忘...

  4. 奥展项目笔记07--vue绑定下拉框和checkbox总结

    1.vue绑定下拉框 <div class="col-md-1 data"> <select class="form-control " v- ...

  5. 表id关联数据获取至页面,制作下拉框多选进行数据多项获取(字段处理)

     这周完成了一张表单,重点碰到以下问题: 1.freemaker获取年份的type值取year,类型直接为Long,传至后台和获取数据不需要转换: 2.freemaker获取日期type值为date, ...

  6. MVC4 绑定下拉框方法,解决编辑时不绑定值

    方法一  Controller 部分代码: public ActionResult Modify(int id) { //3.1.1 检查id //3.1.2根据id查询数据 Models.Stude ...

  7. Select级联菜单,用Ajax获取Json绑定下拉框(jQuery)

    需求类似这样  ↓ ↓ ↓   -->    菜单A发生变化,动态取数据填充下拉菜单B. JS代码如下: <script type="text/javascript"& ...

  8. 分公司下拉框赋值-从后台传到前端jsp

    我的旧代码  List<MetaBranchCfg> list = metaBranchCfgBO.queryAllBranchList();  request.setAttribute( ...

  9. jquery easyui无法绑定下拉框内容

    最近在研究jquery easyui的DataGrid,发现DataGrid中的下拉框无法绑定值,找了很久也没发现是具体问题所在,最后还是同事帮忙搞定的.具体问题竟然是jquery easyui提供的 ...

随机推荐

  1. linux分区和系统文件和挂载

    要以root用户进入 .查看磁盘情况 lsblk .进行分区 sudo cfdisk /dev/sda 在空闲资源的地方新建分区,然后一步步的走下来就行了,最后选择write,然后quit 重启 .创 ...

  2. Java protobuf框架使用向导

    ProtoBuf,全称是Protocol Buffers, 它是谷歌内部用的一种高效的.可扩展的对结构化数据进行编码的格式规范.谷歌自己内部很多程序之间的通信协议都用了ProtoBuf. 下面介绍的是 ...

  3. 关于在transform下的子元素设置fixed无效的困惑

    最近的项目是要实现一个点击显示隐藏边栏的效果,而且需要边栏随着滚动而滚动. 思路简单,不就一个css的动画和一个position为fixed,搞定!但不想,设为fixed的子元素竟然无法fixed,这 ...

  4. Linux下查看Apache的请求数

    在Linux下查看Apache的负载情况,以前也说过,最简单有有效的方式就是查看Apache Server Status(如何开启Apache Server Status点这里),在没有开启Apach ...

  5. jquery1.9学习笔记 之层级选择器(二)

    子孙选择器(“祖先 子孙”) 描述:选择所有给出祖先选择器的子孙选择器. 例子: 用蓝色虚线边框标记所有表单子孙元素的输入.表单里的输入框用黄色背景. <!doctype html>< ...

  6. Ubuntu 配置swftools(Ubuntu14.04)

    1.下载文件 wget http://swftools.org/swftools-0.9.0.tar.gz .tar.gz wget http://www.ijg.org/files/jpegsrc. ...

  7. ECstore报表不显示解决

    最近研究ECSTORE发现后台报表显示空白,Google了一下发现N多统一的做法,直接往表里插几条数据.呵呵,更深入一点 1.要显示报表功能首先要确保已经配置好contab的定时任务,定时任务能够执行 ...

  8. Kafka笔记--分布式环境搭建

    部署: http://www.cnblogs.com/likehua/p/3999538.html http://blog.csdn.net/kimmking/article/details/8263 ...

  9. 继网易博客后搜狐博客也增加了nofollow标签

    继网易博客后搜狐博客也增加了nofollow标签 今天在搜狐博客发表了篇文章,在末端添加上我的版权,结果回头查看是发现,这个锚文本被加上了nofollow标签,也就是说这样的外链已经没有传递权重的作用 ...

  10. Android SDK 下载速度慢解决方法

    Mac 本搞Android开发,遇到Android SDK 下载速度慢,解决方法大概有两种.第一,FQ.这种方法比较彻底,但是要想有稳定的效果还的要花大价钱.第二,有些高人直接给了SDK中各软件的下载 ...