Borrow.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;
using System.Data.SqlTypes;

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

		protected void Page_Load(object sender, System.EventArgs e)
		{
			cmdActualReturnDate.NavigateUrl = Common.Utilities.Calendar.InvokePopupCal(txtActualReturnDate);
			cmdBorrowDate.NavigateUrl = Common.Utilities.Calendar.InvokePopupCal(txtBorrowDate);
			cmdDueReturnDate.NavigateUrl = Common.Utilities.Calendar.InvokePopupCal(txtDueReturnDate);
			if (IsPostBack == true)
				return;
			loadUser();
			LocalizeSetting();

		}
		public void LocalizeSetting()
		{
			this.lblActualReturnDate.Text = DotNetNuke.Services.Localization.Localization.GetString("lblActualReturnDate", this.LocalResourceFile);
			this.lblBorrowDate.Text = DotNetNuke.Services.Localization.Localization.GetString("lblBorrowDate", this.LocalResourceFile);
			this.lblBorrowedBy.Text = DotNetNuke.Services.Localization.Localization.GetString("lblBorrowedBy", this.LocalResourceFile);
			this.lblDueReturnDate.Text = DotNetNuke.Services.Localization.Localization.GetString("lblDueReturnDate", this.LocalResourceFile);
			this.lnkBack.Text = DotNetNuke.Services.Localization.Localization.GetString("lnkBack", this.LocalResourceFile);
		}
		public void loadUser()
		{
			UserController objUserCon = new UserController();
			UserInfo objUserInfo = default(UserInfo);
			ArrayList arrUsers = UserController.GetUsers(PortalId);
			this.cboBorrrowedBy.Items.Add(new ListItem("<Select User>", 0));
			foreach ( objUserInfo in arrUsers) {
				this.cboBorrrowedBy.Items.Add(new ListItem(objUserInfo.Username, objUserInfo.UserID));
			}
		}
		protected void lnkBack_Click(object sender, System.EventArgs e)
		{
			Response.Redirect(EditUrl("ManageBooks"), true);
		}

		protected void lnkSave_Click(object sender, System.EventArgs e)
		{
			if (!string.IsNullOrEmpty(Request.QueryString("LibraryID"))) {
				SqlDateTime sqldate = default(SqlDateTime);
				CELLibraryController objLibraryCon = new CELLibraryController();
				if ((string.IsNullOrEmpty(this.txtActualReturnDate.Text))) {
					sqldate = SqlDateTime.Null;
				} else {
					sqldate = this.txtActualReturnDate.Text;
				}
				if (this.cboBorrrowedBy.SelectedItem.Value == "0"){this.lblError.Text = "Please select user!";return;
}
				if (string.IsNullOrEmpty(this.txtBorrowDate.Text)){this.lblError.Text = "Please select borrow date!";return;
}
				if (string.IsNullOrEmpty(this.txtDueReturnDate.Text)){this.lblError.Text = "Please select due return date!";return;
}
				if (this.cboBorrrowedBy.SelectedItem.Value != "0")
					objLibraryCon.AddLibraryBorrow(Conversion.Val(Request.QueryString("LibraryID")), this.cboBorrrowedBy.SelectedItem.Value, this.txtBorrowDate.Text, this.txtDueReturnDate.Text, sqldate);
				Response.Redirect(EditUrl("ManageBooks"), true);
			}
		}
		public Borrow()
		{
			Load += Page_Load;
		}

	}
}
posted @ 2010-07-13 00:03  小生不才  阅读(143)  评论(0)    收藏  举报