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

📄 basedata_dialogfkey.aspx.cs

📁 通过配置表中的各列支持绝大部分的基础数据
💻 CS
字号:
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;
//using PVCallCenter;
//using PVCallCenter.Common;
namespace comm
{
	/// <summary>
	/// BaseData_DialogFKey 的摘要说明。
	/// </summary>
	public class BaseData_DialogFKey : 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_qry;
		protected System.Web.UI.WebControls.Label hid_act;
		include.Db db=new Db();
		protected E3S.Controls.AspNetPagerEx AspNetPagerEx1;
		BaseDataLogic bdl;
		CDataGrid cdg;
		E3S.Framework.Publics.Data.DataEntity de=new DataEntity();
		#endregion

		#region 页载入
		private void Page_Load(object sender, System.EventArgs e)
		{
            cdg=new CDataGrid(this.Application["system"].ToString(),
                this.Application["IP"].ToString(),
                this.Application["usr"].ToString(),
                this.Application["pwd"].ToString());
            bdl=new BaseDataLogic(this.Application["system"].ToString(),
                this.Application["IP"].ToString(),
                this.Application["usr"].ToString(),
                this.Application["pwd"].ToString());
			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";
			
				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_clr.Click += new System.Web.UI.ImageClickEventHandler(this.ibtn_clr_Click);
			this.dg.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dg_ItemCommand);
			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);
			colcnt=3;
			if(init_edit(tablename,colcnt)==false)
			{
				return false;
			}
			this.Panel_Edit.Visible=true;
			if(init_dg(tablename)==false)
			{
				return false;
			}
			
			return true;
		}
		#endregion

		#region 初始化dg界面
		public bool init_dg(string tablename)
		{
			this.Panel_DG.Visible =false;
			string sql=db.OccurSqlDisplayCn(ViewState["tablename"].ToString().Trim(),true,this.Page,3);//只显示3列
			DataSet ds=new DataSet();
			ds=db.GetDataSet(sql,this.Page);
			E3S.Framework.Publics.Data.DataGroup dgp=new DataGroup();
			
			if(ds==null)
			{
				return false;
			}
			//db.Trim(ref ds);
			cdg.Init(dg,tablename,ds,this.Page);
	

			//db.BindDataGrid(dg,ds,tablename,this.Page);
			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<3;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(); //标题
				lbl_obj.ID ="lbl_"+colinf["NAME_EN"].ToString().Trim();
				if(colinf["NAME_CN"].ToString().Trim()=="")
				{
					lbl_obj.Text =colinf["NAME_EN"].ToString().Trim();
				}
				else
				{
					lbl_obj.Text =colinf["NAME_CN"].ToString().Trim();
				}
				hcell.Controls.Add(lbl_obj);
			
				hcell.Visible =true;
					
				System.Web.UI.WebControls.TableRow  thr=new TableRow();
				//					thr.Cells.Add(hcell); //加列标题
				System.Web.UI.Control ctrl=new Control();
				ctrl=db.GetColControl(tablename,colinf,ViewState["act"].ToString().Trim());
				ctrl.Visible =true;
				ctrl_cell.Controls.Add(ctrl);
				ctrl_cell.Visible =true;
				//					thr.Cells.Add(ctrl_cell);//加列编辑控件
				//db.Msgbox(colcnt.ToString(),cnt.ToString(),this.Page);
				hr.Cells.Add(hcell);
				hr.Cells.Add(ctrl_cell);
				if(colcnt==columnCnt)//如果到第二个,换行
				{
					thr=hr;
					hr.Visible =true;
					thr.Visible=true;
					thr.BackColor =Color.FromArgb(225,240,252) ;
					ht.Rows.Add(thr);
					hr=null;
					hr=new TableRow();
					colcnt=0;
				}
				else
				{
					if(cnt==hasht.Count-1)//如果结束了
					{
						thr=hr;
						for(int j=0;j<2*columnCnt-2*colcnt;j++)
						{
							thr.Cells.Add(new TableCell());
						}
						thr.Visible=true;
						thr.BackColor =Color.FromArgb(225,240,252) ;
						ht.Rows.Add(thr);
					}
						
				}
			}
			ht.Style["Align"]="center";
			//ht.Width.Value  =double.Parse(this.Panel_Edit.Width.Value.ToString());
			this.Panel_Edit.Controls.Add(ht);
			ht.Visible =true;
			//结束
			ret=true;
			Panel_Edit.Visible =true;
			return ret;
		}
		#endregion

		#endregion



		#region 事件
		private void ibtn_clr_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if(bdl.BaseDataTextBoxClear(this.Page,ViewState["tablename"].ToString().Trim())==false)
			{
				db.Msgbox("清空失败!","操作",this.Page);
				return;
			}
			this.Panel_Edit.Visible =true;
			this.hid_act.Text="C";
			ViewState["Act"]="C";
		}


		private void ibtn_qry_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			string table=ViewState["tablename"].ToString().Trim();
			ArrayList al=new ArrayList();
			Hashtable ret=new Hashtable();
			al=db.GetColumnInfo(table,this.Page);//获得列信息
			for(int i=0;i<al.Count;i++)//遍历页面中所有edit_元素
			{
				string str_id=((Hashtable)al[i])["NAME_EN"].ToString().Trim();
				string val=db.GetControlValue(this.Page,"edit_"+str_id);
				if(val==""||val==null)
				{
					continue;
				}
				ret.Add(str_id,val);
				
			}
			string sql=bdl.OccurSqlQuery(table,ret,this.Page);
			if(sql=="")
			{
				db.Msgbox("查询失败","操作",this.Page);
				return;
			}
			DataSet ds=new DataSet();
			ds=db.GetDataSet(sql);
			if(ds==null)
			{
				db.Msgbox("查询失败","操作",this.Page);
				return;
			}
			this.dg.DataSource=ds;
			dg.DataBind();

		}
		#endregion


		private void dg_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			Response.Write("<script language='javascript'>");
			Response.Write("var arrModel = new Array();");
			//			Response.Write("arrModel[0] = '"+e.Item.Cells[0].Text+"';");
			//			Response.Write("arrModel[1] = '"+e.Item.Cells[1].Text+"';");
			
			
			Response.Write("arrModel[0] = '"+e.Item.Cells[1].Text+"';");	
			Response.Write("arrModel[1] = '"+e.Item.Cells[2].Text+"';");
			Response.Write("window.returnValue = arrModel;");
			Response.Write("window.close();");
			Response.Write("</script>");
			Response.End();
		}
	}
}

⌨️ 快捷键说明

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