Beispiel #1
0
 public override void SetValueForDetailPage(IDrisionControl c, object value)
 {
     if (value != null)
     {
         c.SetValue(string.Format("{0:yyyy-MM-dd}", value));
     }
 }
Beispiel #2
0
 public override void SetValueForDetailPage(IDrisionControl c, object value)
 {
     foreach (var p in this.Field.RefEnum.EnumItems)
     {
         if (p.ItemValue == value.ToInt())
         {
             c.SetValue(p.DisplayText);
             break;
         }
     }
 }
Beispiel #3
0
        public override void SetValueForDetailPage(IDrisionControl c, object value)
        {
            DataTable data   = GetData();
            var       source = data.Rows.Cast <DataRow>().Select(p => new
            {
                NAME = Convert.ToString(p["NAME"]),
                ID   = Convert.ToString(p["ID"]),
            }).ToList();

            foreach (var p in source)
            {
                if (p.ID == Convert.ToString(value))
                {
                    c.SetValue(p.NAME);
                    break;
                }
            }
        }
Beispiel #4
0
 public override void SetValueForDetailPage(IDrisionControl c, object value)
 {
     if (value != null)
     {
         string str = value.ToString().ToLower();
         if (str == "1" || str == "true")
         {
             c.SetValue("是");
         }
         else
         {
             c.SetValue("否");
         }
     }
     else
     {
         c.SetValue("否");
     }
 }
Beispiel #5
0
 /// <summary>
 /// 给控件赋值(详情页面)
 /// </summary>
 /// <param name="ff">表单字段</param>
 /// <param name="c">控件</param>
 /// <param name="value">值</param>
 public static void SetValueForDetailPage(SysFormField ff, IDrisionControl c, object value)
 {
     GetControlHelper(ff).SetValueForDetailPage(c, value);
 }
Beispiel #6
0
 public override void SetValueForDetailPage(IDrisionControl c, object value)
 {
     c.SetValue("*********");
 }
Beispiel #7
0
 public override void SetValueForDetailPage(IDrisionControl c, object value)
 {
     c.SetValue(HttpUtility.HtmlEncode(value).Replace("\r\n", "<br />").Replace("\n", "<br />"));
 }
Beispiel #8
0
 public virtual void SetValueForDetailPage(IDrisionControl c, object value)
 {
     c.SetValue(value);
 }
        /// <summary>
        /// 新增表单实例,新增表单实体对象
        /// </summary>
        public int SaveFormInstance(BizDataContext db)
        {
            SysFormInstance fi = new SysFormInstance()
            {
                FormInstanceId = db.GetNextIdentity_Int(),
                FormId         = this.FormId,
                //--------------//
                FormDate        = Convert.ToDateTime(this.lblFormDate.Text.Trim()),
                FormCode        = this.lblFormCode.Text.Trim(),
                FormDescription = Server.HtmlDecode(this.lblFormDescription.Text.Trim()).Replace("<br />", "\r\n"),
                FormTitle       = this.lblFormTitle.Text.Trim(),
                State           = (int)FormInstanceState.New,
                //---------------//
                CreateTime   = DateTime.Now,
                CreateUserId = this.BasePage.LoginUserID,
                OwnerId      = this.BasePage.LoginUserID,
            };

            #region 收集实体字段的值,创建实体对象
            List <SysFormField>         ffList    = db.Where <SysFormField>(p => p.FormId == this.FormId);
            Dictionary <string, object> valueDict = new Dictionary <string, object>();
            foreach (var ff in ffList)
            {
                string          controlId = string.Format("ff_{0}", ff.FormFieldId);
                IDrisionControl control   = this.BasePage.GetControlById <IDrisionControl>(controlId);
                if (control == null)
                {
                    throw new Exception("表单控件解析出错");
                }
                valueDict[control.FieldName] = control.GetValue();
            }
            SysEntity entity = this.BasePage.EntityCache.FindById <SysEntity>(this.EntityId);
            if (entity != null) //元数据预置实体,利用EntitySchema创建对象插入
            {
                var es = IEntitySchemaHelper.Get(this.EntityId);
                if (es == null)
                {
                    throw new Exception("元数据实体EntitySchema找不到");
                }

                object obj      = es.CreateInstance();
                int    objectId = db.GetNextIdentity_Int();
                obj.SetPropertyConvertValue(es.KeyName, objectId); //主键
                foreach (var p in valueDict)
                {
                    obj.SetPropertyConvertValue(p.Key, p.Value);
                }

                //一些默认字段
                if (es.RequiredLevel() != RequireLevelEnum.PlatForm)
                {
                    if (obj.GetPropertyValue(ConstFieldNames.CreateTime) == null)
                    {
                        obj.SetPropertyConvertValue(ConstFieldNames.CreateTime, DateTime.Now);
                    }
                    if (obj.GetPropertyValue(ConstFieldNames.CreateUserId) == null)
                    {
                        obj.SetPropertyConvertValue(ConstFieldNames.CreateUserId, this.BasePage.LoginUserID);
                    }
                    if (obj.GetPropertyValue(ConstFieldNames.OwnerId) == null)
                    {
                        obj.SetPropertyConvertValue(ConstFieldNames.OwnerId, this.BasePage.LoginUserID);
                    }
                    if (obj.GetPropertyValue(ConstFieldNames.State) == null)
                    {
                        obj.SetPropertyConvertValue(ConstFieldNames.State, 0);
                    }
                    if (obj.GetPropertyValue(ConstFieldNames.StateDetail) == null)
                    {
                        obj.SetPropertyConvertValue(ConstFieldNames.StateDetail, 0);
                    }
                }

                db.Insert(obj);

                fi.ObjectId = objectId;
            }
            else //自定义实体
            {
                entity      = this.DataHelper.FindById <SysEntity>(this.EntityId);
                fi.ObjectId = db.DynamicInsert(entity, valueDict);
            }
            #endregion

            db.Insert(fi);
            return(fi.FormInstanceId);
        }
        /// <summary>
        /// 保存表单实体,和表单实体对象
        /// </summary>
        /// <param name="db"></param>
        public int UpdateFormInstance(BizDataContext db)
        {
            SysFormInstance fi = db.FindById <SysFormInstance>(this.FormInstanceId);

            if (fi == null)
            {
                throw new Exception("表单实例不存在");
            }

            if (fi.State != (int)FormInstanceState.Approving)
            {
                fi.State = (int)FormInstanceState.New; //2013-10-8 zhumin 重新保存后状态改为新增,审核中除外
            }
            fi.UpdateUserId = this.BasePage.LoginUserID;
            fi.UpdateTime   = DateTime.Now;

            //收集实体字段的值,创建实体对象
            List <SysFormField>         ffList    = db.Where <SysFormField>(p => p.FormId == this.FormId);
            Dictionary <string, object> valueDict = new Dictionary <string, object>();

            foreach (var ff in ffList)
            {
                string          controlId = string.Format("ff_{0}", ff.FormFieldId);
                IDrisionControl control   = this.BasePage.GetControlById <IDrisionControl>(controlId);
                if (control == null)
                {
                    throw new Exception("表单控件解析出错");
                }
                valueDict[control.FieldName] = control.GetValue();
            }
            SysEntity entity = this.BasePage.EntityCache.FindById <SysEntity>(this.EntityId);

            if (entity != null) //元数据预置实体,利用EntitySchema创建对象插入
            {
                var es = IEntitySchemaHelper.Get(this.EntityId);
                if (es == null)
                {
                    throw new Exception("元数据实体EntitySchema找不到");
                }

                object        obj  = db.FindById(es.EntityType, this.ObjectId);
                List <string> cols = new List <string>();
                foreach (var p in valueDict)
                {
                    if (obj.GetPropertyValue(p.Key) != p.Value)
                    {
                        obj.SetPropertyConvertValue(p.Key, p.Value);
                        cols.Add(p.Key);
                    }
                }

                db.UpdatePartial(obj, cols);
            }
            else //自定义实体
            {
                entity = this.DataHelper.FindById <SysEntity>(this.EntityId);
                db.DynamicUpdate(entity, this.ObjectId, valueDict);
            }

            db.UpdatePartial(fi, p => new { p.State, p.UpdateTime, p.UpdateUserId });
            return(fi.FormInstanceId);
        }
        /// <summary>
        /// 加载表单实体对象
        /// </summary>
        private void LoadObjectData(Dictionary <long, IDrisionControl> controlDict)
        {
            List <SysFormField> ffList = this.DataHelper.Where <SysFormField>(p => p.FormId == this.FormId);
            SysEntity           entity = this.BasePage.EntityCache.FindById <SysEntity>(this.EntityId);

            if (entity != null) //元数据预置实体,利用EntitySchema查询,给控件赋值
            {
                #region 元数据预置实体

                var es = IEntitySchemaHelper.Get(this.EntityId);
                if (es == null)
                {
                    throw new Exception("元数据实体EntitySchema找不到");
                }

                object obj = this.DataHelper.FindById(es.EntityType, this.ObjectId);
                foreach (var ff in ffList)
                {
                    ff.Field = BasePage.GetField(ff.FieldId);
                    if (controlDict.ContainsKey(ff.FormFieldId))
                    {
                        IDrisionControl control = controlDict[ff.FormFieldId];
                        object          value   = obj.GetPropertyValue(control.FieldName);
                        if (this.IsDetailPage)
                        {
                            FormPreviewHelper.SetValueForDetailPage(ff, control, value);
                        }
                        else
                        {
                            FormPreviewHelper.SetValue(ff, control, value);
                        }
                    }
                    else
                    {
                        throw new Exception("表单字段找不到对应控件");
                    }
                }

                #endregion
            }
            else
            {
                #region 自定义实体

                entity = this.DataHelper.FindById <SysEntity>(this.EntityId);
                Dictionary <string, object> valueDict = this.DataHelper.DynamicFindById(entity, this.ObjectId);
                foreach (var ff in ffList)
                {
                    ff.Field = BasePage.GetField(ff.FieldId);
                    if (controlDict.ContainsKey(ff.FormFieldId))
                    {
                        IDrisionControl control = controlDict[ff.FormFieldId];
                        if (!valueDict.ContainsKey(control.FieldName.ToLower()))
                        {
                            throw new Exception(string.Format("字段{0}找不到", control.FieldName));
                        }
                        object value = valueDict[control.FieldName.ToLower()];
                        if (this.IsDetailPage)
                        {
                            FormPreviewHelper.SetValueForDetailPage(ff, control, value);
                        }
                        else
                        {
                            FormPreviewHelper.SetValue(ff, control, value);
                        }
                    }
                    else
                    {
                        throw new Exception("表单字段找不到对应控件");
                    }
                }

                #endregion
            }
        }