Example #1
0
        public static void createFillDataSet(this AtawPageConfigView _this, string formName)
        {
            AtawFormConfigView _form      = _this.Forms[formName];
            DataTable          dt         = _this.Data.Tables[_form.TableName];
            List <string>      tmpComluns = new List <string>();

            foreach (DataRow row in dt.Rows)
            {
                _form.Columns.ForEach(col =>
                {
                    //-----------
                    string _val = row[col.Name].ToString();
                    if (!col.Options.RegName.IsEmpty())
                    {
                        //------------
                        string _indexName = col.Name + "_CODEINDEX";
                        if (row.Table.Columns.Contains(_indexName))
                        {
                            if (row[_indexName] is int[])
                            {
                                int[] _indexs        = row[_indexName].Value <int[]>();
                                DataTable _codetable = _this.Data.Tables[col.Options.RegName];
                                List <string> _texts = new List <string>();
                                foreach (int index in _indexs)
                                {
                                    if (index >= 0)
                                    {
                                        DataRow _row = _codetable.Rows[index];

                                        string _text = _row["CODE_TEXT"].ToString();
                                        Regex reg    = new Regex(@"<[^<>]+>");
                                        // string str = "_text";
                                        // ;
                                        bool isMath = true;
                                        while (isMath)
                                        {
                                            var math = reg.Match(_text);
                                            isMath   = math.Success;
                                            if (isMath)
                                            {
                                                _text = _text.Replace(math.Value, "");
                                            }
                                        }

                                        _texts.Add(_text);
                                    }
                                }
                                //if()
                                if (row.Table.Columns[col.Name].DataType == typeof(string))
                                {
                                    row[col.Name] = _texts.JoinString(",");
                                }
                                else
                                {
                                    if (!row.Table.Columns.Contains(col.Name + "_temp"))
                                    {
                                        row.Table.Columns.Add(col.Name + "_temp", typeof(string));
                                        tmpComluns.Add(col.Name + "_temp");
                                    }
                                    row[col.Name + "_temp"] = _texts.JoinString(",");
                                }
                            }
                            else
                            {
                                int _index           = row[_indexName].Value <int>();
                                DataTable _codetable = _this.Data.Tables[col.Options.RegName];
                                DataRow _row         = _codetable.Rows[_index];
                                string _text         = _row["CODE_TEXT"].ToString();
                                //-------------
                                row[col.Name] = _text;
                            }
                        }
                    }
                });
            }

            foreach (string col in tmpComluns)
            {
                string _c   = col;
                string _col = col.Remove(col.LastIndexOf("_temp"));
                dt.Columns.Remove(_col);
                dt.Columns[_c].ColumnName = _col;
            }

            //----------
            //   return this.Data;
        }
        protected override AtawColumnConfigView CreateColumn(AtawFormConfigView formView, ColumnConfig column)
        {
            var col = base.CreateColumn(formView, column);

            switch (column.ControlType)
            {
            case ControlType.MultiFileUpload:
            case ControlType.SingleFileUpload:
                col.ControlType = ControlType.FileDetail;
                break;

            case ControlType.SingleImageUpload:
            case ControlType.MultiImageUpload:
                col.ControlType = ControlType.AllImageShow;
                break;

            case ControlType.Date:
                col.ControlType = ControlType.DetailDate;
                break;

            case ControlType.Editor:
                col.ControlType = ControlType.EditorDetail;
                break;

            case ControlType.InnerForm:
                col.ControlType = ControlType.InnerForm;
                break;

            case ControlType.DocumentSelector:
                col.ControlType = ControlType.DocumentDetail;
                break;

            case ControlType.Amount:
                col.ControlType = ControlType.AmountDetail;
                break;

            case ControlType.AmountDetail:
                col.ControlType = ControlType.AmountDetail;
                break;

            case ControlType.TwoColumns:
                col.ControlType = ControlType.TwoColumnsDetail;
                break;

            case ControlType.TwoColumnsDetail:
                col.ControlType = ControlType.TwoColumnsDetail;
                break;

            case ControlType.TextArea:
                col.ControlType = ControlType.DetailArea;
                break;

            case ControlType.DetailArea:
                col.ControlType = ControlType.DetailArea;
                break;

            default:
                if (column.ControlType != ControlType.Hidden &&
                    column.ControlType != ControlType.AllImageShow &&
                    column.ControlType != ControlType.ImageDetail
                    )
                {
                    col.ControlType = ControlType.Detail;
                }
                break;
            }
            return(col);
        }