void viewGrid_CellClick(object sender, DataGridViewCellEventArgs e) { if (View == null) { return; } if (viewGrid.dataGridView.CurrentRow == null) { return; } CViewDetail vd = (CViewDetail)View.ViewDetailMgr.GetFirstObj(); viewDetailGrid.ViewDetail = vd; CTable table = (CTable)Program.Ctx.TableMgr.Find(vd.FW_Table_id); if (table == null) { return; } CBaseObject obj = (CBaseObject)viewGrid.dataGridView.CurrentRow.Tag; CBaseObjectMgr objMgr = Program.Ctx.FindBaseObjectMgrCache(table.Code, obj.Id); if (objMgr == null) { objMgr = obj.GetSubObjectMgr(table.Code, typeof(CBaseObjectMgr)); } if (objMgr == null) { CColumn colP = (CColumn)obj.Table.ColumnMgr.Find(vd.PrimaryKey); if (colP == null) { return; } CColumn colF = (CColumn)table.ColumnMgr.Find(vd.ForeignKey); if (colF == null) { return; } object objVal = obj.GetColValue(colP); string sVal = objVal.ToString(); bool bIsStr = false; if (colP.ColType == ColumnType.string_type || colP.ColType == ColumnType.text_type || colP.ColType == ColumnType.ref_type || colP.ColType == ColumnType.guid_type || colP.ColType == ColumnType.datetime_type) { sVal = string.Format("'{0}'", sVal); bIsStr = true; } objMgr = new CBaseObjectMgr(); objMgr.Ctx = Program.Ctx; objMgr.TbCode = table.Code; objMgr.m_Parent = obj; string sWhere = string.Format(" {0}={1}", colF.Code, bIsStr ? sVal : objVal); objMgr.Load(sWhere, false); } viewDetailGrid.BaseObjectMgr = objMgr; }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Response.End(); } m_User = (CUser)Session["User"]; string vid = Request["vid"]; if (string.IsNullOrEmpty(vid)) { Response.End(); } string vdid = Request["vdid"]; if (string.IsNullOrEmpty(vdid)) { Response.End(); } m_View = (CView)Global.GetCtx(Session["TopCompany"].ToString()).ViewMgr.Find(new Guid(vid)); if (m_View == null) { Response.End(); } m_ViewDetail = (CViewDetail)m_View.ViewDetailMgr.Find(new Guid(vdid)); if (m_ViewDetail == null) { Response.End(); } m_Table = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(m_ViewDetail.FW_Table_id); //检查权限 if (!CheckAccess()) { Response.End(); } if (Session["EditMultMasterDetailViewRecord"] == null) { Response.End(); } SortedList <Guid, CBaseObject> arrP = (SortedList <Guid, CBaseObject>)Session["EditMultMasterDetailViewRecord"]; CBaseObject objP = (CBaseObject)arrP.Values[0]; m_BaseObjectMgr = objP.GetSubObjectMgr(m_Table.Code, typeof(CBaseObjectMgr)); if (Request.Params["Action"] == "GetData") { GetData(); Response.End(); } else if (Request.Params["Action"] == "Delete") { Delete(); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Response.End(); } m_User = (CUser)Session["User"]; string vid = Request["vid"]; if (string.IsNullOrEmpty(vid)) { Response.End(); } m_View = (CView)Global.GetCtx(Session["TopCompany"].ToString()).ViewMgr.Find(new Guid(vid)); if (m_View == null) { Response.End(); } m_ViewDetail = (CViewDetail)m_View.ViewDetailMgr.GetFirstObj(); if (m_ViewDetail == null) { Response.End(); } m_Table = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(m_ViewDetail.FW_Table_id); m_sortRestrictColumnAccessType = m_User.GetRestrictColumnAccessTypeList(m_Table); string id = Request["id"]; if (string.IsNullOrEmpty(id)) { Response.End(); } if (Session["EditMasterDetailViewRecord"] == null) { Response.End(); } SortedList <Guid, CBaseObject> arrP = (SortedList <Guid, CBaseObject>)Session["EditMasterDetailViewRecord"]; CBaseObject objP = arrP.Values[0]; m_BaseObjectMgr = objP.GetSubObjectMgr(m_Table.Code, typeof(CBaseObjectMgr)); m_BaseObject = m_BaseObjectMgr.Find(new Guid(id)); if (m_BaseObject == null) { Response.Write("请选择记录!"); Response.End(); } if (!IsPostBack) { recordCtrl.m_ViewDetail = m_ViewDetail; recordCtrl.m_Table = m_Table; recordCtrl.m_sortRestrictColumnAccessType = m_sortRestrictColumnAccessType; recordCtrl.m_BaseObject = m_BaseObject; if (!string.IsNullOrEmpty(Request["UIColCount"])) { recordCtrl.m_iUIColCount = Convert.ToInt32(Request["UIColCount"]); } //隐藏字段 string sHideCols = Request["HideCols"]; if (!string.IsNullOrEmpty(sHideCols)) { string[] arr = sHideCols.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string code in arr) { recordCtrl.m_sortHideColumn.Add(code, code); } } } if (Request.Params["Action"] == "Cancel") { Response.End(); } else if (Request.Params["Action"] == "PostData") { PostData(); Response.End(); } }
void GetDetail() { CBaseObject objP = (CBaseObject)Session["AddMasterDetailViewRecord"]; CViewDetail vd = (CViewDetail)m_View.ViewDetailMgr.GetFirstObj(); CTable table = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(vd.FW_Table_id); //判断表权限 AccessType tableAccessType = m_User.GetTableAccess(table.Id); if (tableAccessType == AccessType.forbide) { Response.Write("没有表权限!"); return; } else if (tableAccessType == AccessType.read) { } else { } m_sortDetailRestrictColumnAccessType = m_User.GetRestrictColumnAccessTypeList(table); // CBaseObjectMgr objMgr = objP.GetSubObjectMgr(table.Code, typeof(CBaseObjectMgr)); string sData = ""; CColumn colF = (CColumn)table.ColumnMgr.Find(vd.ForeignKey); if (colF == null) { return; } List <CBaseObject> lstObj = objMgr.GetList(); foreach (CBaseObject obj in lstObj) { string sRow = ""; foreach (CBaseObject objC in table.ColumnMgr.GetList()) { CColumn col = (CColumn)objC; //判断禁止权限字段 if (m_sortDetailRestrictColumnAccessType.ContainsKey(col.Id)) { AccessType accessType = m_sortDetailRestrictColumnAccessType[col.Id]; if (accessType == AccessType.forbide) { string sVal = ""; sRow += string.Format("\"{0}\":\"{1}\",", col.Code, sVal); continue; } } // if (col.ColType == ColumnType.object_type) { string sVal = ""; if (obj.GetColValue(col) != null) { sVal = "long byte"; } sRow += string.Format("\"{0}\":\"{1}\",", col.Code, sVal); } else if (col.ColType == ColumnType.ref_type) { CTable RefTable = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(col.RefTable); if (RefTable == null) { continue; } CBaseObjectMgr objRefMgr = new CBaseObjectMgr(); objRefMgr.TbCode = RefTable.Code; objRefMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); CColumn RefCol = (CColumn)RefTable.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)RefTable.ColumnMgr.Find(col.RefShowCol); string sWhere = string.Format(" {0}=?", RefCol.Code); List <DbParameter> cmdParas = new List <DbParameter>(); cmdParas.Add(new DbParameter(RefCol.Code, obj.GetColValue(col))); List <CBaseObject> lstObj2 = objRefMgr.GetList(sWhere, cmdParas); string sVal = ""; if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; object objVal = obj2.GetColValue(RefShowCol); if (objVal != null) { sVal = objVal.ToString(); } } sRow += string.Format("\"{0}\":\"{1}\",", col.Code, sVal); } else { string sVal = ""; object objVal = obj.GetColValue(col); if (objVal != null) { sVal = objVal.ToString(); } Util.ConvertJsonSymbol(ref sVal); sRow += string.Format("\"{0}\":\"{1}\",", col.Code, sVal); } } sRow = sRow.TrimEnd(",".ToCharArray()); sRow = "{" + sRow + "},"; sData += sRow; } sData = sData.TrimEnd(",".ToCharArray()); sData = "[" + sData + "]"; string sJson = string.Format("{{\"Rows\":{0},\"Total\":\"{1}\"}}" , sData, lstObj.Count); Response.Write(sJson); }