📄 recordsmanmodule.ascx.cs
字号:
namespace KhfwWeb.Modules
{
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// RecordsManModule 的摘要说明。
/// </summary>
public class RecordsManModule : ModuleBase
{
protected System.Web.UI.WebControls.TextBox ClientNameTextBox;
protected System.Web.UI.WebControls.Button search;
protected System.Web.UI.WebControls.Button ShowAll;
protected System.Web.UI.WebControls.DataList dl_RecordsList;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack) Show_RecordsList();
}
protected void Show_RecordsList()
{
//从文件Web.config中读取连接字符串
string sqldb= ConfigurationSettings.AppSettings["ConnectionString"];
//连接JdglSys数据库
SqlConnection Conn= new SqlConnection (sqldb);
//创建SqlDataAdapter对象,调用存储过程sp_ShowRoomsInfo
SqlDataAdapter myadapter=new SqlDataAdapter ("sp_ShowRecordsInfo",Conn);
//创建并填充DataSet
DataSet ds = new DataSet ();
myadapter.Fill (ds);
dl_RecordsList.DataSource =ds;
dl_RecordsList.DataBind ();
//实现“状态”和“级别”的显示
for(int i=0;i<dl_RecordsList.Items.Count;i++)
{
DataRow dr=ds.Tables[0].Rows[i];
if(dr["RStatus"].ToString()=="1")
{
((Label)dl_RecordsList.Items[i].FindControl("StatusLabel")).Text="待分配";
}
else if(dr["RStatus"].ToString()=="2")
{
((Label)dl_RecordsList.Items[i].FindControl("StatusLabel")).Text="已分配";
}
else if(dr["RStatus"].ToString()=="3")
{
((Label)dl_RecordsList.Items[i].FindControl("StatusLabel")).Text="已解决";
}
if(dr["RLevel"].ToString()=="1")
{
((Label)dl_RecordsList.Items[i].FindControl("LevelLabel")).Text="级别一";
}
else if(dr["RLevel"].ToString()=="2")
{
((Label)dl_RecordsList.Items[i].FindControl("LevelLabel")).Text="级别二";
}
else if(dr["RLevel"].ToString()=="3")
{
((Label)dl_RecordsList.Items[i].FindControl("LevelLabel")).Text="级别三";
}
}
Conn.Close ();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.search.Click += new System.EventHandler(this.search_Click);
this.ShowAll.Click += new System.EventHandler(this.ShowAll_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void search_Click(object sender, System.EventArgs e)
{
//从文件Web.config中读取连接字符串
string sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
//连接JdglSys数据库
SqlConnection Conn = new SqlConnection (sqldb);
//创建SqlDataAdapter对象,调用存储过程sp_GetRecordsByClient
SqlDataAdapter myadapter = new SqlDataAdapter ("sp_GetRecordsByClient",Conn);
myadapter.SelectCommand.CommandType=CommandType.StoredProcedure;
myadapter.SelectCommand.Parameters .Add ("@ClientName",SqlDbType.NVarChar);
myadapter.SelectCommand.Parameters ["@ClientName"].Value =ClientNameTextBox.Text.Trim();
//创建并填充DataSet
DataSet ds = new DataSet ();
myadapter.Fill (ds);
dl_RecordsList.DataSource =ds;
dl_RecordsList.DataBind ();
//实现“状态”和“级别”的显示
for(int i=0;i<dl_RecordsList.Items.Count;i++)
{
DataRow dr=ds.Tables[0].Rows[i];
if(dr["RStatus"].ToString()=="1")
{
((Label)dl_RecordsList.Items[i].FindControl("StatusLabel")).Text="待分配";
}
else if(dr["RStatus"].ToString()=="2")
{
((Label)dl_RecordsList.Items[i].FindControl("StatusLabel")).Text="已分配";
}
else if(dr["RStatus"].ToString()=="3")
{
((Label)dl_RecordsList.Items[i].FindControl("StatusLabel")).Text="已解决";
}
if(dr["RLevel"].ToString()=="1")
{
((Label)dl_RecordsList.Items[i].FindControl("LevelLabel")).Text="级别一";
}
else if(dr["RLevel"].ToString()=="2")
{
((Label)dl_RecordsList.Items[i].FindControl("LevelLabel")).Text="级别二";
}
else if(dr["RLevel"].ToString()=="3")
{
((Label)dl_RecordsList.Items[i].FindControl("LevelLabel")).Text="级别三";
}
}
Conn.Close ();
}
private void ShowAll_Click(object sender, System.EventArgs e)
{
Show_RecordsList();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -