This repository has been archived by the owner on Jul 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccountSelection.ascx.cs
1634 lines (1353 loc) · 54.2 KB
/
AccountSelection.ascx.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;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Jenzabar.Common.Globalization;
//using Jenzabar.Common.Configuration;
using Jenzabar.CRM.Deserializers;
using Jenzabar.CRM.Utility;
using Jenzabar.Portal.Framework;
//using Jenzabar.Portal.Framework.Web.Configuration;
using Jenzabar.Portal.Framework.Web.UI;
using Jenzabar.Portal.Web.UI.Controls;
using Settings = Jenzabar.Portal.Framework.Configuration.Settings;
namespace Jenzabar.CRM.Staff.Web.Portlets.GLAccountLookupPortlet
{
public class AccountSelection : PortletViewBase
{
protected System.Web.UI.WebControls.Label lblYear;
protected System.Web.UI.WebControls.Label lblBeginPeriod;
protected System.Web.UI.WebControls.Label lblBudget;
protected System.Web.UI.WebControls.DropDownList ddlYear;
//protected System.Web.UI.WebControls.DropDownList ddlBegPeriod;
protected System.Web.UI.WebControls.DropDownList ddlEndPeriod;
protected System.Web.UI.WebControls.Button btnLookup;
protected System.Web.UI.WebControls.Button btnCancel;
protected System.Web.UI.WebControls.Label lblError;
protected System.Web.UI.WebControls.DropDownList ddlBudget;
protected Jenzabar.Common.Web.UI.Controls.ContentTabGroup MainScreenTabs;
protected Jenzabar.Common.Web.UI.Controls.ContentTab tbFull;
protected Jenzabar.Common.Web.UI.Controls.ContentTab tbPartial;
protected Jenzabar.Common.Web.UI.Controls.ContentTab tbSelect;
protected System.Web.UI.WebControls.Label lblAcctNumRange;
protected System.Web.UI.WebControls.Label lblBegAcctNum;
protected System.Web.UI.WebControls.Label lblEnAcctNum;
protected System.Web.UI.WebControls.Label lblAcctNumSel;
protected System.Web.UI.WebControls.Label lblDRForTrans;
protected System.Web.UI.WebControls.TextBox txtBeginAcctNum;
protected System.Web.UI.WebControls.TextBox txtEndAcctNum;
protected System.Web.UI.WebControls.TextBox txtFund;
protected System.Web.UI.WebControls.TextBox txtDept;
protected System.Web.UI.WebControls.TextBox txtObject;
protected Hashtable htSearchSavedValues;
protected System.Web.UI.HtmlControls.HtmlTable tblDRControls;
protected System.Web.UI.WebControls.DropDownList ddlLedger;
protected System.Web.UI.WebControls.Label lblLedger;
protected System.Web.UI.WebControls.Label lblTabIns;
protected Jenzabar.Common.Web.UI.Controls.Hint hntFullAcct;
protected Jenzabar.Common.Web.UI.Controls.Hint hntPartAcct;
protected System.Web.UI.WebControls.Label lblResultsPerPage;
protected System.Web.UI.WebControls.DropDownList ddlResultsPerPage;
protected Jenzabar.Portal.Web.UI.Controls.JenzabarGLAccountLookup JenzabarGLAccountLookup;
//Hashtable htPartAcctControls;
//The maximum number of rows we will dynamically create for the partial search
//controls.
private const int MAX_PART_ACCT_CTRL_ROWS = 3;
private const int TAB_FULL = 0;
private const int TAB_PART = 1;
private const int TAB_SEL = 2;
const string SEARCH_TYPE_RANGE = "RANGE";
const string SEARCH_TYPE_PARTIAL = "PARTIAL";
const string SEARCH_TYPE_ACCOUNTS = "ACCOUNTS";
protected System.Web.UI.HtmlControls.HtmlInputHidden hdnSelSort;
protected System.Web.UI.WebControls.DropDownList ddlBegPeriod;
protected System.Web.UI.WebControls.Label lblEndPeriod;
string strShowGLLedger = null;
string strRefineSearch = null;
public override string ViewName
{
get
{
return GLALPConstants.ACCOUNT_SELECTION_SCREEN;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnLookup.Click += new System.EventHandler(this.btnLookup_Click);
this.Load += new System.EventHandler(this.Page_Load);
this.PreRender += new System.EventHandler(this.AccountSelection_PreRender);
if(this.ParentPortlet.Session["glAlPartLookupData"]==null)
{
htSearchSavedValues = new Hashtable();
}
else
{
htSearchSavedValues = (Hashtable)this.ParentPortlet.Session["glAlPartLookupData"];
}
}
#endregion
private void Page_Load(object sender, System.EventArgs e)
{
string strTotalAccounts = null;
//We use this flag to tell us whether the user clicked the "start new search" button on
//the BudgetToActual screen.
strRefineSearch = ((this.ParentPortlet.PortletViewState[GLALPConstants.VS_GL_REFINE_SEARCH]!=null)?this.ParentPortlet.PortletViewState[GLALPConstants.VS_GL_REFINE_SEARCH].ToString():"N");
GenerateJavascript();
//Set Labels and Text
Initialize_Globalization();
//Populate the partial account number search
//controls.
CreatePartSearchControls();
//Initialize the account control
InitAccountControl();
if (this.IsFirstLoad)
{
try
{
//if (CheckForNumberOfAccounts() > ERPSettings.MaximumGLAccountsToDisplay)
//Uncomment the line above once the framework team implements it.
//Get the number of accounts and save it in a viewstate value
strTotalAccounts = (CheckForNumberOfAccounts()).ToString();
this.ParentPortlet.PortletViewState[GLALPConstants.VS_GL_TOTAL_ACCT_COUNT]
= strTotalAccounts;
CallGetERPPortletProperties();
//DataBind for ddls
Initialize_Controls();
//Initialize_Objects();
// //If this is CX then call
// if(Settings.Current.ERPType.ToString()=="CX")
// {
// PopulateLedger();
// }
//If the ERP General Ledger visible property is set
//to "Y" then show the dropdown.
strShowGLLedger = ((this.ParentPortlet.PortletViewState["ERP_GL_ACCT_LEDGER"]!=null)?this.ParentPortlet.PortletViewState["ERP_GL_ACCT_LEDGER"].ToString():"Y");
if(strShowGLLedger.ToUpper().Trim()=="Y")
{
PopulateLedger();
}
//Populate dropdown
PopulateResultsPerPageDropdown();
//Initialize the account control
//InitAccountControl();
}
catch (System.Exception ex)
{
this.lblError.Text = ex.GetBaseException().Message;
}
}
else
{
strTotalAccounts = ((this.ParentPortlet.PortletViewState[GLALPConstants.VS_GL_TOTAL_ACCT_COUNT]!=null)?this.ParentPortlet.PortletViewState[GLALPConstants.VS_GL_TOTAL_ACCT_COUNT].ToString():"0");
strShowGLLedger = ((this.ParentPortlet.PortletViewState["ERP_GL_ACCT_LEDGER"]!=null)?this.ParentPortlet.PortletViewState["ERP_GL_ACCT_LEDGER"].ToString():"Y");
}
//Set the default tab-I am keeping this code outside of the first decision block for
//isFirstLoad just in case I need to comment the first decision statement out on a
//later date.
if(this.MainScreenTabs.ContentTabs.Count > 0 && this.IsFirstLoad ==true)
{
string strSelTab = ((this.ParentPortlet.PortletViewState[GLALPConstants.VS_GL_SELECTED_TAB_VAL]!=null)? this.ParentPortlet.PortletViewState[GLALPConstants.VS_GL_SELECTED_TAB_VAL].ToString(): System.Convert.ToString(TAB_FULL));
SetSelectedTab(strSelTab);
if(strRefineSearch.ToUpper()=="Y")
{
//If the user had selected a tab previously then we will use that value
// string strSelTab = ((this.ParentPortlet.PortletViewState[GLALPConstants.VS_GL_SELECTED_TAB_VAL]!=null)? this.ParentPortlet.PortletViewState[GLALPConstants.VS_GL_SELECTED_TAB_VAL].ToString(): System.Convert.ToString(TAB_FULL));
//SetSelectedTab(strSelTab);
//reset the value
strRefineSearch = "N";
}
else
{
//this.MainScreenTabs.ContentTabs[TAB_FULL].Selected = true;
}
}
//if (CheckForNumberOfAccounts() > ERPSettings.MaximumGLAccountsToDisplay)
//Uncomment the line above once the framework team implements it.
//Get the number of accounts and either display or hide
//the third tab.
if (System.Convert.ToInt32(strTotalAccounts) > Settings.Current.MaxGLAcctsToDisplay)
{
this.tbSelect.Visible = false;
//TTP 13130
this.JenzabarGLAccountLookup.AutoPopulateAccountCodes = false;
}
else
{
this.tbSelect.Visible = true;
//TTP 13130
this.JenzabarGLAccountLookup.AutoPopulateAccountCodes = true;
}
//Get the ERP property values
//strShowGLLedger = ((this.ParentPortlet.PortletViewState["ERP_GL_ACCT_LEDGER"]!=null)?this.ParentPortlet.PortletViewState["ERP_GL_ACCT_LEDGER"].ToString():"Y");
if(strShowGLLedger.ToUpper() =="N")
{
this.lblLedger.Visible = false;
this.ddlLedger.Visible = false;
}
else
{
this.lblLedger.Visible = true;
this.ddlLedger.Visible = true;
}
//AddJavascriptEvents();
}
private void AccountSelection_PreRender(object sender, System.EventArgs e)
{
SortedList slSavedValues = (SortedList)this.ParentPortlet.Session["glAlSelLookupData"];
if(slSavedValues !=null )
{
if(slSavedValues.Count > 0)
{
JenzabarGLAccountLookup.AccountsSelected = slSavedValues;
slSavedValues.Clear();
}
this.ParentPortlet.Session.Remove("glAlSelLookupData");
}
}
#region Custom Methods
private void GenerateJavascript()
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"JavaScript\">");
//This function will save the selected sort by value in a hidden field.
sb.Append("function SetSelectedSort (hdnCtlID, sortByID) {" + Environment.NewLine);
sb.Append("var hdnField = document.getElementById(hdnCtlID); "+ Environment.NewLine);
sb.Append("var sortBy = document.getElementById(sortByID); "+ Environment.NewLine);
sb.Append("if(hdnField != null && sortBy!=null){ hdnField.value = sortBy.value; }"+ Environment.NewLine);
sb.Append("}"+ Environment.NewLine);
// //The Validation Functions
// sb.Append("function ValidateAcctNumData(tabCtlID, strTabNum) { " + Environment.NewLine);
// sb.Append("var begAcctNum = document.getElementById(tabCtlID + '_txtBeginAcctNum'); "+ Environment.NewLine);
//
// //The validation logic for the Full Account Search tab controls
// sb.Append("if(strTabNum == 'FULL'){" + Environment.NewLine);
// sb.Append("if(begAcctNum == null){ return true;}"+ Environment.NewLine);
//
// sb.Append(" if(begAcctNum.value =='' )" + Environment.NewLine);
// sb.Append("{ alert('Please enter a Beginning Account Number'); return false;}"+ Environment.NewLine);
// sb.Append("else{return true;}"+ Environment.NewLine);
// sb.Append("}"+ Environment.NewLine);
//
//
// sb.Append("}"+ Environment.NewLine);
//
//
// //The function to set the hidden field value for the selected tab
// sb.Append("function SetSelectedTab (hdnCtlID, strTabNum) {" + Environment.NewLine);
// sb.Append("var hdnField = document.getElementById(hdnCtlID); "+ Environment.NewLine);
// sb.Append("if(hdnField != null){ hdnField.value = strTabNum;}"+ Environment.NewLine);
// sb.Append("}"+ Environment.NewLine);
sb.Append("</script>"+ Environment.NewLine);
this.Page.RegisterStartupScript("AcctJavaScript",sb.ToString());
}
private void AddJavascriptEvents()
{
if (this.MainScreenTabs.ContentTabs.Count > 0 &&
this.MainScreenTabs.ContentTabs[TAB_FULL].Selected ==true)
{
this.btnLookup.Attributes.Add("onClick","return ValidateAcctNumData('"+ this.tbFull.ClientID +"', 'FULL');");
}
else if(this.MainScreenTabs.ContentTabs.Count > 1 &&
this.MainScreenTabs.ContentTabs[TAB_PART].Selected ==true)
{
this.btnLookup.Attributes.Add("onClick","return ValidateAcctNumData('"+ this.tbFull.ClientID +"', 'PART');");
}
else if(this.MainScreenTabs.ContentTabs.Count > 2 &&
this.MainScreenTabs.ContentTabs[TAB_SEL].Selected ==true)
{
this.btnLookup.Attributes.Add("onClick","return ValidateAcctNumData('"+ this.tbFull.ClientID +"', 'SEL');");
}
}
/// <summary>
/// This method will check for the number of accounts the user ID has access to.
/// </summary>
/// <returns></returns>
private int CheckForNumberOfAccounts()
{
int intRetVal = 0;
string strXML = string.Empty;
string strError = string.Empty;
Jenzabar.CRM.Deserializers.ValidAccountCodes objAccountInfo ;
//TTP 8923
string strHostID = ((PortalUser.Current.HostID !=null)?PortalUser.Current.HostID.ToString():"");
try
{
if (this
.GetInstance<IStaff>()
.GetValidAccountCodes(strHostID, true, "GLAccountLookup", ref strXML, ref strError) != PlugInConstants.SUCCESS)
{
//Do something here to display an error
intRetVal = PlugInConstants.RETURN_TYPE_NONE;
}
else
{
objAccountInfo = (Jenzabar.CRM.Deserializers.ValidAccountCodes)PlugIn.MapXMLToObject(strXML, new XmlSerializer(typeof(Jenzabar.CRM.Deserializers.ValidAccountCodes)));
if(objAccountInfo != null && objAccountInfo.TotalAccounts !=null )
{
intRetVal = System.Convert.ToInt32(objAccountInfo.TotalAccounts) ;
}
}
}
catch(System.Exception ex)
{
this.lblError.Text = ex.Message.ToString();
this.lblError.Visible = true;
}
return intRetVal;
}
/// <summary>
/// This method will populate the ledger control
/// </summary>
private void PopulateLedger()
{
string strXML = null;
string strError = null;
//TTP 8923
string strHostID = ((PortalUser.Current.HostID !=null)?PortalUser.Current.HostID.ToString():"");
//Call the plug in to get the general ledger data
if(this.GetInstance<IStaff>().GetGeneralLedgers(strHostID,
ref strXML,ref strError)== PlugInConstants.SUCCESS)
{
if (strXML !=null && strXML !=string.Empty)
{
GeneralLedgers gl = (GeneralLedgers)PlugIn.MapXMLToObject(strXML, new XmlSerializer(typeof(GeneralLedgers)));
if(gl !=null && gl.Ledger.Length > 0)
{
//If we have any ledger items then add them to the dropdown list
for(int i= 0; i<gl.Ledger.Length; i++)
{
ListItem li = new ListItem(gl.Ledger[i].Name,gl.Ledger[i].ID);
this.ddlLedger.Items.Add(li);
}
}
}
}
}
/// <summary>
/// This method will call the getERPPortletProperties plug in
/// and set the visibility of various controls based on the
/// retrieved values.
/// </summary>
/// <returns></returns>
private int CallGetERPPortletProperties()
{
string strXML = null;
string strError = null;
string lsGLAccountLedger = null;
try
{
if (this.GetInstance<IStaff>().GetERPPortletProperties(ref strXML, ref strError) != PlugInConstants.SUCCESS)
{
this.lblError.Visible = true ;
this.lblError.Text = GLALPMessages.TXT_GLP_ERROR_NO_DATA_RETRIEVED ;
return -1;
}
strXML = strXML.Replace("<Properties>","<ERP><Properties>");
strXML = strXML.Replace("</Properties>","</Properties></ERP>");
ERP ERPProperties = (ERP)PlugIn.MapXMLToObject(strXML, new XmlSerializer(typeof(ERP)));
if (ERPProperties.Items == null || ERPProperties.Items.Length == 0 )
{
this.lblError.Visible = true ;
this.lblError.Text = GLALPMessages.TXT_GLP_ERROR_NO_DATA_RETRIEVED ;
return -1;
}
if(ERPProperties.Items[0].GLAccountLedger!=null && ERPProperties.Items[0].GLAccountLedger.Length > 0)
{
lsGLAccountLedger = ERPProperties.Items[0].GLAccountLedger[0].Visible.ToString();
}
else
{
lsGLAccountLedger = "Y";
}
//Set the Values into PortLet View State
this.ParentPortlet.PortletViewState["ERP_GL_ACCT_LEDGER"] = lsGLAccountLedger;
}
catch(System.Exception ex)
{
this.lblError.Visible = true;
this.lblError.Text = ex.Message.ToString();
}
return 1;
}
/// <summary>
/// This method will build the XML parameter string for the GetBudgetStatus
/// plug in call.
/// </summary>
/// <param name="strSearchType"></param>
/// <param name="ht"></param>
/// <returns></returns>
private string BuildBudgetStatusSearchParamString(string strSearchType, Hashtable ht)
{
CRMStringUtility sb = new CRMStringUtility();
//Make sure the user sent us a hashtable with at least one element
if(ht != null && ht.Count > 0)
{
try
{
//Build the XML parameter string for the Account Range search.
if(strSearchType.ToUpper() == SEARCH_TYPE_RANGE)
{
sb.AppendString("<SearchParameters>");
sb.AppendXML(ht["SearchType"].ToString(), "SearchType");
sb.AppendXML(ht["RangeBeginAcct"].ToString(),"RangeBeginAccount");
sb.AppendXML(ht["RangeEndAcct"].ToString(),"RangeEndAccount");
sb.AppendString("</SearchParameters>");
}
if(strSearchType.ToUpper() == SEARCH_TYPE_PARTIAL)
{
sb.AppendString("<SearchParameters>");
sb.AppendXML(ht["SearchType"].ToString(), "SearchType");
sb.AppendString(ht["SearchParams"].ToString());
sb.AppendString("</SearchParameters>");
}
//Build the XML parameter string for the Account Select search.
if(strSearchType.ToUpper() == SEARCH_TYPE_ACCOUNTS)
{
sb.AppendString("<SearchParameters>");
sb.AppendXML(ht["SearchType"].ToString(), "SearchType");
SortedList sl = (SortedList)ht["SelectedAccounts"];
sb.AppendString("<Accounts>");
if(sl != null && sl.Count > 0)
{
for (int i= 0; i< sl.Count; i++)
{
//string strVal = sl.GetByIndex(i).ToString();
//string strDelimit = "-";
//Get the key value from the sorted list.
//The key will always contain a delimited
//string with the account number as the last
//parameter(i.e. acctNum;acctDesc;acctNum or
//acctDesc;acctNum;acctNum).
string strVal = sl.GetKey(i).ToString();
string strDelimit = ";";
char [] delimiter = strDelimit.ToCharArray();
string[] strAcctNum = strVal.Split(delimiter);
//We must have at least 3 elements and we always use the last
//element to retrieve the account number.
if(strAcctNum.Length > 2)
{
sb.AppendXML(strAcctNum[2].ToString().Trim(), "AccountNumber");
}
else
{
sb.AppendXML("", "AccountNumber");
}
}
}
sb.AppendString("</Accounts>");
sb.AppendString("</SearchParameters>");
}
}
catch
{
sb.AppendString("");
}
}
return sb.myString.ToString();
}
/// <summary>
/// This method will call the GetBudgetStatus plug in.
/// </summary>
/// <returns>An integer indicating success or failure.</returns>
private int CallGetBudgetStatus()
{
object[] PluginParam= new object[7];
string strXML = "";
string strError = "";
BudgetLookupInfo bl;
int intRetValue = 1;
string strSearchParams = string.Empty;
//TTP 8923
string strHostID = ((PortalUser.Current.HostID !=null)?PortalUser.Current.HostID.ToString():"");
//Get all the search values stored in the viewstate variables.
string strLedger = ((this.ParentPortlet.PortletViewState["Ledger"] !=null)?this.ParentPortlet.PortletViewState["Ledger"].ToString():"");
string strYear = ((this.ParentPortlet.PortletViewState["Year"] !=null)?this.ParentPortlet.PortletViewState["Year"].ToString():"");
string strBudRange = ((this.ParentPortlet.PortletViewState["BudRange"] !=null)?this.ParentPortlet.PortletViewState["BudRange"].ToString():"");
string strBeginPeriod = ((this.ParentPortlet.PortletViewState["BeginPeriod"] !=null)?this.ParentPortlet.PortletViewState["BeginPeriod"].ToString():"");
string strEndPeriod = ((this.ParentPortlet.PortletViewState["EndPeriod"] !=null)?this.ParentPortlet.PortletViewState["EndPeriod"].ToString():"");
// PluginParam[0] = PortalUser.Current.HostID.ToString();
// PluginParam[1] = this.ParentPortlet.PortletViewState["BeginAcctNum"].ToString();
// PluginParam[2] = this.ParentPortlet.PortletViewState["EndAcctNum"].ToString();
// PluginParam[1] = this.ParentPortlet.PortletViewState["Ledger"].ToString();
// PluginParam[2] = this.ParentPortlet.PortletViewState["Year"].ToString();
// PluginParam[3] = this.ParentPortlet.PortletViewState["BeginPeriod"].ToString();
// PluginParam[4] = this.ParentPortlet.PortletViewState["EndPeriod"].ToString();
// PluginParam[5] = this.ParentPortlet.PortletViewState["BudRange"].ToString();
//Create the search parameter string for the FULL Account Search
if(MainScreenTabs.ContentTabs.Count > 0 &&
MainScreenTabs.ContentTabs[TAB_FULL].Selected)
{
string strBeginAcct = ((this.ParentPortlet.PortletViewState["BeginAcctNum"] !=null)?this.ParentPortlet.PortletViewState["BeginAcctNum"].ToString():"");
string strEndAcct = ((this.ParentPortlet.PortletViewState["EndAcctNum"] !=null)?this.ParentPortlet.PortletViewState["EndAcctNum"].ToString():"");
Hashtable htSearchParams = new Hashtable();
htSearchParams.Add("SearchType",SEARCH_TYPE_RANGE);
htSearchParams.Add("RangeBeginAcct",strBeginAcct);
htSearchParams.Add("RangeEndAcct",strEndAcct);
//Create the string.
strSearchParams = BuildBudgetStatusSearchParamString(SEARCH_TYPE_RANGE, htSearchParams);
}
//Create the search parameter string for the Partial Account Number Search
// if(MainScreenTabs.ContentTabs.Count > 0 &&
// MainScreenTabs.ContentTabs[TAB_SEL].Selected)
// {
// //Create the hashtable to store the parameters
// Hashtable htSearchParams = new Hashtable();
//
// htSearchParams.Add("SearchType",SEARCH_TYPE_PARTIAL);
// //htSearchParams.Add("SelectedAccounts",slAccounts);
//
// //Create the string.
// strSearchParams = BuildBudgetStatusSearchParamString(SEARCH_TYPE_ACCOUNTS, htSearchParams);
// }
//Create the search parameter string for the Part Account Number Search
if(MainScreenTabs.ContentTabs.Count > 0 &&
MainScreenTabs.ContentTabs[TAB_PART].Selected)
{
Hashtable htSearchParams = new Hashtable();
HtmlTable tbl = (HtmlTable)this.FindControl("MainScreenTabs").FindControl("tbPartial").FindControl("tblSearchByAcctPart");
CRMStringUtility sb = new CRMStringUtility();
string strHiddenFields = ((this.ParentPortlet.PortletViewState["AS_HIDDEN_CTL_ID"]!=null)?this.ParentPortlet.PortletViewState["AS_HIDDEN_CTL_ID"].ToString():"");
sb.AppendString("<PartialElements>");
if(tbl !=null && strHiddenFields !=null && strHiddenFields != string.Empty)
{
char[]aryDelimiter = {';'};
string[]aryHiddenFieldIDs = strHiddenFields.Split(aryDelimiter);
if(aryHiddenFieldIDs.Length > 0)
{
//For each row we retrieve the hidden control and the text box control
//to get the required search parameters
//for(int i=0; i< tbl.Rows.Count; i++)
if(tbl.Rows.Count >= MAX_PART_ACCT_CTRL_ROWS)
{
//Get the last row in the table which should always contain
//the hidden fields with their associated data (ID, Name, Sequence Number).
int i = tbl.Rows.Count-1;
for(int j = 0; j<aryHiddenFieldIDs.Length; j++)
{
//Now we'll get the hidden text box which should contain the values for
//the sequence number, control name and text box ID.
TextBox tbHidden = (TextBox)tbl.Rows[i].FindControl(aryHiddenFieldIDs[j]);
if(tbHidden !=null && tbHidden.Text != string.Empty)
{
string strHiddenVal = tbHidden.Text;
string[]aryHiddenVals = strHiddenVal.Split(aryDelimiter);
if(aryHiddenVals.Length > 2 && aryHiddenFieldIDs[j]!=string.Empty )
{
sb.AppendString("<Element>");
sb.AppendXML(aryHiddenVals[0].ToString(),"ID");
sb.AppendXML(aryHiddenVals[2].ToString(),"Name");
sb.AppendXML(aryHiddenVals[1].ToString(),"Sequence");
//Now find the data entry textbox and get the value the user entered
//if there is any.
TextBox tbVal = (TextBox)tbl.Rows[i].FindControl("AcctSelPartial_txt" + aryHiddenVals[0]);
if(tbVal != null)
{
sb.AppendXML(tbVal.Text.Trim(),"Value");
}
//Append the closing tag
sb.AppendString("</Element>");
}
}
}//End of aryHiddenFieldIDs FOR loop
}//End of tbl.Rows FOR loop
}
}
sb.AppendString("</PartialElements>");
htSearchParams.Add("SearchType",SEARCH_TYPE_PARTIAL);
htSearchParams.Add("SearchParams",sb.myString.ToString());
//Create the string.
strSearchParams = BuildBudgetStatusSearchParamString(SEARCH_TYPE_PARTIAL, htSearchParams);
}
//Create the search parameter string for the Select Account Search
if(MainScreenTabs.ContentTabs.Count > 0 &&
MainScreenTabs.ContentTabs[TAB_SEL].Selected)
{
Hashtable htSearchParams = new Hashtable();
//Create a sorted list for the account numbers
SortedList slAccounts = new SortedList();
if( this.JenzabarGLAccountLookup!=null
&& this.JenzabarGLAccountLookup.AccountsSelected !=null)
{
slAccounts = this.JenzabarGLAccountLookup.AccountsSelected;
}
htSearchParams.Add("SearchType",SEARCH_TYPE_ACCOUNTS);
htSearchParams.Add("SelectedAccounts",slAccounts);
//Create the string.
strSearchParams = BuildBudgetStatusSearchParamString(SEARCH_TYPE_ACCOUNTS, htSearchParams);
}
// Serialize XML form plugin
try
{
this
.GetInstance<IStaff>()
.GetBudgetStatus(strHostID, strLedger, strYear, strBeginPeriod ,strEndPeriod, strBudRange,strSearchParams, true, ref strXML, ref strError);
bl = (BudgetLookupInfo)PlugIn.MapXMLToObject(strXML, new XmlSerializer(typeof(BudgetLookupInfo)));
//Make sure we have at least one account.
if (bl.Accounts != null)
{
intRetValue = bl.Accounts.Length;
//Save the account Search information - TTP 7803
this.ParentPortlet.PortletViewState["GLBudgetStatusXML"] = strXML;
//this.Page.Cache.Insert("GLBudgetStatusXML",bl);
// this.lblPeriod.Text = bl.Period.ToString();
// this.lblPeriod.Font.Bold = true;
// this.ParentPortlet.PortletViewState["BeginPeriodDate"] = bl.BeginPeriod.ToString();
// this.ParentPortlet.PortletViewState["EndPeriodDate"] = bl.EndPeriod.ToString();
}
else
{
intRetValue = -1;
}
}
catch(System.Exception ex)
{
this.lblError.Visible = true;
this.lblError.Text = ex.Message.ToString();
}
return intRetValue;
}
private void PopulateResultsPerPageDropdown()
{
if(this.ddlResultsPerPage !=null)
{
this.ddlResultsPerPage.Items.Clear();
this.ddlResultsPerPage.Items.Add(new ListItem("50","50"));
this.ddlResultsPerPage.Items.Add(new ListItem("100","100"));
this.ddlResultsPerPage.Items.Add(new ListItem("200","200"));
this.ddlResultsPerPage.Items.Add(new ListItem("All Results","ALL"));
this.ddlResultsPerPage.SelectedValue = "ALL";
}
}
/// <summary>
/// This method will remove certain characters from a string so the portlet
/// can correctly handle special character data.
/// </summary>
/// <param name="strInput"></param>
/// <returns></returns>
private string CleanUpString(string strInput)
{
string strOutput = null;
//The unicode representation for a non-breaking space
char chrSpace = '\u00A0';
if(strInput !=null && strInput != string.Empty)
{
string str1 = strInput.Replace('"',chrSpace);
string str2 = str1.Replace('<',chrSpace);
string str3 = str2.Replace('>',chrSpace);
string str4 = str3.Replace(';',chrSpace);
strOutput = str4;
//strOutput = Regex.Replace(strInput, @"[^\w\s\-\'\:\,\.\/\\\&\+ @-]", "");
}
else
{
strOutput = strInput;
}
return strOutput;
}
/// <summary>
/// This method will dynamically populate the controls into the Part Account Number
/// search tab
/// </summary>
private void CreatePartSearchControls()
{
string strXML = null;
bool blnRestoreSavedValues = false;
//string strError = null;
//Clear the viewstate
this.ParentPortlet.PortletViewState["AS_HIDDEN_CTL_ID"] = "";
if(htSearchSavedValues !=null && htSearchSavedValues.Count > 0)
{
blnRestoreSavedValues = true;
}
try
{
HtmlTable tbl = (HtmlTable)this.FindControl("MainScreenTabs").FindControl("tbPartial").FindControl("tblSearchByAcctPart");
if(tbl !=null)
{
//Now create the controls
//First call the plug in to get the control information
this.GetInstance<IStaff>().GetPartialAccountElements(ref strXML);
if(strXML !=null)
{
PartialAccountElements partElements = (PartialAccountElements)PlugIn.MapXMLToObject(strXML, new XmlSerializer(typeof(PartialAccountElements)));
//Get each element's data and create the control in the table which will contain
//all the part search controls.
HtmlTableRow trLabels = new HtmlTableRow();
HtmlTableRow trInput = new HtmlTableRow();
HtmlTableRow trHidden = new HtmlTableRow();
trLabels.Attributes.Add("runat","server");
trInput.Attributes.Add("runat","server");
if(partElements.Elements !=null
&& partElements.Elements.Length > 0)
{
for (int i=0; i< partElements.Elements.Length; i++)
{
HtmlTableCell tcLabel = new HtmlTableCell();
HtmlTableCell tcText = new HtmlTableCell();
HtmlTableCell tcHidden = new HtmlTableCell();
//Create the Label
Label lbl = new Label();
lbl.Attributes.Add("runat","server");
lbl.ID = "AcctSelPartial_lbl" + CleanUpString(partElements.Elements[i].ID);
lbl.Text = CleanUpString(partElements.Elements[i].Name) + ": ";
//Create the textbox
TextBox tb = new TextBox();
tb.Attributes.Add("runat","server");
tb.EnableViewState = true;
tb.ID = "AcctSelPartial_txt" + CleanUpString(partElements.Elements[i].ID);
if(blnRestoreSavedValues)
{
if(htSearchSavedValues.ContainsKey(tb.ID))
{
tb.Text = htSearchSavedValues[tb.ID].ToString();
}
}
else
{
htSearchSavedValues.Add(tb.ID,tb.Text);
}
if(partElements.Elements[i].MaximumLength > 0)
{
tb.MaxLength = partElements.Elements[i].MaximumLength;
}
//Now add a hidden text field which will contain the sequence
//number, the control name and the text box's ID delimited with a ";";
TextBox tbHidden = new TextBox();
tbHidden.EnableViewState = true;
tbHidden.Attributes.Add("runat","server");
tbHidden.ID = "txtHidden" + partElements.Elements[i].ID;
//Save the hidden field's ID value to a viewstate variable
string strPrevVal = ((this.ParentPortlet.PortletViewState["AS_HIDDEN_CTL_ID"] !=null)?this.ParentPortlet.PortletViewState["AS_HIDDEN_CTL_ID"].ToString():"");
this.ParentPortlet.PortletViewState["AS_HIDDEN_CTL_ID"] = strPrevVal + tbHidden.ID + ";";
// tbHidden.Text = tb.ID.ToString() + ";" +
// partElements.Elements[i].Sequence + ";" + partElements.Elements[i].Name;
tbHidden.Text = CleanUpString(partElements.Elements[i].ID) + ";" +
CleanUpString(partElements.Elements[i].Sequence) + ";" + CleanUpString(partElements.Elements[i].Name);
tbHidden.Visible = false;
tbHidden.Width = System.Convert.ToInt32(1);
tbHidden.Height = System.Convert.ToInt32(1);
//tcHidden.Attributes.Add("style","visibility:hidden");
tcLabel.Controls.Add(lbl);
tcText.Controls.Add(tb);
tcHidden.Controls.Add(tbHidden);
trLabels.Cells.Add(tcLabel);
trInput.Cells.Add(tcText);
trHidden.Cells.Add(tcHidden);
//tr.Cells.Add(tcLabel);
//tr.Cells.Add(tcText);
//tr.Cells.Add(tcHidden);
}
}
tbl.Rows.Add(trLabels);
tbl.Rows.Add(trInput);
tbl.Rows.Add(trHidden);
//tbl.Rows.Add(tr);
}
}
//tbl.Border = Convert.ToInt32(1);
}
catch(System.Exception ex)
{
this.lblError.Visible = true;
this.lblError.Text = ex.Message.ToString();
}
if(blnRestoreSavedValues)
{
this.htSearchSavedValues.Clear();
this.ParentPortlet.Session.Remove("glAlPartLookupData");
}
}
// /// <summary>
// /// This method will retrieve all the controls in the tblSearchByAcctPart table and
// /// store the user entered values in a hashtable.
// /// </summary>
// /// <returns></returns>
// private Hashtable StorePartAcctSearchControlValues()
// {
// HtmlTable tbl = (HtmlTable)this.FindControl("MainScreenTabs").FindControl("tbPartial").FindControl("tblSearchByAcctPart");
// if(tbl !=null && tbl.Rows.Count > 0)
// {
// for (int i=0; i < tbl.Rows.Count; i++)
// {
//
//
// }
// }
// }
/// <summary>
/// This method will contains the user data entry validation
/// logic.
/// </summary>
/// <returns></returns>
private bool ValidateSearchData()
{
bool blnValid = true;
//Validation for controls on TAB 1
if (this.MainScreenTabs.ContentTabs.Count > 0 &&
this.MainScreenTabs.ContentTabs[TAB_FULL].Selected ==true)
{
if(this.txtBeginAcctNum.Text.Trim().Length <=0 )
{
this.lblError.Text = "Please enter a valid Beginning Account Number.";
this.lblError.Visible = true;
blnValid = false;
}
}
//Validation for controls on TAB 2
if (this.MainScreenTabs.ContentTabs.Count > 0 &&
this.MainScreenTabs.ContentTabs[TAB_PART].Selected ==true)
{