AddBook.cs

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

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

protected void Page_Load(object sender, System.EventArgs e)
{
if (IsPostBack == true)
return;
LocalizeSetting();
if (!string.IsNullOrEmpty(Request.QueryString("LibraryID")))
loadLibraryData(Conversion.Val(Request.QueryString("LibraryID")));
}
public void loadLibraryData(int LibraryID)
{
CELLibraryController objLibraryCon = new CELLibraryController();
DataTable dtTable = objLibraryCon.getLibraryByID(LibraryID);
if (dtTable.Rows.Count > 0) {
if (!Information.IsDBNull(dtTable.Rows(0)("Author")))
this.txtAuthor.Text = dtTable.Rows(0)("Author");
//If Not IsDBNull(dtTable.Rows(0)("")) Then Me.lblCurrentlyBorrowed.Text = dtTable.Rows(0)("CurrentlyBorrowed")
if (!Information.IsDBNull(dtTable.Rows(0)("ISBN")))
this.txtISB.Text = dtTable.Rows(0)("ISBN");
//   If Not IsDBNull(dtTable.Rows(0)("Owner")) Then Me.txtOwner.Text = dtTable.Rows(0)("Owner")
if (!Information.IsDBNull(dtTable.Rows(0)("PublishDate")))
this.txtPublishDate.Text = dtTable.Rows(0)("PublishDate");
if (!Information.IsDBNull(dtTable.Rows(0)("Publisher")))
this.txtPublisher.Text = dtTable.Rows(0)("Publisher");
if (!Information.IsDBNull(dtTable.Rows(0)("Title")))
this.txtTitle.Text = dtTable.Rows(0)("Title");

if (!Information.IsDBNull(dtTable.Rows(0)("Media")))
cboMedia.Items.FindByValue(dtTable.Rows(0)("Media")).Selected = true;
}
}
public void LocalizeSetting()
{
this.lblMedia.Text = DotNetNuke.Services.Localization.Localization.GetString("lblMedia", this.LocalResourceFile);
this.lblAuthorTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblAuthorTitle", this.LocalResourceFile);
this.lblTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblTitle", this.LocalResourceFile);
this.lblISBTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblISBTitle", this.LocalResourceFile);
//Me.lblOwnerTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblOwnerTitle", Me.LocalResourceFile)
this.lblPublishDateTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblPublishDateTitle", this.LocalResourceFile);
this.lblPublisherTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblPublisherTitle", this.LocalResourceFile);
this.lnkBack.Text = DotNetNuke.Services.Localization.Localization.GetString("lnkBack", this.LocalResourceFile);
this.lnkSave.Text = DotNetNuke.Services.Localization.Localization.GetString("lnkSave", this.LocalResourceFile);
}

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

protected void lnkSave_Click(object sender, System.EventArgs e)
{
CELLibraryController objLibraryCon = new CELLibraryController();
if (!string.IsNullOrEmpty(Request.QueryString("LibraryID"))) {
objLibraryCon.UpdateLibrary(this.txtTitle.Text, this.txtISB.Text, this.txtAuthor.Text, this.txtPublisher.Text, this.txtPublishDate.Text, this.txtOwner.Text, Conversion.Val(Request.QueryString("LibraryID")), this.cboMedia.SelectedItem.Value);
} else {
objLibraryCon.AddBook(this.txtTitle.Text, this.txtISB.Text, this.txtAuthor.Text, this.txtPublisher.Text, this.txtPublishDate.Text, this.txtOwner.Text, ModuleId, this.cboMedia.SelectedItem.Value);
}

Response.Redirect(EditUrl("ManageBooks"), true);
}
public AddBook()
{
Load += Page_Load;
}
}
}

 

posted @ 2010-07-13 00:01  小生不才  阅读(200)  评论(0编辑  收藏  举报