📄 basedata.aspx.cs
字号:
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);
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;
hcell.VerticalAlign =System.Web.UI.WebControls.VerticalAlign.Top;
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);
ctrl_cell.Visible =true;
ctrl_cell.VerticalAlign =System.Web.UI.WebControls.VerticalAlign.Top;
// thr.Cells.Add(ctrl_cell);//加列编辑控件
//db.Msgbox(colcnt.ToString(),cnt.ToString(),this.Page);
if(ctrl.GetType().ToString()=="System.Web.UI.WebControls.TextBox")//如果是多行文本框
{
if(((TextBox)ctrl).Rows>1)
{
for(int i=0;i<columnCnt-1;i++)
{
//thr.Cells.Add(new TableCell());
hr.Cells.Add(new TableCell());
hr.Cells.Add(new TableCell());
}
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;
ctrl_cell.ColumnSpan=2*columnCnt-1;//跨列数=行内列数*2-1(标题列)
}
}
hr.Cells.Add(hcell);
hr.Cells.Add(ctrl_cell);
if(ctrl.GetType().ToString()=="System.Web.UI.WebControls.TextBox")//如果是多行文本框
{
if(((TextBox)ctrl).Rows>1)
{
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;
}
}
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);
}
}
}
//*************************************增加下拉框级联处理**************************
//update by zhouys 2006/02/11
// if(ViewState["act"].ToString()!="S")
// {
// for(int cnt=0;cnt<hasht.Count;cnt++)
// {
// string str_col=((Hashtable)hasht[cnt])["NAME_EN"].ToString();
// string str_tmp=db.Judge_Fkey_IsRec(tablename,str_col);
// string ptab;
// Hashtable hs_sub=new Hashtable();
// if(str_tmp==null||str_tmp=="")//如果不存在下级外键,不处理
// {
// continue;
// }
// ptab=((Hashtable)hasht[cnt])["FTABLE"].ToString();
// hs_sub=db.GetColumnInfo(tablename,str_tmp,this.Page);
// //级联菜单置空
// ((DropDownList)ctrl_list[cnt]).SelectedIndex = 0;
// ((DropDownList)ctrl_list[int.Parse(hs_sub["COL_ID"].ToString())-1]).Items.Clear();
// //委托给Relax_Click
// ((DropDownList)ctrl_list[cnt]).AutoPostBack =true;
// ((DropDownList)ctrl_list[cnt]).SelectedIndexChanged +=new System.EventHandler(Relax_Click);
//
//
// }
// }
//*********************************************************************************
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 事件
#region 级联下拉框按钮事件
void Relax_Click(object sender, System.EventArgs e)
{
//////////////////// Hashtable hs_par=new Hashtable();
//////////////////// Hashtable hs_sub=new Hashtable();
//////////////////// string str_par,str_sub;
//////////////////// str_par=((DropDownList)sender).ID.Trim().Substring(5);//txt_ctrlname获得txt_后的字符串
//////////////////// str_sub=db.Judge_Fkey_IsRec(ViewState["tablename"].ToString(),str_par);
//////////////////// hs_par = db.GetColumnInfo(ViewState["tablename"].ToString(),str_par,this.Page);
//////////////////// hs_sub = db.GetColumnInfo(ViewState["tablename"].ToString(),str_sub,this.Page);
//////////////////// bool enblerelax=true;
//////////////////// if(ViewState["act"].ToString()=="S")
//////////////////// {
//////////////////// enblerelax=false;
//////////////////// }
//////////////////// db.RelaxDdlProcess((DropDownList)sender,hs_par["FTABLE"].ToString(),(DropDownList)ctrl_list[int.Parse(hs_sub["COL_ID"].ToString())-1],hs_sub["FTABLE"].ToString(),((DropDownList)sender).SelectedValue.Trim(),enblerelax);
}
#endregion
#region 编辑
private void dg_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(this.Session["system"]==null)
{
db.Msgbox("超时,请重新登陆!","",this.Page);
return;
}
this.clear_msg();
this.gopage(int.Parse(ViewState["page"].ToString()),ViewState["Quary_sql"].ToString());
DataSet ds=new DataSet();
string table=ViewState["tablename"].ToString().Trim();
string sql=db.OccurSqlDisplayCn(table,false,this.Page);//"select * from " +table;
string[] key_arr=new string[1];
key_arr=db.GetKey(table,this.Page);
int cnt=db.RealCount(key_arr,"");
if(cnt>0)
{
sql=sql+" WHERE ";
}
string str_condition="";
for(int i=0;i<cnt;i++)//获得单条记录的sql语句
{
Hashtable ht=new Hashtable();
ht=db.GetColumnInfo(table,key_arr[i],this.Page);
int colid=int.Parse(ht["COL_ID"].ToString());
str_condition+=","+db.GetCompValue(table,key_arr[i].Trim(),e.Item.Cells[cdg.GetBoundColID(dg,colid)].Text.Trim(),this.Page);
}
str_condition=str_condition.Substring(1);//
// db.Msgbox(str_condition,"",this.Page);
sql+= str_condition;
ds=db.GetDataSet(sql,this.Page);
if(ds==null)
{
return;
}
// if(ds.Tables[0].Rows.Count==0)
// {
// db.Msgbox("没有满足条件的值","条件错误",this.Page);
// return;
// }
if(ds.Tables[0].Rows.Count==0)
{
db.Msgbox("没有满足条件的值","条件错误",this.Page);
return;
}
ArrayList al=db.GetColumnInfo(table,this.Page);
int shift_cnt=0;
for(int j=0;j<al.Count;j++)//给编辑控件赋值
{
if(FindControl("hidtxt_"+ds.Tables[0].Columns[j].Caption.Trim())!=null)
{
db.SetControlValue(this.Page,"hidtxt_"+ds.Tables[0].Columns[j].Caption.Trim(),e.Item.Cells[cdg.GetBoundColID(dg,j+2)+shift_cnt].Text.Trim());
db.SetControlValue(this.Page,"edit_"+ds.Tables[0].Columns[j].Caption.Trim(),e.Item.Cells[cdg.GetBoundColID(dg,j+1)+shift_cnt].Text.Trim());
}
else
{
db.SetControlValue(this.Page,"edit_"+ds.Tables[0].Columns[j].Caption.Trim(),e.Item.Cells[cdg.GetBoundColID(dg,j+1)+shift_cnt].Text.Trim());
}
if(((Hashtable)al[j])["FTABLE"].ToString()!="")
{
shift_cnt++;
}
}
// ViewState["Quary_sql"]=ViewState["sql"].ToString();
this.gopage(int.Parse(ViewState["page"].ToString()),ViewState["Quary_sql"].ToString());
}
#endregion
#region 清除
private void ibtn_clr_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if(this.Session["system"]==null)
{
db.Msgbox("超时,请重新登陆!","",this.Page);
return;
}
this.clear_msg();
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";
// ViewState["Quary_sql"]=ViewState["sql"].ToString();
}
#endregion
#region 查询
private void ibtn_qry_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if(this.Session["system"]==null)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -