Beispiel #1
0
 /// <summary>
 /// 构造字段文本
 /// </summary>
 /// <returns></returns>
 private string BuilderFormFieldText()
 {
     if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_COMBOBOX)
     {
         var dicts = _dataAccessor.Dictionarys(_fapColumn.ComboxSource);
         if (_fapColumn.MultiAble == 1)
         {
             //多选
             List <string> sels = new List <string>();
             GetMultiSelTexts(sels);
             return(string.Join(",", sels));
         }
         else
         {
             var dic = dicts.FirstOrDefault(d => d.Code == FieldValue.ToString());
             if (dic != null)
             {
                 return(dic.Name);
             }
             //单选
             return("");
         }
     }
     else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_CHECKBOXLIST)
     {
         //多选
         List <string> sels = new List <string>();
         GetMultiSelTexts(sels);
         return(string.Join(",", sels));
     }
     else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_REFERENCE)
     {
         return(FieldMCValue.ToStringOrEmpty());
     }
     else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_IMAGE)
     {
         StringBuilder img = new StringBuilder();
         //img.AppendLine("<span class=\"profile-picture\">");
         img.AppendFormat("       <img   class=\"img-responsive\"  src=\"{0}\" />", "/Component/Photo/" + FieldValue).AppendLine();
         //img.AppendLine("   </span>");
         return(img.ToString());
     }
     else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_FILE)
     {
         DynamicParameters param = new DynamicParameters();
         param.Add("Bid", FieldValue);
         var attList = _dataAccessor.QueryWhere <FapAttachment>("bid=@Bid", param);
         if (attList != null && attList.Any())
         {
             string li = string.Join("", attList.Select(a => $"<li class=\"text-info\"><a href=\"/PublicCtrl/DownloadFile/{a.Fid}\" title=\"{a.FileName}\"><i class=\"ace-icon fa fa-paperclip blue bigger-110\"></i>{ a.FileName}</a></li>"));
             return($"<ul class=\"list-unstyled list-inline\">{li}</ul>");
         }
         return("");
     }
     else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_CHECKBOX)
     {
         string _value = FieldValue.ToStringOrEmpty();
         return(_value == "1" ? "<i class=\"fa fa-check\"></i>" : "<i class=\"fa fa-times\"></i>");
     }
     else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_DATE)
     {
         string _value = FieldValue.ToStringOrEmpty();
         return(_value.Length > 10 ? _value.Substring(0, 10) : _value);
     }
     else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_DATETIME)
     {
         string _value = FieldValue.ToStringOrEmpty();
         return(_value.Length > 19 ? _value.Substring(0, 19) : _value);
     }
     else
     {
         return(FieldValue.ToStringOrEmpty());
     }
 }
Beispiel #2
0
        private void BuilderDataFormField(string frmid, string lableName, string editAble, StringBuilder sbFormGroup)
        {
            //angularjs的时候使用,目前没用

            if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_DATE)
            {
                if (FieldValue.ToString().Length > 10)
                {
                    FieldValue = FieldValue.ToString().Substring(0, 10);
                }
                sbFormGroup.AppendLine(_fapColumn.AsDate(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_DATETIME)
            {
                sbFormGroup.AppendLine(_fapColumn.AsDateTime(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_COMBOBOX)
            {
                Guard.Against.Null(_fapColumn.ComboxSource, nameof(_fapColumn.ComboxSource));

                List <string> tempList = new List <string>();
                if (_fapColumn.MultiAble == 1)
                {
                    if (FieldValue != null && FieldValue.ToString().Length > 0)
                    {
                        //获取多选项的值
                        GetMultiSelValues(tempList);
                    }
                }
                IEnumerable <FapDict> dicList = _dataAccessor.Dictionarys(_fapColumn.ComboxSource);
                sbFormGroup.AppendLine(_fapColumn.AsCombobox(editAble, dicList, tempList, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_CHECKBOXLIST)
            {
                List <string> tempList = new List <string>();

                if (FieldValue != null && FieldValue.ToString().Length > 0)
                {
                    //获取多选项的值
                    GetMultiSelValues(tempList);
                }
                string where = "";
                if (_fapColumn.RefCondition.IsPresent())
                {
                    where = " where " + _fapColumn.RefCondition;
                }
                string sql   = string.Format("select {0} Code,{1} Name from {2} {3}", _fapColumn.RefID, _fapColumn.RefName, _fapColumn.RefTable, where);
                var    dlist = _dataAccessor.Query <FapDict>(sql);
                sbFormGroup.AppendLine(_fapColumn.AsCheckboxList(editAble, dlist, tempList));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_REFERENCE)
            {
                sbFormGroup.AppendLine(_fapColumn.AsReference(editAble, FieldValue.ToString(), FieldMCValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_RANGE)
            {
                sbFormGroup.AppendLine(_fapColumn.AsRange(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_MEMO)
            {
                sbFormGroup.AppendLine(_fapColumn.AsTextArea(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_RICHTEXTBOX)
            {
                sbFormGroup.AppendLine(_fapColumn.AsRichTextBox(FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_CHECKBOX)
            {
                IEnumerable <FapDict> dicList = new List <FapDict>();
                if (_fapColumn.ComboxSource.IsPresent())
                {
                    dicList = _dataAccessor.Dictionarys(_fapColumn.ComboxSource);
                }
                sbFormGroup.AppendLine(_fapColumn.AsCheckbox(editAble, dicList, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_EMAIL)
            {
                sbFormGroup.AppendFormat(_fapColumn.AsEmail(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_FILE)
            {
                sbFormGroup.AppendLine(_fapColumn.AsFile(editAble, frmid, FieldValue.ToString(), lableName));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_IMAGE)
            {
                sbFormGroup.AppendLine(_fapColumn.AsImage(FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_PASSWORD)
            {
                sbFormGroup.AppendLine(_fapColumn.AsPassword(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_INT || _fapColumn.CtrlType == FapColumn.CTRL_TYPE_DOUBLE || _fapColumn.CtrlType == FapColumn.CTRL_TYPE_MONEY)
            {
                if (FieldValue.ToString().IsMissing() && _fapColumn.ColDefault.IsPresent())
                {
                    FieldValue = _fapColumn.ColDefault;
                }
                sbFormGroup.AppendLine(_fapColumn.AsTextBox(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_PHONE)
            {
                sbFormGroup.AppendLine(_fapColumn.AsTextBox(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_RADIO)
            {
                throw new NotSupportedException("暂无实现,请用其他控件代替");
                //sbFormGroup.AppendFormat("<div class=\"control-group\" id=\"{0}\" name=\"{0}\">", ctrlName, ngModel).AppendLine();
                ////内容动态添加
                //sbFormGroup.AppendLine("</div>");
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_TEXT)
            {
                if (_fapColumn.IsMultiLang == 1)
                {
                    //多語字段處理
                    string ctrlName     = _fapColumn.ColName;
                    string currCtrlName = ctrlName;
                    FieldValue = FormData.Get(currCtrlName);
                    if (FieldValue == null)
                    {
                        FieldValue = "";
                    }

                    string currentLangDesc = _fapColumn.ColComment;
                    Dictionary <string, string> dicLangValue = new Dictionary <string, string>();

                    var langList = typeof(MultiLanguageEnum).EnumItems();
                    foreach (var langField in langList)
                    {
                        string cname = ctrlName + langField.Value;
                        var    value = FormData.Get(cname);
                        dicLangValue.Add(cname, value?.ToString() ?? "");
                    }
                    sbFormGroup.AppendLine(_fapColumn.AsMultiLanguageTextBox(editAble, currCtrlName, currentLangDesc, dicLangValue, FieldValue.ToString()));
                }
                else
                {
                    sbFormGroup.AppendLine(_fapColumn.AsTextBox(editAble, FieldValue.ToString()));
                }
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_CITY)
            {
                //城市
                sbFormGroup.AppendFormat(_fapColumn.AsCity(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_NATIVE)
            {
                //籍贯
                sbFormGroup.AppendFormat(_fapColumn.AsNative(editAble, FieldValue.ToString()));
            }
            else if (_fapColumn.CtrlType == FapColumn.CTRL_TYPE_STAR)
            {
                //评星级
                sbFormGroup.AppendLine(_fapColumn.AsRate(editAble, FieldValue.ToString()));
            }
            else
            {
                sbFormGroup.AppendLine(_fapColumn.AsTextBox(editAble, FieldValue.ToString()));
            }
        }