| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 486 人关注过本帖
标题:[求助]看看我写的是否对呢?
取消只看楼主 加入收藏
liuminghui
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:2882
专家分:0
注 册:2007-1-26
收藏
 问题点数:0 回复次数:0 
[求助]看看我写的是否对呢?

#region protected
protected System.Web.UI.WebControls.DataGrid dgdRecall;
protected System.Web.UI.WebControls.TextBox txtBookName;
protected System.Web.UI.WebControls.TextBox txtAuthor;
protected System.Web.UI.WebControls.DropDownList ddlCompanyName;
protected System.Web.UI.WebControls.DropDownList ddlBookType;
protected AuoControl.CalendarTextBox calendarMin;
protected AuoControl.CalendarTextBox calendarMax;
protected System.Web.UI.WebControls.Button btnFetchBook;
protected System.Web.UI.WebControls.DataGrid dgdFetchBook;
protected System.Web.UI.WebControls.Button btnPreviewBook;
protected System.Web.UI.WebControls.DataGrid dgdOutRec;
protected System.Web.UI.WebControls.Button btnLendBook;
#endregion protected


#region FullVariable

//定义全局的用户ID和LOCKID
string lock_id="";
string user_id="";
#endregion FullVariable

#region Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
Authority.Check (this,"SA","UACCONFIG","AddNonAUUser_PageLoad");

//获得记录当前使用者的userId
user_id=Authority.GetUacUser(this.Page ).UserId ;

if(!IsPostBack)
{
BookManager book=new BookManager (this);

Session["LOCKID"]=null;
//显示书籍的类型
SQLClass objSQL = new SQLClass();
DataSet DS= objSQL.Search();
DS.Tables[0].Rows.InsertAt(DS.Tables[0].NewRow(),0);
this.ddlBookType .DataSource =DS.Tables[0].DefaultView ;
this.ddlBookType.DataTextField ="type_name";
this.ddlBookType.DataValueField="type_id";
this.ddlBookType.DataBind();

//显示书籍的出版社
SQLClass objSQL1 = new SQLClass();
DataSet DS1=objSQL1.search ();
DS1.Tables[0].Rows.InsertAt(DS1.Tables[0].NewRow(),0);
this.ddlCompanyName .DataSource =DS1.Tables[0].DefaultView ;
this.ddlCompanyName.DataTextField ="company_name";
this.ddlCompanyName.DataValueField="company_id";
this.ddlCompanyName.DataBind();

//显示您查询的书籍
dgdFetchBook.DataSource=new DataTable();
dgdFetchBook.DataBind();

//显示您要借出的图书
dgdOutRec.DataSource=new DataTable();
dgdOutRec.DataBind();
        
//显示当前用户已经借阅的书籍
Session["LendBooks"]=null;
DataTable dt=book.FetchBookOnLendByUser(user_id);
Session["LendBooks"]=dt;
this.dgdRecall .CurrentPageIndex =0;
this.dgdRecall.DataSource= dt;
this.dgdRecall .DataBind();

}

}
#endregion Page_Load


#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnFetchBook.Click += new System.EventHandler(this.btnFetchBook_Click);
this.dgdFetchBook.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgdFetchBook_PageIndexChanged);
this.btnPreviewBook.Click += new System.EventHandler(this.btnPreviewBook_Click);
this.dgdOutRec.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgdOutRec_PageIndexChanged);
this.dgdOutRec.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdOutRec_DeleteCommand);
this.btnLendBook.Click += new System.EventHandler(this.btnLendBook_Click);
this.dgdRecall.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgdRecall_PageIndexChanged);
this.dgdRecall.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdRecall_DeleteCommand);
this.dgdRecall.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgdRecall_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion


#region btnFetchBook_Click
/// <summary>
/// 查询图书
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnFetchBook_Click(object sender, System.EventArgs e)
{
Session["FindBooks"]=null;
string timeMin="",timeMax="";
string s=this.ddlCompanyName.SelectedItem.Text ;

try
{
try
{
if(calendarMin.Text.TrimEnd()!="")
{
timeMin=DateTime.Parse (this.calendarMin.Text).ToString();
}
if(calendarMax.Text.TrimEnd()!="")
{
timeMax=DateTime.Parse (this.calendarMax.Text).ToString();
}
}
catch
{
this.MessageBox("日期格式不正确!",this.Page);
return ;
}

if(txtBookName.Text=="" && this.ddlBookType.SelectedItem.Text =="" && this.txtAuthor.Text =="" && this.ddlCompanyName.SelectedItem.Text =="" && timeMin=="" && timeMax=="")
this.MessageBox("请至少输入一个查询条件!",Page);
else
{
// 创建 ProductManager
BookManager book=new BookManager (this);

// 返回 DataTable
DataTable dt =book.FetchBookInfo(txtBookName.Text ,this.ddlBookType.SelectedItem.Text ,this.txtAuthor.Text ,this.ddlCompanyName.SelectedItem.Text,timeMin,timeMax);

int count = dt.Rows.Count;
for(int i=0;i<count;i++)
{
if(dt.Rows[i]["借阅"].ToString()=="N")
{
dt.Rows[i]["借阅"] = false;
}
else
{
dt.Rows[i]["借阅"]= true;
}
}

//绑定信息
Session["FindBooks"] = dt;
dgdFetchBook.CurrentPageIndex=0;
this.dgdFetchBook .DataSource =dt;
this.dgdFetchBook .DataBind();
}

}
catch(Exception ex)
{
Response.Write("<script>alert(" + ex.Message.ToString() + ");</script>");
}
}
#endregion btnFetchBook_Click

2007-09-28 10:10
快速回复:[求助]看看我写的是否对呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022268 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved