Exemple #1
0
    void GetData()
    {
        string tid = Request["tid"];

        if (string.IsNullOrEmpty(tid))
        {
            Response.End();
            return;
        }

        CTable table = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(new Guid(tid));

        if (table == null)
        {
            Response.End();
            return;
        }

        string             sData  = "";
        List <CBaseObject> lstObj = table.ColumnMgr.GetList();

        foreach (CBaseObject obj in lstObj)
        {
            CColumn col = (CColumn)obj;

            sData += string.Format("{{ \"id\": \"{0}\",\"Name\":\"{1}\", \"Code\":\"{2}\", \"ColType\":\"{3}\" }},"
                                   , col.Id, col.Name, col.Code, CColumn.ConvertColTypeToString(col.ColType));
        }
        sData = sData.TrimEnd(",".ToCharArray());
        sData = "[" + sData + "]";
        string sJson = string.Format("{{\"Rows\":{0},\"Total\":\"{1}\"}}"
                                     , sData, lstObj.Count);

        Response.Write(sJson);
    }
Exemple #2
0
    void GetData()
    {
        string             sData  = "";
        List <CBaseObject> lstObj = m_Table.ColumnMgr.GetList();

        foreach (CBaseObject obj in lstObj)
        {
            CColumn col = (CColumn)obj;
            string  sRefTableName = "", sRefColName = "", sRefShowColName = "", sEnumVal = "";
            if (col.RefTable != Guid.Empty)
            {
                CTable refTable = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Find(col.RefTable);
                if (refTable != null)
                {
                    sRefTableName = refTable.Name;
                    if (col.RefCol != Guid.Empty)
                    {
                        CColumn refCol = (CColumn)refTable.ColumnMgr.Find(col.RefCol);
                        if (refCol != null)
                        {
                            sRefColName = refCol.Name;
                        }
                        CColumn refShowCol = (CColumn)refTable.ColumnMgr.Find(col.RefShowCol);
                        if (refShowCol != null)
                        {
                            sRefShowColName = refShowCol.Name;
                        }
                    }
                }
            }
            List <CBaseObject> lstObjEV = col.ColumnEnumValMgr.GetList();
            foreach (CBaseObject objEV in lstObjEV)
            {
                CColumnEnumVal ev = (CColumnEnumVal)objEV;
                sEnumVal += ev.Val + "/";
            }
            sEnumVal = sEnumVal.TrimEnd("/".ToCharArray());

            sData += string.Format("{{ \"id\": \"{0}\",\"Name\":\"{1}\", \"Code\":\"{2}\", \"ColType\":\"{3}\", \"ColLen\":\"{4}\",\"AllowNull\":\"{5}\",\"IsSystem\":\"{6}\",\"DefaultValue\":\"{7}\",\"ColDecimal\":\"{8}\",\"Formula\":\"{9}\",\"RefTable\":\"{10}\",\"RefTableName\":\"{11}\",\"RefCol\":\"{12}\",\"RefColName\":\"{13}\",\"RefShowCol\":\"{14}\",\"RefShowColName\":\"{15}\",\"EnumVal\":\"{16}\",\"IsUnique\":\"{17}\" }},"
                                   , col.Id, col.Name, col.Code, CColumn.ConvertColTypeToString(col.ColType), col.ColLen, col.AllowNull ? 1 : 0, col.IsSystem ? 1 : 0, col.DefaultValue, col.ColDecimal, col.Formula, col.RefTable, sRefTableName, col.RefCol, sRefColName, col.RefShowCol, sRefShowColName, sEnumVal, col.IsUnique ? 1 : 0);
        }
        sData = sData.TrimEnd(",".ToCharArray());
        sData = "[" + sData + "]";
        string sJson = string.Format("{{\"Rows\":{0},\"Total\":\"{1}\"}}"
                                     , sData, 5);

        Response.Write(sJson);
    }
Exemple #3
0
        void LoadTable()
        {
            if (Table == null)
            {
                return;
            }
            dataGridView.Rows.Clear();
            List <CBaseObject> lstCol = Table.ColumnMgr.GetList();

            dataGridView.Rows.Add(lstCol.Count);
            int iRowIdx = 0;

            //系统字段
            foreach (CBaseObject obj in lstCol)
            {
                CColumn col = (CColumn)obj;
                if (!col.IsSystem)
                {
                    continue;
                }

                DataGridViewRow row = dataGridView.Rows[iRowIdx];
                row.Cells[0].Value = col.Code;
                DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)row.Cells[1];
                cbCell.Value       = CColumn.ConvertColTypeToString(col.ColType);
                row.Cells[2].Value = col.ColLen.ToString();
                DataGridViewCheckBoxCell ckCell2 = (DataGridViewCheckBoxCell)row.Cells[3];
                ckCell2.Value = col.AllowNull;
                row.ReadOnly  = true;

                row.Tag = col;
                iRowIdx++;
            }
            //自定义字段
            foreach (PO po in lstCol)
            {
                CColumn col = (CColumn)po;
                if (col.IsSystem)
                {
                    continue;
                }

                DataGridViewRow row = dataGridView.Rows[iRowIdx];
                row.Cells[0].Value = col.Code;
                DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)row.Cells[1];
                cbCell.Value       = CColumn.ConvertColTypeToString(col.ColType);
                row.Cells[2].Value = col.ColLen.ToString();
                DataGridViewCheckBoxCell ckCell2 = (DataGridViewCheckBoxCell)row.Cells[3];
                ckCell2.Value = col.AllowNull;

                //text image 类型字段不允许修改
                if (col.ColType == ColumnType.text_type ||
                    col.ColType == ColumnType.object_type)
                {
                    row.ReadOnly = true;
                }
                else
                {
                    row.ReadOnly = false;
                }

                row.Tag = col;
                iRowIdx++;
            }
            dataGridView.ClearSelection();
        }
Exemple #4
0
        void LoadList()
        {
            dataGridView.Rows.Clear();

            if (m_Table == null)  //新建
            {
                m_Table     = new CTable();
                m_Table.Ctx = Program.Ctx;
                if (Program.User != null)
                {
                    m_Table.Creator = Program.User.Id;
                    m_Table.Updator = Program.User.Id;
                }
                //m_Table.m_CmdType = CmdType.AddNew;
                Program.Ctx.TableMgr.AddNew(m_Table);
                //系统字段
                dataGridView.Rows.Add(5);
                DataGridViewRow row = dataGridView.Rows[0];
                row.Cells[0].Value = "id";
                DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)row.Cells[1];
                cbCell.Value       = "GUID";
                row.Cells[2].Value = "16";
                DataGridViewCheckBoxCell ckCell = (DataGridViewCheckBoxCell)row.Cells[3];
                ckCell.Value = false;
                DataGridViewCheckBoxCell ckCell2 = (DataGridViewCheckBoxCell)row.Cells[4];
                ckCell2.Value = true;
                DataGridViewCheckBoxCell ckCell3 = (DataGridViewCheckBoxCell)row.Cells[5];
                ckCell3.Value = true;
                row.ReadOnly  = true;
                CColumn col = new CColumn();
                col.Name      = "id";
                col.Code      = "id";
                col.ColType   = ColumnType.guid_type;
                col.ColLen    = 16;
                col.AllowNull = false;
                col.IsSystem  = true;
                col.IsUnique  = true;
                col.IsVisible = false;
                col.Idx       = 0;
                m_Table.ColumnMgr.AddNew(col);
                row.Tag = col;

                row = dataGridView.Rows[1];
                row.Cells[0].Value = "Created";
                cbCell             = (DataGridViewComboBoxCell)row.Cells[1];
                cbCell.Value       = "日期型";
                row.Cells[2].Value = "8";
                ckCell             = (DataGridViewCheckBoxCell)row.Cells[3];
                ckCell.Value       = true;
                ckCell2            = (DataGridViewCheckBoxCell)row.Cells[4];
                ckCell2.Value      = true;
                ckCell3            = (DataGridViewCheckBoxCell)row.Cells[5];
                ckCell3.Value      = false;
                row.ReadOnly       = true;
                col              = new CColumn();
                col.Name         = "创建时间";
                col.Code         = "Created";
                col.ColType      = ColumnType.datetime_type;
                col.ColLen       = 8;
                col.DefaultValue = "getdate()";
                col.AllowNull    = true;
                col.IsSystem     = true;
                col.IsUnique     = false;
                col.IsVisible    = false;
                col.Idx          = 1;
                m_Table.ColumnMgr.AddNew(col);
                row.Tag = col;

                row = dataGridView.Rows[2];
                row.Cells[0].Value = "Creator";
                cbCell             = (DataGridViewComboBoxCell)row.Cells[1];
                cbCell.Value       = "引用型";
                row.Cells[2].Value = "16";
                ckCell             = (DataGridViewCheckBoxCell)row.Cells[3];
                ckCell.Value       = true;
                ckCell2            = (DataGridViewCheckBoxCell)row.Cells[4];
                ckCell2.Value      = true;
                ckCell3            = (DataGridViewCheckBoxCell)row.Cells[5];
                ckCell3.Value      = false;
                row.ReadOnly       = true;
                col         = new CColumn();
                col.Name    = "创建者";
                col.Code    = "Creator";
                col.ColType = ColumnType.ref_type;
                CTable tableUser = (CTable)Program.Ctx.TableMgr.FindByCode("B_User");
                Guid   guidUid   = Guid.Empty;
                Guid   guidUname = Guid.Empty;
                if (tableUser != null)
                {
                    col.RefTable = tableUser.Id;
                    CColumn colUid = tableUser.ColumnMgr.FindByCode("id");
                    col.RefCol = colUid.Id;
                    guidUid    = col.RefCol;
                    CColumn colUname = tableUser.ColumnMgr.FindByCode("name");
                    col.RefShowCol = colUname.Id;
                    guidUname      = col.RefShowCol;
                }
                col.ColLen       = 16;
                col.DefaultValue = "0";
                col.AllowNull    = true;
                col.IsSystem     = true;
                col.IsUnique     = false;
                col.IsVisible    = false;
                col.Idx          = 2;
                m_Table.ColumnMgr.AddNew(col);
                row.Tag = col;

                row = dataGridView.Rows[3];
                row.Cells[0].Value = "Updated";
                cbCell             = (DataGridViewComboBoxCell)row.Cells[1];
                cbCell.Value       = "日期型";
                row.Cells[2].Value = "8";
                ckCell             = (DataGridViewCheckBoxCell)row.Cells[3];
                ckCell.Value       = true;
                ckCell2            = (DataGridViewCheckBoxCell)row.Cells[4];
                ckCell2.Value      = true;
                ckCell3            = (DataGridViewCheckBoxCell)row.Cells[5];
                ckCell3.Value      = false;
                row.ReadOnly       = true;
                col              = new CColumn();
                col.Name         = "修改时间";
                col.Code         = "Updated";
                col.ColType      = ColumnType.datetime_type;
                col.ColLen       = 8;
                col.DefaultValue = "getdate()";
                col.AllowNull    = true;
                col.IsSystem     = true;
                col.IsUnique     = false;
                col.IsVisible    = false;
                col.Idx          = 3;
                m_Table.ColumnMgr.AddNew(col);
                row.Tag = col;

                row = dataGridView.Rows[4];
                row.Cells[0].Value = "Updator";
                cbCell             = (DataGridViewComboBoxCell)row.Cells[1];
                cbCell.Value       = "引用型";
                row.Cells[2].Value = "16";
                ckCell             = (DataGridViewCheckBoxCell)row.Cells[3];
                ckCell.Value       = true;
                ckCell2            = (DataGridViewCheckBoxCell)row.Cells[4];
                ckCell2.Value      = true;
                ckCell3            = (DataGridViewCheckBoxCell)row.Cells[5];
                ckCell3.Value      = false;
                row.ReadOnly       = true;
                col         = new CColumn();
                col.Name    = "修改者";
                col.Code    = "Updator";
                col.ColType = ColumnType.ref_type;
                if (tableUser != null)
                {
                    col.RefTable   = tableUser.Id;
                    col.RefCol     = guidUid;
                    col.RefShowCol = guidUname;
                }
                col.ColLen       = 16;
                col.DefaultValue = "0";
                col.AllowNull    = true;
                col.IsSystem     = true;
                col.IsUnique     = false;
                col.IsVisible    = false;
                col.Idx          = 4;
                m_Table.ColumnMgr.AddNew(col);
                row.Tag = col;
            }
            else
            {
                //m_Table.m_CmdType = CmdType.Update;
                Program.Ctx.TableMgr.Update(m_Table);
                txtTableName.Text  = m_Table.Name;
                txtTableCode.Text  = m_Table.Code;
                ckIsSystem.Checked = m_Table.IsSystem;
                List <CBaseObject> lstCol = m_Table.ColumnMgr.GetList();

                dataGridView.Rows.Add(lstCol.Count);
                int iRowIdx = 0;
                foreach (CBaseObject obj in lstCol)
                {
                    CColumn col = (CColumn)obj;

                    DataGridViewRow row = dataGridView.Rows[iRowIdx];
                    row.Cells[0].Value = col.Code;
                    DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)row.Cells[1];
                    cbCell.Value       = CColumn.ConvertColTypeToString(col.ColType);
                    row.Cells[2].Value = col.ColLen.ToString();
                    DataGridViewCheckBoxCell ckCell = (DataGridViewCheckBoxCell)row.Cells[3];
                    ckCell.Value = col.AllowNull;
                    DataGridViewCheckBoxCell ckCell2 = (DataGridViewCheckBoxCell)row.Cells[4];
                    ckCell2.Value = col.IsSystem;
                    DataGridViewCheckBoxCell ckCell3 = (DataGridViewCheckBoxCell)row.Cells[5];
                    ckCell3.Value = col.IsUnique;

                    if (col.IsSystem)
                    {
                        row.ReadOnly = true;
                    }
                    else
                    {
                        //text image 类型字段不允许修改
                        //if (col.ColType == ColumnType.text_type
                        //    || col.ColType == ColumnType.object_type
                        //    || col.ColType == ColumnType.guid_type)
                        //    row.ReadOnly = true;
                        //else
                        row.ReadOnly = false;
                    }
                    ckCell2.ReadOnly = false;

                    iRowIdx++;
                    row.Tag = col;
                }
            }
        }