コード例 #1
0
    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);
    }
コード例 #2
0
    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);
    }
コード例 #3
0
ファイル: ViewPanel.cs プロジェクト: stonezhu870/RapidCore
        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);
                }
            }
        }
コード例 #4
0
ファイル: ViewPanel.cs プロジェクト: stonezhu870/RapidCore
        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);
                    }
                }
            }
        }
コード例 #5
0
    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);
    }
コード例 #6
0
ファイル: ViewPanel.cs プロジェクト: stonezhu870/RapidCore
        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;
        }
コード例 #7
0
    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);
    }
コード例 #8
0
        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;
        }
コード例 #9
0
ファイル: TableGrid.cs プロジェクト: zhangyunyong/RapidCore
        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);
                }
            }
        }
コード例 #10
0
ファイル: TableGrid.cs プロジェクト: zhangyunyong/RapidCore
        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++;
            }
        }
コード例 #11
0
    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);
    }