📄 customersmanmodule.ascx.cs
字号:
namespace JdglWeb.Modules
{
using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
/// <summary>
/// CustomersManModule 的摘要说明。
/// </summary>
public class CustomersManModule : ModuleBase
{
protected System.Web.UI.WebControls.Button search;
protected System.Web.UI.WebControls.DataGrid dg_CustomersList;
protected System.Web.UI.WebControls.DropDownList StatusList;
protected System.Web.UI.WebControls.TextBox InputTextBox;
protected System.Web.UI.WebControls.DropDownList MouthFromList;
protected System.Web.UI.WebControls.DropDownList DayFromList;
protected System.Web.UI.WebControls.DropDownList MouthToList;
protected System.Web.UI.WebControls.DropDownList DayToList;
protected System.Web.UI.WebControls.DropDownList YearFromList;
protected System.Web.UI.WebControls.DropDownList YearToList;
protected System.Web.UI.WebControls.Button ShowAll;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack) Show_CustomersList();
}
protected void Show_CustomersList()
{
//从文件Web.config中读取连接字符串
string sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
//连接JdglSys数据库
SqlConnection Conn = new SqlConnection (sqldb);
//定义sql语句
String selsql="select c.CName,c.CIdentityId,r.RoomId,r.BeginTime,c.CPhone "+
"from RoomOperation r,CustomersInfo c where c.CIdentityId=r.CIdentityId";
//创建SqlDataAdapter对象,调用selsql
SqlDataAdapter myadapter = new SqlDataAdapter (selsql,Conn);
//创建并填充DataSet
DataSet ds = new DataSet ();
myadapter.Fill (ds);
dg_CustomersList.DataSource =ds;
dg_CustomersList.DataBind ();
Conn.Close ();
}
protected void DataGrid_Page(Object sender,DataGridPageChangedEventArgs E)
{
dg_CustomersList.CurrentPageIndex =E.NewPageIndex ;
Show_CustomersList();
}
#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 ShowAll_Click(object sender, System.EventArgs e)
{
Show_CustomersList();
}
private void search_Click(object sender, System.EventArgs e)
{
dg_CustomersList.CurrentPageIndex=0;
//从文件Web.config中读取连接字符串
string sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
//连接JdglSys数据库
SqlConnection Conn = new SqlConnection (sqldb);
//定义sql语句
String selsql="select c.CName,c.CIdentityId,r.RoomId,r.BeginTime,c.CPhone "+
"from RoomOperation r,CustomersInfo c where c.CIdentityId=r.CIdentityId";
//读取时间纪录
string datefrom=YearFromList.SelectedItem.Value.ToString()+"-"+MouthFromList.SelectedItem.Value.ToString()+"-"+DayFromList.SelectedItem.Value.ToString();
string dateto=YearToList.SelectedItem.Value.ToString()+"-"+MouthToList.SelectedItem.Value.ToString()+"-"+DayToList.SelectedItem.Value.ToString();
selsql=selsql+" and r.BeginTime between '"+datefrom+"'and'"+dateto+"'";
//读取方式记录
if(InputTextBox.Text!="")
{
//按姓名
if(StatusList.SelectedIndex==1)
selsql=selsql+" and c.CName='"+InputTextBox.Text.Trim()+"'";
//按身份证号
else if(StatusList.SelectedIndex==2)
selsql=selsql+" and c.CIdentityId='"+InputTextBox.Text.Trim()+"'";
}
//创建SqlDataAdapter对象,调用selsql
SqlDataAdapter myadapter = new SqlDataAdapter (selsql,Conn);
//创建并填充DataSet
DataSet ds = new DataSet ();
myadapter.Fill (ds);
dg_CustomersList.DataSource =ds;
dg_CustomersList.DataBind ();
Conn.Close ();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -