Esempio n. 1
0
        /// <summary>
        /// 点中父类,展开子类
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void TreeView2_SelectedNodeChanged(object sender, EventArgs e)
        {
            //点击根节点
            if (TreeView2.SelectedValue.Substring(2, 4).Equals("0000"))
            {
                TreeView2.CollapseAll();
                TreeView2.SelectedNode.Expanded = true;
                return;
            }
            //当前用户当前菜单功能分配
            gongneng mGongneng = new gongneng();
            string   pBianhao  = TreeView2.SelectedValue;

            mGongneng.Daihao   = yonghuLabel.Text;
            mGongneng.Yingyong = RadioButtonList_Yingyong.SelectedValue.ToString();
            mGongneng.Bianhao  = TreeView2.SelectedValue;
            DataTable dt = bGongneng.getGongneng_Bianhao(mGongneng);

            if (dt.Rows.Count < 1)
            {
                return;
            }

            for (int i = 0; i < 10; i++)
            {
                if (dt.Rows[0]["canshu" + i.ToString()].ToString().Equals("1"))
                {
                    CheckBoxList_canshu.Items[i].Selected = true;
                }
                else
                {
                    CheckBoxList_canshu.Items[i].Selected = false;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 取父节点下子节点的数据,进行删除!
        /// </summary>
        /// <param name="tn"></param>
        /// <param name="mGongneng"></param>
        protected void getChildNodevalue(TreeNode tn, gongneng mGongneng)
        {
            for (int i = 0; i < tn.ChildNodes.Count; i++)
            {
                if (tn.ChildNodes[i].Checked)
                {
                    mGongneng.Xuhao     = tn.ChildNodes[i].Value.ToString();
                    mGongneng.Bianhao   = tn.ChildNodes[i].Value.ToString();
                    mGongneng.Mingcheng = tn.ChildNodes[i].Text.ToString();

                    if (checkgongnengcanshu(mGongneng) == 1)
                    {
                        //如果没有功能则直接删除数据库当中的对应列
                        result = bGongneng.DelGongneng(mGongneng);
                        if (result.ReturnInt < 0)
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "<script>alert('用户功能权限分配失败,请联系管理员!')</script>", false);
                            break;
                        }
                    }
                    else
                    {
                        //如果有功能权限,则先删在增加
                        result = bGongneng.DelGongneng(mGongneng);
                        result = bGongneng.InsertGongneng(mGongneng);

                        if (result.ReturnInt < 0)
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "<script>alert('用户功能权限分配失败,请联系管理员!')</script>", false);
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 ///  判断功能是否存在
 /// </summary>
 /// <param name="mGongneng"></param>
 /// <returns></returns>
 protected int checkgongnengcanshu(gongneng mGongneng)
 {
     if (mGongneng.Canshu0 == "0")
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 查看用户功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RadioButtonList_shouquan_SelectedIndexChanged(object sender, EventArgs e)
        {
            gongneng mGongneng = new gongneng();

            mGongneng.Daihao   = yonghuLabel.Text;
            mGongneng.Yingyong = RadioButtonList_Yingyong.SelectedValue;
            mGongneng.Canshu0  = RadioButtonList_shouquan.SelectedValue;
            DataTable dt = bGongneng.getGongneng_Yonghu(mGongneng);

            dt.PrimaryKey = new DataColumn[] { dt.Columns["bianhao"] };
            TreeView2.Nodes.Clear();
            getCaidanTree(dt, TreeView2, null);
        }
Esempio n. 5
0
        /// <summary>
        /// 获取用户功能菜单
        /// </summary>
        /// <param name="pYonghu">用户代号</param>
        /// <param name="pCanshu">参数</param>
        /// <returns>返回DataTable</returns>
        public DataTable getGongneng_Yonghu(gongneng mGongneng)
        {
            string sql = "select *,left(bianhao,2)+'0000' fuxuhao from gongneng a where a.daihao=@daihao and yingyong=@yingyong and a.canshu0=@canshu order by a.xuhao ;";

            SqlParameter[] param = new SqlParameter[] { new SqlParameter("@daihao", SqlDbType.VarChar, 20),
                                                        new SqlParameter("@yingyong", SqlDbType.VarChar, 20),
                                                        new SqlParameter("@canshu", SqlDbType.VarChar, 1) };
            param[0].Value = mGongneng.Daihao;
            param[1].Value = mGongneng.Yingyong;
            param[2].Value = mGongneng.Canshu0;
            DataTable dt = SQLHelper.ExecuteDt(base.User_Admin, sql, param);

            return(dt);
        }
Esempio n. 6
0
        /// <summary>
        /// 获取用户功能
        /// </summary>
        /// <param name="pYonghu">用户代号</param>
        /// <param name="pBianhao">菜单编号</param>
        /// <returns>DataTable</returns>
        public DataTable getGongneng_Bianhao(gongneng mGongneng)
        {
            string sql = "select * from gongneng where daihao=@daihao and yingyong=@yingyong and bianhao=@bianhao; ";

            SqlParameter[] param = new SqlParameter[] { new SqlParameter("@daihao", SqlDbType.VarChar, 20),
                                                        new SqlParameter("@yingyong", SqlDbType.VarChar, 20),
                                                        new SqlParameter("@bianhao", SqlDbType.VarChar, 6) };
            param[0].Value = mGongneng.Daihao;
            param[1].Value = mGongneng.Yingyong;
            param[2].Value = mGongneng.Bianhao;
            DataTable dt = SQLHelper.ExecuteDt(base.User_Admin, sql, param);

            return(dt);
        }
Esempio n. 7
0
        /// <summary>
        /// 删除功能
        /// </summary>
        /// <param name="mGongneng"></param>
        /// <returns></returns>
        public xt_result DelGongneng(gongneng mGongneng)
        {
            string sql = "delete from gongneng where daihao=@daihao and yingyong=@yingyong and  bianhao=@bianhao ";

            SqlParameter[] param = new SqlParameter[] { new SqlParameter("@daihao", SqlDbType.VarChar, 20),
                                                        new SqlParameter("@yingyong", SqlDbType.VarChar, 20),
                                                        new SqlParameter("@bianhao", SqlDbType.VarChar, 6) };
            param[0].Value = mGongneng.Daihao;
            param[1].Value = mGongneng.Yingyong;
            param[2].Value = mGongneng.Bianhao;
            xt_result result = new xt_result();

            result.ReturnInt = SQLHelper.ExecuteNonQuery(base.User_Admin, sql, param);
            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// 插入功能
        /// </summary>
        /// <param name="mXt_gongneng"></param>
        /// <returns></returns>
        public xt_result InsertGongneng(gongneng mGongneng)
        {
            string sql = "insert into  gongneng values (@daihao,@yingyong,@bianhao,@xuhao,@mingcheng,@canshu0,@canshu1,@canshu2,@canshu3,@canshu4,@canshu5,@canshu6,@canshu7,@canshu8,@canshu9 )";

            SqlParameter[] param = new SqlParameter[] { new SqlParameter("@daihao", SqlDbType.NVarChar, 20),
                                                        new SqlParameter("@yingyong", SqlDbType.NVarChar, 20),
                                                        new SqlParameter("@bianhao", SqlDbType.NVarChar, 6),
                                                        new SqlParameter("@xuhao", SqlDbType.NVarChar, 6),
                                                        new SqlParameter("@mingcheng", SqlDbType.NVarChar, 10),
                                                        new SqlParameter("@canshu0", SqlDbType.NVarChar, 1),
                                                        new SqlParameter("@canshu1", SqlDbType.NVarChar, 1),
                                                        new SqlParameter("@canshu2", SqlDbType.NVarChar, 1),
                                                        new SqlParameter("@canshu3", SqlDbType.NVarChar, 1),
                                                        new SqlParameter("@canshu4", SqlDbType.NVarChar, 1),
                                                        new SqlParameter("@canshu5", SqlDbType.NVarChar, 1),
                                                        new SqlParameter("@canshu6", SqlDbType.NVarChar, 1),
                                                        new SqlParameter("@canshu7", SqlDbType.NVarChar, 1),
                                                        new SqlParameter("@canshu8", SqlDbType.NVarChar, 1),
                                                        new SqlParameter("@canshu9", SqlDbType.NVarChar, 1) };

            param[0].Value  = mGongneng.Daihao;
            param[1].Value  = mGongneng.Yingyong;
            param[2].Value  = mGongneng.Bianhao;
            param[3].Value  = mGongneng.Xuhao;
            param[4].Value  = mGongneng.Mingcheng;
            param[5].Value  = mGongneng.Canshu0;
            param[6].Value  = mGongneng.Canshu1;
            param[7].Value  = mGongneng.Canshu2;
            param[8].Value  = mGongneng.Canshu3;
            param[9].Value  = mGongneng.Canshu4;
            param[10].Value = mGongneng.Canshu5;
            param[11].Value = mGongneng.Canshu6;
            param[12].Value = mGongneng.Canshu7;
            param[13].Value = mGongneng.Canshu8;
            param[14].Value = mGongneng.Canshu9;

            //开始事务
            xt_result      result = new xt_result();
            SqlTransaction Trans;
            SqlConnection  conn = SQLHelper.CreateConnection(base.User_Admin);

            conn.Open();
            Trans = conn.BeginTransaction("trans1");
            try
            {
                result.ReturnInt = SQLHelper.ExecuteNonQuery(Trans, CommandType.Text, sql, param);
                if (result.ReturnInt > 0)
                {
                    Trans.Commit();
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.Message = result.Message.Replace("\r\n", "\\n");
                result.Message = result.Message.Replace("'", "");
                Trans.Rollback();
            }
            finally
            {
                conn.Close();
            }
            return(result);
        }
Esempio n. 9
0
 /// <summary>
 /// 获取用户功能菜单
 /// </summary>
 /// <param name="pYonghu">用户代号</param>
 /// <param name="pCanshu">参数</param>
 /// <returns>返回DataTable</returns>
 public DataTable getGongneng_Yonghu(gongneng mGongneng)
 {
     return(bGongneng.getGongneng_Yonghu(mGongneng));
 }
Esempio n. 10
0
 /// <summary>
 /// 获取用户功能
 /// </summary>
 /// <param name="pYonghu">用户代号</param>
 /// <param name="pBianhao">菜单编号</param>
 /// <returns>DataTable</returns>
 public DataTable getGongneng_Bianhao(gongneng mGongneng)
 {
     return(bGongneng.getGongneng_Bianhao(mGongneng));
 }
Esempio n. 11
0
 /// <summary>
 /// 插入功能
 /// </summary>
 /// <param name="mXt_gongneng"></param>
 /// <returns></returns>
 public xt_result InsertGongneng(gongneng mGongneng)
 {
     return(bGongneng.InsertGongneng(mGongneng));
 }
Esempio n. 12
0
 /// <summary>
 /// 删除功能
 /// </summary>
 /// <param name="mGongneng"></param>
 /// <returns></returns>
 public xt_result DelGongneng(gongneng mGongneng)
 {
     return(bGongneng.DelGongneng(mGongneng));
 }
Esempio n. 13
0
        protected void Button_save_Click(object sender, EventArgs e)
        {
            gongneng mGongneng = new gongneng();

            mGongneng.Yingyong = RadioButtonList_Yingyong.SelectedValue;
            string pCanshu;

            // 取参数
            for (int j = 0; j < CheckBoxList_canshu.Items.Count; j++)
            {
                if (CheckBoxList_canshu.Items[j].Selected)
                {
                    pCanshu = "1";
                }
                else
                {
                    pCanshu = "0";
                }

                switch (j)
                {
                case 0:
                    mGongneng.Canshu0 = pCanshu;
                    break;

                case 1:
                    mGongneng.Canshu1 = pCanshu;
                    break;

                case 2:
                    mGongneng.Canshu2 = pCanshu;
                    break;

                case 3:
                    mGongneng.Canshu3 = pCanshu;
                    break;

                case 4:
                    mGongneng.Canshu4 = pCanshu;
                    break;

                case 5:
                    mGongneng.Canshu5 = pCanshu;
                    break;

                case 6:
                    mGongneng.Canshu6 = pCanshu;
                    break;

                case 7:
                    mGongneng.Canshu7 = pCanshu;
                    break;

                case 8:
                    mGongneng.Canshu8 = pCanshu;
                    break;

                case 9:
                    mGongneng.Canshu9 = pCanshu;
                    break;
                }
            }

            //   循环取treeview3 父节点的数据
            for (int j = 0; j < TreeView3.Nodes.Count; j++)
            {
                if (TreeView3.Nodes[j].Checked)
                {
                    mGongneng.Daihao = TreeView3.Nodes[j].Value.ToString();

                    for (int i = 0; i < TreeView1.Nodes.Count; i++)
                    {
                        if (TreeView1.Nodes[i].Checked)
                        {
                            mGongneng.Xuhao     = TreeView1.Nodes[i].Value.ToString();
                            mGongneng.Bianhao   = TreeView1.Nodes[i].Value.ToString();
                            mGongneng.Mingcheng = TreeView1.Nodes[i].Text.ToString();
                            if (checkgongnengcanshu(mGongneng) == 1)
                            {
                                result = bGongneng.DelGongneng(mGongneng);
                                if (result.ReturnInt < 0)
                                {
                                    ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "<script>alert('用户功能权限分配失败,请联系管理员!')</script>", false);
                                    break;
                                }
                            }
                            else
                            {
                                result = bGongneng.DelGongneng(mGongneng);
                                result = bGongneng.InsertGongneng(mGongneng);
                            }
                            // 循环取父节点 下子节点的数据
                            getChildNodevalue(TreeView1.Nodes[i], mGongneng);
                        }
                        else
                        {
                            // 在不经过父节点的情况下  取子节点数据
                            getChildNodevalue(TreeView1.Nodes[i], mGongneng);
                        }
                    }
                }
            }
            ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "<script>alert('用户功能权限分配成功!')</script>", false);
        }