📄 commreport.aspx.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;
namespace comm
{
/// <summary>
/// CommReport 的摘要说明。
/// </summary>
public class CommReport : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lbl_tablename;
protected System.Web.UI.WebControls.Label hid_act;
protected System.Web.UI.WebControls.ImageButton ibtn_qry;
protected System.Web.UI.WebControls.ImageButton ibtn_clr;
protected System.Web.UI.WebControls.ImageButton ibtn_prt;
protected System.Web.UI.WebControls.Panel Panel_Operate;
protected System.Web.UI.WebControls.Table ht;
protected System.Web.UI.WebControls.Panel Panel_Edit;
protected System.Web.UI.WebControls.Panel Panel_DG;
include.Db db=new Db();
include.BaseData bd=new comm.include.BaseData();
BaseDataLogic bdl;
CDataGrid cdg;
E3S.Framework.Publics.Data.DataEntity de=new DataEntity();
protected System.Web.UI.WebControls.DataGrid dg;
ArrayList ctrl_list=new ArrayList();
#region 页载入
private void Page_Load(object sender, System.EventArgs e)
{
/************************************************
*
* ViewState["act"]:
* A:add
* Q:quary
* S:DropDownList
* U:Upate
* C:InterFace Inited
* R:reload
* *****************************/
ViewState["act"]="R";
// bdl=new BaseDataLogic(this.Application["system"].ToString(),
// this.Application["IP"].ToString(),
// this.Application["usr"].ToString(),
// this.Application["pwd"].ToString());
// cdg=new CDataGrid(this.Application["system"].ToString(),
// this.Application["IP"].ToString(),
// this.Application["usr"].ToString(),
// this.Application["pwd"].ToString());
// db.DataBase =this.Application["system"].ToString();
// db.IP = this.Application["IP"].ToString();
// db.Usr= this.Application["usr"].ToString();
// db.Pwd= this.Application["pwd"].ToString();
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.Application["system"]==null)
if(this.Session["system"]==null)
{
db.Msgbox("非法登陆!","警告",this.Page);
this.Dispose();
}
else
{
// db.DataBase=this.Application["system"].ToString().Trim();
db.DataBase=this.Session["system"].ToString().Trim();
}
if(this.Request["tablename"]==null)
{
return;
}
else
{
if(this.Request["tablename"].Trim()=="")
{
return;
}
}
string tablename =this.Request["tablename"].Trim();
ViewState["tablename"]=tablename;
// GetPageData();
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_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.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;
}
if(this.init_dg(tablename)==false)//初始化编辑面板
{
return false;
}
this.Panel_Edit.Visible=true;
// if(init_dg(tablename)==false)//初始化datagrid
// {
// return false;
// }
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(); //标题
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);
// this.Page.Controls.Add(lbl_obj);
if(colinf["ISNULL"].ToString().Trim()=="0")//如果非空,加红*
{
Label lbl_isnull=new Label();
lbl_isnull.Text ="*";
lbl_isnull.ForeColor=Color.Red;
lbl_isnull.Visible =true;
hcell.Controls.Add(lbl_isnull);
}
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.Controls.Add(ctrl);//将输入控件加入数组供后面处理用 update by zhouys date:2006/02/11
ctrl_list.Add(ctrl);
// this.Page.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());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -