Ejemplo n.º 1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     //获得所有选中的末端树节点(即功能模块)的id列表
     funcsLst.Clear();
     foreach (TreeNode node in trV.Nodes)
     {
         getAllCheckedIds(node);
     }
     //删除当前角色的缘由的功能模块
     trolefuncsTableAdapter1 = new trolefuncsTableAdapter();
     trolefuncsTableAdapter1.DeleteQuery(roleId);
     //向trolesfuncs表中插入所有选中的功能模块id
     //方法:构造一个可插入多条记录的INSERT语句
     if (funcsLst.Count > 0)
     {
         string[] insLst = funcsLst.ConvertAll(delegate(int n) {
             string s = roleId + "," + n;
             return(ClsQ.Q0(s, '('));
         }).ToArray();
         string str = string.Join(",", insLst);
         string sql = "INSERT INTO trolefuncs (roleid, funcid) VALUES " + str;
         ClsMSSQL.ExecuteCmd(sql, ClsDBCon.ConStrKj);
     }
     this.DialogResult = DialogResult.OK;
 }
Ejemplo n.º 2
0
        private void deleting(object sender, EventArgs e)
        {
            DialogResult dr = ((Form)sender).DialogResult;

            if (dr == DialogResult.Yes)
            {
                //删除数据库中的机构记录
                string cmd  = string.Format("DELETE FROM tjigou WHERE id = {0}", trV.SelectedNode.Name);
                int    rows = ClsMSSQL.ExecuteCmd(cmd, ClsDBCon.ConStrKj);
                if (rows != 1)
                {
                    string s = string.Format("删除机构表命令影响的记录行数{0}不为1。", rows);
                    ClsMsgBox.Cw(s);
                }
                else
                {
                    //删除机构树中的结点
                    TreeNode tn = trV.SelectedNode;
                    TreeNode tm = tn.NextNode != null ? tn.NextNode :
                                  tn.PrevNode != null ? tn.PrevNode : tn.Parent;
                    trV.SelectedNode = tm;
                    if (tn.Level == 0)
                    {
                        trV.Nodes.Remove(tn);
                    }
                    else
                    {
                        tn.Parent.Nodes.Remove(tn);
                    }
                }
            }
        }