예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            lst.Items.Add(ClsDBCon.ConStrKj);
            string    cmd = "SELECT * FROM tlogin";
            DataTable dt  = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrKj);

            dgv.DataSource          = dt;
            tabControl1.SelectedTab = tpDgv;
        }
        /// <summary>
        /// 获取给定角色的所有功能模块id
        /// </summary>
        /// <param name="aRoleId"></param>
        /// <returns></returns>
        private List <int> getFuncsList(int aRoleId)
        {
            string    cmd = "SELECT funcid FROM trolefuncs WHERE roleid = " + roleId;
            DataTable dt  = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrKj);
            //使用Linq将DataTable中的整数数据列funcid转换为一个更简洁的List<int>
            List <int> lst = (from r in dt.AsEnumerable() select r.Field <int>("funcid")).ToList <int>();

            return(lst);
        }
예제 #3
0
        private void createFuncTree()
        {
            string cmd = @"
SELECT id, mc, bm, jb,
       id0, mc0, bm0, id1, mc1, bm1, id2, mc2, bm2,
       id3, mc3, bm3, id4, mc4, bm4, id5, mc5, bm5 
FROM vfuncsa 
WHERE jb > 0
ORDER BY xh0, xh1, xh2, xh3, xh4, xh5
";

            DSjckja.vusersRow userRow = VWGContext.Current.Session["userRow"] as DSjckja.vusersRow;
            if (userRow.qx >= 1024)
            {
                string[] cmds = cmd.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                cmds[4] = string.Format(@"WHERE ID IN (SELECT funcid FROM trolefuncs where roleid={0})", userRow.roleid);
                cmd     = string.Join(Environment.NewLine, cmds);
            }
            DataTable dt = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrKj);
            TreeNode  tn, tp;

            TreeNode[] tns;
            int        jb;
            string     id;

            foreach (DataRow r in dt.Rows)
            {
                jb = Convert.ToInt32(r["jb"].ToString());
                tp = null;
                for (int i = 1; i <= jb; i++)
                {
                    id = "id" + i;
                    //按照以r[id].ToString()为名查找具有指定键的树节点,可以选择搜索子节点,返回一个list[]。
                    tns = trV.Nodes.Find(r[id].ToString(), true);
                    if (tns.Length > 0)
                    {
                        tp = tns[0];
                    }
                    else
                    {
                        tn = createANode(r, i);
                        if (tp == null)
                        {
                            trV.Nodes.Add(tn);//向trV控件添加节点
                        }
                        else
                        {
                            tp.Nodes.Add(tn);//向父节点tp中添加节点
                        }
                        tp = tn;
                    }
                }
            }
        }
예제 #4
0
        private void fillCmbRole()
        {
            string    cmd = @"
SELECT id, mc FROM troles 
ORDER BY mc";
            DataTable dt  = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrKj);

            cmbRole.DataSource    = dt;
            cmbRole.DisplayMember = "mc";
            cmbRole.ValueMember   = "id";
        }
예제 #5
0
        private void fillCmbBmlx()
        {
            string    cmd = @"
SELECT dm, mc, dmmc FROM voptionxm 
WHERE lbdm = 'bnlx'
ORDER BY dm";
            DataTable dt  = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrKj);

            cmbBmlx.DataSource    = dt;
            cmbBmlx.DisplayMember = "dmmc";
            cmbBmlx.ValueMember   = "dm";
        }
예제 #6
0
        private void createTableAndRelation()
        {
            string cmd;

            cmd               = "SELECT id AS jhdid, hj FROM vjhdhj ORDER BY jhdid";
            dtJhdHj           = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrJxc);
            dtJhdHj.TableName = "vjhdhj";
            dsJxc.Tables.Add(dtJhdHj);
            DataRelation rel;

            rel = new DataRelation("jhdhj", dtJhdHj.Columns["jhdid"], dsJxc.tjhd.idColumn);
            dsJxc.Relations.Add(rel);
            dsJxc.tjhd.hjaColumn.Expression = "Parent(jhdhj).hj";
        }
예제 #7
0
        private void fillCmbJgTree(TreeView trV)
        {
            string    cmd = @"
SELECT id, mc, jb,
       id0, mc0, id1, mc1, id2, mc2,
       id3, mc3, id4, mc4, id5, mc5 
FROM vjigoua 
WHERE jb > 0
ORDER BY xh0, xh1, xh2, xh3, xh4, xh5
";
            DataTable dt = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrKj);
            TreeNode  tn, tp;

            TreeNode[] tns;
            int        jb;
            string     idFld, mcFld;

            foreach (DataRow r in dt.Rows)
            {
                jb = Convert.ToInt32(r["jb"].ToString());
                tp = null;
                for (int i = 1; i <= jb; i++)
                {
                    idFld = "id" + i;
                    tns   = trV.Nodes.Find(r[idFld].ToString(), true);
                    if (tns.Length > 0)
                    {
                        tp = tns[0];
                    }
                    else
                    {
                        mcFld                 = "mc" + i;
                        tn                    = new TreeNode(r[idFld].ToString() + ":" + r[mcFld].ToString());
                        tn.Name               = r[idFld].ToString();
                        tn.ImageIndex         = 0;
                        tn.SelectedImageIndex = 1;
                        if (tp == null)
                        {
                            trV.Nodes.Add(tn);
                        }
                        else
                        {
                            tp.Nodes.Add(tn);
                        }
                        tp = tn;
                    }
                }
            }
        }
        private void createFuncTree()
        {
            string    cmd = @"
SELECT id, mc, bm, jb,
       id0, mc0, bm0, id1, mc1, bm1, id2, mc2, bm2,
       id3, mc3, bm3, id4, mc4, bm4, id5, mc5, bm5 
FROM vfuncsa 
WHERE jb > 0
ORDER BY xh0, xh1, xh2, xh3, xh4, xh5
";
            DataTable dt = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrKj);
            TreeNode  tn, tp;

            TreeNode[] tns;
            int        jb;
            string     id;

            foreach (DataRow r in dt.Rows)
            {
                jb = Convert.ToInt32(r["jb"].ToString());
                tp = null;
                for (int i = 1; i <= jb; i++)
                {
                    id = "id" + i;
                    //按照以r[id].ToString()为名查找具有指定键的树节点,可以选择搜索子节点,返回一个list[]。
                    tns = trV.Nodes.Find(r[id].ToString(), true);
                    if (tns.Length > 0)
                    {
                        tp = tns[0];
                    }
                    else
                    {
                        tn = createANode(r, i);
                        if (tp == null)
                        {
                            trV.Nodes.Add(tn);//向trV控件添加节点
                        }
                        else
                        {
                            tp.Nodes.Add(tn);//向父节点tp中添加节点
                        }
                    }
                }
            }
        }
예제 #9
0
        private void createTableAndRelation()
        {
            String cmd;

            cmd = "SELECT dm,mc FROM toptionxm WHERE lbdm='gwlx' ORDER BY dm";
            DataTable dtGw = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrKj);

            cmd = "SELECT dm,mc FROM toptionxm WHERE lbdm='xllx' ORDER BY dm";
            DataTable dtxl = ClsMSSQL.GetDataTable(cmd, ClsDBCon.ConStrKj);

            dSjckja1.Tables.Add(dtGw);
            dSjckja1.Tables.Add(dtxl);
            DataRelation rel;

            rel = new DataRelation("tyg_gwlx", dtGw.Columns["dm"], dSjckja1.tyg.gwColumn);
            dSjckja1.Relations.Add(rel);
            rel = new DataRelation("tyg_xllx", dtxl.Columns["dm"], dSjckja1.tyg.xlColumn);
            dSjckja1.Relations.Add(rel);
            dSjckja1.tyg.gwsColumn.Expression = "Parent(tyg_gwlx).mc";
            dSjckja1.tyg.xlsColumn.Expression = "Parent(tyg_xllx).mc";
        }