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
{
/// -----------------------------------------------------------------------------
/// <summary>
/// The ViewDynamicModule class displays the content
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// </history>
/// -----------------------------------------------------------------------------
partial class ViewCELLibrary : Entities.Modules.PortalModuleBase, Entities.Modules.IActionable
{
#region "Private Members"
private string strTemplate;
#endregion
#region "Event Handlers"
/// -----------------------------------------------------------------------------
/// Nomi: header #cedef7 Nomi: row1 #eeeeee Nomi: row2 #f6f4eb Nomi: row2 #ebe8da Nomi: mouseover #ffffcc
/// <summary>
/// Page_Load runs when the control is loaded
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// </history>
/// -----------------------------------------------------------------------------
private void Page_Load(System.Object sender, System.EventArgs e)
{
try {
if (!Page.IsPostBack) {
if (!string.IsNullOrEmpty(Convert.ToString(Settings("template")))) {
strTemplate = Convert.ToString(Settings("template"));
} else {
strTemplate = Localization.GetString("Template.Text", LocalResourceFile);
}
Entities.Modules.ModuleController objModules = new Entities.Modules.ModuleController();
CELLibraryController objLibraryCon = new CELLibraryController();
if (!string.IsNullOrEmpty(Convert.ToString(Settings("HasModuleID")))) {
} else {
DataTable dtTable = objLibraryCon.GetAllLibraryWithoutModuleID();
objModules.UpdateTabModuleSetting(TabModuleId, "HasModuleID", ModuleId);
int rowCount = 0;
for (rowCount = 0; rowCount <= dtTable.Rows.Count - 1; rowCount++) {
objLibraryCon.UpdateLibraryModuleID(ModuleId, Conversion.Val(dtTable.Rows(rowCount)("LibraryID")));
}
}
ViewState("AllowPaging") = "False";
this.lnkShow.Text = "Show 10 records per page";
LocalizeSetting();
LoadLibraryGrid("", ModuleId);
}
//Module failed to load
} catch (Exception exc) {
ProcessModuleLoadException(this, exc);
}
}
public void LocalizeSetting()
{
this.lblSearch.Text = DotNetNuke.Services.Localization.Localization.GetString("lblSearch", this.LocalResourceFile);
this.lnkSearch.Text = DotNetNuke.Services.Localization.Localization.GetString("lnkSearch", this.LocalResourceFile);
}
public string getViewDetailLink(string Title, int LibraryID, int ReferenceOnly)
{
string strImg = "";
if (ReferenceOnly == 1)
strImg = "<img src='" + this.TemplateSourceDirectory + "/book_open.jpg'> ";
return strImg + "<a href='" + EditUrl("LibraryID", LibraryID, "ViewDetail") + "'>" + Title + "</a>";
}
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'");
}
}
public void LoadLibraryGrid(string SearchString, int ModuleID)
{
string strSortExp = null;
string strSortField = null;
string strSortOrder = null;
if (string.IsNullOrEmpty(Convert.ToString(ViewState("SortField"))) || string.IsNullOrEmpty(Convert.ToString(ViewState("SortOrder")))) {
ViewState("SortField") = "Title";
ViewState("SortOrder") = "ASC";
}
strSortField = Convert.ToString(ViewState("SortField"));
strSortOrder = Convert.ToString(ViewState("SortOrder"));
strSortExp = strSortField + " " + strSortOrder;
CELLibraryController objLibraryCon = new CELLibraryController();
DataTable dtTable = null;
if (SearchString == "Title") {
dtTable = objLibraryCon.getLibraryByTitle(this.txtSearch.Text, strSortExp, ModuleID);
} else if (SearchString == "Author") {
dtTable = objLibraryCon.getLibraryByAuthor(this.txtSearch.Text, strSortExp, ModuleID);
} else if (SearchString == "Publisher") {
dtTable = objLibraryCon.getLibraryByPublisher(this.txtSearch.Text, strSortExp, ModuleID);
} else if (SearchString == "PublishDate") {
dtTable = objLibraryCon.getLibraryByPublishDate(this.txtSearch.Text, strSortExp, ModuleID);
} else if (SearchString == "Media") {
dtTable = objLibraryCon.getLibraryByPublishDate(this.txtSearch.Text, strSortExp, ModuleID);
} else if (string.IsNullOrEmpty(SearchString)) {
dtTable = objLibraryCon.getAllLibrary(strSortExp, 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 lnkSearch_Click(object sender, System.EventArgs e)
{
if (this.cboFields.Items.Count < 0){this.lblError.Text = "Error: No field to search with";return;
}
ViewState("SearchString") = "";
if (!string.IsNullOrEmpty(this.txtSearch.Text)) {
ViewState("SearchString") = this.cboFields.SelectedItem.Value;
LoadLibraryGrid(this.cboFields.SelectedItem.Value, ModuleId);
} else {
ViewState("SearchString") = "";
LoadLibraryGrid("", ModuleId);
}
// Me.txtSearch.Text = ""
}
protected void dgLibrary_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
dgLibrary.CurrentPageIndex = e.NewPageIndex;
LoadLibraryGrid("", ModuleId);
}
#endregion
#region "Optional Interfaces"
/// -----------------------------------------------------------------------------
/// <summary>
/// Registers the module actions required for interfacing with the portal framework
/// </summary>
/// <value></value>
/// <returns></returns>
/// <remarks></remarks>
/// <history>
/// </history>
/// -----------------------------------------------------------------------------
public Entities.Modules.Actions.ModuleActionCollection ModuleActions {
get {
Entities.Modules.Actions.ModuleActionCollection Actions = new Entities.Modules.Actions.ModuleActionCollection();
Actions.Add(GetNextActionID, Localization.GetString(Entities.Modules.Actions.ModuleActionType.AddContent, LocalResourceFile), Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl("ManageBooks"), false, Security.SecurityAccessLevel.Edit, true, false);
return Actions;
}
}
#endregion
protected void dgLibrary_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
string[] strSort = Strings.Split(e.SortExpression, "|");
if (strSort[0] == Convert.ToString(ViewState("SortField"))) {
if (Convert.ToString(ViewState("SortOrder")) == "ASC") {
ViewState("SortOrder") = "DESC";
} else {
ViewState("SortOrder") = "ASC";
}
} else {
ViewState("SortOrder") = strSort[1];
}
ViewState("SortField") = strSort[0];
LoadLibraryGrid(Convert.ToString(ViewState("SearchString")), ModuleId);
}
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(Convert.ToString(ViewState("SearchString")), ModuleId);
}
public ViewCELLibrary()
{
Load += Page_Load;
Load += Page_Load;
}
}
}