protected override void OnInitData() { ModelDBHelper helper = ModelDBHelper.Create(ModelName); Criteria c = CreateEntryCriteria(); DataTable dt = helper.Query(c, CreateOrders(), 0, 0, Fields); if (null != dt) { JoinEx joinex = new JoinEx(); MoldPanel mp = new MoldPanel(); ColumnInfoCollection columns = mp.GetPanelContext(ModelName, "list").Panel.ListInfo.Groups[0].Columns; foreach (ColumnInfo item in columns) { if (!string.IsNullOrEmpty(item.Params["model"])) { joinex.JoinInfo.Add(item.Name, new JoinEx() { MainField = item.Name, PriMaryKeyName = item.Params["valuefield"], ToField = item.Params["textfield"], ToTableName = item.Params["model"] }); } } if (joinex.JoinInfo != null && joinex.JoinInfo.Count > 0) { DataBaseAssistant db = new DataBaseAssistant(); dt = db.Join(dt, joinex); } } /*end*/ Item = dt != null && dt.Rows.Count > 0 ? dt.Rows[0] : dt.NewRow(); //更新点击次数 if (dt.Columns.Contains("Clicks")) { Dictionary <string, object> dic = new Dictionary <string, object>(); int clicks = Item["Clicks"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(Item["Clicks"]); clicks++; dic.Add("Clicks", clicks); helper.Update(dic, c); } }
protected override void OnInitData() { Criteria c = CreateCriteria(); List <Order> os = CreateOrders(); ModelDBHelper dbhelper = ModelDBHelper.Create(ModelName); // Items = dbhelper.QueryPagedList(c, os, 0, PageSize).Rows; DataTable dt = dbhelper.QueryPagedList(c, os, 0, PageSize, Fields); /*begin 表关联相关*/ if (null != dt) { JoinEx joinex = new JoinEx(); MoldPanel mp = new MoldPanel(); ColumnInfoCollection columns = mp.GetPanelContext(ModelName, "list").Panel.ListInfo.Groups[0].Columns; foreach (ColumnInfo item in columns) { if (!string.IsNullOrEmpty(item.Params["model"])) { joinex.JoinInfo.Add(item.Name, new JoinEx() { MainField = item.Name, PriMaryKeyName = item.Params["valuefield"], ToField = item.Params["textfield"], ToTableName = item.Params["model"] }); } } if (joinex.JoinInfo != null && joinex.JoinInfo.Count > 0) { DataBaseAssistant db = new DataBaseAssistant(); dt = db.Join(dt, joinex); } } /*end*/ if (dt != null) { Items = dt.Rows; } }