Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the OKHOSTING.UI.Net4.WebForms.Controls.Autocomplete class.
        /// <para xml:alng="es">Inicializa una nueva instacia de la clase OKHOSTING.UI.Net4.WebForms.Controls.Autocomplete</para>
        /// </summary>
        public Autocomplete()
        {
            //set a default id so we ensure the extender's TargetControlID is set
            InnerTextBox    = (TextBox)Platform.Current.Create <ITextBox>();
            InnerTextBox.ID = "Autocomplete_InnerTextBox_" + new Random().Next();
            base.Controls.Add(InnerTextBox);

            //ajax autocompleter
            InnerAutoCompleteExtender    = new AjaxControlToolkit.AutoCompleteExtender();
            InnerAutoCompleteExtender.ID = base.UniqueID + "_AutoCompleteExtender";
            InnerAutoCompleteExtender.TargetControlID = InnerTextBox.ID;
            InnerAutoCompleteExtender.UseContextKey   = true;
            InnerAutoCompleteExtender.ServiceMethod   = "Search";
            InnerAutoCompleteExtender.ServicePath     = "/Services/AutoCompleteService.asmx";
            //InnerAutoCompleteExtender.CompletionListCssClass = "AutoComplete_List";
            //InnerAutoCompleteExtender.CompletionListItemCssClass = "AutoComplete_ListItem";
            InnerAutoCompleteExtender.EnableCaching = false;
            base.Controls.Add(InnerAutoCompleteExtender);

            //ajax watermark
            InnerWatermarkExtender = new AjaxControlToolkit.TextBoxWatermarkExtender();
            InnerWatermarkExtender.WatermarkText   = "Search";
            InnerWatermarkExtender.ID              = base.UniqueID + "_TextBoxWatermarkExtender";
            InnerWatermarkExtender.TargetControlID = InnerTextBox.ID;
            //InnerWatermarkExtender.WatermarkCssClass = "AutoComplete_Watermark";
            base.Controls.Add(InnerWatermarkExtender);

            //add a unique id to session so we can invoke OnSearching from a ashx page
            SessionId = "Autocomplete_" + new Random().Next();
            OKHOSTING.UI.Session.Current[SessionId] = this;
            InnerAutoCompleteExtender.ContextKey    = SessionId;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the OKHOSTING.UI.Net4.Ajax.Controls.TextBox class.
        /// <para xml:alng="es">Inicializa una nueva instacia de la clase OKHOSTING.UI.Net4.Ajax.Controls.TextBox</para>
        /// </summary>
        public TextBox()
        {
            //set a default id so we ensure the extender's TargetControlID is set
            base.ID = "TextBox_InnerTextBox_" + new Random().Next();

            //ajax watermark
            InnerWatermarkExtender    = new AjaxControlToolkit.TextBoxWatermarkExtender();
            InnerWatermarkExtender.ID = base.UniqueID + "_TextBoxWatermarkExtender";
            InnerWatermarkExtender.TargetControlID = base.ID;
            //InnerWatermarkExtender.WatermarkCssClass = "AutoComplete_Watermark";
            base.Controls.Add(InnerWatermarkExtender);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the OKHOSTING.UI.Net4.WebForms.Controls.TextBox class.
        /// <para xml:alng="es">Inicializa una nueva instacia de la clase OKHOSTING.UI.Net4.WebForms.Controls.TextBox</para>
        /// </summary>
        public TextBox()
        {
            //set a default id so we ensure the extender's TargetControlID is set
            base.ID = "TextBox_InnerTextBox_" + Guid.NewGuid().ToString().Replace('-', '_');

            //ajax watermark
            InnerWatermarkExtender    = new AjaxControlToolkit.TextBoxWatermarkExtender();
            InnerWatermarkExtender.ID = ID + "_TextBoxWatermarkExtender";
            InnerWatermarkExtender.TargetControlID = ID;
            //InnerWatermarkExtender.WatermarkCssClass = "AutoComplete_Watermark";
            //base.Controls.Add(InnerWatermarkExtender);
        }
        /// <summary>
        /// Creates the controls for displaying the field
        /// </summary>
        protected override void CreateValueControls()
        {
            //create TextBox from base
            base.CreateValueControls();

            //ajax autocompleter
            AjaxControlToolkit.AutoCompleteExtender autoComplete = new AjaxControlToolkit.AutoCompleteExtender();
            autoComplete.ID                         = ValueControlId + "_AutoCompleteExtender";
            autoComplete.UseContextKey              = true;
            autoComplete.ContextKey                 = ((DataType)ValueType).UniqueId;
            autoComplete.TargetControlID            = ValueControlId;
            autoComplete.ServiceMethod              = "SearchDataObjects";
            autoComplete.ServicePath                = "/Services/DataObjectAutoCompleteService.asmx";
            autoComplete.CompletionListCssClass     = "AutoComplete_List";
            autoComplete.CompletionListItemCssClass = "AutoComplete_ListItem";
            autoComplete.EnableCaching              = false;
            AditionalControls.Add(autoComplete);

            //ajax watermark
            AjaxControlToolkit.TextBoxWatermarkExtender watermark = new AjaxControlToolkit.TextBoxWatermarkExtender();
            watermark.WatermarkText     = OKHOSTING.Softosis.Core.Globalization.Translator.Current["OKHOSTING.Softosis.UI.Web.Controls.DataForms.DataObjectAutoCompleteField.Write here to search"];
            watermark.ID                = ValueControlId + "_TextBoxWatermarkExtender";
            watermark.TargetControlID   = ValueControlId;
            watermark.WatermarkCssClass = "AutoComplete_Watermark";
            AditionalControls.Add(watermark);

            //"Show All" button

            /*
             * System.Web.UI.HtmlControls.HtmlAnchor showAll = new System.Web.UI.HtmlControls.HtmlAnchor();
             * showAll.InnerText = "+";
             * showAll.Style.Add("cursor", "pointer");
             * showAll.Title = OKHOSTING.Softosis.Core.Globalization.LocalizedDictionary.Current["OKHOSTING.Softosis.UI.Web.Controls.DataForms.DataObjectAutoCompleteField.Show all"];
             * showAll.PreRender += new EventHandler(showAll_PreRender);
             * AditionalControls.Add(showAll);
             */
        }
		/// <summary>
		/// Creates the controls for displaying the field
		/// </summary>
		protected override void CreateValueControls()
		{
			//create TextBox from base
			base.CreateValueControls();

			//ajax autocompleter
			AjaxControlToolkit.AutoCompleteExtender autoComplete = new AjaxControlToolkit.AutoCompleteExtender();
			autoComplete.ID = ValueControlId + "_AutoCompleteExtender";
			autoComplete.UseContextKey = true;
			autoComplete.ContextKey = ((DataType)ValueType).UniqueId;
			autoComplete.TargetControlID = ValueControlId;
			autoComplete.ServiceMethod = "SearchDataObjects";
			autoComplete.ServicePath = "/Services/DataObjectAutoCompleteService.asmx";
			autoComplete.CompletionListCssClass = "AutoComplete_List";
			autoComplete.CompletionListItemCssClass = "AutoComplete_ListItem";
			autoComplete.EnableCaching = false;
			AditionalControls.Add(autoComplete);

			//ajax watermark
			AjaxControlToolkit.TextBoxWatermarkExtender watermark = new AjaxControlToolkit.TextBoxWatermarkExtender();
			watermark.WatermarkText = OKHOSTING.Softosis.Core.Globalization.Translator.Current["OKHOSTING.Softosis.UI.Web.Controls.DataForms.DataObjectAutoCompleteField.Write here to search"];
			watermark.ID = ValueControlId + "_TextBoxWatermarkExtender";
			watermark.TargetControlID = ValueControlId;
			watermark.WatermarkCssClass = "AutoComplete_Watermark";
			AditionalControls.Add(watermark);

			//"Show All" button
			/*
			System.Web.UI.HtmlControls.HtmlAnchor showAll = new System.Web.UI.HtmlControls.HtmlAnchor();
			showAll.InnerText = "+";
			showAll.Style.Add("cursor", "pointer");
			showAll.Title = OKHOSTING.Softosis.Core.Globalization.LocalizedDictionary.Current["OKHOSTING.Softosis.UI.Web.Controls.DataForms.DataObjectAutoCompleteField.Show all"];
			showAll.PreRender += new EventHandler(showAll_PreRender);
			AditionalControls.Add(showAll);
			*/
		}
        //Funzione di creazione a runtime dei campi relativi ad ogni tabella. Parametri in ingresso il nome tabella e la lista campi da visualizzare
        private Table CaricaTabella(String nomeTabella, List<AutorizzazioneCampi> myAutorizzazioneCampiList, DataTable myDealerDetailsDataTable)
        {
            //Creo la tabella nella quale inserire i controls
            Table myTable = new Table();
            myTable.ID = nomeTabella + "Table";
            myTable.CssClass = "tableDD";

            Int32 i = 0;
            //Effettuo un ciclo per settare le autorizzazioni sui Campi (myAutorizzazioneCampiList) in base al profilo utente e caricare i dettagli del Dealer selezionato (myDealerDetailsDataTable)
            foreach (AutorizzazioneCampi myAutorizzazioneCampi in myAutorizzazioneCampiList)
            {
                //Verifico che il Control vada caricato sulla tabella inviata (nomeTabella)
                if ((myAutorizzazioneCampi.NomeTabella == nomeTabella) & myAutorizzazioneCampi.Visibile)
                {
                    //Creo le label prendendo il text da NomeCampoFrontEnd definito a database
                    Label myLabel = new Label();
                    myLabel.ID = "Label_" + Convert.ToString(myAutorizzazioneCampi.NomeCampo);
                    myLabel.Text = myAutorizzazioneCampi.NomeCampoFrontEnd + ":";
                    myLabel.Visible = myAutorizzazioneCampi.Visibile;
                    myLabel.Enabled = myAutorizzazioneCampi.SolaLettura;
                    myLabel.CssClass = "labelDD";

                    //Creo un Control generico e poi ne faccio il cast appena ho individuato la tipologia
                    Control myRuntimeControl = new Control();
                    RegularExpressionValidator myRegularExpressionValidator = new RegularExpressionValidator();
                    AjaxControlToolkit.TextBoxWatermarkExtender myTextBoxWatermarkExtender = new AjaxControlToolkit.TextBoxWatermarkExtender();
                    AjaxControlToolkit.ModalPopupExtender myModalPopupExtender = new AjaxControlToolkit.ModalPopupExtender();
                    AjaxControlToolkit.CalendarExtender myCalendarExtender = new AjaxControlToolkit.CalendarExtender();

                    //Faccio il cast del Control sulla base di quanto definito a database ne setto le proprietà specifiche, validazione, extender e carico il valore da visualizzare.
                    switch (myAutorizzazioneCampi.TipoWebControl)
                    {
                        case("TextBox"):
                            #region CreazioneTextBox_Validazione
                            myRuntimeControl = new TextBox();
                            myRuntimeControl.ID = myAutorizzazioneCampi.TipoWebControl + "_" + Convert.ToString(myAutorizzazioneCampi.NomeCampo);
                            this.Controls.Add(myRuntimeControl);
                            myRuntimeControl.Visible = myAutorizzazioneCampi.Visibile;
                            (myRuntimeControl as TextBox).ReadOnly = myAutorizzazioneCampi.SolaLettura;
                            (myRuntimeControl as TextBox).MaxLength = myAutorizzazioneCampi.LunghezzaMassima;
                            if (myAutorizzazioneCampi.SolaLettura)
                            {
                                (myRuntimeControl as TextBox).CssClass = "textBoxReadOnlyDD";
                                (myRuntimeControl as TextBox).ToolTip = "Campo non modificabile";
                            }
                            else
                            {
                                (myRuntimeControl as TextBox).CssClass = "textBoxDD";
                                (myRuntimeControl as TextBox).ToolTip = "Campo modificabile";
                            }
                            if (myAutorizzazioneCampi.TipoDato == "Note")
                            {
                                (myRuntimeControl as TextBox).TextMode = TextBoxMode.MultiLine;
                                (myRuntimeControl as TextBox).Rows = 5;
                                (myRuntimeControl as TextBox).MaxLength = 0;
                                if (myAutorizzazioneCampi.SolaLettura)
                                {
                                    (myRuntimeControl as TextBox).CssClass = "noteReadOnlyDD";
                                }
                                else
                                {
                                    (myRuntimeControl as TextBox).CssClass = "noteDD";
                                }
                            }

                            if(myAutorizzazioneCampi.ValidaControlli)
                            {
                                myRegularExpressionValidator.ID = (myRuntimeControl as TextBox).ID + "_RegularExpressionValidator";
                                myRegularExpressionValidator.ForeColor = System.Drawing.Color.Red;
                                myRegularExpressionValidator.ControlToValidate = (myRuntimeControl as TextBox).ID;
                                myRegularExpressionValidator.ValidationGroup = "ValidazioneControlli";
                                myRegularExpressionValidator.Display = ValidatorDisplay.None;
                                myRegularExpressionValidator.ErrorMessage = myAutorizzazioneCampi.NomeTabella + " - " + myAutorizzazioneCampi.NomeCampoFrontEnd + ":";

                                if(myAutorizzazioneCampi.ValidaEmail)
                                {
                                    myRegularExpressionValidator.ValidationExpression = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
                                    myRegularExpressionValidator.ErrorMessage += " Indirizzo Email non valido";
                                   }
                                if (myAutorizzazioneCampi.ValidaData)
                                {
                                    myRegularExpressionValidator.ValidationExpression = @"^(3[01]|[12][0-9]|0?[1-9])/(1[0-2]|0?[1-9])/(?:[0-9]{2})?[0-9]{2}$";
                                    myRegularExpressionValidator.ErrorMessage += " Data non valida";

                                    myTextBoxWatermarkExtender.ID = (myRuntimeControl as TextBox).ID +  "_TextBoxWatermarkExtender";
                                    myTextBoxWatermarkExtender.BehaviorID = (myRuntimeControl as TextBox).ID + "_TextBoxWatermarkExtender";
                                    myTextBoxWatermarkExtender.TargetControlID = (myRuntimeControl as TextBox).ID;
                                    myTextBoxWatermarkExtender.WatermarkText = "--gg/mm/aaaa--";
                                    myTextBoxWatermarkExtender.WatermarkCssClass = "watermarkDD textBoxDD";

                                    myCalendarExtender.ID = (myRuntimeControl as TextBox).ID + "_TextBoxCalendarExtender";
                                    myCalendarExtender.BehaviorID = (myRuntimeControl as TextBox).ID + "_TextBoxCalendarExtender";
                                    myCalendarExtender.TargetControlID = (myRuntimeControl as TextBox).ID;
                                    myCalendarExtender.Format = "dd/MM/yyyy";

                                }
                                if (myAutorizzazioneCampi.ValidaNumero)
                                {
                                    myRegularExpressionValidator.ValidationExpression = @"[0-9]+";
                                    myRegularExpressionValidator.ErrorMessage += " Numero non valido";
                                }
                                // if(myAutorizzazioneCampi.ValidaTelefono)
                                //{
                                //    myRegularExpressionValidator.ValidationExpression = @"^(1\s*[-\/\.]?)?(\((\d{3})\)|(\d{3}))\s*[-\/\.]?\s*(\d{3})\s*[-\/\.]?\s*(\d{4})\s*(([xX]|[eE][xX][tT])\.?\s*(\d+))*$";
                                //    myRegularExpressionValidator.ErrorMessage = "* Telefono non valido";
                                //}
                            }
                            #endregion
                            #region AssegnazioneValore
                            if (myDealerDetailsDataTable.Rows.Count > 0)
                            {
                                if (myDealerDetailsDataTable.Columns.Contains(myAutorizzazioneCampi.NomeCampo) &&
                                    (myDealerDetailsDataTable.Rows[0][myAutorizzazioneCampi.NomeCampo] != DBNull.Value))
                                {
                                    if (myAutorizzazioneCampi.TipoDato == "Data")
                                    {
                                        (myRuntimeControl as TextBox).Text = Convert.ToDateTime(myDealerDetailsDataTable.Rows[0][myAutorizzazioneCampi.NomeCampo]).ToShortDateString();
                                    }
                                    else
                                    {
                                        (myRuntimeControl as TextBox).Text = myDealerDetailsDataTable.Rows[0][myAutorizzazioneCampi.NomeCampo].ToString();
                                    }
                                }
                            }
                            #endregion
                            break;
                        case("DropDownList"):
                            #region CreazioneDropDownList
                            myRuntimeControl = new DropDownList();
                            myRuntimeControl.ID = myAutorizzazioneCampi.TipoWebControl + "_" + Convert.ToString(myAutorizzazioneCampi.NomeCampo);
                            this.Controls.Add(myRuntimeControl);
                            myRuntimeControl.Visible = myAutorizzazioneCampi.Visibile;
                            (myRuntimeControl as DropDownList).Enabled = !myAutorizzazioneCampi.SolaLettura;
                            (myRuntimeControl as DropDownList).CssClass = "dropDownListDD";
                            if (myAutorizzazioneCampi.SolaLettura)
                            {
                                (myRuntimeControl as DropDownList).ToolTip = "Campo non modificabile";
                             }
                            else
                            {
                                (myRuntimeControl as DropDownList).ToolTip = "Campo modificabile";

                            }
                            #endregion
                            #region AssegnazioneValore
                            DataTable myDropDownListDataTable = proxyMtd.Dealer_CaricaValoriMultipli(myAutorizzazioneCampi.NomeCampo);
                            Boolean listItemSelected = false;
                            string valoreCampo = "";

                            if(myDealerDetailsDataTable.Rows[0][myAutorizzazioneCampi.NomeCampo] != DBNull.Value)
                            {
                                valoreCampo = myDealerDetailsDataTable.Rows[0][myAutorizzazioneCampi.NomeCampo].ToString();
                            }

                            foreach (DataRow myDataRow in myDropDownListDataTable.Rows)
                            {
                                ListItem myListItem = new ListItem();
                                myListItem.Text = myDataRow["Descrizione"].ToString();
                                myListItem.Value = myDataRow["ID"].ToString();
                                if (myListItem.Text == valoreCampo)
                                    {
                                        myListItem.Selected = true;
                                        listItemSelected = true;
                                    }
                                (myRuntimeControl as DropDownList).Items.Add(myListItem);
                            }
                            if (listItemSelected == false)
                            {
                                ListItem myListItem = new ListItem();
                                myListItem.Text = valoreCampo;
                                myListItem.Value = "-1";
                                myListItem.Selected = true;
                                (myRuntimeControl as DropDownList).Items.Insert(0, myListItem);
                            }
                            #endregion
                            break;
                        case("CheckBox"):
                            #region CreazioneCheckBox
                            myRuntimeControl = new CheckBox();
                            myRuntimeControl.ID = myAutorizzazioneCampi.TipoWebControl + "_" + Convert.ToString(myAutorizzazioneCampi.NomeCampo);
                            this.Controls.Add(myRuntimeControl);
                            myRuntimeControl.Visible = myAutorizzazioneCampi.Visibile;
                            (myRuntimeControl as CheckBox).Enabled = !myAutorizzazioneCampi.SolaLettura;
                            if (myAutorizzazioneCampi.SolaLettura)
                            {
                                (myRuntimeControl as CheckBox).ToolTip = "Campo non modificabile";
                            }
                            else
                            {
                                (myRuntimeControl as CheckBox).ToolTip = "Campo modificabile";
                            }
                            #endregion
                            #region AssegnazioneValore
                            if (myDealerDetailsDataTable.Rows.Count > 0)
                            {
                                if (myDealerDetailsDataTable.Columns.Contains(myAutorizzazioneCampi.NomeCampo) &&
                                    (myDealerDetailsDataTable.Rows[0][myAutorizzazioneCampi.NomeCampo] != DBNull.Value))
                                {
                                    (myRuntimeControl as CheckBox).Checked = Convert.ToBoolean(myDealerDetailsDataTable.Rows[0][myAutorizzazioneCampi.NomeCampo]);
                                }
                            }
                            #endregion
                            break;
                        case ("CheckBoxList"):
                            #region CreazioneCheckBoxLit
                            myRuntimeControl = new CheckBoxList();
                            myRuntimeControl.ID = myAutorizzazioneCampi.TipoWebControl + "_" + Convert.ToString(myAutorizzazioneCampi.NomeCampo);
                            this.Controls.Add(myRuntimeControl);
                            myRuntimeControl.Visible = myAutorizzazioneCampi.Visibile;
                            (myRuntimeControl as CheckBoxList).Enabled = !myAutorizzazioneCampi.SolaLettura;
                            (myRuntimeControl as CheckBoxList).RepeatDirection = RepeatDirection.Horizontal;
                            (myRuntimeControl as CheckBoxList).RepeatLayout = RepeatLayout.Flow;
                            (myRuntimeControl as CheckBoxList).Width = 254;
                            if (myAutorizzazioneCampi.SolaLettura)
                            {
                                (myRuntimeControl as CheckBoxList).CssClass = "checkBoxListReadOnlyDD";
                                (myRuntimeControl as CheckBoxList).ToolTip = "Campo non modificabile";
                            }
                            else
                            {
                                (myRuntimeControl as CheckBoxList).CssClass = "checkBoxListDD";
                                (myRuntimeControl as CheckBoxList).ToolTip = "Campo modificabile";
                            }
                            #endregion
                            #region AssegnazioneValore
                            DataTable myCheckBoxListDataTable = proxyMtd.Dealer_CaricaValoriMultipli(myAutorizzazioneCampi.NomeCampo);
                            DataTable myCheckBoxListSelectedDataTable = proxyMtd.Dealer_CaricaValoriMultipliSelected(IDDealer, myAutorizzazioneCampi.NomeCampo);
                            //Boolean checkItemSelected = false;
                            foreach (DataRow myDataRow in myCheckBoxListDataTable.Rows)
                            {
                                ListItem myListItem = new ListItem();
                                myListItem.Text = myDataRow["Descrizione"].ToString();
                                myListItem.Value = myDataRow["ID"].ToString();
                                foreach (DataRow myDataRowSelected in myCheckBoxListSelectedDataTable.Rows)
                                    if (myListItem.Text == myDataRowSelected["Descrizione"].ToString())
                                    {
                                        myListItem.Selected = true;
                                    }
                                (myRuntimeControl as CheckBoxList).Items.Add(myListItem);
                            }
                            #endregion
                            break;
                        case ("OrarioApertura"):
                            #region CreazioneOrarioApertura
                            myRuntimeControl = new Panel();
                            myRuntimeControl.ID = "Panel_OrarioApertura";
                            //(myRuntimeControl as Panel).BorderStyle = BorderStyle.Solid;
                            //(myRuntimeControl as Panel).BorderWidth = 1;
                            (myRuntimeControl as Panel).CssClass = "panelDD";
                            this.Controls.Add(myRuntimeControl);
                            myRuntimeControl.Visible = myAutorizzazioneCampi.Visibile;

                            this.Controls.Add(myRuntimeControl);

                            Table myOrarioTable = new Table();
                            myOrarioTable.ID = "Table_OrarioApertura";
                            myRuntimeControl.Controls.Add(myOrarioTable);

                            DataTable myOrarioAperturaDataTable = proxyMtd.Dealer_OrarioApertura_Get(IDDealer);

                            //Replico 4 blocchi dove poter definire l'orario di apertura
                            for (int blocco = 1; blocco <= 4; blocco++)
                            {
                                int riga = 1;
                                int cella = 1;

                                string idRiga = blocco + "_" + riga;
                                string idCella = blocco + "_" + riga + "_" + cella;

                                //Costruisco la riga con le DropDownList e le CheckBox
                                TableRow myTableRow = new TableRow();
                                TableCell myTableCell = new TableCell();

                                cella = 1;
                                myTableRow.ID = "myTableRow_" + idRiga;
                                myOrarioTable.Rows.Add(myTableRow);
                                riga++;
                                idRiga = blocco + "_" + riga;

                                myTableCell.ID = "myTableCell_" + idCella;
                                myTableRow.Cells.Add(myTableCell);
                                cella++;
                                idCella = blocco + "_" + riga + "_" + cella;

                                Label label1 = new Label();
                                label1.ID = "dalleMattinaLabel_" + idRiga ;
                                label1.Text = "dalle: ";
                                myTableCell.Controls.Add(label1);

                                DropDownList dalleMattinaDropDownList = new DropDownList();
                                dalleMattinaDropDownList.ID = "dalleMattinaDropDownList_" + idRiga;
                                dalleMattinaDropDownList.CssClass = "dropDownListSmallDD";
                                dalleMattinaDropDownList.Enabled = !myAutorizzazioneCampi.SolaLettura;
                                myTableCell.Controls.Add(dalleMattinaDropDownList);

                                myTableCell = new TableCell();
                                myTableCell.ID = "myTableCell_" + idCella;
                                   myTableRow.Cells.Add(myTableCell);
                                cella++;
                                idCella = blocco + "_" + riga + "_" + cella;

                                Label label2 = new Label();
                                label2.ID = "alleMattinaLabel_" + idRiga;
                                label2.Text = " alle: ";
                                myTableCell.Controls.Add(label2);
                                DropDownList alleMattinaDropDownList = new DropDownList();
                                alleMattinaDropDownList.ID = "alleMattinaDropDownList_" + idRiga;
                                alleMattinaDropDownList.CssClass = "dropDownListSmallDD";
                                alleMattinaDropDownList.Enabled = !myAutorizzazioneCampi.SolaLettura;
                                myTableCell.Controls.Add(alleMattinaDropDownList);

                                myTableCell = new TableCell();
                                myTableCell.ID = "myTableCell_" + idCella;
                                myTableRow.Cells.Add(myTableCell);
                                cella++;
                                idCella = blocco + "_" + riga + "_" + cella;

                                Label label3 = new Label();
                                label3.ID = "dallePomeriggioLabel_" + idRiga;
                                label3.Text = " dalle: ";
                                myTableCell.Controls.Add(label3);

                                DropDownList dallePomeriggioDropDownList = new DropDownList();
                                dallePomeriggioDropDownList.ID = "dallePomeriggioDropDownList_" + idRiga;
                                dallePomeriggioDropDownList.CssClass = "dropDownListSmallDD";
                                dallePomeriggioDropDownList.Enabled = !myAutorizzazioneCampi.SolaLettura;
                                myTableCell.Controls.Add(dallePomeriggioDropDownList);

                                myTableCell = new TableCell();
                                myTableCell.ID = "myTableCell_" + idCella;
                                myTableRow.Cells.Add(myTableCell);
                                cella++;
                                idCella = blocco + "_" + riga + "_" + cella;

                                Label label4 = new Label();
                                label4.ID = "allePomeriggioLabel_" + idRiga;
                                label4.Text = " alle: ";
                                myTableCell.Controls.Add(label4);

                                DropDownList allePomeriggioDropDownList = new DropDownList();
                                allePomeriggioDropDownList.ID = "allePomeriggioDropDownList_" + idRiga;
                                allePomeriggioDropDownList.CssClass = "dropDownListSmallDD";
                                allePomeriggioDropDownList.Enabled = !myAutorizzazioneCampi.SolaLettura;
                                myTableCell.Controls.Add(allePomeriggioDropDownList);

                                dalleMattinaDropDownList.Items.Add("--");
                                alleMattinaDropDownList.Items.Add("--");
                                dallePomeriggioDropDownList.Items.Add("--");
                                allePomeriggioDropDownList.Items.Add("--");

                                for (int j = 7; j <= 24; j++)
                                {
                                    dalleMattinaDropDownList.Items.Add(j + ":00");
                                    alleMattinaDropDownList.Items.Add(j + ":00");
                                    dallePomeriggioDropDownList.Items.Add(j + ":00");
                                    allePomeriggioDropDownList.Items.Add(j + ":00");
                                    if(j<24)
                                    {
                                        dalleMattinaDropDownList.Items.Add(j + ":30");
                                        alleMattinaDropDownList.Items.Add(j + ":30");
                                        dallePomeriggioDropDownList.Items.Add(j + ":30");
                                        allePomeriggioDropDownList.Items.Add(j + ":30");
                                    }
                                }

                                myTableCell = new TableCell();
                                myTableCell.ID = "myTableCell_" + idCella;
                                myTableCell.ColumnSpan = 4;
                                myTableRow.Cells.Add(myTableCell);
                                cella++;
                                idCella = blocco + "_" + riga + "_" + cella;

                                Label label5 = new Label();
                                label5.ID = "giorni_" + idRiga;
                                label5.Text = " - Giorni: ";
                                myTableCell.Controls.Add(label5);

                                CheckBoxList myGiorniCheckBoxList = new CheckBoxList();
                                myGiorniCheckBoxList.ID = "giorniCheckBoxList_" + idRiga;
                                myTableCell.Controls.Add(myGiorniCheckBoxList);

                                myGiorniCheckBoxList.Enabled = !myAutorizzazioneCampi.SolaLettura;
                                myGiorniCheckBoxList.RepeatDirection = RepeatDirection.Horizontal;
                                myGiorniCheckBoxList.RepeatLayout = RepeatLayout.Flow;
                                myGiorniCheckBoxList.Width = 254;
                                if (myAutorizzazioneCampi.SolaLettura)
                                {
                                    myGiorniCheckBoxList.CssClass = "checkBoxListReadOnlyDD";
                                    myGiorniCheckBoxList.ToolTip = "Campo non modificabile";
                                }
                                else
                                {
                                    myGiorniCheckBoxList.CssClass = "checkBoxListDD";
                                    myGiorniCheckBoxList.ToolTip = "Campo modificabile";
                                }
                                ListItem myGiornoListItem = new ListItem();
                                myGiornoListItem.Text = "Lu";
                                myGiornoListItem.Value = "Lu";
                                myGiorniCheckBoxList.Items.Add(myGiornoListItem);
                                myGiornoListItem = new ListItem();
                                myGiornoListItem.Text = "Ma";
                                myGiornoListItem.Value = "Ma";
                                myGiorniCheckBoxList.Items.Add(myGiornoListItem);
                                myGiornoListItem = new ListItem();
                                myGiornoListItem.Text = "Me";
                                myGiornoListItem.Value = "Me";
                                myGiorniCheckBoxList.Items.Add(myGiornoListItem);
                                myGiornoListItem = new ListItem();
                                myGiornoListItem.Text = "Gi";
                                myGiornoListItem.Value = "Gi";
                                myGiorniCheckBoxList.Items.Add(myGiornoListItem);
                                myGiornoListItem = new ListItem();
                                myGiornoListItem.Text = "Ve";
                                myGiornoListItem.Value = "Ve";
                                myGiorniCheckBoxList.Items.Add(myGiornoListItem);
                                myGiornoListItem = new ListItem();
                                myGiornoListItem.Text = "Sa";
                                myGiornoListItem.Value = "Sa";
                                myGiorniCheckBoxList.Items.Add(myGiornoListItem);
                                myGiornoListItem = new ListItem();
                                myGiornoListItem.Text = "Do";
                                myGiornoListItem.Value = "Do";
                                myGiorniCheckBoxList.Items.Add(myGiornoListItem);

                                #region AssegnazioneValore
                                if (blocco <= myOrarioAperturaDataTable.Rows.Count)
                                {

                                    foreach (ListItem myListItem in dalleMattinaDropDownList.Items)
                                    {
                                        if (myListItem.Text == myOrarioAperturaDataTable.Rows[blocco - 1]["dalleMattina"].ToString())
                                        {
                                            myListItem.Selected = true;
                                            break;
                                        }
                                    }

                                    foreach (ListItem myListItem in alleMattinaDropDownList.Items)
                                    {
                                        if (myListItem.Text == myOrarioAperturaDataTable.Rows[blocco - 1]["alleMattina"].ToString())
                                        {
                                            myListItem.Selected = true;
                                            break;
                                        }
                                    }

                                    foreach (ListItem myListItem in dallePomeriggioDropDownList.Items)
                                    {
                                        if (myListItem.Text == myOrarioAperturaDataTable.Rows[blocco - 1]["dallePomeriggio"].ToString())
                                        {
                                            myListItem.Selected = true;
                                            break;
                                        }
                                    }

                                    foreach (ListItem myListItem in allePomeriggioDropDownList.Items)
                                    {
                                        if (myListItem.Text == myOrarioAperturaDataTable.Rows[blocco - 1]["allePomeriggio"].ToString())
                                        {
                                            myListItem.Selected = true;
                                            break;
                                        }
                                    }

                                    myGiorniCheckBoxList.Items.FindByText("Lu").Selected = (Boolean)myOrarioAperturaDataTable.Rows[blocco - 1]["Lun"];
                                    myGiorniCheckBoxList.Items.FindByText("Ma").Selected = (Boolean)myOrarioAperturaDataTable.Rows[blocco - 1]["Mar"];
                                    myGiorniCheckBoxList.Items.FindByText("Me").Selected = (Boolean)myOrarioAperturaDataTable.Rows[blocco - 1]["Mer"];
                                    myGiorniCheckBoxList.Items.FindByText("Gi").Selected = (Boolean)myOrarioAperturaDataTable.Rows[blocco - 1]["Gio"];
                                    myGiorniCheckBoxList.Items.FindByText("Ve").Selected = (Boolean)myOrarioAperturaDataTable.Rows[blocco - 1]["Ven"];
                                    myGiorniCheckBoxList.Items.FindByText("Sa").Selected = (Boolean)myOrarioAperturaDataTable.Rows[blocco - 1]["Sab"];
                                    myGiorniCheckBoxList.Items.FindByText("Do").Selected = (Boolean)myOrarioAperturaDataTable.Rows[blocco - 1]["Dom"];
                                }

                            }
                                #endregion
                            #endregion
                            break;
                    }
                    #region RenderingControl
                    List<AutorizzazioneCampi> filteredList;
                    filteredList = myAutorizzazioneCampiList.Where(x => x.Visibile == true && x.TipoDato != "OrarioApertura" && x.TipoDato != "Note").ToList();

                    if (myTable.Rows.Count < Math.Ceiling(filteredList.Count / 2.0))
                    {
                        TableRow tRow = new TableRow();
                        myTable.Rows.Add(tRow);

                        TableCell tCell1 = new TableCell();
                        tCell1.CssClass = "tableColumn1DD";
                        tRow.Cells.Add(tCell1);

                        TableCell tCell2 = new TableCell();
                        tCell2.CssClass = "tableColumn2DD";
                        tRow.Cells.Add(tCell2);

                        TableCell tCell3 = new TableCell();
                        tCell3.CssClass = "tableColumn3DD";
                        tRow.Cells.Add(tCell3);

                        TableCell tCell4 = new TableCell();
                        tCell4.CssClass = "tableColumn1DD";
                        tRow.Cells.Add(tCell4);

                        TableCell tCell5 = new TableCell();
                        tCell5.CssClass = "tableColumn2DD";
                        tRow.Cells.Add(tCell5);

                        tCell1.Controls.Add(myLabel);
                        tCell2.Controls.Add(myRuntimeControl);
                        if (myAutorizzazioneCampi.ValidaControlli)
                        {
                            tCell2.Controls.Add(myRegularExpressionValidator);
                            if (myAutorizzazioneCampi.ValidaData)
                            {
                                tCell2.Controls.Add(myTextBoxWatermarkExtender);
                                tCell2.Controls.Add(myCalendarExtender);
                            }
                        }
                    }
                    else
                    {
                        if (myRuntimeControl.GetType() == typeof(Panel) || myAutorizzazioneCampi.TipoDato == "Note")
                        {
                            TableRow tRow = new TableRow();
                            myTable.Rows.Add(tRow);

                            TableCell tCell1 = new TableCell();
                            tCell1.CssClass = "tableColumn1DD";
                            tRow.Cells.Add(tCell1);

                            TableCell tCell2 = new TableCell();
                            //tCell2.CssClass = "tableColumn2DD";
                            tCell2.ColumnSpan = 4;
                            tRow.Cells.Add(tCell2);

                            tCell1.Controls.Add(myLabel);
                            tCell2.Controls.Add(myRuntimeControl);
                        }
                        else
                        {
                            Int32 riga = i - myTable.Rows.Count;
                            myTable.Rows[riga].Cells[3].Controls.Add(myLabel);
                            myTable.Rows[riga].Cells[4].Controls.Add(myRuntimeControl);
                            if (myAutorizzazioneCampi.ValidaControlli)
                            {
                                myTable.Rows[riga].Cells[4].Controls.Add(myRegularExpressionValidator);
                                if (myAutorizzazioneCampi.ValidaData)
                                {
                                    myTable.Rows[riga].Cells[4].Controls.Add(myTextBoxWatermarkExtender);
                                    myTable.Rows[riga].Cells[4].Controls.Add(myCalendarExtender);
                                }
                            }
                        }
                    }
                    i++;
                    #endregion
                }
            }
            return myTable;
        }
Ejemplo n.º 7
0
		/// <summary>
		/// Initializes a new instance of the OKHOSTING.UI.Net4.WebForms.Controls.TextBox class.
		/// <para xml:alng="es">Inicializa una nueva instacia de la clase OKHOSTING.UI.Net4.WebForms.Controls.TextBox</para>
		/// </summary>
		public TextBox()
		{
			//set a default id so we ensure the extender's TargetControlID is set
			base.ID = "TextBox_InnerTextBox_" + new Random().Next();

			//ajax watermark
			InnerWatermarkExtender = new AjaxControlToolkit.TextBoxWatermarkExtender();
			InnerWatermarkExtender.ID = base.UniqueID + "_TextBoxWatermarkExtender";
			InnerWatermarkExtender.TargetControlID = base.ID;
			//InnerWatermarkExtender.WatermarkCssClass = "AutoComplete_Watermark";
			base.Controls.Add(InnerWatermarkExtender);
		}