Exemple #1
0
        public ActionResult LoadField(string dataSource = "", string tableName = "")
        {
            List <object> dataParams = new List <object>();

            dataParams.Add("@pageSize");
            dataParams.Add("1");
            dataParams.Add("@pageNum");
            dataParams.Add("1");
            object[]  parms  = new object[] { "@tableName", tableName.Trim() };
            DataTable fTable = new SqlFieldFilterAutoDao().GetDataTable(parms, "cofTableRenderAuto_GetAllColumnForFilter");

            if (fTable != null && fTable.Rows.Count > 0)
            {
                foreach (DataRow r in fTable.Rows)
                {
                    if (r["FieldType"] != null)
                    {
                        if (r["FieldType"].ToString() != "")
                        {
                            dataParams.Add(r["COLUMN_NAME"].ToString());
                            dataParams.Add(Request[r["COLUMN_NAME"].ToString()] != null ? Request[r["COLUMN_NAME"].ToString()] : "");
                        }
                    }
                }
            }
            #region 'Load List Data'
            DataTable result = new SqlFieldListAutoDao().GetDataTable(dataParams.ToArray(), dataSource);
            #endregion
            ViewBag.Resources   = new SqlResourceListAutoDao().GetFilter(tableName);
            ViewBag.TableRender = tableName;
            ViewBag.DataSource  = dataSource;
            return(View(result));
        }
        public JsonResult GetSingle(long id = 0)
        {
            object[]  parms = new object[] { "@tableName", TableName };
            DataTable table = new SqlFieldFilterAutoDao().GetDataTable(parms, "cofTableRenderAuto_GetAllColumnForFilter");
            List <FieldAddUpdateAuto> fieldAU = new List <FieldAddUpdateAuto>();

            if (table != null && table.Rows.Count > 0)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (row["FieldType"] != null)
                    {
                        FieldAddUpdateAuto field = new FieldAddUpdateAuto()
                        {
                            FieldName = row["COLUMN_NAME"].ToString(),
                            FieldType = row["FieldType"].ToString()
                        };
                        fieldAU.Add(field);
                    }
                }
            }
            TestQuestion   TestQuestion = new SqlTestQuestionDao().GetSingle(id);
            EditTableField fieldId      = new EditTableField()
            {
                FieldName = "ID", FieldType = 0, FieldValue = id.ToString()
            };
            List <EditTableField> editFields = Mapper.MapObjectToEditModel <TestQuestion>(TestQuestion, fieldAU);

            editFields.Add(fieldId);
            return(Json(editFields, JsonRequestBehavior.AllowGet));
        }
        public ActionResult FRender(string tableName = "", string formTitle = "", string targetArea = "", bool allowAU = false)
        {
            FormInfo formInfo = new FormInfo(formTitle, "/" + targetArea + "/" + tableName.Replace("tbl", ""));

            object[]  parms = new object[] { "@tableName", tableName.Trim() };
            DataTable table = new SqlFieldFilterAutoDao().GetDataTable(parms, "cofTableRenderAuto_GetAllColumnForFilter");

            if (table != null && table.Rows.Count > 0)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (row["FieldType"] != null)
                    {
                        if (row["FieldType"].ToString() != "")
                        {
                            int         fieldType = Convert.ToInt32(row["FieldType"]);
                            FormControl control   = new FormControl(fieldType, row["COLUMN_NAME"].ToString(), row["COLUMN_NAME"].ToString(), Request[row["COLUMN_NAME"].ToString()] != null ? Request[row["COLUMN_NAME"].ToString()].ToString() : "", row["DisplayName"].ToString(), row["PlaceHolder"].ToString(), "");
                            if (row["DataSource"] != null)
                            {
                                control.DataSource = row["DataSource"].ToString();
                            }
                            formInfo.Controls.Add(control);
                        }
                    }
                }
            }
            ViewBag.AllowAU = allowAU;
            return(View(formInfo));
        }
Exemple #4
0
        public ActionResult GetAllTableColumnForFilter(string tableName = "")
        {
            object[]  parms = new object[] { "@tableName", tableName.Trim() };
            DataTable table = new SqlFieldFilterAutoDao().GetDataTable(parms, "cofTableRenderAuto_GetAllColumnForFilter");

            ViewBag.DenyFields = Mapper.SplitString(StaticConst.ListFilterDenyFields);
            ViewBag.TableName  = tableName;
            return(View(table));
        }
        public ActionResult LRender(string tableName = "", string titleForm = "", string targetArea = "", bool allowAU = false)
        {
            #region 'Init'
            List <object> dataParams = new List <object>();
            ListInfo      model      = new ListInfo();
            model.ActiveController = tableName.Replace("tbl", "");
            model.ActiveArea       = targetArea;
            model.Title            = titleForm;
            int currentPage = Request["currentPage"] != null?Convert.ToInt32(Request["currentPage"].ToString()) : 1;

            #endregion
            #region 'Load Field & Data Source'
            object[] parms = new object[] { "@tableName", tableName.Trim() };

            TableRenderAuto dataSource = new SqlTableRenderAutoDao().GetTableRenderAuto(tableName);
            #endregion

            dataParams.Add("@pageSize");
            dataParams.Add(dataSource != null ? dataSource.PageSize : 10);
            dataParams.Add("@pageNum");
            dataParams.Add(currentPage);
            DataTable fTable = new SqlFieldFilterAutoDao().GetDataTable(parms, "cofTableRenderAuto_GetAllColumnForFilter");
            if (fTable != null && fTable.Rows.Count > 0)
            {
                foreach (DataRow r in fTable.Rows)
                {
                    if (r["FieldType"] != null)
                    {
                        if (r["FieldType"].ToString() != "")
                        {
                            dataParams.Add(r["COLUMN_NAME"].ToString());
                            dataParams.Add(Request[r["COLUMN_NAME"].ToString()] != null ? Request[r["COLUMN_NAME"].ToString()] : "");
                        }
                    }
                }
            }
            #region 'Load List Data'
            if (dataSource != null && dataSource.ExtentionProperty["DataSource"] != null)
            {
                if (dataSource.ExtentionProperty["DataSource"].ToString() != "")
                {
                    model.DataInfo = new SqlFieldListAutoDao().GetDataTable(dataParams.ToArray(), dataSource.ExtentionProperty["DataSource"].ToString());
                    if (model.DataInfo != null)
                    {
                        model.DataInfo.Columns.Add("StatusDisplay", typeof(System.String));
                        if (model.DataInfo.Rows.Count > 0)
                        {
                            foreach (DataRow r in model.DataInfo.Rows)
                            {
                                for (int c = 0; c < model.DataInfo.Columns.Count; c++)
                                {
                                    if (model.DataInfo.Columns[c].ToString() == "Status" || model.DataInfo.Columns[c].ToString() == "status" || model.DataInfo.Columns[c].ToString() == "STATUS")
                                    {
                                        r["StatusDisplay"] = StatusMapping(Convert.ToInt32(r[c].ToString()), tableName);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            #region 'Paging'
            model.PagingInfo.CurrentPage = currentPage;
            if (model.DataInfo != null && model.DataInfo.Rows.Count > 0)
            {
                model.PagingInfo.TotalRecords = Convert.ToInt32(model.DataInfo.Rows[0]["TotalRec"]);
            }
            #endregion

            #region 'Load Resource'
            model.Resources = new SqlResourceListAutoDao().GetFilter(tableName);
            #endregion

            ViewBag.AllowAU = allowAU;
            return(View(model));
        }