-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathItemsControl.cs
2728 lines (2296 loc) · 95.9 KB
/
ItemsControl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Resources;
using System.Globalization;
//using DigitalPlatform.CirculationClient;
using DigitalPlatform.Xml;
using DigitalPlatform.IO;
using DigitalPlatform.OPAC.Server;
using DigitalPlatform.Text;
using DigitalPlatform.LibraryClient;
using DigitalPlatform.LibraryClient.localhost;
using DigitalPlatform.Script;
namespace DigitalPlatform.OPAC.Web
{
/// <summary>
/// 显示同种之中全部册信息的控件
/// </summary>
[ToolboxData("<{0}:ItemsControl runat=server></{0}:ItemsControl>")]
public class ItemsControl : WebControl, INamingContainer
{
public string FocusRecPath = ""; // 需要显示出来的焦点评注记录的路径
public string Barcode = "";
public string BiblioRecPath = "";
public string WarningText = "";
public bool Wrapper = false;
public ItemDispStyle ItemDispStyle = ItemDispStyle.Items;
// string tempOutput = "";
// // ItemConverter ItemConverter = null;
List<string> tempItemBarcodes = null;
// 2007/10/18
// 取消最外面的tag
public override void RenderBeginTag(HtmlTextWriter writer)
{
}
public override void RenderEndTag(HtmlTextWriter writer)
{
}
ResourceManager m_rm = null;
ResourceManager GetRm()
{
if (this.m_rm != null)
return this.m_rm;
this.m_rm = new ResourceManager("DigitalPlatform.OPAC.Web.res.ItemsControl.cs",
typeof(ItemsControl).Module.Assembly);
return this.m_rm;
}
public string GetString(string strID)
{
CultureInfo ci = new CultureInfo(Thread.CurrentThread.CurrentUICulture.Name);
// TODO: 如果抛出异常,则要试着取zh-cn的字符串,或者返回一个报错的字符串
try
{
string s = GetRm().GetString(strID, ci);
if (String.IsNullOrEmpty(s) == true)
return strID;
return s;
}
catch (Exception /*ex*/)
{
return strID + " 在 " + Thread.CurrentThread.CurrentUICulture.Name + " 中没有找到对应的资源。";
}
}
public string Lang
{
get
{
return Thread.CurrentThread.CurrentUICulture.Name;
}
}
// TODO: 从Session中取消
// 册行数
public int LineCount
{
get
{
object o = this.Page.Session[this.ID + "ItemsControl_LineCount"];
return (o == null) ? 5 : (int)o;
}
set
{
this.Page.Session[this.ID + "ItemsControl_LineCount"] = (object)value;
}
}
public void Clear()
{
this.StartIndex = 0;
}
public int StartIndex
{
get
{
object o = ViewState[this.ID + "ItemsControl_StartIndex"];
if (o == null)
return 0;
else
return (int)o;
}
set
{
ViewState[this.ID + "ItemsControl_StartIndex"] = value;
}
}
public int PageMaxLines
{
get
{
object o = ViewState[this.ID + "ItemsControl_PageMaxLines"];
if (o == null)
return 10;
else
return (int)o;
}
set
{
ViewState[this.ID + "ItemsControl_PageMaxLines"] = value;
}
}
// 计算出页码总数
public int GetPageCount(int nResultCount)
{
int nDelta = nResultCount % this.PageMaxLines;
if (nDelta > 0)
return (nResultCount / this.PageMaxLines) + 1;
return (nResultCount / this.PageMaxLines);
}
// 条码号列表
public List<string> ItemBarcodes
{
get
{
object o = this.Page.Session[this.ID + "ItemsControl_ItemBarcodes"];
return (o == null) ? new List<string>() : (List<string>)o;
}
set
{
this.Page.Session[this.ID + "ItemsControl_ItemBarcodes"] = (object)value;
}
}
// 设置结果集有关数量参数
public void SetResultInfo(int nResultCount)
{
int nPageNo = this.StartIndex / this.PageMaxLines;
int nPageCount = GetPageCount(nResultCount);
LiteralControl resultinfo = (LiteralControl)this.FindControl("resultinfo");
if (nResultCount != 0)
{
resultinfo.Text = string.Format(this.GetString("册共n个"), // "册共 {0} 个"
nResultCount.ToString());
// "册共 " + Convert.ToString(nResultCount) + " 个";
}
else
{
resultinfo.Text = this.GetString("无册"); // "(无册)"
// "(无册)";
}
/*
if (nResultCount != 0) // 2007/8/24 new changed
resultinfo.Text = "册共 " + Convert.ToString(nResultCount) + " 个, 分 " + Convert.ToString(nPageCount) + " 页显示, 当前为第 " + Convert.ToString(nPageNo + 1) + "页。";
else
resultinfo.Text = "(无册)";
*/
#if NO
LiteralControl maxpagecount = (LiteralControl)this.FindControl("maxpagecount");
maxpagecount.Text = string.Format(this.GetString("共n页"), // (共 {0} 页)
nPageCount.ToString());
// " (共 " + Convert.ToString(nPageCount) + " 页)";
LiteralControl currentpageno = (LiteralControl)this.FindControl("currentpageno");
currentpageno.Text = Convert.ToString(nPageNo + 1);
#endif
PageSwitcherControl pager = (PageSwitcherControl)this.FindControl("pager");
pager.CurrentPageNo = nPageNo;
pager.TotalCount = nPageCount;
if (nPageCount <= 1)
{
pager.Visible = false;
}
else
{
pager.Visible = true;
}
PlaceHolder pageswitcher = (PlaceHolder)this.FindControl("pageswitcher");
if (nPageCount <= 1)
{
pageswitcher.Visible = false;
resultinfo.Visible = false; // 2009/6/10
}
else
{
pageswitcher.Visible = true;
resultinfo.Visible = true;
}
}
void CreateDebugLine(PlaceHolder line)
{
line.Controls.Add(new LiteralControl("<tr class='debugline'><td colspan='13'>"));
LiteralControl literal = new LiteralControl();
literal.ID = "debugtext";
literal.Text = "";
line.Controls.Add(literal);
line.Controls.Add(new LiteralControl("</td></tr>"));
}
void SetDebugInfo(string strText)
{
PlaceHolder line = (PlaceHolder)FindControl("debugline");
line.Visible = true;
LiteralControl text = (LiteralControl)line.FindControl("debugtext");
text.Text = strText;
}
void SetDebugInfo(string strSpanClass,
string strText)
{
PlaceHolder line = (PlaceHolder)FindControl("debugline");
line.Visible = true;
LiteralControl text = (LiteralControl)line.FindControl("debugtext");
if (strSpanClass == "errorinfo")
text.Text = "<div class='errorinfo-frame'><div class='" + strSpanClass + "'>" + strText + "</div></div>";
else
text.Text = "<div class='" + strSpanClass + "'>" + strText + "</div>";
}
public int ResultCount
{
get
{
return GetResultCount();
}
set
{
SetResultCount(value);
}
}
void SetResultCount(int nResultCount)
{
// PlaceHolder line = (PlaceHolder)FindControl("debugline");
HiddenField hidden = (HiddenField)this.FindControl("resultcount");
hidden.Value = nResultCount.ToString();
}
int GetResultCount()
{
// PlaceHolder line = (PlaceHolder)FindControl("debugline");
HiddenField hidden = (HiddenField)this.FindControl("resultcount");
if (String.IsNullOrEmpty(hidden.Value) == true)
return 0;
return Convert.ToInt32(hidden.Value);
}
void CreateCmdLine(PlaceHolder line)
{
line.Controls.Clear();
line.Controls.Add(new LiteralControl("<tr class='cmdline'><td colspan='13'><div class='reservation'>"));
// 读者证条码号和前面文字一体的PlaceHolder,便于一起显示和隐藏
PlaceHolder reservationreaderbarcode_holder = new PlaceHolder();
reservationreaderbarcode_holder.ID = "reservationreaderbarcode_holder";
line.Controls.Add(reservationreaderbarcode_holder);
LiteralControl literal = new LiteralControl();
literal.Text = this.GetString("针对读者"); // "针对读者(证条码号)";
reservationreaderbarcode_holder.Controls.Add(literal);
TextBox reservationreaderbarcode = new TextBox();
reservationreaderbarcode.Text = "";
reservationreaderbarcode.ID = "reservationreaderbarcode";
reservationreaderbarcode_holder.Controls.Add(reservationreaderbarcode);
Button reservationbutton = new Button();
reservationbutton.ID = "reservationbutton";
reservationbutton.Text = this.GetString("加入预约列表");
reservationbutton.Click += new EventHandler(reservationbutton_Click);
line.Controls.Add(reservationbutton);
line.Controls.Add(new LiteralControl(
"</div>"));
///
PlaceHolder pageswitcher = new PlaceHolder();
pageswitcher.ID = "pageswitcher";
line.Controls.Add(pageswitcher);
// 信息文字
pageswitcher.Controls.Add(new LiteralControl(
"<div class='pager'> -- "
));
LiteralControl resultinfo = new LiteralControl();
resultinfo.ID = "resultinfo";
pageswitcher.Controls.Add(resultinfo);
pageswitcher.Controls.Add(new LiteralControl(
" -- "
));
PageSwitcherControl pager = new PageSwitcherControl();
pager.Wrapper = false; // 不要外围的<div>
pager.ID = "pager";
pager.PageSwitch += new PageSwitchEventHandler(pager_PageSwitch);
pageswitcher.Controls.Add(pager);
pageswitcher.Controls.Add(new LiteralControl(
"</div>"));
#if NO
LinkButton firstpage = new LinkButton();
firstpage.ID = "first";
firstpage.Text = this.GetString("首页");
firstpage.CssClass = "firstpage";
firstpage.Click += new EventHandler(firstpage_Click);
pageswitcher.Controls.Add(firstpage);
pageswitcher.Controls.Add(new LiteralControl(
" "
));
LinkButton prevpage = new LinkButton();
prevpage.ID = "prev";
prevpage.Text = this.GetString("前页");
prevpage.CssClass = "prevpage";
prevpage.Click += new EventHandler(prevpage_Click);
pageswitcher.Controls.Add(prevpage);
pageswitcher.Controls.Add(new LiteralControl(
" "
));
literal = new LiteralControl();
literal.ID = "currentpageno";
literal.Text = "";
pageswitcher.Controls.Add(literal);
pageswitcher.Controls.Add(new LiteralControl(
" "
));
LinkButton nextpage = new LinkButton();
nextpage.ID = "next";
nextpage.Text = this.GetString("后页");
nextpage.CssClass = "nextpage";
nextpage.Click += new EventHandler(nextpage_Click);
pageswitcher.Controls.Add(nextpage);
pageswitcher.Controls.Add(new LiteralControl(
" "
));
LinkButton lastpage = new LinkButton();
lastpage.ID = "last";
lastpage.Text = this.GetString("末页");
lastpage.CssClass = "lastpage";
lastpage.Click += new EventHandler(lastpage_Click);
pageswitcher.Controls.Add(lastpage);
literal = new LiteralControl();
literal.Text = " | ";
pageswitcher.Controls.Add(literal);
Button gotobutton = new Button();
gotobutton.ID = "gotobutton";
gotobutton.Text = this.GetString("跳到");
gotobutton.CssClass = "goto";
gotobutton.Click += new EventHandler(gotobutton_Click);
pageswitcher.Controls.Add(gotobutton);
literal = new LiteralControl();
literal.Text = " " + this.GetString("第") + " "; // " 第 ";
pageswitcher.Controls.Add(literal);
TextBox textbox = new TextBox();
textbox.ID = "gotopageno";
textbox.Width = new Unit("40");
textbox.CssClass = "gotopageno";
pageswitcher.Controls.Add(textbox);
/*
literal = new LiteralControl();
literal.Text = " 页";
pageswitcher.Controls.Add(literal);
* */
literal = new LiteralControl();
literal.ID = "maxpagecount";
literal.Text = " (共 " + Convert.ToString(1/*this.PageCount*/) + " 页)";
pageswitcher.Controls.Add(literal);
///
#endif
line.Controls.Add(new LiteralControl("</td></tr>"));
}
void pager_PageSwitch(object sender, PageSwitchEventArgs e)
{
this.StartIndex = this.PageMaxLines * e.GotoPageNo;
if (this.StartIndex >= this.ResultCount)
{
lastpage_Click(sender, e);
}
}
// 跳到指定的页号
void gotobutton_Click(object sender, EventArgs e)
{
TextBox textbox = (TextBox)this.FindControl("gotopageno");
int nPageNo = 0;
try
{
nPageNo = Convert.ToInt32(textbox.Text);
}
catch
{
return;
}
if (nPageNo < 1)
nPageNo = 1;
this.StartIndex = this.PageMaxLines * (nPageNo - 1);
// TODO: 放到Render()中检查
if (this.StartIndex >= this.ResultCount)
{
lastpage_Click(sender, e);
}
}
void lastpage_Click(object sender, EventArgs e)
{
int delta = this.ResultCount % this.PageMaxLines;
if (delta > 0)
this.StartIndex = (this.ResultCount / this.PageMaxLines) * this.PageMaxLines;
else
this.StartIndex = Math.Max(0, (this.ResultCount / this.PageMaxLines) * this.PageMaxLines - 1);
/*
this.StartIndex = -1; // 暗号
* */
}
void nextpage_Click(object sender, EventArgs e)
{
this.StartIndex += this.PageMaxLines;
// TODO: 放到Render()中检查
if (this.StartIndex >= this.ResultCount)
{
lastpage_Click(sender, e);
}
}
void prevpage_Click(object sender, EventArgs e)
{
this.StartIndex -= this.PageMaxLines;
if (this.StartIndex < 0)
this.StartIndex = 0;
}
void firstpage_Click(object sender, EventArgs e)
{
this.StartIndex = 0;
}
void reservationbutton_Click(object sender, EventArgs e)
{
string strBarcodeList = "";
LoginState loginstate = GlobalUtil.GetLoginState(this.Page);
// 如果尚未登录
if (loginstate == LoginState.NotLogin)
{
this.SetDebugInfo("errorinfo", this.GetString("尚未登录,不能使用预约功能")); // "尚未登录,不能使用预约功能"
return;
/*
this.Page.Response.Redirect("login.aspx");
this.Page.Response.End();
* */
}
// 如果是访客身份
if (loginstate == LoginState.Public)
{
this.SetDebugInfo("errorinfo", this.GetString("当前为访客身份,不能使用预约功能"));
return;
}
for (int i = 0; i < this.LineCount; i++)
{
CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "checkbox");
if (checkbox.Checked == true)
{
if (this.ItemBarcodes.Count <= i)
{
this.SetDebugInfo("errorinfo", "ItemBarcodes失效...");
return;
}
string strBarcode = this.ItemBarcodes[i];
if (strBarcodeList != "")
strBarcodeList += ",";
strBarcodeList += strBarcode;
checkbox.Checked = false;
}
}
OpacApplication app = (OpacApplication)this.Page.Application["app"];
SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];
Debug.Assert(String.IsNullOrEmpty(sessioninfo.UserID) == false, "");
// 获得读者证条码号
string strReaderBarcode = "";
if (String.IsNullOrEmpty(sessioninfo.UserID) == false
&& sessioninfo.IsReader == true
&& sessioninfo.ReaderInfo != null)
{
// 如果为一般读者身份,帐户信息中具有证条码号
strReaderBarcode = sessioninfo.ReaderInfo.Barcode;
}
else
{
// 否则从textbox中取得当时输入的证条码号
TextBox reservationreaderbarcode = (TextBox)this.FindControl("reservationreaderbarcode");
Debug.Assert(reservationreaderbarcode != null, "");
strReaderBarcode = reservationreaderbarcode.Text;
}
if (strReaderBarcode == "")
{
SetDebugInfo("errorinfo", this.GetString("尚未指定读者证条码号, 无法进行预约操作")); // "尚未指定读者证条码号, 无法进行预约操作。"
return;
}
LibraryChannel channel = sessioninfo.GetChannel(true);
try
{
string strError = "";
long lRet = // sessioninfo.Channel.
channel.Reservation(null,
"new",
strReaderBarcode,
strBarcodeList,
out strError);
if (lRet == -1)
SetDebugInfo("errorinfo", strError);
else
{
string strMessage = this.GetString("预约成功"); // "预约成功。请看“<a href='./reservationinfo.aspx'>预约</a>”中的新增信息。";
// 成功时也可能有提示信息
if (String.IsNullOrEmpty(strError) == false)
strMessage += "<br/><br/>" + strError;
SetDebugInfo(strMessage);
}
}
finally
{
sessioninfo.ReturnChannel(channel);
}
// 清除读者记录缓存
sessioninfo.ClearLoginReaderDomCache();
}
#if NO
// 创建标题行
void CreateTitleLine(PlaceHolder line)
{
line.Controls.Clear();
string strText = "";
strText += "<tr class='columntitle'>";
strText += "<td nowrap class='no'>"
+ this.GetString("册序号")
+ "</td>";
strText += "<td nowrap class='barcode'>"
+ this.GetString("册条码号")
+ "</td>";
strText += "<td nowrap class='state'>"
+ this.GetString("状态")
+ "</td>";
strText += "<td nowrap class='location'>"
+ this.GetString("馆藏地")
+ "</td>";
strText += "<td nowrap class='accessNo'>"
+ this.GetString("索取号")
+ "</td>"; // 2009/4/7
strText += "<td nowrap class='publishTime'>"
+ this.GetString("出版日期")
+ "</td>"; // 2010/4/22
strText += "<td nowrap class='volume'>"
+ this.GetString("卷期")
+ "</td>"; // 2009/4/7
strText += "<td nowrap class='price'>"
+ this.GetString("价格")
+ "</td>";
strText += "<td nowrap class='comment'>"
+ this.GetString("注释")
+ "</td>";
/*
strText += "<td nowrap>借者证条码号</td>";
strText += "<td nowrap>续借次</td>";
* */
strText += "<td nowrap class='borrows'>"
+ this.GetString("借阅情况")
+ "</td>";
/*
strText += "<td nowrap>借阅期限</td>";
strText += "<td nowrap>超期情况</td>";
* */
strText += "<td nowrap class='reservations'>"
+ this.GetString("预约情况")
+ "</td>";
/*
strText += "<td nowrap>种id</td>";
* */
strText += "</tr>";
line.Controls.Add(new LiteralControl(strText));
}
#endif
// 创建标题行
// 根据配置对某些列进行了隐藏
void CreateTitleLine(PlaceHolder line,
List<string> hideColumns)
{
line.Controls.Clear();
string strText = "";
strText += "<tr class='columntitle'>";
strText += "<td nowrap class='no'>"
+ this.GetString("册序号")
+ "</td>";
if (hideColumns == null
|| hideColumns.IndexOf("barcode") == -1)
strText += "<td nowrap class='barcode'>"
+ this.GetString("册条码号")
+ "</td>";
if (hideColumns == null
|| hideColumns.IndexOf("state") == -1)
strText += "<td nowrap class='state'>"
+ this.GetString("状态")
+ "</td>";
if (hideColumns == null
|| hideColumns.IndexOf("location") == -1)
strText += "<td nowrap class='location'>"
+ this.GetString("馆藏地")
+ "</td>";
if (hideColumns == null
|| hideColumns.IndexOf("accessNo") == -1)
strText += "<td nowrap class='accessNo'>"
+ this.GetString("索取号")
+ "</td>"; // 2009/4/7
if (hideColumns == null
|| hideColumns.IndexOf("currentLocation") == -1)
strText += "<td nowrap class='shelfNo'>"
+ this.GetString("当前位置")
+ "</td>"; // 2021/11/26
if (hideColumns == null
|| hideColumns.IndexOf("publishTime") == -1)
strText += "<td nowrap class='publishTime'>"
+ this.GetString("出版日期")
+ "</td>"; // 2010/4/22
if (hideColumns == null
|| hideColumns.IndexOf("volume") == -1)
strText += "<td nowrap class='volume'>"
+ this.GetString("卷期")
+ "</td>"; // 2009/4/7
if (hideColumns == null
|| hideColumns.IndexOf("price") == -1)
strText += "<td nowrap class='price'>"
+ this.GetString("价格")
+ "</td>";
if (hideColumns == null
|| hideColumns.IndexOf("comment") == -1)
strText += "<td nowrap class='comment'>"
+ this.GetString("注释")
+ "</td>";
if (hideColumns == null
|| hideColumns.IndexOf("borrows") == -1)
strText += "<td nowrap class='borrows'>"
+ this.GetString("借阅情况")
+ "</td>";
if (hideColumns == null
|| hideColumns.IndexOf("reservations") == -1)
strText += "<td nowrap class='reservations'>"
+ this.GetString("预约情况")
+ "</td>";
if (hideColumns == null
|| hideColumns.IndexOf("borrowcount") == -1)
strText += "<td nowrap class='borrowcount'>"
+ this.GetString("流通次数")
+ "</td>";
strText += "</tr>";
line.Controls.Add(new LiteralControl(strText));
}
PlaceHolder NewLine(int index,
Control insertbefore)
{
PlaceHolder line = new PlaceHolder();
line.ID = "line" + Convert.ToString(index);
if (insertbefore == null)
this.Controls.Add(line);
else
{
int pos = this.Controls.IndexOf(insertbefore);
this.Controls.AddAt(pos, line);
}
// 左侧文字
LiteralControl literal = new LiteralControl();
literal.ID = "line" + Convert.ToString(index) + "left";
literal.Text = "<tr class='content'><td>";
line.Controls.Add(literal);
// checkbox
CheckBox checkbox = new CheckBox();
checkbox.ID = "line" + Convert.ToString(index) + "checkbox";
line.Controls.Add(checkbox);
// 右侧文字
literal = new LiteralControl();
literal.ID = "line" + Convert.ToString(index) + "right";
literal.Text = "</td></tr>";
line.Controls.Add(literal);
return line;
}
public bool Active
{
get
{
this.EnsureChildControls();
HiddenField s = (HiddenField)this.FindControl("active");
if (String.IsNullOrEmpty(s.Value) == true)
return false;
if (s.Value == "0")
return false;
return true;
}
set
{
this.EnsureChildControls();
HiddenField s = (HiddenField)this.FindControl("active");
s.Value = value == true ? "1" : "0";
}
}
// 布局控件
protected override void CreateChildControls()
{
// 表格开头
if (this.Wrapper == true)
{
this.Controls.Add(new AutoIndentLiteral(
"<%begin%>"
+ this.GetPrefixString(
this.GetString("册信息"),
"content_wrapper")));
}
string strClass = "items";
if (this.Wrapper == true)
strClass += " wrapper";
// width='100%' cellspacing='1' cellpadding='4'
this.Controls.Add(new AutoIndentLiteral("<%begin%><table class='" + strClass + "'>"));
HiddenField active = new HiddenField();
active.ID = "active";
active.Value = "1";
this.Controls.Add(active);
/*
// 信息文字
LiteralControl resultinfo = new LiteralControl();
resultinfo.ID = "resultinfo";
this.Controls.Add(resultinfo);
* */
// 期刊封面图片区
PlaceHolder coverline = new PlaceHolder();
coverline.ID = "coverline";
this.Controls.Add(coverline);
// 标题行
PlaceHolder titleline = new PlaceHolder();
titleline.ID = "titleline";
this.Controls.Add(titleline);
CreateTitleLine(titleline, null);
// 每一行一个占位控件
for (int i = 0; i < this.LineCount; i++)
{
PlaceHolder line = NewLine(i, null);
line.Visible = false;
}
// 命令行
PlaceHolder cmdline = new PlaceHolder();
cmdline.ID = "cmdline";
this.Controls.Add(cmdline);
CreateCmdLine(cmdline);
// 隐藏字段,用来转值
HiddenField hidden = new HiddenField();
hidden.ID = "resultcount";
this.Controls.Add(hidden);
// 调试信息行
PlaceHolder debugline = new PlaceHolder();
debugline.ID = "debugline";
debugline.Visible = false;
this.Controls.Add(debugline);
CreateDebugLine(debugline);
// 表格结尾
/*
literal = new LiteralControl();
literal.ID = "end";
literal.Text = "</table>";
* */
this.Controls.Add(new AutoIndentLiteral("<%end%></table>"));
if (this.Wrapper == true)
{
this.Controls.Add(new AutoIndentLiteral("<%end%>" + this.GetPostfixString()));
}
}
/*
* Barcode和BiblioRecPath是否具有值, 分为3种情况
* 1)Barcode和BiblioRecPath都有值。
* 这通常表示需要通过种记录路径获得全部册显示出来,把特定的barcode对应行加亮显示
* 如果此时ItemDispStyle为Item,则不好理解,这时只需指定Barcode,而Biblio不需要有值
* 2)Barcode有值
* 这需要先获得册记录,然后从册记录<parent>中获得种记录的id
* 3)BiblioRecPath有值
* 这表示需要显示同种的全部册
*/
protected override void Render(HtmlTextWriter output)
{
int nRet = 0;
string strError = "";
if (String.IsNullOrEmpty(this.Barcode) == true
&& String.IsNullOrEmpty(this.BiblioRecPath) == true)
{
strError = "Barcode和BiblioRecPath均为空, 无法显示";
goto ERROR1;
}
LoginState loginstate = GlobalUtil.GetLoginState(this.Page);
OpacApplication app = (OpacApplication)this.Page.Application["app"];
SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];
/*
if (sessioninfo.Account == null)
{
//strError = "尚未登录";
//goto ERROR1;
this.Page.Response.Redirect("login.aspx");
this.Page.Response.End();
return;
}
* */
// 设置 预约按钮文字和状态
Button reservationbutton = (Button)this.FindControl("reservationbutton");
/*
if (sessioninfo.Account == null
|| (sessioninfo.Account != null && sessioninfo.Account.UserID == "public")) // 2006/12/24
* */
if (loginstate == LoginState.NotLogin
|| loginstate == LoginState.Public) // 2007/7/10
{
reservationbutton.Text = this.GetString("加入预约列表");
reservationbutton.Enabled = false;
}
else
{
// 2023/11/9
if (loginstate == LoginState.Librarian)
{
// 没有姓名
reservationbutton.Text = this.GetString("加入预约列表");
}
// Debug.Assert(sessioninfo.ReaderInfo != null);
else if (sessioninfo.ReaderInfo == null