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

📄 basedata.aspx.cs

📁 通过配置表中的各列支持绝大部分的基础数据
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using comm.include ;
using comm.Logic;
using E3S.Framework.UI;
using E3S.Framework.Publics.Data;
using E3S.Framework.Publics ;
using E3S.Controls.Define;
using E3S.Controls;

namespace comm
{
    /// <summary>
    /// BaseData 的摘要说明。
    /// </summary>
    public class BaseData : System.Web.UI.Page 
    {
        #region 变量定义
        protected System.Web.UI.WebControls.Panel Panel_Operate;
        protected System.Web.UI.WebControls.Panel Panel_Page;
        protected System.Web.UI.WebControls.Panel Panel_DG;
        protected System.Web.UI.WebControls.Panel Panel_Edit;
        protected System.Web.UI.WebControls.Table ht;
        protected System.Web.UI.WebControls.DataGrid dg;
        protected System.Web.UI.WebControls.Label lbl_tablename;
        protected System.Web.UI.WebControls.Panel Panel_Title;
        protected System.Web.UI.WebControls.ImageButton ibtn_clr;
        protected System.Web.UI.WebControls.ImageButton ibtn_del;
        protected System.Web.UI.WebControls.ImageButton ibtn_save;
        protected System.Web.UI.WebControls.ImageButton ibtn_add;
        protected System.Web.UI.WebControls.ImageButton ibtn_qry;
        protected System.Web.UI.WebControls.Label hid_act;
        include.Db db=new Db();
        include.BaseData bd=new comm.include.BaseData();
        BaseDataLogic bdl;
        CDataGrid cdg;
        protected System.Web.UI.WebControls.ImageButton imgbtn_next;
        protected System.Web.UI.WebControls.ImageButton imgbtn_first;
        protected System.Web.UI.WebControls.ImageButton imgbtn_pre;
        protected System.Web.UI.WebControls.ImageButton imgbtn_end;
        protected System.Web.UI.WebControls.ImageButton imgbtn_go;
        protected System.Web.UI.WebControls.Label lbl_currpage;
        protected System.Web.UI.WebControls.Label lbl_pagecnt;
        protected System.Web.UI.WebControls.TextBox txt_page;
        protected System.Web.UI.WebControls.ImageButton ibtn_prt;
        E3S.Framework.Publics.Data.DataEntity de=new DataEntity();
        protected System.Web.UI.WebControls.RadioButtonList rdlist_shift;
        protected System.Web.UI.WebControls.Label show_message;
        ArrayList ctrl_list=new ArrayList();
        #endregion

        #region 页载入
        private void Page_Load(object sender, System.EventArgs e)
        {
            if(this.Session["system"]==null)
            {
                db.Msgbox("超时,请重新登陆!","",this.Page);
                return;
            }
            this.ibtn_del.Attributes.Add("onclick","window.confirm('确认删除?')");
            bdl=new BaseDataLogic(this.Session["system"].ToString(),
                this.Session["IP"].ToString(),
                this.Session["usr"].ToString(),
                this.Session["pwd"].ToString());
            cdg=new CDataGrid(this.Session["system"].ToString(),
                this.Session["IP"].ToString(),
                this.Session["usr"].ToString(),
                this.Session["pwd"].ToString());
            db.DataBase =this.Session["system"].ToString();
            db.IP =  this.Session["IP"].ToString();
            db.Usr=   this.Session["usr"].ToString();
            db.Pwd= this.Session["pwd"].ToString();
            if(this.Session["system"]==null)
            {
                db.Msgbox("非法登陆!","警告",this.Page);
                this.Dispose();
            }
            else
            {
                db.DataBase=this.Session["system"].ToString().Trim();
            }
            if(this.Request["tablename"]==null)
            {
                return;
            }
            string tablename =this.Request["tablename"].Trim();
            ViewState["tablename"]=tablename;
            if(!this.IsPostBack)
            {
                //db.Msgbox(tablename,"",this.Page);
                ViewState["act"]="C";
                this.hid_act.Text ="C";
                ViewState["page"]=1;
                //				string sql=db.OccurSqlDisplayCn(ViewState["tablename"].ToString().Trim(),true,this.Page,0,true);
                //				ViewState["sql"]=sql;
                //				ViewState["Quary_sql"]=sql;
				
				
            }
            if(init(tablename)==false)
            {
                return;
            }
            // 在此处放置用户代码以初始化页面
        }
        #endregion

        #region Web 窗体设计器生成的代码
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
            //
            InitializeComponent();
            base.OnInit(e);
        }
		
        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {    
            this.ibtn_qry.Click += new System.Web.UI.ImageClickEventHandler(this.ibtn_qry_Click);
            this.ibtn_add.Click += new System.Web.UI.ImageClickEventHandler(this.ibtn_add_Click);
            this.ibtn_save.Click += new System.Web.UI.ImageClickEventHandler(this.ibtn_save_Click);
            this.ibtn_del.Click += new System.Web.UI.ImageClickEventHandler(this.ibtn_del_Click);
            this.ibtn_clr.Click += new System.Web.UI.ImageClickEventHandler(this.ibtn_clr_Click);
            this.ibtn_prt.Click += new System.Web.UI.ImageClickEventHandler(this.ibtn_prt_Click);
            this.imgbtn_first.Click += new System.Web.UI.ImageClickEventHandler(this.imgbtn_first_Click);
            this.imgbtn_pre.Click += new System.Web.UI.ImageClickEventHandler(this.imgbtn_pre_Click);
            this.imgbtn_next.Click += new System.Web.UI.ImageClickEventHandler(this.imgbtn_next_Click);
            this.imgbtn_end.Click += new System.Web.UI.ImageClickEventHandler(this.imgbtn_end_Click);
            this.imgbtn_go.Click += new System.Web.UI.ImageClickEventHandler(this.imgbtn_go_Click);
            this.dg.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dg_EditCommand);
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion

        #region 初始化界面

        #region 初始化所有界面
        public bool init(string tablename)
        {
            this.lbl_tablename.Text =tablename;
            int colcnt;
            ArrayList al=new ArrayList();
            al=db.GetColumnInfo(tablename,this.Page);
            for(int i=0;i<al.Count;i++)//初始化实体
            {
                de.Add(((Hashtable)al[i])["NAME_EN"].ToString().Trim(),((Hashtable)al[i])["NAME_EN"].ToString().Trim());
            }
            if(Request["colcnt"]==null)
            {
                if(al.Count<8)
                {
                    colcnt=2;
                }
                else if(al.Count>=9&&al.Count<16)
                {
                    colcnt=3;
                }
                else
                {
                    colcnt=3;
                }
            }
            else
            {
                colcnt=int.Parse(Request["colcnt"].Trim());
            }
            if(init_edit(tablename,colcnt)==false)//初始化编辑面板
            {
                return false;
            }
            this.Panel_Edit.Visible=true;
            if(init_dg(tablename)==false)//初始化datagrid
            {
                return false;
            }
			
            return true;
        }
        #endregion

        #region 初始化dg界面
        public bool init_dg(string tablename)
        {
            this.Panel_DG.Visible =false;
            DataSet ds=new DataSet();
            string sql=sql=db.OccurSqlDisplayCn(ViewState["tablename"].ToString().Trim(),true,this.Page,0,true);
            if(ViewState["sql"]==null)//如果是空,select * from tablename
            {
                ViewState["sql"]=sql;
            }
            else //否则,用上一次的查询结果
            {
                ViewState["sql"]=ViewState["Quary_sql"].ToString();
            }
            if(ViewState["Quary_sql"]==null)
            {
                ViewState["Quary_sql"]=ViewState["sql"].ToString();
            }
            ds=db.GetDataSet(ViewState["Quary_sql"].ToString(),this.Page);
            if(ds==null)
            {
                return false;
            }
            cdg.Init(dg,tablename,ds,this.Page);
            db.Url_Check(ref ds);
            this.dg.DataSource=ds;
            dg.DataBind();
            this.gopage(int.Parse(ViewState["page"].ToString()),ViewState["Quary_sql"].ToString());
            ViewState["sql"]=sql;
            dg.Visible=true;
            this.Panel_DG.Visible =true;
				
            return true;
        }
        #endregion

        #region 初始化编辑界面
        public bool init_edit(string tablename,int columnCnt)
        {
            bool ret=false;
            //主体
            this.Panel_Edit.Visible =false;
            ArrayList hasht=new ArrayList();
            hasht=db.GetColumnInfo(tablename,this.Page);
            if(hasht==null)
            {
                db.Msgbox("初始化失败!","",this.Page);
                return ret;
            }
            int colcnt=0;
            //System.Web.UI.WebControls.Table ht=new Table();
            ht.Rows.Clear(); //清空所有行
            System.Web.UI.WebControls.TableRow  hr=new TableRow();
            ht.Rows.Clear();
            for(int cnt=0;cnt<hasht.Count;cnt++)
            {
					
                System.Web.UI.WebControls.TableCell hcell=new TableCell();
                System.Web.UI.WebControls.TableCell ctrl_cell=new TableCell();
                colcnt++;
                Hashtable colinf=new Hashtable();
                colinf=(Hashtable)hasht[cnt];
                Label lbl_obj=new Label(); //标题

⌨️ 快捷键说明

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