ViewArchived.cs

using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using DotNetNuke;
using System.Web.UI;
using System.Reflection;

namespace CEL.Modules.CELLibrary
{
	partial class ViewArchived : Entities.Modules.PortalModuleBase
	{

		protected void Page_Load(object sender, System.EventArgs e)
		{
			try {

				if (!Page.IsPostBack) {
					LocalizeSetting();
					ViewState("AllowPaging") = "False";
					this.lnkShow.Text = "Show 10 records per page";
					LoadLibraryGrid("");
				}
			//Module failed to load
			} catch (Exception exc) {
				ProcessModuleLoadException(this, exc);
			}
		}
		public void LocalizeSetting()
		{
			//Me.lblSearch.Text = DotNetNuke.Services.Localization.Localization.GetString("lblSearch", Me.LocalResourceFile)


		}

		public string getViewDetailLink(string Title, int LibraryID)
		{
			return "<a href='" + EditUrl("LibraryID", LibraryID, "ViewBookDetails", "back=arch") + "'>" + Title + "</a>";
		}

		protected void dgLibrary_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			if (e.CommandName == "ViewBookDetails") {
			// Response.Redirect(EditUrl("LibraryID", Val(e.CommandArgument), "ViewBookDetails", "back=arch"), True)
			} else if (e.CommandName == "Delete") {
				CELLibraryController objLibraryCon = new CELLibraryController();
				objLibraryCon.DeleteLibraryByID(Conversion.Val(e.CommandArgument));
				LoadLibraryGrid("");
			} else if (e.CommandName == "UnArchive") {
				CELLibraryController objLibraryCon = new CELLibraryController();
				objLibraryCon.UnArchiveBook(Conversion.Val(e.CommandArgument));
				LoadLibraryGrid("");
			}

		}
		protected void dgLibrary_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if (e.Item.ItemType == ListItemType.Header | e.Item.ItemType == ListItemType.Footer) {
			} else {
				e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#ffffcc'");
				e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#eeeeee'");

				LinkButton lnkUnArchiveIT = (LinkButton)e.Item.FindControl("lnkUnArchive");
				lnkUnArchiveIT.Attributes.Add("onclick", "return confirm('Confirm UnArchive It');");

				LinkButton lnkDelete = (LinkButton)e.Item.FindControl("lnkDelete");
				lnkDelete.Attributes.Add("onclick", "return confirm('Confirm Delete It');");
			}
		}
		public void LoadLibraryGrid(string SearchString)
		{
			CELLibraryController objLibraryCon = new CELLibraryController();
			DataTable dtTable = null;
			dtTable = objLibraryCon.getAllArchivedLibrary(ModuleId);
			if (Convert.ToString(ViewState("AllowPaging")) == "True") {
				this.dgLibrary.AllowPaging = true;
				this.dgLibrary.PageSize = 10;

			} else {
				this.dgLibrary.AllowPaging = false;
			}
			this.dgLibrary.DataSource = dtTable;
			this.dgLibrary.DataBind();
		}

		protected void lnkBack_Click(object sender, System.EventArgs e)
		{
			Response.Redirect(EditUrl("ManageBooks"), true);
		}

		protected void dgLibrary_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
		{
			dgLibrary.CurrentPageIndex = e.NewPageIndex;
			LoadLibraryGrid("");
		}

		protected void lnkShow_Click(object sender, System.EventArgs e)
		{
			if (this.lnkShow.Text == "Show 10 records per page") {
				ViewState("AllowPaging") = "True";
				//ViewState("PagingSize") = "10"
				this.lnkShow.Text = "Show all records";
			} else if (this.lnkShow.Text == "Show all records") {
				ViewState("AllowPaging") = "False";
				this.lnkShow.Text = "Show 10 records per page";
			}
			LoadLibraryGrid("");
		}
		public ViewArchived()
		{
			Load += Page_Load;
		}
	}
}
posted @ 2010-07-13 00:16  小生不才  阅读(213)  评论(0编辑  收藏  举报