예제 #1
0
        public bool AddDefaultScene(int formId)
        {
            CPForm form = this._CPFormRep.Get(formId);

            if (form == null)
            {
                return(false);
            }
            CPFormUseScene scene = new CPFormUseScene();
            int            autoIndex;

            scene.FormId          = formId;
            scene.SceneCode       = CPAutoNumHelper.Instance().GetNextAutoNum("FormSceneCodeAuto", out autoIndex);
            scene.AutoIndex       = autoIndex;
            scene.FormSavedAction = CPFormEnum.FormSavedActionEnum.ReturnEditPage;
            scene.SceneName       = "默认";
            scene.FuncCol         = new List <CPFormUseSceneFunc>();
            CPFormUseSceneFunc func = new CPFormUseSceneFunc();

            func.FuncTitle        = "保存";
            func.ShowOrder        = 10;
            func.FuncExeJS        = "CPFormSaveFormData()";
            func.FuncIsShowInView = CPFormEnum.FuncIsShowInViewEnum.OnlyWriteShow;
            func.IsControlByRight = false;
            func.FormId           = formId;
            scene.FuncCol.Add(func);
            this._CPFormUseSceneRep.Add(scene);
            return(true);
        }
예제 #2
0
        public bool InitFormDefaultView(int formId)
        {
            CPForm form = this._CPFormRep.Get(formId);

            if (form == null)
            {
                return(false);
            }
            CPFormView view = new Form.CPFormView();
            int        autoIndex;

            view.ViewCode       = CPAutoNumHelper.Instance().GetNextAutoNum("FormViewCodeAuto", out autoIndex);
            view.AutoIndex      = autoIndex;
            view.ViewName       = "默认一行两列式视图";
            view.FormId         = form.Id;
            view.ViewType       = CPFormEnum.ViewTypeEnum.TwoColumn;
            view.ViewDeviceType = CPFormEnum.ViewDeviceTypeEnum.PCIphoneIpad;
            view.IsDefault      = true;
            view.ViewFieldCol   = new List <CPFormViewField>();
            #region 获取所有的字段
            List <CPFormField> fieldCol = this.GetFormFieldCol(formId);
            int nOrder = 10;
            fieldCol.ForEach(t => {
                CPFormViewField vT = new CPFormViewField();
                vT.FormId          = form.Id;
                vT.FieldId         = t.Id;
                vT.ShowOrder       = nOrder;
                nOrder             = nOrder + 10;
                vT.ViewBlockIndex  = 0;
                //  vT.FieldStatus = CPFormEnum.FieldStatusEnum.Edit;
                vT.IsSpanAll = false;
                //vT.FieldTitleShowWidth = 20;
                //vT.ShowWidth = "98%";
                //vT.MultiRows = 5;
                //vT.ShowHeight = 100;

                view.ViewFieldCol.Add(vT);
            });
            #endregion
            this._CPFormViewRep.Add(view);
            return(true);
        }
예제 #3
0
        private string GetInitValue(CPFormFieldInit init, out int autoIndex, out string autoIndexField)
        {
            autoIndex      = 0;
            autoIndexField = "";
            string sValue = "";

            if (init.InitType == CPFormEnum.InitTypeEnum.StaticValue)
            {
                sValue = init.InitInfo;
            }
            else if (init.InitType == CPFormEnum.InitTypeEnum.Auto)
            {
                sValue = CPAutoNumHelper.Instance().GetNextAutoNum(init.InitInfo, out autoIndex);
                //再获取下存储索引号的字段名
                autoIndexField = CPAutoNumHelper.Instance().GetAutoNum(init.InitInfo).FormAumField;
            }
            else if (init.InitType == CPFormEnum.InitTypeEnum.Expression)
            {
                sValue = CPExpressionHelper.Instance.RunCompile(init.InitInfo);
            }
            else if (init.InitType == CPFormEnum.InitTypeEnum.Sql)
            {
                if (string.IsNullOrEmpty(init.InitSqlDbIns))
                {
                    throw new Exception("获取初始化信息时,存储数据库链接的字段值InitSqlDbIns值为空");
                }
                DbHelper _helper = new DbHelper(init.InitSqlDbIns, CPAppContext.CurDbType());
                string   sql     = init.InitInfo;
                sql = CPExpressionHelper.Instance.RunCompile(sql);
                object obj = _helper.ExecuteScalar(sql);
                if (Convert.IsDBNull(obj) == false && obj != null)
                {
                    sValue = obj.ToString();
                }
            }
            else
            {
                sValue = init.InitInfo;
            }
            return(sValue);
        }
예제 #4
0
        public bool InitFormDefaultViewForEditor(int formId)
        {
            CPForm form = this.GetForm(formId, true, true, false, false, false, true);

            if (form == null)
            {
                return(false);
            }
            CPFormView view = new Form.CPFormView();
            int        autoIndex;

            view.ViewCode       = CPAutoNumHelper.Instance().GetNextAutoNum("FormViewCodeAuto", out autoIndex);
            view.AutoIndex      = autoIndex;
            view.ViewName       = "使用编辑器排版视图";
            view.FormId         = form.Id;
            view.ViewType       = CPFormEnum.ViewTypeEnum.TextEditor;
            view.ViewDeviceType = CPFormEnum.ViewDeviceTypeEnum.PCIphoneIpad;
            view.IsDefault      = false;
            view.FormViewHTML   = "";
            view.ViewFieldCol   = new List <CPFormViewField>();
            #region 默认组一个一行四列的排版
            List <CPFormField>     fieldCol     = this.GetFormFieldCol(form.Id);
            List <CPFormViewField> viewFieldCol = new List <CPFormViewField>();
            int nIndex = 10;
            fieldCol.ForEach(t => {
                CPFormViewField vF = new CPFormViewField();
                vF.FieldId         = t.Id;
                vF.FormId          = t.FormId;
                vF.IsSpanAll       = false;
                vF.ShowOrder       = nIndex;
                nIndex++;
                vF.ViewBlockIndex = 0;
                vF.ViewId         = 0;
                viewFieldCol.Add(vF);
            });
            view.ViewFieldCol = viewFieldCol;
            //先取出主表的和包括子拓展表的字段
            List <CPFormField> mainTableField = fieldCol.Where(t => t.TableName.Equals(form.MainTableName) || t.IsChildTable.Value).ToList();
            List <int>         fieidCol       = new List <int>();
            mainTableField.ForEach(t => { fieidCol.Add(t.Id); });
            //转化成视图中的字段
            List <CPFormViewField> mainTableFormViewField = view.ViewFieldCol.Where(c => fieidCol.Contains(c.FieldId)).ToList();
            string mainHTML = this.FormatOneTableHTML(form, fieldCol, view, mainTableFormViewField,
                                                      new List <CPFormFieldRight>(), CPEnum.DeviceTypeEnum.PCBrowser, 4, true, false, false);
            //再看看子表的
            if (form.ChildTableCol != null && form.ChildTableCol.Count > 0)
            {
                form.ChildTableCol.ForEach(cTable => {
                    List <CPFormField> cTableField = fieldCol.Where(t => t.TableName.Equals(cTable.TableName) && t.IsChildTable.Value == false).ToList();
                    fieidCol.Clear();
                    cTableField.ForEach(t => { fieidCol.Add(t.Id); });
                    //转化成视图中的字段
                    List <CPFormViewField> cTableFormViewField = view.ViewFieldCol.Where(c => fieidCol.Contains(c.FieldId)).ToList();
                    string cHTML = this.FormatOneTableHTML(form, fieldCol, view, cTableFormViewField,
                                                           new List <CPFormFieldRight>(), CPEnum.DeviceTypeEnum.PCBrowser, 4, false, false, false);
                    mainHTML = mainHTML.Replace("{@" + cTable.TableName + "@}", cHTML);
                });
            }
            // sbHTML.Append(mainHTML);
            view.FormViewHTML = mainHTML;
            #endregion
            this._CPFormViewRep.Add(view);
            return(true);
        }