Esempio n. 1
0
		private static Panel CreatePickListSearchControl(PickListTerm pickListTerm, bool canEditProfile, SecurityHelper securityHelper)
		{
			Panel pnl = new Panel();
			pnl.ID = ControlID(pickListTerm.Name);

			if (pickListTerm.PickListItems.Count == 1)    //1 picklist item: single check box
			{
				CheckBox chk = new CheckBox();
				chk.BorderStyle = BorderStyle.None;
				chk.ID = pnl.ID + "_lst";    // ????
				chk.CssClass = Common.Names._STYLE_CSSCLASS_EDIT;
				chk.Text = pickListTerm.PickListItems[0].Value;
				pnl.Controls.Add(chk);
			}
			else
			{
				if (pickListTerm.MultiSelect ?? false)  // multi-select picklist: MultiSelectGrid control
				{
					pnl.Height = Unit.Pixel(4 + 20 * Math.Min(4, pickListTerm.PickListItems.Count));
					pnl.Width = Unit.Percentage(100.0);

					MultiSelectGrid grd = new MultiSelectGrid();
					grd.ID = pnl.ID + "_lst";
					grd.CheckboxColumn = 0;
					grd.DataSource = pickListTerm.PickListItems;
					grd.BoundColumns = "Value";
					//grd.DataKeyNames = new string[] { "Value" };
					grd.Container = pnl.ID;
					grd.HeaderContainer = "";
					grd.AutoGenerateColumns = false;
					grd.RowHighlighting = false;
					grd.EnableClickEvent = false;
					grd.EnableDoubleClickEvent = false;
					grd.EnableHeaderClick = false;
					grd.ShowHeader = false;
					grd.ColumnWidths = "100%";
					grd.DataBind();
					pnl.Controls.Add(grd);
				}
				else
				{
					if (pickListTerm.PickListItems.Count == 2)   //2 item single-select picklist: RadioButtonList
					{
						RadioButtonList rdolst = new RadioButtonList();
						rdolst.ID = pnl.ID + "_lst";
						rdolst.CellPadding = 0;
						rdolst.CellSpacing = 0;
						rdolst.RepeatDirection = RepeatDirection.Vertical;
						AddListItems(rdolst, pickListTerm.PickListItems);
						pnl.Controls.Add(rdolst);
					}
					else          // 3 or more item single-select list: DropDrownList
					{
						DropDownList ddl = new DropDownList();
						ddl.ID = pnl.ID + "_lst";
						ddl.Width = Unit.Percentage(100.0);
						ddl.Items.Add(new ListItem("(Select One)", ""));
						AddListItems(ddl, pickListTerm.PickListItems);
						pnl.Controls.Add(ddl);
					}
				}
			}
			return pnl;
		}
Esempio n. 2
0
		private static Panel CreateFacilitySearchControl(FacilityTerm facilityTerm, bool canEditProfile, SecurityHelper securityHelper)
		{
			bool canEdit = canEditProfile;
			if (facilityTerm.SystemTerm && facilityTerm.OwningFacilityIDs.Count > 0)
				canEdit = false;

			Panel pnl = new Panel();
			pnl.ID = ControlID(facilityTerm.Name);
			pnl.CssClass = "NoBorder";

			if (canEdit)
			{

				FacilityCollection facilities;
				if (facilityTerm.UseUserSecurity ?? false)
					if (facilityTerm.IncludeChildren ?? false)
						facilities = FacilityCollection.FilteredFacilityList(securityHelper.AllUserFacilities, facilityTerm);
					else
						facilities = FacilityCollection.FilteredFacilityList(securityHelper.UserFacilities, facilityTerm);
				else
					facilities = FacilityCollection.FilteredFacilityList(FacilityCollection.FacilityList(Data.Facility.CorporateFacilityId, facilityTerm.IncludeChildren ?? false), facilityTerm);
				List<Data.FacilityDataRow> sortedFacilities = facilities.SortedList(facilityTerm.SortField);

				if (facilityTerm.MultiSelect ?? false)
				{
					pnl.Height = Unit.Pixel(4 + 20 * Math.Min(4, facilities.Count));
					pnl.Width = Unit.Percentage(100.0);

					MultiSelectGrid grd = new MultiSelectGrid();
					grd.CssClass = "MSG";
					grd.ID = pnl.ID + "_lst";
					grd.CheckboxColumn = 0;
					grd.BoundColumns = "FacilityId SapFacilityId FacilityName";
					grd.ColumnWidths = "0px 60px 100%";
					//grd.DataKeyNames = new string[] { "FacilityId" };
					grd.Container = pnl.ID;
					grd.HeaderContainer = "";
					grd.AutoGenerateColumns = false;
					grd.EnableClickEvent = false;
					grd.RowHighlighting = false;
					grd.EnableDoubleClickEvent = false;
					grd.EnableHeaderClick = false;
					grd.ShowHeader = false;
					grd.DataSource = sortedFacilities;
					grd.DataBind();
					pnl.Controls.Add(grd);
				}
				else
				{
					DropDownList ddl = new DropDownList();
					ddl.ID = pnl.ID + "_lst";
					ddl.Width = Unit.Parse("100%");
					Helper.LoadListControl(ddl, sortedFacilities, "SapIdPlusName", "FacilityId", "", true, "(Select a Facility)", "0");
					pnl.Controls.Add(ddl);
				}
			}
			else
			{
				Label lbl = new Label();
				lbl.Text = string.Format("{0} - {1}", facilityTerm.DisplayValue(XMLNames._TPS_SAPID), facilityTerm.DisplayValue(XMLNames._TPS_FacilityName));
				pnl.Controls.Add(lbl);
			}
			return pnl;
		}