public DataTable QuerySwitch(QueryType QT, ArrayList ParameterList ) { DBO.SYS_USERPROGAUTHRELDBO RoleProgauthrel = new SYS_USERPROGAUTHRELDBO(ref USEDB); DataTable Dt; try { switch (QT) { case QueryType.ALL: Dt = RoleProgauthrel.doQueryAll(); break; case QueryType.CODE: Dt = RoleProgauthrel.doQueryByCode(ParameterList); break; case QueryType.ID: Dt = RoleProgauthrel.doQueryByID(ParameterList); break; case QueryType.Custom: Dt = RoleProgauthrel.doQueryByFind(ParameterList); break; default: Dt = new DataTable(); break; } return Dt; } catch (Exception ex) { throw ex; } }
public DataTable QueryRow(ArrayList ParameterList, bool likeSearch) { try { DBO.SYS_USERPROGAUTHRELDBO Program = new SYS_USERPROGAUTHRELDBO(ref USEDB); if (likeSearch) { ParameterList[0] = ParameterList[0] + "%"; //code ParameterList[1] = ParameterList[1] + "%"; //name ParameterList[2] = ParameterList[2]; //createdate_s ParameterList[3] = ParameterList[3]; //createdate_e ParameterList[4] = ParameterList[4] + "%"; //createuid ParameterList[5] = ParameterList[5]; //updatedate_s ParameterList[6] = ParameterList[6]; //updatedate_e ParameterList[7] = ParameterList[7] + "%"; //updateuid ParameterList[8] = ParameterList[8] + "%"; //UserCode ParameterList[9] = ParameterList[9] + "%"; //ProgramCode ParameterList[10] = ParameterList[10] + "%"; //SystemCode ParameterList[11] = ParameterList[11] + "%"; //CanCreate ParameterList[12] = ParameterList[12] + "%"; //CanDelete ParameterList[13] = ParameterList[13] + "%"; //CanRead ParameterList[14] = ParameterList[14] + "%"; //CanUpdate ParameterList[15] = ParameterList[15] + "%"; //ENABLE ParameterList[16] = ParameterList[16]; //rownum } return Program.QueryRow(ParameterList); } catch (Exception ex) { throw ex; } }
public DataTable QueryUserprogauthrelByALL() { try { DBO.SYS_USERPROGAUTHRELDBO RoleProgauthrel = new SYS_USERPROGAUTHRELDBO(ref USEDB); return RoleProgauthrel.doQueryAll(); } catch (Exception ex) { throw ex; } }
/// <summary> /// 測試多BCO呼叫 /// </summary> /// <param name="ParameterList">變數</param> /// <param name="RootDBT">是否有主交易,無主交易輸入null</param> public void TestParentTranscation(ArrayList ParameterList, DbTransaction RootDBT ) { bool IsRootTranscation = false; try { DBO.SYS_USERPROGAUTHRELDBO RoleProgauthrel = new SYS_USERPROGAUTHRELDBO(ref USEDB); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion CreateUserprogauthrel(ParameterList, DBT); CreateUserprogauthrel(ParameterList, DBT); #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion throw ex; } finally { #region 判斷是否關閉交易連線 if (IsRootTranscation) { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } #endregion } }
/// <summary> /// 基本表單新增BCO /// </summary> /// <param name="DetailData">輸入變數</param> /// <param name="RootDBT">是否有主交易,無主交易輸入null</param> /// <returns>回傳異動筆數</returns> public int CreateDetail(ArrayList ParameterList, DataRow dRow, DbTransaction RootDBT) { bool IsRootTranscation = false; Int32 iResult = 0; string s_Log_User = string.Empty; DateTime d_Now; try { DBO.SYS_USERPROGAUTHRELDBO dbo = new SYS_USERPROGAUTHRELDBO(ref USEDB); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion d_Now = DateTime.Now; s_Log_User = ParameterList[1].ToString(); iResult = dbo.doCreate(DBT, dRow, ParameterList, s_Log_User, d_Now); #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion return iResult; } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion throw ex; } finally { #region 判斷是否關閉交易連線 if (IsRootTranscation) { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } #endregion } }
public int UpdateProgramList(ArrayList ParameterList, DbTransaction RootDBT ) { bool IsRootTranscation = false; try { //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion DBO.SYS_USERPROGAUTHRELDBO programlist = new SYS_USERPROGAUTHRELDBO(ref USEDB); int result = programlist.doUpdateProgramList(ParameterList, DBT); #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } return result; #endregion } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion throw ex; } finally { #region 判斷是否關閉交易連線 if (IsRootTranscation) { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } #endregion } }
public DataTable QueryProgramHierarchyByUser(ArrayList ParameterList) { try { DBO.SYS_USERPROGAUTHRELDBO UserProgauthrel = new SYS_USERPROGAUTHRELDBO(ref USEDB); ParameterList[0] = ParameterList[0]; //user ParameterList[1] = ParameterList[1];//code return UserProgauthrel.doQueryProgramHierarchyByUser(ParameterList); } catch (Exception ex) { throw ex; } }
/// <summary> /// 抓取使用者及角色程式權限 /// </summary> /// <param name="ParameterList">輸入變數</param> /// <returns>回傳CRUD權限</returns> public DataTable QueryPermissionByUser(ArrayList ParameterList) { try { DBO.SYS_USERPROGAUTHRELDBO UserProgauthrel = new SYS_USERPROGAUTHRELDBO(ref USEDB); return UserProgauthrel.doQueryPermissionByUser(ParameterList); } catch (Exception ex) { throw ex; } }
/// <summary> /// 抓取使用者及群組CRUD權限 /// </summary> /// <param name="ParameterList">傳入參數</param> /// <returns>回傳權限</returns> public DataTable QueryUserprogauthrelByID(ArrayList ParameterList) { try { DBO.SYS_USERPROGAUTHRELDBO RoleProgauthrel = new SYS_USERPROGAUTHRELDBO(ref USEDB); return RoleProgauthrel.doQueryByID(ParameterList); } catch (Exception ex) { throw ex; } }
public DataTable QueryProgramList(ArrayList ParameterList) { try { DBO.SYS_USERPROGAUTHRELDBO ProgramList = new SYS_USERPROGAUTHRELDBO(ref USEDB); return ProgramList.doQueryProgramList(ParameterList); } catch (Exception ex) { throw ex; } }
/// <summary> /// 判別程式的CRUD權限 /// </summary> /// <param name="ParameterList">輸入變數</param> /// <returns>回傳程式的CRUD權限</returns> public DataTable QueryProgramCRUD(ArrayList ParameterList) { try { int i = 0; int j = 0; SYS_ROLEPROGAUTHRELDBO rolepg = new SYS_ROLEPROGAUTHRELDBO(ref USEDB); SYS_USERPROGAUTHRELDBO userpg = new SYS_USERPROGAUTHRELDBO(ref USEDB); //抓取角色設定目前程式的狀態 DataTable RolePGDt = rolepg.doQueryByProgramCode(ParameterList); //抓取使用者設定目前程式的狀態 DataTable UserPGDt = userpg.doQueryByProgramCode(ParameterList); //建立回傳資訊 DataTable Dt = new DataTable("ProgCRUD"); DataColumn dc = new DataColumn("Code"); DataColumn dc1 = new DataColumn("CanCreate"); DataColumn dc2 = new DataColumn("CanRead"); DataColumn dc3 = new DataColumn("CanUpdate"); DataColumn dc4 = new DataColumn("CanDelete"); Dt.Columns.Add(dc); Dt.Columns.Add(dc1); Dt.Columns.Add(dc2); Dt.Columns.Add(dc3); Dt.Columns.Add(dc4); //使用者權限設定不為空的 if (UserPGDt.Rows.Count > 0) { DataRow Dr = Dt.NewRow(); Dr["Code"] = UserPGDt.Rows[0]["Code"]; Dr["CanCreate"] = UserPGDt.Rows[0]["CanCreate"]; Dr["CanRead"] = UserPGDt.Rows[0]["CanRead"]; Dr["CanUpdate"] = UserPGDt.Rows[0]["CanUpdate"]; Dr["CanDelete"] = UserPGDt.Rows[0]["CanDelete"]; Dt.Rows.Add(Dr); } if (Dt.Rows.Count > 0) { if (RolePGDt.Rows.Count > 0) { Dt.Rows[0]["CanCreate"] = (Dt.Rows[0]["CanCreate"].ToString() == "1") ? Dt.Rows[0]["CanCreate"] : RolePGDt.Rows[0]["CanCreate"]; Dt.Rows[0]["CanRead"] = (Dt.Rows[0]["CanRead"].ToString() == "1") ? Dt.Rows[0]["CanRead"] : RolePGDt.Rows[0]["CanRead"]; Dt.Rows[0]["CanUpdate"] = (Dt.Rows[0]["CanUpdate"].ToString() == "1") ? Dt.Rows[0]["CanUpdate"] : RolePGDt.Rows[0]["CanUpdate"]; Dt.Rows[0]["CanDelete"] = (Dt.Rows[0]["CanDelete"].ToString() == "1") ? Dt.Rows[0]["CanDelete"] : RolePGDt.Rows[0]["CanDelete"]; } } else { if (RolePGDt.Rows.Count > 0) { DataRow Dr = Dt.NewRow(); Dr["Code"] = RolePGDt.Rows[0]["Code"]; Dr["CanCreate"] = RolePGDt.Rows[0]["CanCreate"]; Dr["CanRead"] = RolePGDt.Rows[0]["CanRead"]; Dr["CanUpdate"] = RolePGDt.Rows[0]["CanUpdate"]; Dr["CanDelete"] = RolePGDt.Rows[0]["CanDelete"]; Dt.Rows.Add(Dr); } } return Dt; } catch(Exception ex) { throw ex; } }
/// <summary> /// 列出所有程式並依使用者判斷可否使用 /// </summary> /// <param name="ParameterList"></param> /// <returns></returns> public DataTable QueryAllProgramForUser(ArrayList ParameterList) { try { int i = 0; int j = 0; SYS_ProgramDBO prog = new SYS_ProgramDBO(ref USEDB); SYS_ROLEPROGAUTHRELDBO rolepg = new SYS_ROLEPROGAUTHRELDBO(ref USEDB); SYS_USERPROGAUTHRELDBO userpg = new SYS_USERPROGAUTHRELDBO(ref USEDB); //抓取目前所有程式 DataTable ProgramDt = prog.doQueryAllWithStatus(); //抓取目前使用者所屬角色所有程式 DataTable RolePGDt = rolepg.doQueryByUserID(ParameterList); //列出角色權限與功能列表相符清單 for (i = 0; i < ProgramDt.Rows.Count; i++) { for (j = 0; j < RolePGDt.Rows.Count; j++) { //角色權限與功能列表相符 if (ProgramDt.Rows[i]["CODE"].ToString() == RolePGDt.Rows[j]["PROGRAMCODE"].ToString()) { //如果未被設定開啟 if (ProgramDt.Rows[i]["Status"].ToString() == "0") { ProgramDt.Rows[i]["Status"] = 1; } } } } //列出使用者權限與功能列表相符清單 DataTable UserPGDt = userpg.doQueryByUserID(ParameterList); for (i = 0; i < ProgramDt.Rows.Count; i++) { for (j = 0; j < UserPGDt.Rows.Count; j++) { //人員權限與功能列表相符 if (ProgramDt.Rows[i]["CODE"].ToString() == UserPGDt.Rows[j]["PROGRAMCODE"].ToString()) { //如果未被設定開啟 if (ProgramDt.Rows[i]["Status"].ToString() == "0") { ProgramDt.Rows[i]["Status"] = 1; } } } } return ProgramDt; } catch (Exception ex) { throw ex; } }