using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using BookCommunityClient.AuthWS;
using BookCommunityClient.DataWS;

using System.Data;

namespace BookCommunityClient
{
	/// <summary>
	/// BorrowFrm 的摘要说明。
	/// </summary>
	public class BorrowFrm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ToolBar tbrMain;
		private System.Windows.Forms.ToolBarButton tbbSave;
		private System.Windows.Forms.ToolBarButton tbbCancel;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label25;
		private System.Windows.Forms.Label lblBookNameChn;
		private System.Windows.Forms.Label lblBookNameEng;
		private System.Windows.Forms.Label label20;
		private System.Windows.Forms.DateTimePicker dtpPlanStartDate;
		private System.Windows.Forms.GroupBox gpbBook;
		private System.Windows.Forms.GroupBox gpbBorrower;
		private System.Windows.Forms.DateTimePicker dtpPlanEndDate;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.DateTimePicker dtpActualStartDate;
		private System.Windows.Forms.DateTimePicker dtpActualEndDate;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.ComboBox cbbRating;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Panel s;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.RadioButton rdbBorrowedYes;
		private System.Windows.Forms.RadioButton rdbBorrowedNo;
		private System.Windows.Forms.Label lblFrom;
		private System.Windows.Forms.ImageList ilRatingIcon;



		#region 自定义字段
		private MainFrm frmMain;
		private int CurrentSelectedID;

		private DataSetShareInfo.SHARE_INFORow rowShareInfo=null;
		private DataSetBook.BOOK_INFORow rowBook=null;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.ComboBox cbbOriginalRating;
		internal System.Windows.Forms.ImageList ilToolbar;
		private DataSetUserInfo.USER_INFORow rowUser=null;
		#endregion

		public BorrowFrm(MainFrm form, int id)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
			this.frmMain = form;
			this.CurrentSelectedID = id;
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(BorrowFrm));
			this.tbrMain = new System.Windows.Forms.ToolBar();
			this.tbbSave = new System.Windows.Forms.ToolBarButton();
			this.tbbCancel = new System.Windows.Forms.ToolBarButton();
			this.ilToolbar = new System.Windows.Forms.ImageList(this.components);
			this.s = new System.Windows.Forms.Panel();
			this.gpbBorrower = new System.Windows.Forms.GroupBox();
			this.cbbRating = new System.Windows.Forms.ComboBox();
			this.label3 = new System.Windows.Forms.Label();
			this.dtpActualStartDate = new System.Windows.Forms.DateTimePicker();
			this.dtpActualEndDate = new System.Windows.Forms.DateTimePicker();
			this.label5 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.lblFrom = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.dtpPlanStartDate = new System.Windows.Forms.DateTimePicker();
			this.dtpPlanEndDate = new System.Windows.Forms.DateTimePicker();
			this.label2 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.label7 = new System.Windows.Forms.Label();
			this.cbbOriginalRating = new System.Windows.Forms.ComboBox();
			this.gpbBook = new System.Windows.Forms.GroupBox();
			this.rdbBorrowedYes = new System.Windows.Forms.RadioButton();
			this.lblBookNameEng = new System.Windows.Forms.Label();
			this.label20 = new System.Windows.Forms.Label();
			this.label25 = new System.Windows.Forms.Label();
			this.lblBookNameChn = new System.Windows.Forms.Label();
			this.label11 = new System.Windows.Forms.Label();
			this.rdbBorrowedNo = new System.Windows.Forms.RadioButton();
			this.ilRatingIcon = new System.Windows.Forms.ImageList(this.components);
			this.s.SuspendLayout();
			this.gpbBorrower.SuspendLayout();
			this.gpbBook.SuspendLayout();
			this.SuspendLayout();
			// 
			// tbrMain
			// 
			this.tbrMain.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
			this.tbrMain.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																					   this.tbbSave,
																					   this.tbbCancel});
			this.tbrMain.ButtonSize = new System.Drawing.Size(53, 22);
			this.tbrMain.DropDownArrows = true;
			this.tbrMain.ImageList = this.ilToolbar;
			this.tbrMain.Location = new System.Drawing.Point(0, 0);
			this.tbrMain.Name = "tbrMain";
			this.tbrMain.ShowToolTips = true;
			this.tbrMain.Size = new System.Drawing.Size(552, 36);
			this.tbrMain.TabIndex = 6;
			this.tbrMain.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
			this.tbrMain.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbrMain_ButtonClick);
			// 
			// tbbSave
			// 
			this.tbbSave.ImageIndex = 0;
			this.tbbSave.Text = "保存并关闭";
			this.tbbSave.ToolTipText = "发送拒绝消息";
			// 
			// tbbCancel
			// 
			this.tbbCancel.ImageIndex = 1;
			this.tbbCancel.Text = "关闭";
			// 
			// ilToolbar
			// 
			this.ilToolbar.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
			this.ilToolbar.ImageSize = new System.Drawing.Size(24, 24);
			this.ilToolbar.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ilToolbar.ImageStream")));
			this.ilToolbar.TransparentColor = System.Drawing.Color.White;
			// 
			// s
			// 
			this.s.Controls.Add(this.gpbBorrower);
			this.s.Controls.Add(this.gpbBook);
			this.s.Dock = System.Windows.Forms.DockStyle.Fill;
			this.s.DockPadding.Bottom = 4;
			this.s.DockPadding.Left = 4;
			this.s.DockPadding.Right = 4;
			this.s.Location = new System.Drawing.Point(0, 36);
			this.s.Name = "s";
			this.s.Size = new System.Drawing.Size(552, 346);
			this.s.TabIndex = 7;
			// 
			// gpbBorrower
			// 
			this.gpbBorrower.Controls.Add(this.cbbRating);
			this.gpbBorrower.Controls.Add(this.label3);
			this.gpbBorrower.Controls.Add(this.dtpActualStartDate);
			this.gpbBorrower.Controls.Add(this.dtpActualEndDate);
			this.gpbBorrower.Controls.Add(this.label5);
			this.gpbBorrower.Controls.Add(this.label1);
			this.gpbBorrower.Controls.Add(this.lblFrom);
			this.gpbBorrower.Controls.Add(this.label4);
			this.gpbBorrower.Controls.Add(this.dtpPlanStartDate);
			this.gpbBorrower.Controls.Add(this.dtpPlanEndDate);
			this.gpbBorrower.Controls.Add(this.label2);
			this.gpbBorrower.Controls.Add(this.label6);
			this.gpbBorrower.Controls.Add(this.label7);
			this.gpbBorrower.Controls.Add(this.cbbOriginalRating);
			this.gpbBorrower.Dock = System.Windows.Forms.DockStyle.Top;
			this.gpbBorrower.Location = new System.Drawing.Point(4, 104);
			this.gpbBorrower.Name = "gpbBorrower";
			this.gpbBorrower.Size = new System.Drawing.Size(544, 144);
			this.gpbBorrower.TabIndex = 95;
			this.gpbBorrower.TabStop = false;
			// 
			// cbbRating
			// 
			this.cbbRating.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
			this.cbbRating.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbbRating.ItemHeight = 14;
			this.cbbRating.Items.AddRange(new object[] {
														   "1",
														   "2",
														   "3",
														   "4",
														   "5",
														   "6",
														   "7",
														   "8",
														   "9"});
			this.cbbRating.Location = new System.Drawing.Point(116, 110);
			this.cbbRating.Name = "cbbRating";
			this.cbbRating.Size = new System.Drawing.Size(100, 20);
			this.cbbRating.TabIndex = 99;
			this.cbbRating.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.cbbRating_DrawItem);
			// 
			// label3
			// 
			this.label3.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label3.Location = new System.Drawing.Point(16, 76);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(92, 17);
			this.label3.TabIndex = 96;
			this.label3.Text = "实际开始时间:";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// dtpActualStartDate
			// 
			this.dtpActualStartDate.Location = new System.Drawing.Point(116, 72);
			this.dtpActualStartDate.Name = "dtpActualStartDate";
			this.dtpActualStartDate.Size = new System.Drawing.Size(152, 21);
			this.dtpActualStartDate.TabIndex = 98;
			// 
			// dtpActualEndDate
			// 
			this.dtpActualEndDate.Enabled = false;
			this.dtpActualEndDate.Location = new System.Drawing.Point(380, 72);
			this.dtpActualEndDate.Name = "dtpActualEndDate";
			this.dtpActualEndDate.Size = new System.Drawing.Size(152, 21);
			this.dtpActualEndDate.TabIndex = 97;
			// 
			// label5
			// 
			this.label5.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label5.Location = new System.Drawing.Point(280, 76);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(92, 17);
			this.label5.TabIndex = 95;
			this.label5.Text = "实际结束时间:";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label1
			// 
			this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.Location = new System.Drawing.Point(16, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(60, 17);
			this.label1.TabIndex = 92;
			this.label1.Text = "拥有者:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblFrom
			// 
			this.lblFrom.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.lblFrom.Location = new System.Drawing.Point(116, 16);
			this.lblFrom.Name = "lblFrom";
			this.lblFrom.Size = new System.Drawing.Size(312, 16);
			this.lblFrom.TabIndex = 91;
			this.lblFrom.Text = "lblFrom";
			this.lblFrom.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label4
			// 
			this.label4.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label4.Location = new System.Drawing.Point(16, 48);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(92, 17);
			this.label4.TabIndex = 93;
			this.label4.Text = "计划开始时间:";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// dtpPlanStartDate
			// 
			this.dtpPlanStartDate.Enabled = false;
			this.dtpPlanStartDate.Location = new System.Drawing.Point(116, 44);
			this.dtpPlanStartDate.Name = "dtpPlanStartDate";
			this.dtpPlanStartDate.Size = new System.Drawing.Size(152, 21);
			this.dtpPlanStartDate.TabIndex = 94;
			// 
			// dtpPlanEndDate
			// 
			this.dtpPlanEndDate.Enabled = false;
			this.dtpPlanEndDate.Location = new System.Drawing.Point(380, 44);
			this.dtpPlanEndDate.Name = "dtpPlanEndDate";
			this.dtpPlanEndDate.Size = new System.Drawing.Size(152, 21);
			this.dtpPlanEndDate.TabIndex = 94;
			// 
			// label2
			// 
			this.label2.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label2.Location = new System.Drawing.Point(280, 48);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(92, 17);
			this.label2.TabIndex = 93;
			this.label2.Text = "计划结束时间:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label6
			// 
			this.label6.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label6.Location = new System.Drawing.Point(16, 112);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(88, 17);
			this.label6.TabIndex = 96;
			this.label6.Text = "给他打分:";
			this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label7
			// 
			this.label7.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label7.Location = new System.Drawing.Point(280, 112);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(88, 17);
			this.label7.TabIndex = 96;
			this.label7.Text = "历史信用:";
			this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// cbbOriginalRating
			// 
			this.cbbOriginalRating.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
			this.cbbOriginalRating.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbbOriginalRating.Enabled = false;
			this.cbbOriginalRating.ItemHeight = 14;
			this.cbbOriginalRating.Items.AddRange(new object[] {
																   "1",
																   "2",
																   "3",
																   "4",
																   "5",
																   "6",
																   "7",
																   "8",
																   "9"});
			this.cbbOriginalRating.Location = new System.Drawing.Point(380, 110);
			this.cbbOriginalRating.Name = "cbbOriginalRating";
			this.cbbOriginalRating.Size = new System.Drawing.Size(100, 20);
			this.cbbOriginalRating.TabIndex = 99;
			// 
			// gpbBook
			// 
			this.gpbBook.Controls.Add(this.rdbBorrowedYes);
			this.gpbBook.Controls.Add(this.lblBookNameEng);
			this.gpbBook.Controls.Add(this.label20);
			this.gpbBook.Controls.Add(this.label25);
			this.gpbBook.Controls.Add(this.lblBookNameChn);
			this.gpbBook.Controls.Add(this.label11);
			this.gpbBook.Controls.Add(this.rdbBorrowedNo);
			this.gpbBook.Dock = System.Windows.Forms.DockStyle.Top;
			this.gpbBook.Location = new System.Drawing.Point(4, 0);
			this.gpbBook.Name = "gpbBook";
			this.gpbBook.Size = new System.Drawing.Size(544, 104);
			this.gpbBook.TabIndex = 8;
			this.gpbBook.TabStop = false;
			// 
			// rdbBorrowedYes
			// 
			this.rdbBorrowedYes.Checked = true;
			this.rdbBorrowedYes.Location = new System.Drawing.Point(116, 68);
			this.rdbBorrowedYes.Name = "rdbBorrowedYes";
			this.rdbBorrowedYes.Size = new System.Drawing.Size(52, 24);
			this.rdbBorrowedYes.TabIndex = 100;
			this.rdbBorrowedYes.TabStop = true;
			this.rdbBorrowedYes.Text = "是";
			// 
			// lblBookNameEng
			// 
			this.lblBookNameEng.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.lblBookNameEng.Location = new System.Drawing.Point(116, 40);
			this.lblBookNameEng.Name = "lblBookNameEng";
			this.lblBookNameEng.Size = new System.Drawing.Size(312, 16);
			this.lblBookNameEng.TabIndex = 82;
			this.lblBookNameEng.Text = "lblBookNameEng";
			this.lblBookNameEng.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label20
			// 
			this.label20.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label20.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label20.Location = new System.Drawing.Point(16, 16);
			this.label20.Name = "label20";
			this.label20.Size = new System.Drawing.Size(64, 17);
			this.label20.TabIndex = 79;
			this.label20.Text = "中文书名:";
			this.label20.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label25
			// 
			this.label25.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label25.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label25.Location = new System.Drawing.Point(16, 40);
			this.label25.Name = "label25";
			this.label25.Size = new System.Drawing.Size(60, 17);
			this.label25.TabIndex = 84;
			this.label25.Text = "英文书名:";
			this.label25.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblBookNameChn
			// 
			this.lblBookNameChn.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.lblBookNameChn.Location = new System.Drawing.Point(116, 16);
			this.lblBookNameChn.Name = "lblBookNameChn";
			this.lblBookNameChn.Size = new System.Drawing.Size(312, 16);
			this.lblBookNameChn.TabIndex = 83;
			this.lblBookNameChn.Text = "lblBookNameChn";
			this.lblBookNameChn.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label11
			// 
			this.label11.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label11.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label11.Location = new System.Drawing.Point(16, 72);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(92, 17);
			this.label11.TabIndex = 96;
			this.label11.Text = "已借到:";
			this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// rdbBorrowedNo
			// 
			this.rdbBorrowedNo.Location = new System.Drawing.Point(168, 68);
			this.rdbBorrowedNo.Name = "rdbBorrowedNo";
			this.rdbBorrowedNo.Size = new System.Drawing.Size(52, 24);
			this.rdbBorrowedNo.TabIndex = 100;
			this.rdbBorrowedNo.Text = "否";
			// 
			// ilRatingIcon
			// 
			this.ilRatingIcon.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
			this.ilRatingIcon.ImageSize = new System.Drawing.Size(64, 12);
			this.ilRatingIcon.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ilRatingIcon.ImageStream")));
			this.ilRatingIcon.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// BorrowFrm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(216)), ((System.Byte)(228)), ((System.Byte)(248)));
			this.ClientSize = new System.Drawing.Size(552, 382);
			this.Controls.Add(this.s);
			this.Controls.Add(this.tbrMain);
			this.Name = "BorrowFrm";
			this.Text = "BorrowFrm";
			this.Load += new System.EventHandler(this.BorrowFrm_Load);
			this.s.ResumeLayout(false);
			this.gpbBorrower.ResumeLayout(false);
			this.gpbBook.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void tbrMain_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			switch(this.tbrMain.Buttons.IndexOf(e.Button))
			{
				case 0://保存并关闭
					//将该SHARE_INFO的status定为BORROWED或CANCEL
					if(this.rdbBorrowedYes.Checked)
					{
						rowShareInfo.Status = Enum.GetName(typeof(ShareInfoStatusTypeEnum)
							,ShareInfoStatusTypeEnum.BORROWED);
						rowShareInfo.ActualBeginDate = this.dtpActualStartDate.Value;
					}
					else//CANCEL
					{
						rowShareInfo.Status = Enum.GetName(typeof(ShareInfoStatusTypeEnum)
							,ShareInfoStatusTypeEnum.CANCEL);
						rowShareInfo.ActualBeginDate = this.dtpActualStartDate.Value;
					}

					rowBook.Status = Enum.GetName(typeof(BookStatusTypeEnum),BookStatusTypeEnum.BORROWED);
					
					rowUser.Credit = ((int)(rowUser.Credit * rowUser.RatingNumber + (this.cbbRating.SelectedIndex+1))
						/(rowUser.RatingNumber+1));
					rowUser.RatingNumber++;


					//将界面上的信息保存到数据库
					//注意有些控件是只读的，不需要更新到数据库

					this.Close();
					break;
				case 1://取消
					//直接关闭窗口
					this.Close();
					break;
			}
		
		}

		private void cbbRating_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
		{
			int i = e.Index;
			Image img = this.ilRatingIcon.Images[e.Index];
			e.DrawBackground();
			e.Graphics.DrawImageUnscaled(img, e.Bounds.X, e.Bounds.Y);
			e.DrawFocusRectangle();

		}

		/// <summary>
		/// 载入数据
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void BorrowFrm_Load(object sender, System.EventArgs e)
		{
			rowShareInfo = this.frmMain.DsShareInfo.SHARE_INFO.FindByID(this.CurrentSelectedID);
			int bookid = rowShareInfo.Book;

			rowBook = this.frmMain.DsBook.BOOK_INFO.FindByID(bookid);
			if(rowBook == null)
			{
				DataSetBook dsb = this.frmMain.m_dataSvc.GetAllBooks(this.frmMain.m_authTicket);
				if(dsb == null)
					return;//error!

				this.frmMain.DsBook.Merge(dsb);
				rowBook = this.frmMain.DsBook.BOOK_INFO.FindByID(bookid);
				if(rowBook == null)
					return;//error!
			}

			rowUser = this.frmMain.DsUserInfo.USER_INFO.FindByID(rowShareInfo.ShareTo);
			if(rowUser == null)
			{
				DataSetUserInfo dsui = this.frmMain.m_dataSvc.GetUserDetailInfo(this.frmMain.m_authTicket,rowShareInfo.ShareTo);
				if(dsui == null)
					return;//error!

				this.frmMain.DsUserInfo.Merge(dsui);
				rowUser = this.frmMain.DsUserInfo.USER_INFO.FindByID(rowShareInfo.ShareTo);
				if(rowUser == null)
					return;//error!
			}

			this.lblBookNameChn.Text = rowBook["BookNameChn"] as string;
			this.lblBookNameEng.Text = rowBook["BookNameEng"] as string;

			this.lblFrom.Text = rowUser.UserName;

			this.dtpPlanEndDate.Value = rowShareInfo.PlanEndDate;
			this.dtpPlanStartDate.Value = rowShareInfo.PlanBeginDate;
			if(rowShareInfo.Status != Enum.GetName(typeof(ShareInfoStatusTypeEnum)
				,ShareInfoStatusTypeEnum.BORROWED))
			{//NOT BORROWED
				this.dtpActualStartDate.Value = DateTime.Today;
			}
			else//BORROWED, so we have actual begin date
			{
				this.dtpActualStartDate.Value = rowShareInfo.ActualBeginDate;
			}

			this.cbbOriginalRating.SelectedIndex = rowUser.Credit-1;
			this.cbbRating.SelectedIndex = rowUser.Credit-1;

			//if not QUEUE, there's no button to save
			if(rowShareInfo.Status != Enum.GetName(typeof(ShareInfoStatusTypeEnum)
				,ShareInfoStatusTypeEnum.QUEUE))
			{
				this.tbrMain.Buttons[0].Visible = false;
			}

		}
	}
}
