public void AddDeptFunc(List <FuncList> lfunc, string deptid)//,string strCardType) { try { conn = ConnectionPool.BorrowConnection(); trans = conn.BeginTransaction(); SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "delete from tbDeptFunc where cnnDeptID = " + deptid);// +" and cnvcCardType='"+strCardType+"'"); for (int i = 0; i < lfunc.Count; i++) { //string strFuncCode = lfunc[i]; FuncList fl = lfunc[i] as FuncList; DeptFunc func = new DeptFunc(); func.cnnDeptID = Convert.ToInt32(deptid); func.cnvcFuncCode = fl.cnvcFuncCode; //strFuncCode; func.cnvcCardType = fl.cnvcCardType; //strCardType; EntityMapping.Create(func, trans); } trans.Commit(); } catch (BusinessException bex) //业务异常 { //LogAdapter.WriteBusinessException(bex); trans.Rollback(); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { foreach (TreeNode tnParent in treeView2.Nodes) { tnParent.Checked = false; } string strdeptsql = ""; string stropersql = ""; switch (Login.constApp.strCardType) { case "l6": strdeptsql = "select * from tbDeptFunc where cnnDeptID={0} and cnvcCardType in('l6','l6l8')"; stropersql = "select * from tbOperFunc where cnnOperID={0} and cnvcCardType in('l6','l6l8')"; break; case "l8": strdeptsql = "select * from tbDeptFunc where cnnDeptID={0} and cnvcCardType in('l8','l6l8')"; stropersql = "select * from tbOperFunc where cnnOperID={0} and cnvcCardType in('l8','l6l8')"; break; case "l6l8": strdeptsql = "select * from tbDeptFunc where cnnDeptID={0} and cnvcCardType in('l6','l8','l6l8')"; stropersql = "select * from tbOperFunc where cnnOperID={0} and cnvcCardType in('l6','l8','l6l8')"; break; } if (e.Node.Name.StartsWith("dept-")) { string deptid = e.Node.Name.Substring("dept-".Length); DataTable dt = Helper.Query(string.Format(strdeptsql, deptid));//("select * from tbDeptFunc where cnnDeptID=" + deptid+" and cnvcCardType='"+Login.constApp.strCardType+"'"); foreach (DataRow dr in dt.Rows) { DeptFunc df = new DeptFunc(dr); TreeNode[] tns = treeView2.Nodes.Find(df.cnvcFuncCode, true); if (tns.Length > 0) { for (int i = 0; i < tns.Length; i++) { tns[i].Checked = true; } } } } if (e.Node.Name.StartsWith("oper-")) { string operid = e.Node.Name.Substring("oper-".Length); DataTable dt = Helper.Query(string.Format(stropersql, operid));//("select * from tbOperFunc where cnnOperID=" + operid + " and cnvcCardType='" + Login.constApp.strCardType + "'"); foreach (DataRow dr in dt.Rows) { OperFunc of = new OperFunc(dr); TreeNode[] tns = treeView2.Nodes.Find(of.cnvcFuncCode, true); if (tns.Length > 0) { for (int i = 0; i < tns.Length; i++) { tns[i].Checked = true; } } } } }