Ejemplo n.º 1
0
        private void GenValidateBoxTemplate(String ExtraName)
        {
            if (ExtraName == "")
            {
                System.Web.UI.WebControls.Label aLabel = new System.Web.UI.WebControls.Label();
                aLabel.ID = "l" + FTableName + FFieldItem.DataField + ExtraName + "GridView";
                aLabel.ToolTip = FFieldItem.DataField;
                FContainer.Controls.Add(aLabel);

                Boolean Found = false;
                foreach (System.Web.UI.WebControls.Label bLabel in aLabelList)
                {
                    if (String.Compare(aLabel.ID, bLabel.ID) == 0)
                    {
                        Found = true;
                        break;
                    }
                }
                if (!Found)
                {
                    aLabelList.Add(aLabel);
                }
            }
            else
            {
                WebValidateBox aValidateBox = new WebValidateBox();
                aValidateBox.ID = "wvb" + FTableName + FFieldItem.DataField + ExtraName + "GridView";
                aValidateBox.WebValidateID = aWebValidate.ID;
                aValidateBox.ValidateField = FFieldItem.DataField;
                FContainer.Controls.Add(aValidateBox);

                Boolean Found = false;
                foreach (WebValidateBox aBox in aWebValidateBoxList)
                {
                    if (String.Compare(aBox.ID, aValidateBox.ID) == 0)
                    {
                        Found = true;
                        break;
                    }
                }
                if (!Found)
                {
                    aWebValidateBoxList.Add(aValidateBox);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取得Control对应的xml
        /// </summary>
        /// <param name="item">blockfielditem</param>
        /// <param name="tableName">tablename</param>
        /// <param name="id">控件的id</param>
        /// <returns>xml</returns>
        private string GetControlXml(TBlockFieldItem item, string tableName, ref string id)
        {
            WebControl control = null;
            PropertyInfo info = null;

            #region DropDownList
            if (string.Compare(item.ControlType, "combobox", true) == 0)
            {
                control = new WebDropDownList();
                control.ID = string.Format("{0}DropDownList", item.DataField);
                control.Width = new Unit(130, UnitType.Pixel);
                (control as WebDropDownList).DataSourceID = GenWebDataSource(item, tableName, "ComboBox", string.Empty);
                (control as WebDropDownList).DataMember = item.ComboEntityName;
                (control as WebDropDownList).DataTextField = item.ComboTextField;
                (control as WebDropDownList).DataValueField = item.ComboValueField;
                info = control.GetType().GetProperty("SelectedValue");
            }
            #endregion

            #region RefVal
            else if (string.Compare(item.ControlType, "refvalbox", true) == 0)
            {
            #warning GenWebDataSource未完成FSYS_REFVAL部分
                control = new WebRefVal();
                control.ID = string.Format("{0}RefVal", item.DataField);
                if (!string.IsNullOrEmpty(item.RefValNo) || (item.RefField != null))
                {
                    (control as WebRefVal).DataSourceID = GenWebDataSource(item, tableName, "RefVal", string.Empty);
                    (control as WebRefVal).DataBindingField = item.DataField;
                    (control as WebRefVal).DataTextField = FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString();
                    (control as WebRefVal).DataValueField = FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString();
                    if (!string.IsNullOrEmpty(item.RefValNo))
                    {
                        IDbConnection conn = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, false);
                        InfoCommand command = new InfoCommand(FClientData.DatabaseType);
                        command.Connection = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, true);
                        //command.Connection = conn;
                        command.CommandText = String.Format("Select * from SYS_REFVAL_D1 where REFVAL_NO = '{0}'", item.RefValNo);
                        IDbDataAdapter adapter = WzdUtils.AllocateDataAdapter(FClientData.DatabaseType);
                        adapter.SelectCommand = command.GetInternalCommand();
                        DataSet dataset = new DataSet();
                        WzdUtils.FillDataAdapter(FClientData.DatabaseType, adapter, dataset, item.RefValNo);
                        if (dataset != null && dataset.Tables.Count > 0 && dataset.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow DR in dataset.Tables[0].Rows)
                            {
                                WebRefColumn refcolumn = new WebRefColumn();
                                refcolumn.ColumnName = DR["FIELD_NAME"].ToString();
                                refcolumn.HeadText = DR["HEADER_TEXT"].ToString();
                                refcolumn.Width = 100;
                                (control as WebRefVal).Columns.Add(refcolumn);
                            }
                        }
                    }
                    info = control.GetType().GetProperty("BindingValue");
                }
                else
                {
                    control = new TextBox();
                    control.ID = string.Format("{0}TextBox", item.DataField);
                    (control as TextBox).MaxLength = item.Length;
                    info = control.GetType().GetProperty("Text");
                }

            }
            #endregion

            #region DateTimePicker
            else if (string.Compare(item.ControlType, "datetimebox", true) == 0)
            {
                control = new WebDateTimePicker();
                control.ID = string.Format("{0}DateTimePicker", item.DataField);
                (control as WebDateTimePicker).MaxLength = item.Length;
                if (string.IsNullOrEmpty(item.EditMask))
                {
                    (control as WebDateTimePicker).DateFormat = dateFormat.ShortDate;
                }
                if (item.DataType == typeof(DateTime))
                {
                    info = control.GetType().GetProperty("Text");
                }
                else if (item.DataType == typeof(string))
                {
                    (control as WebDateTimePicker).DateTimeType = dateTimeType.VarChar;
                    info = control.GetType().GetProperty("DataString");
                }
            }
            #endregion

            #region ValidateBox
            else if (string.Compare(item.ControlType, "validatebox", true) == 0)
            {
                control = new WebValidateBox();
                control.ID = string.Format("{0}ValidateBox", item.DataField);
                (control as WebValidateBox).WebValidateID = string.Format("wv{0}", tableName);
                (control as WebValidateBox).ValidateField = item.DataField;
                (control as WebValidateBox).MaxLength = item.Length;
                info = control.GetType().GetProperty("Text");
            }
            #endregion

            #region CheckBox
            else if (string.Compare(item.ControlType, "checkbox", true) == 0)
            {
                control = new CheckBox();
                control.ID = string.Format("{0}CheckBox", item.DataField);
                info = control.GetType().GetProperty("Checked");
            }
            #endregion

            #region TextBox
            else
            {
                control = new TextBox();
                control.ID = string.Format("{0}TextBox", item.DataField);
                (control as TextBox).MaxLength = item.Length;
                info = control.GetType().GetProperty("Text");
            }
            #endregion

            control.ID = string.Format("{0}{1}", control.ID, id);
            id = control.ID;
            item.EditMask = FormatEditMask(item.EditMask);
            return GetControlXml(control, info, item.DataField, item.EditMask);
        }