formbase.aspx.cs
来自「ASP.NET的一些开发实例,有论坛管理系统等」· CS 代码 · 共 639 行 · 第 1/2 页
CS
639 行
dr["window_value"]=sLogData[3];
dt.Rows.Add(dr);
}
//更新用户日志表
protected void UpdateUserLog(string[] sLogData)
{
if(Application["user_log"]==null)
{
CreatUserLog();
}
DataSet ds=(DataSet)Application["user_log"];
string log_where="user_num='"+sLogData[0]+"' and window_name='"+sLogData[2]+"'";
DataRow[] CurrRow=ds.Tables[0].Select(log_where,null,DataViewRowState.CurrentRows);
if(CurrRow.Length>0)
{
foreach(DataRow row in CurrRow)
{
row["user_num"]=sLogData[0];
row["window_status"]=sLogData[1];
row["window_name"]=sLogData[2];
row["window_value"]=sLogData[3];
}
}
else
{
InsertUserLog(sLogData);
}
}
//取窗口记录参数
public string GetValueFromUserLog(string sWindowName)
{
if(Application["user_log"]==null)
{
CreatUserLog();
}
string s_return="W";
DataSet ds=(DataSet)Application["user_log"];
string log_where="user_num='"+(string)Session["userid"]+"' and window_name='"+sWindowName+"' and window_status='1'";
DataRow[] CurrRow=ds.Tables[0].Select(log_where,null,DataViewRowState.CurrentRows);
if(CurrRow.Length>0)
{
foreach(DataRow row in CurrRow)
{
s_return=row["window_value"].ToString();
}
}
return s_return;
}
//关闭用户日志
protected void UserLogClose(string sWindowName)
{
if(Application["user_log"]==null)
{
CreatUserLog();
}
DataSet ds=(DataSet)Application["user_log"];
string log_where="user_num='"+(string)Session["userid"]+"' and window_name='"+sWindowName+"'";
DataRow[] CurrRow=ds.Tables[0].Select(log_where,null,DataViewRowState.CurrentRows);
if(CurrRow.Length>0)
{
foreach(DataRow row in CurrRow)
{
row["window_status"]="0";
}
}
}
//建立用户当前窗口的父窗口数据集
protected void CreatUserLogParentWindow(string sWindowName,string sParentWindowName)
{
DataSet ds;
if(Application["user_parent"]==null)
{
DataTable dt=new DataTable();
dt.Columns.Add(new DataColumn("inc_num",typeof(int)));
dt.Columns.Add(new DataColumn("user_num",typeof(string)));
dt.Columns.Add(new DataColumn("window_name",typeof(string)));
dt.Columns.Add(new DataColumn("window_parent",typeof(string)));
dt.Columns.Add(new DataColumn("window_status",typeof(string)));
ds=new DataSet();
ds.Tables.Add(dt);
Application["user_parent"]=ds;
}
else
{
ds=(DataSet)Application["user_parent"];
}
string log_where="user_num='"+(string)Session["userid"]+"' and window_name='"+sWindowName+"'";
DataRow[] CurrRow=ds.Tables[0].Select(log_where,null,DataViewRowState.CurrentRows);
if(CurrRow.Length>0)
{
foreach(DataRow row in CurrRow)
{
row["window_parent"]=sParentWindowName;
}
}
else
{
DataRow dr=ds.Tables[0].NewRow();
int inc_num=ds.Tables[0].Rows.Count+1;
dr["inc_num"]=inc_num;
dr["user_num"]=(string)Session["userid"];
dr["window_name"]=sWindowName;
dr["window_parent"]=sParentWindowName;
dr["window_status"]="1";
ds.Tables[0].Rows.Add(dr);
}
}
//取当前窗口的父窗口值
protected string GetParentWindowValueFromUserLog(string sWindowName)
{
string s_return="W";
if(Application["user_parent"]!=null)
{
DataSet ds=(DataSet)Application["user_parent"];
string log_where="user_num='"+(string)Session["userid"]+"' and window_name='"+sWindowName+"' and window_status='1'";
DataRow[] CurrRow=ds.Tables[0].Select(log_where,null,DataViewRowState.CurrentRows);
if(CurrRow.Length>0)
{
foreach(DataRow row in CurrRow)
{
s_return=row["window_parent"].ToString();
}
}
}
//UserLogParentWindowClose(sWindowName);
return s_return;
}
//关闭父窗口日志
protected void UserLogParentWindowClose(string sWindowName)
{
DataSet ds=(DataSet)Application["user_parent"];
string log_where="user_num='"+(string)Session["userid"]+"' and window_name='"+sWindowName+"'";
DataRow[] CurrRow=ds.Tables[0].Select(log_where,null,DataViewRowState.CurrentRows);
if(CurrRow.Length>0)
{
foreach(DataRow row in CurrRow)
{
row["window_status"]="0";
}
}
}
//储存当前状态值
protected void SaveFormStatus(string l_str_FormName,string l_str_StatusData)
{
if(Session["userid"]==null)
{
Session["userid"]="1";
}
string[] sLogData=new String[4];
sLogData[0]=(string)Session["userid"];
sLogData[1]="1";
sLogData[2]=l_str_FormName;
sLogData[3]=l_str_StatusData;
this.UpdateUserLog(sLogData);//记录当前窗口数据值
}
//取DropDownList的选择行
protected void DropSelectNum(DropDownList dr,string s_value)
{
int i_cou,i_num;
i_num=0;
i_cou=dr.Items.Count;
for(int i=0;i<i_cou;i++)
{
if(dr.Items[i].Value==s_value)
{
i_num=i;
break;
}
}
dr.SelectedIndex=i_num;
}
/*给控件标签赋值*/
protected void Out_label(string m_num,string FaceName,System.Web.UI.Page Out_page)
{
DataSet dsTitle=this.COMInterface.DsInterfaceTitle(m_num,FaceName);
string ls_id;
int i=1;
foreach(DataRow row in dsTitle.Tables[0].Rows)
{
System.Web.UI.Control con = Out_page.FindControl("Out_Label"+i.ToString());
if(con!=null)
{
if (con.GetType().ToString()== "System.Web.UI.WebControls.Label")
{
((System.Web.UI.WebControls.Label)con).Text=row["t_title"].ToString();
}
}
i++;
}
}
/*给控件内容赋值*/
protected void Put_IntextBox(string m_num,string FaceName,DataSet dsData,System.Web.UI.Page Out_page)
{
DataSet dsTitle=this.COMInterface.DsInterfaceTitle(m_num,FaceName);
for(int i=1;i<=dsTitle.Tables[0].Rows.Count;i++)
{
foreach(DataRow row in dsData.Tables[0].Rows)
{
System.Web.UI.Control con = Out_page.FindControl("In_TextBox"+i.ToString());
if(con!=null)
{
if (con.GetType().ToString()== "System.Web.UI.WebControls.Label")
{
((System.Web.UI.WebControls.Label)con).Text=row[i-1].ToString();
}
if (con.GetType().ToString()== "System.Web.UI.WebControls.TextBox")
{
((System.Web.UI.WebControls.TextBox)con).Text=row[i-1].ToString();
}
if (con.GetType().ToString()== "System.Web.UI.WebControls.DropDownList")
{
DropSelectNum((System.Web.UI.WebControls.DropDownList)con,row[i-1].ToString());
}
}
}
}
}
/*将界面数据组织成DataSet*/
protected DataSet SetFaceDataToDataSet(string m_num,string FaceName,System.Web.UI.Page Out_page)
{
DataSet dsTitle=this.COMInterface.DsInterfaceTitle(m_num,FaceName);
DataSet dsData=new DataSet();
DataTable dtData=new DataTable();
DataRow dr;
foreach(DataRow row in dsTitle.Tables[0].Rows)
{
dtData.Columns.Add(new DataColumn(row["t_name"].ToString(),typeof(string)));
}
// string ls_id;
// int li_start,li_count;
dr=dtData.NewRow();
// foreach (System.Web.UI.Control con in Out_page.Controls[1].Controls)
// {
// ls_id=con.ID;
// if (ls_id==null) continue;
// li_start=ls_id.IndexOf("In_TextBox");
// if (li_start>=0)//如果是字段标题
// {
// li_count=int.Parse(ls_id.Substring(10));
// if (con.GetType().ToString()== "System.Web.UI.WebControls.TextBox")
// {
// dr[sFieldName[li_count -1]]=((System.Web.UI.WebControls.TextBox)con).Text;
// }
// }
// }
int i=1;
foreach(DataRow row in dsTitle.Tables[0].Rows)
{
System.Web.UI.Control con = Out_page.FindControl("In_TextBox"+i.ToString());
if(con!=null)
{
if (con.GetType().ToString()== "System.Web.UI.WebControls.TextBox")
{
dr[row["t_name"].ToString()]=((System.Web.UI.WebControls.TextBox)con).Text;
}
if (con.GetType().ToString()== "System.Web.UI.WebControls.DropDownList")
{
dr[row["t_name"].ToString()]=((System.Web.UI.WebControls.DropDownList)con).SelectedItem.Value;
}
}
i++;
}
dtData.Rows.Add(dr);
dsData.Tables.Add(dtData);
return dsData;
}
protected void CommonButtonInit()
{
string thisPageUrl=Page.Request.Url.ToString();
int i_index=thisPageUrl.IndexOf("/WhiteForum/");
thisPageUrl = thisPageUrl.Substring(i_index+12);
string sqlquery="select * from system_module where m_type='3' and m_name<>'Enter' and m_up in(select m_num from system_module where m_url='"+thisPageUrl+"')";
DataSet DsmapRole=this.COMInterface.CreateDataSetFromSql(sqlquery);
foreach(DataRow mapRoleRow in DsmapRole.Tables[0].Rows)
{
string enableRole=mapRoleRow["enable_role"].ToString();
string rolePoint=mapRoleRow["m_name"].ToString();
object obj=this.Page.FindControl(rolePoint);
if(obj==null)
{
continue;
}
string type=obj.GetType().ToString();
if((type=="System.Web.UI.WebControls.TextBox")||(type=="System.Web.UI.WebControls.DropDownList"))
{
continue;
}
this.Page.FindControl(rolePoint).Visible=false;
DataSet DsuserRole=(DataSet)Session["DsUserRole"];
foreach(DataRow userRoleRow in DsuserRole.Tables[0].Rows)
{
if(enableRole.IndexOf(userRoleRow["role_num"].ToString())>-1)
{
this.Page.FindControl(rolePoint).Visible=true;
break;
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?