private void button4_Click(object sender, EventArgs e) { m_baseMgr = new CBaseObjectMgr(); m_baseMgr.Ctx = Program.Ctx; m_baseMgr.TbCode = "test5"; m_baseMgr.GetList(); MessageBox.Show(m_baseMgr.GetList().Count.ToString()); }
void Delete() { string delid = Request["delid"]; if (string.IsNullOrEmpty(delid)) { Response.Write("请选择记录!"); return; } CBaseObjectMgr BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(m_Table.Code, m_guidParentId); if (BaseObjectMgr == null) { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = m_Table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); string sWhere = string.Format(" id='{0}'", delid); BaseObjectMgr.GetList(sWhere); } if (!BaseObjectMgr.Delete(new Guid(delid), true)) { Response.Write("删除失败!"); return; } }
private void button2_Click(object sender, EventArgs e) { CTable tb = Program.Ctx.TableMgr.FindByCode("test5"); CColumn col = tb.ColumnMgr.FindByCode("val"); DateTime now1 = DateTime.Now; double dlbSum = 0; List <CBaseObject> lst = m_baseMgr.GetList(); //foreach (CBaseObject obj in lst) //{ // //dlbSum += obj.m_arrNewVal["val"].DoubleVal; //} int idx = lst[0].GetColIdx("val"); for (int i = 0; i < lst.Count; i++) { CBaseObject obj = lst[i]; dlbSum += obj.GetColValue2(idx).DoubleVal; } DateTime now2 = DateTime.Now; TimeSpan span = now2 - now1; string sText = string.Format("求和:{0} ,耗时:{1}", dlbSum, span.TotalSeconds); MessageBox.Show(sText); }
void Delete() { string ids = Request["ids"]; if (string.IsNullOrEmpty(ids)) { Response.Write("请选择行!"); return; } if (m_ViewAccessType != AccessType.write) { Response.Write("没有写权限!"); return; } if (m_TableAccessType != AccessType.write) { Response.Write("没有写权限!"); return; } CBaseObjectMgr BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(m_Table.Code, m_guidParentId); if (BaseObjectMgr == null) { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = m_Table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); string sWhere = string.Format(" id in ('{0}')", ids.TrimEnd(",".ToCharArray())); BaseObjectMgr.GetList(sWhere); } string[] arr = ids.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string sId in arr) { if (!BaseObjectMgr.Delete(new Guid(sId))) { Response.Write(BaseObjectMgr.Ctx.LastError); return; } } if (!BaseObjectMgr.Save(true)) { Response.Write("删除失败!"); return; } }
private void tbtEdit_Click(object sender, EventArgs e) { if (dataGridView.CurrentRow == null) { MessageBox.Show("请选择一项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } CView obj = (CView)dataGridView.CurrentRow.Tag; if (obj.VType == enumViewType.Single) { SingleViewInfo frm = new SingleViewInfo(); frm.m_View = obj; frm.m_Catalog_id = obj.UI_ViewCatalog_id; if (frm.ShowDialog() != DialogResult.OK) { return; } } else if (obj.VType == enumViewType.MasterDetail) { MasterDetailViewInfo frm = new MasterDetailViewInfo(); frm.m_View = obj; frm.m_Catalog_id = obj.UI_ViewCatalog_id; if (frm.ShowDialog() != DialogResult.OK) { return; } } else { MultMasterDetailViewInfo frm = new MultMasterDetailViewInfo(); frm.m_View = obj; frm.m_Catalog_id = obj.UI_ViewCatalog_id; if (frm.ShowDialog() != DialogResult.OK) { return; } } CBaseObjectMgr BaseObjectMgr = Program.Ctx.ViewMgr; DataGridViewRow row = dataGridView.CurrentRow; foreach (DataGridViewColumn column in dataGridView.Columns) { CColumn col = (CColumn)column.Tag; if (col.ColType == ColumnType.object_type) { if (obj.GetColValue(col) != null) { row.Cells[column.Name].Value = "long byte"; } } else if (col.ColType == ColumnType.ref_type) { CTable table = (CTable)Program.Ctx.TableMgr.Find(col.RefTable); if (table == null) { continue; } CColumn RefCol = (CColumn)table.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)table.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { row.Cells[column.Name].Value = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); } else { CBaseObjectMgr objMgr = Program.Ctx.FindBaseObjectMgrCache(table.Code, Guid.Empty); if (objMgr != null) { CBaseObject objCache = objMgr.FindByValue(RefCol, objVal); if (objCache != null) { row.Cells[column.Name].Value = objCache.GetColValue(RefShowCol); } } else { objMgr = new CBaseObjectMgr(); objMgr.TbCode = table.Code; objMgr.Ctx = Program.Ctx; 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 = objMgr.GetList(sWhere, cmdParas); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; row.Cells[column.Name].Value = obj2.GetColValue(RefShowCol); } } } } else { row.Cells[column.Name].Value = obj.GetColValue(col); } } }
private void tbtNew_Click(object sender, EventArgs e) { SelViewType frmVT = new SelViewType(); if (frmVT.ShowDialog() != DialogResult.OK) { return; } CView obj = null; if (frmVT.m_enumViewType == enumViewType.Single) { SingleViewInfo frm = new SingleViewInfo(); if (frm.ShowDialog() != DialogResult.OK) { return; } obj = frm.m_View; } else if (frmVT.m_enumViewType == enumViewType.MasterDetail) { MasterDetailViewInfo frm = new MasterDetailViewInfo(); if (frm.ShowDialog() != DialogResult.OK) { return; } obj = frm.m_View; } else { MultMasterDetailViewInfo frm = new MultMasterDetailViewInfo(); if (frm.ShowDialog() != DialogResult.OK) { return; } obj = frm.m_View; } CBaseObjectMgr BaseObjectMgr = Program.Ctx.ViewMgr; dataGridView.Rows.Add(1); DataGridViewRow row = dataGridView.Rows[dataGridView.Rows.Count - 1]; row.Tag = obj; foreach (DataGridViewColumn column in dataGridView.Columns) { CColumn col = (CColumn)column.Tag; if (col.ColType == ColumnType.object_type) { if (obj.GetColValue(col) != null) { row.Cells[column.Name].Value = "long byte"; } } else if (col.ColType == ColumnType.ref_type) { CTable table = (CTable)Program.Ctx.TableMgr.Find(col.RefTable); if (table == null) { continue; } CColumn RefCol = (CColumn)table.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)table.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { row.Cells[column.Name].Value = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); } else { CBaseObjectMgr objMgr = Program.Ctx.FindBaseObjectMgrCache(table.Code, Guid.Empty); if (objMgr != null) { CBaseObject objCache = objMgr.FindByValue(RefCol, objVal); if (objCache != null) { row.Cells[column.Name].Value = objCache.GetColValue(RefShowCol); } } else { objMgr = new CBaseObjectMgr(); objMgr.TbCode = table.Code; objMgr.Ctx = Program.Ctx; 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 = objMgr.GetList(sWhere, cmdParas); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; row.Cells[column.Name].Value = obj2.GetColValue(RefShowCol); } } } } else { row.Cells[column.Name].Value = obj.GetColValue(col); } } dataGridView.ClearSelection(); row.Selected = true; row.Cells[1].Selected = true; }
void GetDetail() { string pid = Request["pid"]; if (string.IsNullOrEmpty(pid)) { return; } 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 BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(m_Table.Code, new Guid(pid)); if (BaseObjectMgr == null) { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); CColumn colF = (CColumn)table.ColumnMgr.Find(vd.ForeignKey); if (colF == null) { return; } string sWhere0 = string.Format(" {0}='{1}'", colF.Code, pid); BaseObjectMgr.GetList(sWhere0); } List <CBaseObject> lstObj = BaseObjectMgr.GetList(); string sData = ""; 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; } CColumn RefCol = (CColumn)RefTable.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)RefTable.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); string sVal = ""; Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { object objVal2 = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } else { CBaseObjectMgr objRefMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(RefTable.Code, guidParentId); if (objRefMgr != null) { CBaseObject objCache = objRefMgr.FindByValue(RefCol, objVal); if (objCache != null) { object objVal2 = objCache.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } } else { objRefMgr = new CBaseObjectMgr(); objRefMgr.TbCode = RefTable.Code; objRefMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); 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); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; object objVal2 = obj2.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.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); }
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); }
//生成自引用树节点 List <TreeNode> SelfLoop(CTableInFormControl tiwc, string sFilter, TreeNode pnode) { List <TreeNode> lstTreeNode = new List <TreeNode>(); CTable table = (CTable)Program.Ctx.TableMgr.Find(tiwc.FW_Table_id); if (table == null) { return(lstTreeNode); } CBaseObjectMgr BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.Ctx = Program.Ctx; BaseObjectMgr.TbCode = table.Code; List <CBaseObject> lstObj = BaseObjectMgr.GetList(sFilter); foreach (CBaseObject obj in lstObj) { string sText = tiwc.Text.ToLower(); int iStart = 0; while (sText.IndexOf('[', iStart) > -1) { int idx1 = sText.IndexOf('[', iStart); int idx2 = sText.IndexOf(']', idx1); iStart = idx1 + 1; if (idx2 > idx1) { string sCodeN = sText.Substring(idx1, idx2 - idx1 + 1); string sCode = sCodeN.Substring(1, sCodeN.Length - 2); CColumn column = table.ColumnMgr.FindByCode(sCode); if (column == null) { continue; } string sVal = obj.GetColValue(column).ToString(); sText = sText.Replace(sCodeN, sVal); } } TreeNode node = new TreeNode(); node.Text = sText; node.Tag = obj; if (pnode == null) { treeView.Nodes.Add(node); } else { pnode.Nodes.Add(node); } CColumn col = (CColumn)table.ColumnMgr.Find(tiwc.NodeIDCol); CColumn pcol = (CColumn)table.ColumnMgr.Find(tiwc.PNodeIDCol); string sVal2 = obj.GetColValue(col).ToString(); if (col.ColType == ColumnType.string_type || col.ColType == ColumnType.ref_type || col.ColType == ColumnType.guid_type || col.ColType == ColumnType.datetime_type || col.ColType == ColumnType.text_type) { sVal2 = "'" + sVal2 + "'"; } string sSubFilter2 = string.Format(" {0}={1}", pcol.Code, sVal2); string sFilter2 = tiwc.QueryFilter; if (sFilter2.Trim() != "") { sFilter2 += " and "; } sFilter2 += sSubFilter2; SelfLoop(tiwc, sFilter2, node); lstTreeNode.Add(node); } return(lstTreeNode); }
protected void Page_Load(object sender, EventArgs e) { string tid = Request["tid"]; if (string.IsNullOrEmpty(tid)) { Response.Write("请选择表!"); Response.End(); } m_Table = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(new Guid(tid)); string id = Request["id"]; if (string.IsNullOrEmpty(id)) { Response.Write("请选择记录!"); Response.End(); } string ParentId = Request["ParentId"]; if (!string.IsNullOrEmpty(ParentId)) { m_guidParentId = new Guid(ParentId); } m_BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(m_Table.Code, m_guidParentId); if (m_BaseObjectMgr == null) { m_BaseObjectMgr = new CBaseObjectMgr(); m_BaseObjectMgr.TbCode = m_Table.Code; m_BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); string sWhere = string.Format(" id='{0}'", id); m_BaseObjectMgr.GetList(sWhere); } m_BaseObject = m_BaseObjectMgr.Find(new Guid(id)); if (m_BaseObject == null) { Response.Write("请选择记录!"); Response.End(); } //保存到编辑对象 EditObject.Add(Session.SessionID, m_BaseObject); if (!IsPostBack) { recordCtrl.m_Table = m_Table; //recordCtrl.m_sortRestrictColumnAccessType = m_sortRestrictColumnAccessType; recordCtrl.m_BaseObject = m_BaseObject; } if (Request.Params["Action"] == "Cancel") { m_BaseObject.Cancel(); Response.End(); } else if (Request.Params["Action"] == "PostData") { PostData(); //从编辑对象移除 EditObject.Remove(Session.SessionID, m_BaseObject); Response.End(); } }
private void tbtNew_Click(object sender, EventArgs e) { RecordWindow frm = new RecordWindow(BaseObjectMgr, null); if (frm.ShowDialog() != DialogResult.OK) { return; } CBaseObject obj = frm.BaseObject; dataGridView.Rows.Add(1); DataGridViewRow row = dataGridView.Rows[dataGridView.Rows.Count - 1]; row.Tag = obj; foreach (DataGridViewColumn column in dataGridView.Columns) { //工作流 if (column.Name.Equals("workflow")) { continue; } // CColumn col = (CColumn)column.Tag; if (col.ColType == ColumnType.object_type) { if (obj.GetColValue(col) != null) { row.Cells[column.Name].Value = "long byte"; } } else if (col.ColType == ColumnType.ref_type) { CTable table = (CTable)Program.Ctx.TableMgr.Find(col.RefTable); if (table == null) { continue; } CColumn RefCol = (CColumn)table.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)table.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { row.Cells[column.Name].Value = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); } else { CBaseObjectMgr objMgr = Program.Ctx.FindBaseObjectMgrCache(table.Code, Guid.Empty); if (objMgr != null) { CBaseObject objCache = objMgr.FindByValue(RefCol, objVal); if (objCache != null) { row.Cells[column.Name].Value = objCache.GetColValue(RefShowCol); } } else { objMgr = new CBaseObjectMgr(); objMgr.TbCode = table.Code; objMgr.Ctx = Program.Ctx; 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 = objMgr.GetList(sWhere, cmdParas); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; row.Cells[column.Name].Value = obj2.GetColValue(RefShowCol); } } } } else { row.Cells[column.Name].Value = obj.GetColValue(col); } } }
public void LoadData() { if (BaseObjectMgr == null) { return; } if (dataGridView.Columns.Count == 0) { return; } dataGridView.Rows.Clear(); List <CBaseObject> lstObj = BaseObjectMgr.GetList(); if (lstObj.Count == 0) { return; } dataGridView.Rows.Add(lstObj.Count); int nRowIdx = 0; foreach (CBaseObject obj in lstObj) { DataGridViewRow row = dataGridView.Rows[nRowIdx]; row.Tag = obj; foreach (DataGridViewColumn column in dataGridView.Columns) { //工作流 if (column.Name.Equals("workflow")) { continue; } // CColumn col = (CColumn)column.Tag; if (col.ColType == ColumnType.object_type) { if (obj.GetColValue(col) != null) { row.Cells[column.Name].Value = "long byte"; } } else if (col.ColType == ColumnType.ref_type) { CTable table = (CTable)Program.Ctx.TableMgr.Find(col.RefTable); if (table == null) { continue; } CColumn RefCol = (CColumn)table.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)table.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { row.Cells[column.Name].Value = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); } else { CBaseObjectMgr objMgr = Program.Ctx.FindBaseObjectMgrCache(table.Code, Guid.Empty); if (objMgr != null) { CBaseObject objCache = objMgr.FindByValue(RefCol, objVal); if (objCache != null) { row.Cells[column.Name].Value = objCache.GetColValue(RefShowCol); } } else { objMgr = new CBaseObjectMgr(); objMgr.TbCode = table.Code; objMgr.Ctx = Program.Ctx; 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 = objMgr.GetList(sWhere, cmdParas); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; row.Cells[column.Name].Value = obj2.GetColValue(RefShowCol); } } } } else { row.Cells[column.Name].Value = obj.GetColValue(col); } } UpdateRowWorkflow(row); nRowIdx++; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Response.Redirect("../Login.aspx"); Response.End(); } m_User = (CUser)Session["User"]; m_Company = (CCompany)Global.GetCtx(Session["TopCompany"].ToString()).CompanyMgr.Find(m_User.B_Company_id); string TbCode = Request["TbCode"]; string id = Request["id"]; if (string.IsNullOrEmpty(TbCode) || string.IsNullOrEmpty(id)) { Response.Write("数据不完整!"); Response.End(); return; } string ParentId = Request["ParentId"]; if (!string.IsNullOrEmpty(ParentId)) { m_guidParentId = new Guid(ParentId); } m_BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(TbCode, m_guidParentId); if (m_BaseObjectMgr == null) { m_BaseObjectMgr = new CBaseObjectMgr(); m_BaseObjectMgr.TbCode = TbCode; m_BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); } m_BaseObjectMgr.GetList(); m_BaseObject = m_BaseObjectMgr.Find(new Guid(id)); if (Request.Params["Action"] == "GetData") { GetData(); Response.End(); } else if (Request.Params["Action"] == "GetActivesData") { GetActivesData(); Response.End(); } else if (Request.Params["Action"] == "CancelWF") { CancelWF(); Response.End(); } else if (Request.Params["Action"] == "CanApproval") { CanApproval(); Response.End(); } }
public void LoadData() { if (dataGridView == null) { return; } if (dataGridView.Columns.Count == 0) { return; } dataGridView.Rows.Clear(); CBaseObjectMgr BaseObjectMgr = Program.Ctx.ViewMgr; List <CBaseObject> lstObj = BaseObjectMgr.GetList(); if (lstObj.Count == 0) { return; } foreach (CBaseObject obj in lstObj) { CView view = (CView)obj; if (catalog == null) { if (view.UI_ViewCatalog_id != Guid.Empty) { continue; } } else { if (view.UI_ViewCatalog_id != catalog.Id) { continue; } } dataGridView.Rows.Add(1); DataGridViewRow row = dataGridView.Rows[dataGridView.Rows.Count - 1]; row.Tag = obj; foreach (DataGridViewColumn column in dataGridView.Columns) { CColumn col = (CColumn)column.Tag; if (col.ColType == ColumnType.object_type) { if (obj.GetColValue(col) != null) { row.Cells[column.Name].Value = "long byte"; } } else if (col.ColType == ColumnType.ref_type) { CTable table = (CTable)Program.Ctx.TableMgr.Find(col.RefTable); if (table == null) { continue; } CColumn RefCol = (CColumn)table.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)table.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { row.Cells[column.Name].Value = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); } else { CBaseObjectMgr objMgr = Program.Ctx.FindBaseObjectMgrCache(table.Code, Guid.Empty); if (objMgr != null) { CBaseObject objCache = objMgr.FindByValue(RefCol, objVal); if (objCache != null) { row.Cells[column.Name].Value = objCache.GetColValue(RefShowCol); } } else { objMgr = new CBaseObjectMgr(); objMgr.TbCode = table.Code; objMgr.Ctx = Program.Ctx; 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 = objMgr.GetList(sWhere, cmdParas); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; row.Cells[column.Name].Value = obj2.GetColValue(RefShowCol); } } } } else { row.Cells[column.Name].Value = obj.GetColValue(col); } } } }
void GetData() { int page = Convert.ToInt32(Request.Params["page"]); int pageSize = Convert.ToInt32(Request.Params["pagesize"]); string sData = ""; List <CBaseObject> lstObj = m_Company.OrgMgr.GetList(); int totalPage = lstObj.Count % pageSize == 0 ? lstObj.Count / pageSize : lstObj.Count / pageSize + 1; // 计算总页数 int index = (page - 1) * pageSize; // 开始记录数 for (int i = index; i < pageSize + index && i < lstObj.Count; i++) { CBaseObject obj = (CBaseObject)lstObj[i]; string sRow = ""; foreach (CBaseObject objC in m_Table.ColumnMgr.GetList()) { CColumn col = (CColumn)objC; 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); }
void GetData() { int page = Convert.ToInt32(Request.Params["page"]); int pageSize = Convert.ToInt32(Request.Params["pagesize"]); m_iCurPage = page; m_iCurPageSize = pageSize; CBaseObjectMgr BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(m_Table.Code, m_guidParentId); if (BaseObjectMgr == null) { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = m_Table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); } string sData = ""; List <CBaseObject> lstObj; if (Request["Filter"] == null || Session["ViewFilterMgr"] == null) { lstObj = BaseObjectMgr.FilterByView(m_View); //清空过滤条件 Session["ViewFilterMgr"] = null; } else { //过滤查询 SortedList <Guid, CViewFilterMgr> sortObj = (SortedList <Guid, CViewFilterMgr>)Session["ViewFilterMgr"]; if (sortObj.ContainsKey(m_View.Id)) { CViewFilterMgr ViewFilterMgr = sortObj[m_View.Id]; lstObj = BaseObjectMgr.FilterByView(m_View, ViewFilterMgr); } else { lstObj = BaseObjectMgr.FilterByView(m_View); } } int totalPage = lstObj.Count % pageSize == 0 ? lstObj.Count / pageSize : lstObj.Count / pageSize + 1; // 计算总页数 int index = (page - 1) * pageSize; // 开始记录数 for (int i = index; i < pageSize + index && i < lstObj.Count; i++) { CBaseObject obj = (CBaseObject)lstObj[i]; string sRow = ""; foreach (CBaseObject objC in m_Table.ColumnMgr.GetList()) { CColumn col = (CColumn)objC; //判断禁止权限字段 if (m_sortRestrictColumnAccessType.ContainsKey(col.Id)) { AccessType accessType = m_sortRestrictColumnAccessType[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; } CColumn RefCol = (CColumn)RefTable.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)RefTable.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); string sVal = ""; Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { object objVal2 = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } else { CBaseObjectMgr objRefMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(RefTable.Code, guidParentId); if (objRefMgr != null) { CBaseObject objCache = objRefMgr.FindByValue(RefCol, objVal); if (objCache != null) { object objVal2 = objCache.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } } else { objRefMgr = new CBaseObjectMgr(); objRefMgr.TbCode = RefTable.Code; objRefMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); 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); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; object objVal2 = obj2.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.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); }
private void tbtNew_Click(object sender, EventArgs e) { ReportWizard frm = new ReportWizard(); Guid Catalog_id = (catalog == null)?Guid.Empty:catalog.Id; frm.m_Catalog_id = Catalog_id; frm.m_Company = Company; if (frm.ShowDialog() != DialogResult.OK) { return; } CBaseObjectMgr BaseObjectMgr = Company.ReportMgr; CReport obj = (CReport)frm.m_Report; dataGridView.Rows.Add(1); DataGridViewRow row = dataGridView.Rows[dataGridView.Rows.Count - 1]; row.Tag = obj; foreach (DataGridViewColumn column in dataGridView.Columns) { CColumn col = (CColumn)column.Tag; if (col.ColType == ColumnType.object_type) { if (obj.GetColValue(col) != null) { row.Cells[column.Name].Value = "long byte"; } } else if (col.ColType == ColumnType.ref_type) { CTable table = (CTable)Program.Ctx.TableMgr.Find(col.RefTable); if (table == null) { continue; } CColumn RefCol = (CColumn)table.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)table.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { row.Cells[column.Name].Value = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); } else { CBaseObjectMgr objMgr = Program.Ctx.FindBaseObjectMgrCache(table.Code, Guid.Empty); if (objMgr != null) { CBaseObject objCache = objMgr.FindByValue(RefCol, objVal); if (objCache != null) { row.Cells[column.Name].Value = objCache.GetColValue(RefShowCol); } } else { objMgr = new CBaseObjectMgr(); objMgr.TbCode = table.Code; objMgr.Ctx = Program.Ctx; 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 = objMgr.GetList(sWhere, cmdParas); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; row.Cells[column.Name].Value = obj2.GetColValue(RefShowCol); } } } } else { row.Cells[column.Name].Value = obj.GetColValue(col); } } dataGridView.ClearSelection(); row.Selected = true; row.Cells[1].Selected = true; }
void OutPut() { DateTime dtNow = DateTime.Now; string sNewFile = string.Format("{0}{1}{2}{3}{4}{5}.xls", dtNow.Year, dtNow.Month, dtNow.Day, dtNow.Hour, dtNow.Minute, dtNow.Second); string sDir = Server.MapPath(ConfigurationManager.AppSettings["VirtualDir"] + "/uploadfiles/"); if (!Directory.Exists(sDir)) { Directory.CreateDirectory(sDir); } string sFileSrc = Server.MapPath("templet/grid.xls"); string sFileDst = sDir + sNewFile; if (File.Exists(sFileDst)) { File.Delete(sFileDst); } File.Copy(sFileSrc, sFileDst); string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Extended Properties='Excel 8.0;HDR=YES;IMEX=0';" + "data source=" + sFileDst; OleDbConnection conn = new OleDbConnection(connStr); try { conn.Open(); } catch { return; } int page = Convert.ToInt32(Request.Params["page"]); int pageSize = Convert.ToInt32(Request.Params["pagesize"]); CBaseObjectMgr BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(m_Table.Code, m_guidParentId); if (BaseObjectMgr == null) { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = m_Table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); } List <CBaseObject> lstObj; if (Request["Filter"] == null || Session["ViewFilterMgr"] == null) { lstObj = BaseObjectMgr.FilterByView(m_View); //清空过滤条件 Session["ViewFilterMgr"] = null; } else { //过滤查询 SortedList <Guid, CViewFilterMgr> sortObj = (SortedList <Guid, CViewFilterMgr>)Session["ViewFilterMgr"]; if (sortObj.ContainsKey(m_View.Id)) { CViewFilterMgr ViewFilterMgr = sortObj[m_View.Id]; lstObj = BaseObjectMgr.FilterByView(m_View, ViewFilterMgr); } else { lstObj = BaseObjectMgr.FilterByView(m_View); } } int totalPage = lstObj.Count % pageSize == 0 ? lstObj.Count / pageSize : lstObj.Count / pageSize + 1; // 计算总页数 string sCols = ""; string sColV = ""; //创建表 string sCreate = string.Format("CREATE TABLE [{0}] (", m_Table.Name); List <CColumn> lstCols = GetColList(); SortedList <string, CColumn> sortCols = new SortedList <string, CColumn>(); foreach (CColumn col in lstCols) { sortCols.Add(col.Name, col); sCols += string.Format("[{0}],", col.Name); sColV += "?,"; sCreate += string.Format("[{0}] varchar(255),", col.Name); } sCols = sCols.TrimEnd(",".ToCharArray()); sColV = sColV.TrimEnd(",".ToCharArray()); sCreate = sCreate.TrimEnd(",".ToCharArray()); sCreate += ")"; OleDbCommand cmdC = new OleDbCommand(sCreate, conn); try { cmdC.ExecuteNonQuery(); } catch { conn.Close(); return; } int index = (page - 1) * pageSize; // 开始记录数 for (int i = index; i < pageSize + index && i < lstObj.Count; i++) { CBaseObject obj = (CBaseObject)lstObj[i]; string sIns = string.Format("insert into [{0}] ({1}) values ({2})", m_Table.Name, sCols, sColV); CCompany Company = (CCompany)Global.GetCtx(Session["TopCompany"].ToString()).CompanyMgr.Find(m_User.B_Company_id); OleDbCommand cmd = new OleDbCommand(sIns, conn); foreach (CBaseObject objC in m_Table.ColumnMgr.GetList()) { CColumn col = (CColumn)objC; if (!sortCols.ContainsKey(col.Name)) { continue; } //判断禁止权限字段 if (m_sortRestrictColumnAccessType.ContainsKey(col.Id)) { AccessType accessType = m_sortRestrictColumnAccessType[col.Id]; if (accessType == AccessType.forbide) { string sVal = ""; cmd.Parameters.Add(new OleDbParameter(col.Name, sVal)); continue; } } // if (col.ColType == ColumnType.object_type) { string sVal = ""; if (obj.GetColValue(col) != null) { sVal = "long byte"; } cmd.Parameters.Add(new OleDbParameter(col.Name, sVal)); } else if (col.ColType == ColumnType.ref_type) { CTable RefTable = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(col.RefTable); if (RefTable == null) { continue; } CColumn RefCol = (CColumn)RefTable.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)RefTable.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); string sVal = ""; Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { object objVal2 = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } else { CBaseObjectMgr objRefMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(RefTable.Code, guidParentId); if (objRefMgr != null) { CBaseObject objCache = objRefMgr.FindByValue(RefCol, objVal); if (objCache != null) { object objVal2 = objCache.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } } else { objRefMgr = new CBaseObjectMgr(); objRefMgr.TbCode = RefTable.Code; objRefMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); 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); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; object objVal2 = obj2.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } } } cmd.Parameters.Add(new OleDbParameter(col.Name, sVal)); } else { string sVal = ""; object objVal = obj.GetColValue(col); if (objVal != null) { sVal = objVal.ToString(); } //转义特殊字符 Util.ConvertJsonSymbol(ref sVal); cmd.Parameters.Add(new OleDbParameter(col.Name, sVal)); } } try { cmd.ExecuteNonQuery(); } catch { conn.Close(); return; } } conn.Close(); Response.Write(sNewFile); }
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_Table = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(m_View.FW_Table_id); //检查权限 if (!CheckAccess()) { Response.End(); } string ParentId = Request["ParentId"]; if (!string.IsNullOrEmpty(ParentId)) { m_guidParentId = new Guid(ParentId); } string id = Request["id"]; if (string.IsNullOrEmpty(id)) { Response.Write("请选择记录!"); Response.End(); } if (Session["EditMultMasterDetailViewRecord"] != null) { SortedList <Guid, CBaseObject> arrP = (SortedList <Guid, CBaseObject>)Session["EditMultMasterDetailViewRecord"]; CBaseObject objP = (CBaseObject)arrP.Values[0]; if (objP.Id.ToString() != id) { Session["EditMultMasterDetailViewRecord"] = null; } } if (Session["EditMultMasterDetailViewRecord"] == null) { CBaseObjectMgr BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(m_Table.Code, m_guidParentId); if (BaseObjectMgr == null) { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = m_Table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); string sWhere = string.Format(" id='{0}'", id); BaseObjectMgr.GetList(sWhere); } CBaseObject obj = BaseObjectMgr.Find(new Guid(id)); if (obj == null) { Response.Write("请选择记录!"); Response.End(); } SortedList <Guid, CBaseObject> arrP = new SortedList <Guid, CBaseObject>(); arrP.Add(obj.Id, obj); Session["EditMultMasterDetailViewRecord"] = arrP; } SortedList <Guid, CBaseObject> arrP2 = (SortedList <Guid, CBaseObject>)Session["EditMultMasterDetailViewRecord"]; m_BaseObject = (CBaseObject)arrP2.Values[0]; //保存到编辑对象 EditObject.Add(Session.SessionID, m_BaseObject); if (!IsPostBack) { recordCtrl.m_View = m_View; 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") { Session["EditMultMasterDetailViewRecord"] = null; m_BaseObject.Cancel(); //从编辑对象移除 EditObject.Remove(Session.SessionID, m_BaseObject); Response.End(); } else if (Request.Params["Action"] == "PostData") { PostData(); //从编辑对象移除 EditObject.Remove(Session.SessionID, m_BaseObject); Response.End(); } }
Control ColumnMapControl(CColumn col) { //自扩展类优先 if (!string.IsNullOrEmpty(col.UIControl)) { try { object obj = Activator.CreateInstance(Type.GetType(col.UIControl)); IColumnCtrl ctrl = (IColumnCtrl)obj; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return((Control)ctrl); } catch { } } switch (col.ColType) { case ColumnType.string_type: { ExTextBox ctrl = new ExTextBox(); ctrl.Width = 300; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); break; } case ColumnType.text_type: { ExTextBox ctrl = new ExTextBox(); ctrl.textBox.Multiline = true; ctrl.textBox.ScrollBars = ScrollBars.Both; ctrl.Width = 300; ctrl.Height = 100; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); break; } case ColumnType.int_type: { ExTextBox ctrl = new ExTextBox(); ctrl.Width = 300; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); break; } case ColumnType.ref_type: { ExComboBox ctrl = new ExComboBox(); ctrl.Width = 300; CTable table = (CTable)Program.Ctx.TableMgr.Find(col.RefTable); CBaseObjectMgr BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = table.Code; BaseObjectMgr.Ctx = Program.Ctx; CColumn RefCol = (CColumn)table.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)table.ColumnMgr.Find(col.RefShowCol); List <CBaseObject> lstObj = BaseObjectMgr.GetList(); foreach (CBaseObject obj in lstObj) { DataItem item = new DataItem(); item.name = obj.GetColValue(RefShowCol).ToString(); item.Data = obj.GetColValue(RefCol); ctrl.comboBox.Items.Add(item); } ctrl.comboBox.DropDownStyle = ComboBoxStyle.DropDownList; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); break; } case ColumnType.enum_type: { ExComboBox ctrl = new ExComboBox(); ctrl.Width = 300; //引用显示字段优先 if (col.RefShowCol != Guid.Empty) { CTable table = (CTable)Program.Ctx.TableMgr.Find(col.RefTable); CBaseObjectMgr BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = table.Code; BaseObjectMgr.Ctx = Program.Ctx; CColumn RefShowCol = (CColumn)table.ColumnMgr.Find(col.RefShowCol); List <CBaseObject> lstObj = BaseObjectMgr.GetList(); foreach (CBaseObject obj in lstObj) { DataItem item = new DataItem(); item.name = obj.GetColValue(RefShowCol).ToString(); ctrl.comboBox.Items.Add(item); } } else { List <CBaseObject> lstObj = col.ColumnEnumValMgr.GetList(); foreach (CBaseObject obj in lstObj) { CColumnEnumVal cev = (CColumnEnumVal)obj; DataItem item = new DataItem(); item.name = cev.Val; item.Data = cev.Val; ctrl.comboBox.Items.Add(item); } } ctrl.comboBox.DropDownStyle = ComboBoxStyle.DropDown; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); break; } case ColumnType.long_type: { ExTextBox ctrl = new ExTextBox(); ctrl.Width = 300; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); } case ColumnType.bool_type: { ExCheckBox ctrl = new ExCheckBox(); ctrl.Width = 300; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); break; } case ColumnType.numeric_type: { ExTextBox ctrl = new ExTextBox(); ctrl.Width = 300; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); break; } case ColumnType.datetime_type: { ExDateTimePicker ctrl = new ExDateTimePicker(); ctrl.Width = 300; ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); break; } case ColumnType.object_type: { BinaryCtrl ctrl = new BinaryCtrl(); ctrl.SetCaption(col.Name + ":"); if (BaseObject != null) { ctrl.SetValue(BaseObject.GetColValue(col)); } return(ctrl); break; } } return(new ExTextBox()); }
void GetData() { int page = Convert.ToInt32(Request.Params["page"]); int pageSize = Convert.ToInt32(Request.Params["pagesize"]); string catalog_id = Request["catalog_id"]; string sData = ""; List <CBaseObject> lstObj = new List <CBaseObject>(); CBaseObjectMgr BaseObjectMgr = m_Company.ReportMgr; List <CBaseObject> lstRpt = BaseObjectMgr.GetList(); foreach (CBaseObject objRpt in lstRpt) { CReport Report = (CReport)objRpt; if (!string.IsNullOrEmpty(catalog_id)) { Guid guid = new Guid(catalog_id); if (Report.RPT_ReportCatalog_id == guid) { lstObj.Add(Report); } } else { //所有目录不存在的都放置根目录 CBaseObject objCatalog = m_Company.ReportCatalogMgr.Find(Report.RPT_ReportCatalog_id); if (objCatalog == null) { lstObj.Add(Report); } } } int totalPage = lstObj.Count % pageSize == 0 ? lstObj.Count / pageSize : lstObj.Count / pageSize + 1; // 计算总页数 int index = (page - 1) * pageSize; // 开始记录数 for (int i = index; i < pageSize + index && i < lstObj.Count; i++) { CBaseObject obj = (CBaseObject)lstObj[i]; string sRow = ""; foreach (CBaseObject objC in m_Table.ColumnMgr.GetList()) { CColumn col = (CColumn)objC; 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; } CColumn RefCol = (CColumn)RefTable.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)RefTable.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); string sVal = ""; Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && BaseObjectMgr.m_Parent.Id == (Guid)objVal) { object objVal2 = BaseObjectMgr.m_Parent.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } else { CBaseObjectMgr objRefMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(RefTable.Code, guidParentId); if (objRefMgr != null) { CBaseObject objCache = objRefMgr.FindByValue(RefCol, objVal); if (objCache != null) { object objVal2 = objCache.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } } else { objRefMgr = new CBaseObjectMgr(); objRefMgr.TbCode = RefTable.Code; objRefMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); 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); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; object objVal2 = obj2.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.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); }
void LoopTreeNode(int iLevel, List <CBaseObject> lstTIWC, TreeNode pnode) { if (iLevel >= lstTIWC.Count) { return; } CTableInFormControl tiwc = (CTableInFormControl)lstTIWC[iLevel]; CTable table = (CTable)Program.Ctx.TableMgr.Find(tiwc.FW_Table_id); if (table == null) { return; } if (!tiwc.IsLoop) { CBaseObjectMgr BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.Ctx = Program.Ctx; BaseObjectMgr.TbCode = table.Code; List <CBaseObject> lstObj = BaseObjectMgr.GetList(tiwc.QueryFilter); foreach (CBaseObject obj in lstObj) { string sText = tiwc.Text.ToLower(); int iStart = 0; while (sText.IndexOf('[', iStart) > -1) { int idx1 = sText.IndexOf('[', iStart); int idx2 = sText.IndexOf(']', idx1); iStart = idx1 + 1; if (idx2 > idx1) { string sCodeN = sText.Substring(idx1, idx2 - idx1 + 1); string sCode = sCodeN.Substring(1, sCodeN.Length - 2); CColumn column = table.ColumnMgr.FindByCode(sCode); if (column == null) { continue; } string sVal = obj.GetColValue(column).ToString(); sText = sText.Replace(sCodeN, sVal); } } TreeNode node = new TreeNode(); node.Text = sText; node.Tag = obj; if (pnode == null) { treeView.Nodes.Add(node); } else { pnode.Nodes.Add(node); } LoopTreeNode(iLevel + 1, lstTIWC, node); } } else { string sFilter = tiwc.QueryFilter; if (sFilter.Trim() != "") { sFilter += " and "; } sFilter += tiwc.RootFilter; List <TreeNode> lstTreeNode = SelfLoop(tiwc, sFilter, pnode); foreach (TreeNode node in lstTreeNode) { LoopTreeNode(iLevel + 1, lstTIWC, node); } } }
void GetData() { string sData = ""; CBaseObjectMgr BaseObjectMgr = m_BaseObjectMgr; List <CBaseObject> lstObj = BaseObjectMgr.GetList(); foreach (CBaseObject obj in lstObj) { string sRow = ""; foreach (CBaseObject objC in m_Table.ColumnMgr.GetList()) { CColumn col = (CColumn)objC; //判断禁止权限字段 if (m_sortRestrictColumnAccessType.ContainsKey(col.Id)) { AccessType accessType = m_sortRestrictColumnAccessType[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; } CColumn RefCol = (CColumn)RefTable.ColumnMgr.Find(col.RefCol); CColumn RefShowCol = (CColumn)RefTable.ColumnMgr.Find(col.RefShowCol); object objVal = obj.GetColValue(col); Guid guidParentId = Guid.Empty; if (BaseObjectMgr.m_Parent != null && col.Code.Equals(BaseObjectMgr.m_Parent.TbCode + "_id", StringComparison.OrdinalIgnoreCase)) { guidParentId = BaseObjectMgr.m_Parent.Id; } CBaseObjectMgr objRefMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(RefTable.Code, guidParentId); string sVal = ""; if (objRefMgr != null) { CBaseObject objCache = objRefMgr.FindByValue(RefCol, objVal); if (objCache != null) { object objVal2 = objCache.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.ToString(); } } } else { objRefMgr = new CBaseObjectMgr(); objRefMgr.TbCode = RefTable.Code; objRefMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); 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); if (lstObj2.Count > 0) { CBaseObject obj2 = lstObj2[0]; object objVal2 = obj2.GetColValue(RefShowCol); if (objVal2 != null) { sVal = objVal2.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); }
//唯一性字段判断 bool IsUniqueValue(CColumn col, string val) { if (col.ColType == ColumnType.string_type || col.ColType == ColumnType.text_type || col.ColType == ColumnType.path_type) { CBaseObjectMgr BaseObjectMgr = m_BaseObjectMgr; if (BaseObjectMgr != null) { List <CBaseObject> lstObj = BaseObjectMgr.GetList(); var varObj = from obj in lstObj where obj.Id != m_BaseObject.Id && obj.m_arrNewVal[col.Code.ToLower()].StrVal.EndsWith(val, StringComparison.OrdinalIgnoreCase) select obj; if (varObj.Count() > 0) { return(false); } } else { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = m_Table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); string sWhere = string.Format(" [id]<>'{0}' and [{1}]='{2}'", m_BaseObject.Id, col.Code, val); List <CBaseObject> lstObj = BaseObjectMgr.GetList(sWhere); if (lstObj.Count > 0) { return(false); } } } else if (col.ColType == ColumnType.datetime_type) { CBaseObjectMgr BaseObjectMgr = m_BaseObjectMgr; if (BaseObjectMgr != null) { List <CBaseObject> lstObj = BaseObjectMgr.GetList(); var varObj = from obj in lstObj where obj.Id != m_BaseObject.Id && obj.m_arrNewVal[col.Code.ToLower()].DatetimeVal == DateTime.Parse(val) select obj; if (varObj.Count() > 0) { return(false); } } else { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = m_Table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); string sWhere = string.Format(" [id]<>'{0}' and [{1}]='{2}'", m_BaseObject.Id, col.Code, val); List <CBaseObject> lstObj = BaseObjectMgr.GetList(sWhere); if (lstObj.Count > 0) { return(false); } } } else if (col.ColType == ColumnType.int_type || col.ColType == ColumnType.long_type || col.ColType == ColumnType.numeric_type) { CBaseObjectMgr BaseObjectMgr = m_BaseObjectMgr; if (BaseObjectMgr != null) { List <CBaseObject> lstObj = BaseObjectMgr.GetList(); if (col.ColType == ColumnType.int_type) { var varObj = from obj in lstObj where obj.Id != m_BaseObject.Id && obj.m_arrNewVal[col.Code.ToLower()].IntVal == Convert.ToInt32(val) select obj; if (varObj.Count() > 0) { return(false); } } else if (col.ColType == ColumnType.long_type) { var varObj = from obj in lstObj where obj.Id != m_BaseObject.Id && obj.m_arrNewVal[col.Code.ToLower()].LongVal == Convert.ToInt64(val) select obj; if (varObj.Count() > 0) { return(false); } } else { var varObj = from obj in lstObj where obj.Id != m_BaseObject.Id && obj.m_arrNewVal[col.Code.ToLower()].DoubleVal == Convert.ToDouble(val) select obj; if (varObj.Count() > 0) { return(false); } } } else { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = m_Table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); string sWhere = string.Format(" [id]<>'{0}' and [{1}]={2}", m_BaseObject.Id, col.Code, val); List <CBaseObject> lstObj = BaseObjectMgr.GetList(sWhere); if (lstObj.Count > 0) { return(false); } } } else if (col.ColType == ColumnType.guid_type || col.ColType == ColumnType.ref_type) { CBaseObjectMgr BaseObjectMgr = m_BaseObjectMgr; if (BaseObjectMgr != null) { List <CBaseObject> lstObj = BaseObjectMgr.GetList(); var varObj = from obj in lstObj where obj.Id != m_BaseObject.Id && obj.m_arrNewVal[col.Code.ToLower()].GuidVal == new Guid(val) select obj; if (varObj.Count() > 0) { return(false); } } else { BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.TbCode = m_Table.Code; BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); string sWhere = string.Format(" [id]<>'{0}' and [{1}]='{2}'", m_BaseObject.Id, col.Code, val); List <CBaseObject> lstObj = BaseObjectMgr.GetList(sWhere); if (lstObj.Count > 0) { return(false); } } } return(true); }
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_Table = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(m_View.FW_Table_id); //检查权限 if (!CheckAccess()) { Response.End(); } string ParentId = Request["ParentId"]; if (!string.IsNullOrEmpty(ParentId)) { m_guidParentId = new Guid(ParentId); } string id = Request["id"]; if (string.IsNullOrEmpty(id)) { Response.Write("请选择记录!"); Response.End(); } m_BaseObjectMgr = Global.GetCtx(Session["TopCompany"].ToString()).FindBaseObjectMgrCache(m_Table.Code, m_guidParentId); if (m_BaseObjectMgr == null) { m_BaseObjectMgr = new CBaseObjectMgr(); m_BaseObjectMgr.TbCode = m_Table.Code; m_BaseObjectMgr.Ctx = Global.GetCtx(Session["TopCompany"].ToString()); string sWhere = string.Format(" id='{0}'", id); m_BaseObjectMgr.GetList(sWhere); } m_BaseObject = m_BaseObjectMgr.Find(new Guid(id)); if (m_BaseObject == null) { Response.Write("请选择记录!"); Response.End(); } //保存到编辑对象 EditObject.Add(Session.SessionID, m_BaseObject); if (!IsPostBack) { recordCtrl.m_View = m_View; 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"]); } } if (Request.Params["Action"] == "Cancel") { m_BaseObject.Cancel(); Response.End(); } else if (Request.Params["Action"] == "PostData") { PostData(); //从编辑对象移除 EditObject.Remove(Session.SessionID, m_BaseObject); Response.End(); } }