protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //首次進入 if (!AclExpress.IsAclAdminUser()) { divError.Visible = true; DivMainList.Visible = false; DivMainSingle.Visible = false; DivDetailArea.Visible = false; labErrMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, AclRS.Resources.Msg_AclAdminDeny); return; } //強制顯示主檔清單 _IsADD = false; _RuleID = ""; _AreaID = ""; _GrantID = ""; Refresh(true); } //彈出視窗 事件訂閱 ucModalPopup1.onClose += ucModalPopup1_onClose; //主檔清單 事件訂閱 ucGridMain.RowCommand += ucGridMain_RowCommand; //明細檔清單 訂閱 RowCommand 事件 ucGridDetail.RowCommand += ucGridDetail_RowCommand; }
protected void btnMainDelete_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); try { Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); dicKey.Add("AreaID", _AreaID); AclExpress.IsAclTableLog("AclAdminRuleArea", dicKey, LogHelper.AppTableLogType.Delete); AclExpress.IsAclTableLog("AclAdminRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Delete); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Delete AclAdminRuleAreaGrantList Where RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" and AreaID = ").AppendParameter("AreaID", _AreaID); sb.AppendStatement("Delete AclAdminRuleArea Where RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" and AreaID = ").AppendParameter("AreaID", _AreaID); db.ExecuteNonQuery(sb.BuildCommand()); Util.NotifyMsg("刪除成功", Util.NotifyKind.Success); _RuleID = ""; _AreaID = ""; _GrantID = ""; Refresh(true, true); } catch { throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { AclArea.ucSourceDictionary = Util.getDictionary(Util.getDictionary(AclExpress.getAclAreaData().Select(" IsEnabled = 'Y' ").CopyToDataTable())); AclArea.Refresh(); } }
/// <summary> /// 頁面載入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { qryAreaGrant.ucServiceMethod = AclExpress._AclAreaGrantServiceMethod; qryAreaGrant.ucCategory01 = "AreaID"; qryAreaGrant.ucCategory02 = "GrantID"; qryAreaGrant.ucDropDownListEnabled01 = true; qryAreaGrant.ucDropDownListEnabled02 = true; qryAreaGrant.ucDropDownListEnabled03 = false; qryAreaGrant.ucDropDownListEnabled04 = false; qryAreaGrant.ucDropDownListEnabled05 = false; qryAreaGrant.Refresh(); if (!IsPostBack) { //首次載入 qryRuleID.ucSourceDictionary = Util.getDictionary(AclExpress.getAclRuleData(), 0, 1, true); qryRuleID.Refresh(); qryAuthType.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthTypeList()); qryAuthType.Refresh(); ucGridView1.ucDBName = _DBName; ucGridView1.ucDataQrySQL = _QryResultSQL; ucGridView1.ucDataKeyList = _PKList; Dictionary <string, string> dicDisplay = new Dictionary <string, string>(); dicDisplay.Clear(); dicDisplay.Add("AreaID", "區域代號"); dicDisplay.Add("AreaName", "區域名稱"); dicDisplay.Add("GrantID", "項目代號"); dicDisplay.Add("GrantName", "項目名稱"); dicDisplay.Add("AuthType", "授權類型"); dicDisplay.Add("AllowActList", "限定動作"); dicDisplay.Add("UpdUser", "更新人員"); dicDisplay.Add("UpdDateTime", "更新時間@T"); ucGridView1.ucDataGroupKey = "RuleID"; ucGridView1.ucDataDisplayDefinition = dicDisplay; ucGridView1.ucSelectEnabled = false; ucGridView1.ucAddEnabled = true; ucGridView1.ucEditEnabled = true; ucGridView1.ucCopyEnabled = true; ucGridView1.ucDeleteEnabled = true; //Data Dump 2016.11.08 ucGridView1.ucDataDumpEnabled = true; ucGridView1.Refresh(true); } //事件訂閱 ucGridView1.RowCommand += new Util_ucGridView.GridViewRowClick(ucGridView1_RowCommand); ucModalPopup1.onClose += ucModalPopup1_onClose; }
/// <summary> /// 確認新增明細 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDetailInsert_Click(object sender, EventArgs e) { Dictionary <string, string> oDic = Util.getControlEditResult(fmDetail); if (!string.IsNullOrEmpty(_RuleID)) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); //新增明細 sb.AppendStatement("Insert AclRuleExp "); sb.Append("(RuleID,ChkGrpNo,ChkSeqNo,IsEnabled,ChkOrgUserObjectProperty,ChkOrgUserSW,ChkOrgUserExp,ChkOrgUserPropertyValue,ChkCodeMapSW,ChkCodeMapFldName,Remark,UpdUser,UpdDateTime) "); sb.Append(" Values (").AppendParameter("RuleID", _RuleID); sb.Append(" ,").AppendParameter("ChkGrpNo", oDic["ChkGrpNo"]); sb.Append(" ,").AppendParameter("ChkSeqNo", oDic["ChkSeqNo"]); sb.Append(" ,").AppendParameter("IsEnabled", oDic["IsEnabled"]); sb.Append(" ,").AppendParameter("ChkOrgUserObjectProperty", oDic["ChkOrgUserObjectProperty"]); sb.Append(" ,").AppendParameter("ChkOrgUserSW", oDic["ChkOrgUserSW"]); sb.Append(" ,").AppendParameter("ChkOrgUserExp", oDic["ChkOrgUserExp"]); sb.Append(" ,").AppendParameter("ChkOrgUserPropertyValue", oDic["ChkOrgUserPropertyValue"]); sb.Append(" ,").AppendParameter("ChkCodeMapSW", oDic["ChkCodeMapSW"]); sb.Append(" ,").AppendParameter("ChkCodeMapFldName", oDic["ChkCodeMapFldName"]); sb.Append(" ,").AppendParameter("Remark", oDic["Remark"]); sb.Append(" ,").AppendParameter("UpdUser", UserInfo.getUserInfo().UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(")"); try { db.ExecuteNonQuery(sb.BuildCommand()); _ChkGrpNo = int.Parse(oDic["ChkGrpNo"]); _ChkSeqNo = int.Parse(oDic["ChkSeqNo"]); Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); dicKey.Add("ChkGrpNo", _ChkGrpNo.ToString()); dicKey.Add("ChkSeqNo", _ChkSeqNo.ToString()); AclExpress.IsAclTableLog("AclRuleExp", dicKey, LogHelper.AppTableLogType.Create); Util.NotifyMsg("條件新增成功", Util.NotifyKind.Success); } catch { Util.NotifyMsg("條件新增失敗", Util.NotifyKind.Error); } Refresh(false, true); } }
protected void btnMainInsert_Click(object sender, EventArgs e) { //取得表單輸入資料 Dictionary <string, string> oDic = Util.getControlEditResult(fmMain); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Insert AclRule "); sb.Append("( "); sb.Append(" RuleID,RuleName,IsEnabled,Remark,UpdUser,UpdDateTime"); sb.Append(" ) Values ("); sb.Append(" ").AppendParameter("RuleID", oDic["RuleID"]); sb.Append(" ,").AppendParameter("RuleName", oDic["RuleName"]); sb.Append(" ,").AppendParameter("IsEnabled", oDic["IsEnabled"]); sb.Append(" ,").AppendParameter("Remark", oDic["Remark"]); sb.Append(" ,").AppendParameter("UpdUser", UserInfo.getUserInfo().UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(" )"); if (_IsADD && _RuleID != oDic["RuleID"]) { //Copy Detail sb.AppendStatement(Util.getDataCopySQL(AclExpress._AclDBName, _Main_KeyList, _RuleID.Split(','), oDic["RuleID"].Split(','), "AclRuleExp".Split(','))); } try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { _IsADD = false; _RuleID = oDic["RuleID"]; Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); AclExpress.IsAclTableLog("AclRule", dicKey, LogHelper.AppTableLogType.Create); AclExpress.IsAclTableLog("AclRuleExp", dicKey, LogHelper.AppTableLogType.Create); Util.NotifyMsg(string.Format("[{0}]新增成功,可進行後續編修。", oDic["RuleID"]), Util.NotifyKind.Success); Refresh(true, true); } else { Util.NotifyMsg("新增失敗", Util.NotifyKind.Error); } } catch { Util.NotifyMsg("新增錯誤,請檢查資料是否重複", Util.NotifyKind.Error); } }
/// <summary> /// 「新增」按鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnInsert_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); //取得 FormView 編輯控制項的編輯結果 Dictionary <string, string> oEditResult = Util.getControlEditResult(fmMain); sb.Reset(); sb.AppendStatement("Insert AclAuthRuleAreaGrantList "); sb.Append("( "); sb.Append(" RuleID,AreaID,GrantID,AuthType,AllowActList,Remark,UpdUser,UpdDateTime"); sb.Append(" ) Values ("); sb.Append(" ").AppendParameter("RuleID", oEditResult["RuleID"]); sb.Append(" ,").AppendParameter("AreaID", (oEditResult["AreaGrant"]).Split(',')[0]); sb.Append(" ,").AppendParameter("GrantID", (oEditResult["AreaGrant"]).Split(',')[1]); sb.Append(" ,").AppendParameter("AuthType", oEditResult["AuthType"]); sb.Append(" ,").AppendParameter("AllowActList", oEditResult["AllowActList"]); sb.Append(" ,").AppendParameter("Remark", oEditResult["Remark"]); sb.Append(" ,").AppendParameter("UpdUser", UserInfo.getUserInfo().UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(" )"); try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", oEditResult["RuleID"]); dicKey.Add("AreaID", (oEditResult["AreaGrant"]).Split(',')[0]); dicKey.Add("GrantID", (oEditResult["AreaGrant"]).Split(',')[1]); AclExpress.IsAclTableLog("AclAuthRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Create); Util.NotifyMsg(RS.Resources.Msg_AddSucceed, Util.NotifyKind.Success); //新增成功 DivQryArea.Visible = true; divMainFormView.Visible = false; divMainGridview.Visible = true; ucGridView1.Refresh(true); } else { Util.NotifyMsg(RS.Resources.Msg_AddFail, Util.NotifyKind.Error); //新增失敗 } } catch (Exception ex) { Util.MsgBox(ex.Message); } }
protected void btnMainInsert_Click(object sender, EventArgs e) { //取得表單輸入資料 Dictionary <string, string> oDic = Util.getControlEditResult(fmMain); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Insert AclAdminUserArea "); sb.Append("( "); sb.Append(" UserID,UserName,AreaID,AdminType,Remark,UpdUser,UpdDateTime"); sb.Append(" ) Values ("); sb.Append(" ").AppendParameter("UserID", oDic["UserID"]); sb.Append(" ,").AppendParameter("UserName", UserInfo.findUserName(oDic["UserID"])); sb.Append(" ,").AppendParameter("AreaID", oDic["AreaID"]); sb.Append(" ,").AppendParameter("AdminType", oDic["AdminType"]); sb.Append(" ,").AppendParameter("Remark", oDic["Remark"]); sb.Append(" ,").AppendParameter("UpdUser", UserInfo.getUserInfo().UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(" )"); try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { _IsADD = false; _UserID = oDic["UserID"]; _AreaID = oDic["AreaID"]; Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("UserID", _UserID); dicKey.Add("AreaID", _AreaID); AclExpress.IsAclTableLog("AclAdminUserArea", dicKey, LogHelper.AppTableLogType.Create); Util.NotifyMsg(string.Format("[{0}-{1}]新增成功,可進行後續編修。", _UserID, _AreaID), Util.NotifyKind.Success); Refresh(true, true); } else { Util.NotifyMsg("新增失敗", Util.NotifyKind.Error); } } catch { Util.NotifyMsg("新增錯誤,請檢查資料是否重複", Util.NotifyKind.Error); } }
/// <summary> /// 確認更新明細 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDetailUpdate_Click(object sender, EventArgs e) { Dictionary <string, string> oDic = Util.getControlEditResult(fmDetail); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); //更新明細 sb.AppendStatement("Update AclRuleExp Set "); sb.Append(" IsEnabled = ").AppendParameter("IsEnabled", oDic["IsEnabled"]); sb.Append(", ChkOrgUserObjectProperty = ").AppendParameter("ChkOrgUserObjectProperty", oDic["ChkOrgUserObjectProperty"]); sb.Append(", ChkOrgUserSW = ").AppendParameter("ChkOrgUserSW", oDic["ChkOrgUserSW"]); sb.Append(", ChkOrgUserExp = ").AppendParameter("ChkOrgUserExp", oDic["ChkOrgUserExp"]); sb.Append(", ChkOrgUserPropertyValue = ").AppendParameter("ChkOrgUserPropertyValue", oDic["ChkOrgUserPropertyValue"]); sb.Append(", ChkCodeMapSW = ").AppendParameter("ChkCodeMapSW", oDic["ChkCodeMapSW"]); sb.Append(", ChkCodeMapFldName = ").AppendParameter("ChkCodeMapFldName", oDic["ChkCodeMapFldName"]); sb.Append(", Remark = ").AppendParameter("Remark", oDic["Remark"]); sb.Append(", UpdUser = "******"UpdUser", UserInfo.getUserInfo().UserID); sb.Append(", UpdDateTime = ").AppendDbDateTime(); sb.Append(" Where 0=0 "); sb.Append(" And RuleID =").AppendParameter("RuleID", _RuleID); sb.Append(" And ChkGrpNo =").AppendParameter("ChkGrpNo", _ChkGrpNo); sb.Append(" And ChkSeqNo =").AppendParameter("ChkSeqNo", _ChkSeqNo); try { db.ExecuteNonQuery(sb.BuildCommand()); Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); dicKey.Add("ChkGrpNo", _ChkGrpNo.ToString()); dicKey.Add("ChkSeqNo", _ChkSeqNo.ToString()); AclExpress.IsAclTableLog("AclRuleExp", dicKey, LogHelper.AppTableLogType.Update); Util.NotifyMsg("條件更新成功", Util.NotifyKind.Success); } catch { Util.NotifyMsg("條件更新失敗", Util.NotifyKind.Error); } Refresh(); }
protected void btnMainUpdate_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); Dictionary <string, string> oDic = Util.getControlEditResult(fmMain); sb.Reset(); sb.AppendStatement("Update AclAdminUserArea Set "); sb.Append(" UserName = "******"UserName", UserInfo.findUserName(_UserID)); sb.Append(", AdminType = ").AppendParameter("AdminType", oDic["AdminType"]); sb.Append(", Remark = ").AppendParameter("Remark", oDic["Remark"]); sb.Append(", UpdUser = "******"UpdUser", UserInfo.getUserInfo().UserID); sb.Append(", UpdDateTime = ").AppendDbDateTime(); sb.Append(" Where UserID = ").AppendParameter("UserID", _UserID); sb.Append(" and AreaID = ").AppendParameter("AreaID", _AreaID); try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("UserID", _UserID); dicKey.Add("AreaID", _AreaID); AclExpress.IsAclTableLog("AclAdminUserArea", dicKey, LogHelper.AppTableLogType.Update); Util.NotifyMsg("更新成功", Util.NotifyKind.Success); _IsADD = false; _UserID = ""; Refresh(false, true); } } catch (Exception ex) { string strErrMsg = "更新主檔失敗"; //將錯誤記錄到 Log 模組 LogHelper.WriteSysLog(ex); //將 Exception 丟給 Log 模組 Util.NotifyMsg(strErrMsg, Util.NotifyKind.Error); //錯誤發生時,因為頁面需保留目前主檔表單輸入的內容,故只更新明細清單清單 ucGridDetail.Refresh(); } }
/// <summary> /// 「更新」按鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); //取得編輯結果 Dictionary <string, string> oEditResult = Util.getControlEditResult(fmMain); //組合SQL // RuleID,AreaID,GrantID ,AuthType,AllowActList,Remark,UpdUser,UpdDateTime sb.Reset(); sb.AppendStatement("Update AclAuthRuleAreaGrantList set "); sb.Append(" AuthType = ").AppendParameter("AuthType", oEditResult["AuthType"]); sb.Append(", AllowActList = ").AppendParameter("AllowActList", oEditResult["AllowActList"]); sb.Append(", Remark = ").AppendParameter("Remark", oEditResult["Remark"]); sb.Append(", UpdUser = "******"UpdUser", UserInfo.getUserInfo().UserID); sb.Append(", UpdDateTime = ").AppendDbDateTime(); sb.Append(" Where 0 = 0 "); sb.Append(" and RuleID = ").AppendParameter("RuleID", oEditResult["RuleID"]); sb.Append(" and AreaID = ").AppendParameter("AreaID", (oEditResult["AreaGrant"]).Split(',')[0]); sb.Append(" and GrantID = ").AppendParameter("GrantID", (oEditResult["AreaGrant"]).Split(',')[1]); //執行SQL if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", oEditResult["RuleID"]); dicKey.Add("AreaID", (oEditResult["AreaGrant"]).Split(',')[0]); dicKey.Add("GrantID", (oEditResult["AreaGrant"]).Split(',')[1]); AclExpress.IsAclTableLog("AclAuthRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Update); Util.NotifyMsg(RS.Resources.Msg_EditSucceed, Util.NotifyKind.Success); //更新成功 } else { Util.NotifyMsg(RS.Resources.Msg_EditFail, Util.NotifyKind.Error); //更新失敗 } DivQryArea.Visible = true; divMainFormView.Visible = false; divMainGridview.Visible = true; ucGridView1.Refresh(); }
/// <summary> /// 確認新增明細 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDetailInsert_Click(object sender, EventArgs e) { Dictionary <string, string> oDic = Util.getControlEditResult(fmDetail); if (!string.IsNullOrEmpty(_RuleID)) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); //新增明細 sb.AppendStatement("Insert AclAdminRuleAreaGrantList "); sb.Append("(RuleID,AreaID,GrantID,Remark,UpdUser,UpdDateTime) "); sb.Append(" Values (").AppendParameter("RuleID", _RuleID); sb.Append(" ,").AppendParameter("AreaID", _AreaID); sb.Append(" ,").AppendParameter("GrantID", oDic["AreaGrant"].Split(',')[1]); sb.Append(" ,").AppendParameter("Remark", oDic["Remark"]); sb.Append(" ,").AppendParameter("UpdUser", UserInfo.getUserInfo().UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(")"); try { db.ExecuteNonQuery(sb.BuildCommand()); _GrantID = oDic["AreaGrant"].Split(',')[1]; Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); dicKey.Add("AreaID", _AreaID); dicKey.Add("GrantID", _GrantID); AclExpress.IsAclTableLog("AclAdminRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Create); Util.NotifyMsg("項目新增成功", Util.NotifyKind.Success); } catch { Util.NotifyMsg("項目新增失敗", Util.NotifyKind.Error); } Refresh(false, true); } }
protected void Page_Load(object sender, EventArgs e) { if (ucAclInfo == null) { divAclInfo.Visible = false; labErrMsg.Visible = true; labErrMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, string.Format(RS.Resources.Msg_ParaNotFound1, "ucAclInfo")); } if (!IsPostBack) { if (AclExpress.IsAclAdminUser()) { tab03.Visible = true; } else { tab03.Visible = false; } } }
/// <summary> /// 「刪除」按鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); //取得編輯結果 Dictionary <string, string> oEditResult = Util.getControlEditResult(fmMain); try { Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", oEditResult["RuleID"]); dicKey.Add("AreaID", (oEditResult["AreaGrant"]).Split(',')[0]); dicKey.Add("GrantID", (oEditResult["AreaGrant"]).Split(',')[1]); AclExpress.IsAclTableLog("AclAuthRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Delete); sb.Reset(); sb.AppendStatement("Delete AclAuthRuleAreaGrantList "); sb.Append(" Where 0 = 0 "); sb.Append(" and RuleID = ").AppendParameter("RuleID", oEditResult["RuleID"]); sb.Append(" and AreaID = ").AppendParameter("AreaID", (oEditResult["AreaGrant"]).Split(',')[0]); sb.Append(" and GrantID = ").AppendParameter("GrantID", (oEditResult["AreaGrant"]).Split(',')[1]); if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { Util.NotifyMsg(RS.Resources.Msg_DeleteSucceed, Util.NotifyKind.Success); //刪除成功 DivQryArea.Visible = true; divMainFormView.Visible = false; divMainGridview.Visible = true; ucGridView1.Refresh(true); } else { Util.NotifyMsg(RS.Resources.Msg_DeleteFail, Util.NotifyKind.Error); //刪除失敗 } } catch (Exception ex) { Util.MsgBox(ex.Message); } }
/// <summary> /// 確認更新明細 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDetailUpdate_Click(object sender, EventArgs e) { Dictionary <string, string> oDic = Util.getControlEditResult(fmDetail); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); //更新明細 sb.AppendStatement("Update AclAdminRuleAreaGrantList Set "); sb.Append(" Remark = ").AppendParameter("Remark", oDic["Remark"]); sb.Append(", UpdUser = "******"UpdUser", UserInfo.getUserInfo().UserID); sb.Append(", UpdDateTime = ").AppendDbDateTime(); sb.Append(" Where 0=0 "); sb.Append(" And RuleID =").AppendParameter("RuleID", _RuleID); sb.Append(" And AreaID =").AppendParameter("AreaID", _AreaID); sb.Append(" And GrantID =").AppendParameter("GrantID", _GrantID); try { db.ExecuteNonQuery(sb.BuildCommand()); Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); dicKey.Add("AreaID", _AreaID); dicKey.Add("GrantID", _GrantID); AclExpress.IsAclTableLog("AclAdminRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Update); Util.NotifyMsg("項目更新成功", Util.NotifyKind.Success); } catch { Util.NotifyMsg("項目更新失敗", Util.NotifyKind.Error); } Refresh(); }
void ucGridDetail_RowCommand(object sender, Util_ucGridView.RowCommandEventArgs e) { //承接明細檔 GridView 按鈕事件 DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); string[] oDataKeys = e.DataKeys; if (oDataKeys != null) { _RuleID = oDataKeys[0]; _AreaID = oDataKeys[1]; _GrantID = oDataKeys[2]; } ucModalPopup1.Reset(); ucModalPopup1.ucPopupWidth = 640; ucModalPopup1.ucPopupHeight = 320; ucModalPopup1.ucPopupHeader = "項目設定"; ucModalPopup1.ucPanelID = pnlDetailForm.ID; //處理按鈕命令 switch (e.CommandName) { case "cmdAdd": fmDetail.ChangeMode(FormViewMode.Insert); fmDetail.DataSource = null; fmDetail.DataBind(); Util.setJS_AlertDirtyData(fmDetail); ucModalPopup1.Show(); break; case "cmdCopy": sb.Reset(); sb.AppendStatement("Select * From AclAdminRuleAreaGrantList Where 0=0 "); sb.Append(" And RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" And AreaID = ").AppendParameter("AreaID", _AreaID); sb.Append(" And GrantID = ").AppendParameter("GrantID", _GrantID); fmDetail.ChangeMode(FormViewMode.Insert); fmDetail.DataSource = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; fmDetail.DataBind(); Util.setJS_AlertDirtyData(fmDetail); ucModalPopup1.Show(); break; case "cmdEdit": sb.Reset(); sb.AppendStatement("Select * From AclAdminRuleAreaGrantList Where 0=0 "); sb.Append(" And RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" And AreaID = ").AppendParameter("AreaID", _AreaID); sb.Append(" And GrantID = ").AppendParameter("GrantID", _GrantID); fmDetail.ChangeMode(FormViewMode.Edit); fmDetail.DataSource = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; fmDetail.DataBind(); Util.setJS_AlertDirtyData(fmDetail); ucModalPopup1.Show(); break; case "cmdDelete": try { Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); dicKey.Add("AreaID", _AreaID); dicKey.Add("GrantID", _GrantID); AclExpress.IsAclTableLog("AclAdminRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Delete); sb.Reset(); sb.AppendStatement("Delete From AclAdminRuleAreaGrantList Where 0=0 "); sb.Append(" And RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" And AreaID = ").AppendParameter("AreaID", _AreaID); sb.Append(" And GrantID = ").AppendParameter("GrantID", _GrantID); db.ExecuteNonQuery(sb.BuildCommand()); _GrantID = ""; Util.NotifyMsg(RS.Resources.Msg_DeleteSucceed, Util.NotifyKind.Success); } catch { Util.NotifyMsg(RS.Resources.Msg_DeleteFail, Util.NotifyKind.Error); } break; default: //未定義的命令 Util.MsgBox(string.Format(RS.Resources.Msg_Undefined1, e.CommandName)); break; } fmMainRefresh(); }
void ucGridMain_RowCommand(object sender, Util_ucGridView.RowCommandEventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); //處理自訂命令,AP 可視需要自行增加想要的 CommandName switch (e.CommandName) { case "cmdAdd": _IsADD = true; _RuleID = ""; _AreaID = ""; Refresh(true, true); break; case "cmdCopy": _IsADD = true; _RuleID = e.DataKeys[0]; _AreaID = e.DataKeys[1]; Refresh(true, true); break; case "cmdDelete": _IsADD = false; _RuleID = ""; _AreaID = ""; _GrantID = ""; try { Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", e.DataKeys[0]); dicKey.Add("AreaID", e.DataKeys[1]); AclExpress.IsAclTableLog("AclAdminRuleArea", dicKey, LogHelper.AppTableLogType.Delete); AclExpress.IsAclTableLog("AclAdminRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Delete); sb.Reset(); sb.AppendStatement("Delete AclAdminRuleAreaGrantList Where RuleID = ").AppendParameter("RuleID", e.DataKeys[0]); sb.Append(" and AreaID = ").AppendParameter("AreaID", e.DataKeys[1]); sb.AppendStatement("Delete AclAdminRuleArea Where RuleID = ").AppendParameter("RuleID", e.DataKeys[0]); sb.Append(" and AreaID = ").AppendParameter("AreaID", e.DataKeys[1]); db.ExecuteNonQuery(sb.BuildCommand()); Util.NotifyMsg(RS.Resources.Msg_DeleteSucceed, Util.NotifyKind.Success); } catch { Util.NotifyMsg(RS.Resources.Msg_DeleteFail, Util.NotifyKind.Error); } break; case "cmdEdit": case "cmdSelect": _IsADD = false; _RuleID = e.DataKeys[0]; _AreaID = e.DataKeys[1]; _GrantID = ""; Refresh(false, true); break; case "cmdDownload": //Data Dump 2016.11.08 string strHeader = string.Format("[{0} - {1}] 資料轉儲 SQL", e.DataKeys[0], e.DataKeys[1]); string strDataFilter = string.Format(" RuleID = '{0}' and AreaID = '{1}' ", e.DataKeys[0], e.DataKeys[1]); string strDumpSQL = string.Empty; strDumpSQL += "/* ==================================================================== */ \n"; strDumpSQL += string.Format("/* {0} on [{1}] */ \n", strHeader, DateTime.Now); strDumpSQL += "/* ==================================================================== */ \n"; strDumpSQL += string.Format("Use {0} \nGo\n", AclExpress._AclDBName); strDumpSQL += "/* ==================== */ \n"; strDumpSQL += "/* AclAdminRuleArea 相關物件 */ \n"; strDumpSQL += "/* ==================== */ \n"; strDumpSQL += Util.getDataDumpSQL(AclExpress._AclDBName, "AclAdminRuleArea", strDataFilter); strDumpSQL += "\n"; strDumpSQL += "/* ==================== */ \n"; strDumpSQL += "/* AclAdminRuleAreaGrantList 相關物件 */ \n"; strDumpSQL += "/* ==================== */ \n"; strDumpSQL += Util.getDataDumpSQL(AclExpress._AclDBName, "AclAdminRuleAreaGrantList", strDataFilter); txtDumpSQL.ucTextData = strDumpSQL; ucModalPopup1.Reset(); ucModalPopup1.ucPopupWidth = 850; ucModalPopup1.ucPopupHeight = 600; ucModalPopup1.ucPopupHeader = strHeader; ucModalPopup1.ucPanelID = pnlDumpSQL.ID; ucModalPopup1.Show(); break; default: Util.MsgBox(string.Format("cmd=[{0}],key=[{1}]", e.CommandName, Util.getStringJoin(e.DataKeys))); break; } }
public void RefreshTreeView() { TreeView1.Nodes.Clear(); TreeNode tRootNode = new TreeNode(); tRootNode.Text = "ACL資料查詢"; tRootNode.NavigateUrl = string.Format(_ContentUrlFormat, AclExpress._AclSysPath + "AclInfo.aspx"); tRootNode.PopulateOnDemand = false; tRootNode.Expanded = true; TreeView1.Nodes.Add(tRootNode); //管理專用 if (AclExpress.IsAclAdminUser()) { //Acl 管理員專用 TreeNode tManageNode = new TreeNode(); tManageNode.Text = "管理作業"; tManageNode.Expanded = true; tManageNode.SelectAction = TreeNodeSelectAction.Expand; tRootNode.ChildNodes.Add(tManageNode); TreeNode tBaseNode = new TreeNode(); tBaseNode.Text = "基本資料"; tBaseNode.Expanded = true; tBaseNode.SelectAction = TreeNodeSelectAction.Expand; tManageNode.ChildNodes.Add(tBaseNode); TreeNode tChildNode = new TreeNode(); tChildNode.Text = "區域資料(AclArea)"; tChildNode.PopulateOnDemand = false; tChildNode.Expanded = false; tChildNode.SelectAction = TreeNodeSelectAction.Select; tChildNode.NavigateUrl = string.Format(_ContentUrlFormat, "AclArea.aspx"); tBaseNode.ChildNodes.Add(tChildNode); tChildNode = new TreeNode(); tChildNode.Text = "規則資料(AclRule)"; tChildNode.PopulateOnDemand = false; tChildNode.Expanded = false; tChildNode.SelectAction = TreeNodeSelectAction.Select; tChildNode.NavigateUrl = string.Format(_ContentUrlFormat, "AclRule.aspx"); tBaseNode.ChildNodes.Add(tChildNode); TreeNode tAdminNode = new TreeNode(); tAdminNode.Text = "管理權"; tAdminNode.Expanded = true; tAdminNode.SelectAction = TreeNodeSelectAction.Expand; tManageNode.ChildNodes.Add(tAdminNode); tChildNode = new TreeNode(); tChildNode.Text = "規則<->區域(AclAdminRuleArea)"; //AclAdminRuleArea tChildNode.PopulateOnDemand = false; tChildNode.Expanded = false; tChildNode.SelectAction = TreeNodeSelectAction.Select; tChildNode.NavigateUrl = string.Format(_ContentUrlFormat, "AclAdminRuleArea.aspx"); tAdminNode.ChildNodes.Add(tChildNode); tChildNode = new TreeNode(); tChildNode.Text = "使用者<->區域(AclAdminUserArea)"; //AclAdminUserArea tChildNode.PopulateOnDemand = false; tChildNode.Expanded = false; tChildNode.SelectAction = TreeNodeSelectAction.Select; tChildNode.NavigateUrl = string.Format(_ContentUrlFormat, "AclAdminUserArea.aspx"); tAdminNode.ChildNodes.Add(tChildNode); tAdminNode = new TreeNode(); tAdminNode.Text = "使用權"; tAdminNode.Expanded = true; tAdminNode.SelectAction = TreeNodeSelectAction.Expand; tManageNode.ChildNodes.Add(tAdminNode); tChildNode = new TreeNode(); tChildNode.Text = "規則<->區域(AclAuthRuleArea)"; //AclAuthRuleArea tChildNode.PopulateOnDemand = false; tChildNode.Expanded = false; tChildNode.SelectAction = TreeNodeSelectAction.Select; tChildNode.NavigateUrl = string.Format(_ContentUrlFormat, "AclAuthRuleArea.aspx"); tAdminNode.ChildNodes.Add(tChildNode); tChildNode = new TreeNode(); tChildNode.Text = "使用者<->區域(AclAuthUserArea)"; //AclAuthUserArea tChildNode.PopulateOnDemand = false; tChildNode.Expanded = false; tChildNode.SelectAction = TreeNodeSelectAction.Select; tChildNode.NavigateUrl = string.Format(_ContentUrlFormat, "AclAreaSelect.aspx"); tAdminNode.ChildNodes.Add(tChildNode); tAdminNode = new TreeNode(); tAdminNode.Text = "工具"; tAdminNode.Expanded = true; tAdminNode.SelectAction = TreeNodeSelectAction.Expand; tManageNode.ChildNodes.Add(tAdminNode); tChildNode = new TreeNode(); tChildNode.Text = "CodeMap"; tChildNode.PopulateOnDemand = false; tChildNode.Expanded = false; tChildNode.SelectAction = TreeNodeSelectAction.Select; tChildNode.NavigateUrl = string.Format(_ContentUrlFormat, string.Format("{0}?DBName={1}&LogDBName={2}", Util._CodeMapAdminUrl, AclExpress._AclDBName, AclExpress._AclLogDBName)); tAdminNode.ChildNodes.Add(tChildNode); tChildNode = new TreeNode(); tChildNode.Text = "AppLog"; tChildNode.PopulateOnDemand = false; tChildNode.Expanded = false; tChildNode.SelectAction = TreeNodeSelectAction.Select; tChildNode.NavigateUrl = string.Format(_ContentUrlFormat, string.Format("{0}?DBName={1}&AllowPurgeYN=Y", Util._AppLogQryUrl, AclExpress._AclDBName)); tAdminNode.ChildNodes.Add(tChildNode); } //一般授權作業 string[] tAreaList = AclInfo.getAclInfo().getAdminAreaList(); if (tAreaList != null && tAreaList.Length > 0) { string[] tGrantIDList = AclInfo.getAclInfo().getAdminAreaGrantList(tAreaList[0]); if (tGrantIDList != null && !string.IsNullOrEmpty(tGrantIDList[0])) { //確定有資料才產生 TreeNode TreeNode tAreaNode = new TreeNode(); tAreaNode.Text = "一般授權"; tAreaNode.Expanded = true; tAreaNode.SelectAction = TreeNodeSelectAction.Expand; tRootNode.ChildNodes.Add(tAreaNode); DataTable dtArea = AclExpress.getAclAreaData().Select(string.Format(" AreaID in ('{0}') and IsEnabled = 'Y' ", Util.getStringJoin(tAreaList, "','"))).CopyToDataTable(); if (dtArea != null && dtArea.Rows.Count > 0) { for (int i = 0; i < dtArea.Rows.Count; i++) { DataRow dr = dtArea.Rows[i]; //AreaID 節點 TreeNode tChildNode = new TreeNode(); tChildNode.PopulateOnDemand = false; tChildNode.Text = string.Format("{0}【{1}】", dr["AreaID"], dr["AreaName"]); tChildNode.NavigateUrl = string.Format(_ContentUrlFormat, string.Format("{0}?AreaID={1}&IsDebug=Y", AclExpress._AclSysPath + "AclAuthUserArea.aspx", dr["AreaID"])); tChildNode.Expanded = false; tChildNode.SelectAction = TreeNodeSelectAction.Select; tAreaNode.ChildNodes.Add(tChildNode); //AddStepNodes(tSpecNode, dr["FlowID"].ToString()); } } } } }
void ucGridDetail_RowCommand(object sender, Util_ucGridView.RowCommandEventArgs e) { //承接明細檔 GridView 按鈕事件 DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); string[] oDataKeys = e.DataKeys; if (oDataKeys != null) { _RuleID = oDataKeys[0]; _ChkGrpNo = int.Parse(oDataKeys[1]); _ChkSeqNo = int.Parse(oDataKeys[2]); } ucModalPopup1.Reset(); ucModalPopup1.ucPopupWidth = 640; ucModalPopup1.ucPopupHeight = 320; ucModalPopup1.ucPopupHeader = "條件設定"; ucModalPopup1.ucPanelID = pnlDetailForm.ID; //處理按鈕命令 switch (e.CommandName) { case "cmdAdd": fmDetail.ChangeMode(FormViewMode.Insert); fmDetail.DataSource = null; fmDetail.DataBind(); Util.setJS_AlertDirtyData(fmDetail); ucModalPopup1.Show(); break; case "cmdCopy": sb.Reset(); sb.AppendStatement("Select * From AclRuleExp Where 0=0 "); sb.Append(" And RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" And ChkGrpNo = ").AppendParameter("ChkGrpNo", _ChkGrpNo); sb.Append(" And ChkSeqNo = ").AppendParameter("ChkSeqNo", _ChkSeqNo); fmDetail.ChangeMode(FormViewMode.Insert); fmDetail.DataSource = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; fmDetail.DataBind(); Util.setJS_AlertDirtyData(fmDetail); ucModalPopup1.Show(); break; case "cmdEdit": sb.Reset(); sb.AppendStatement("Select * From AclRuleExp Where 0=0 "); sb.Append(" And RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" And ChkGrpNo = ").AppendParameter("ChkGrpNo", _ChkGrpNo); sb.Append(" And ChkSeqNo = ").AppendParameter("ChkSeqNo", _ChkSeqNo); fmDetail.ChangeMode(FormViewMode.Edit); fmDetail.DataSource = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; fmDetail.DataBind(); Util.setJS_AlertDirtyData(fmDetail); ucModalPopup1.Show(); break; case "cmdDelete": try { Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); dicKey.Add("ChkGrpNo", _ChkGrpNo.ToString()); dicKey.Add("ChkSeqNo", _ChkSeqNo.ToString()); AclExpress.IsAclTableLog("AclRuleExp", dicKey, LogHelper.AppTableLogType.Delete); sb.Reset(); sb.AppendStatement("Delete From AclRuleExp Where 0=0 "); sb.Append(" And RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" And ChkGrpNo = ").AppendParameter("ChkGrpNo", _ChkGrpNo); sb.Append(" And ChkSeqNo = ").AppendParameter("ChkSeqNo", _ChkSeqNo); db.ExecuteNonQuery(sb.BuildCommand()); _ChkGrpNo = 0; _ChkSeqNo = 0; Util.NotifyMsg(RS.Resources.Msg_DeleteSucceed, Util.NotifyKind.Success); } catch { Util.NotifyMsg(RS.Resources.Msg_DeleteFail, Util.NotifyKind.Error); } break; case "cmdMultilingual": sb.Reset(); sb.AppendStatement("Select ChkCodeMapFldName From AclRuleExp Where 0=0 "); sb.Append(" And RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" And ChkGrpNo = ").AppendParameter("ChkGrpNo", _ChkGrpNo); sb.Append(" And ChkSeqNo = ").AppendParameter("ChkSeqNo", _ChkSeqNo); string strFldName = db.ExecuteDataSet(sb.BuildCommand()).Tables[0].Rows[0][0].ToString(); if (string.IsNullOrEmpty(strFldName)) { Util.MsgBox("「對照表欄位」尚未設定!"); } else { ucModalPopup1.Reset(); ucModalPopup1.ucPopupWidth = 820; ucModalPopup1.ucPopupHeight = 650; ucModalPopup1.ucPopupHeader = "對照表資料維護"; ucModalPopup1.ucFrameURL = string.Format("{0}?DBName={1}&LogDBName={2}&TabName={3}&FldName={4}", Util._CodeMapAdminUrl, AclExpress._AclDBName, AclExpress._AclLogDBName, _RuleID, strFldName); ucModalPopup1.Show(); } break; default: //未定義的命令 Util.MsgBox(string.Format(RS.Resources.Msg_Undefined1, e.CommandName)); break; } fmMainRefresh(); }
/// <summary> /// fmMain 資料繫結事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void fmMain_DataBound(object sender, EventArgs e) { //初始物件 Util_ucTextBox oText; Util_ucCascadingDropDown oCascad; Util_ucCommSingleSelect oDdl; Util_ucCheckBoxList oChkList; string strObjID; DataRow dr = null; if (fmMain.DataSource != null) { dr = ((DataTable)fmMain.DataSource).Rows[0]; } //「新增」「資料複製」模式 if (fmMain.CurrentMode == FormViewMode.Insert) { //自訂檢核失敗時的JS提醒訊息 Util.setJS_AlertPageNotValid("btnInsert"); strObjID = "RuleID"; oDdl = (Util_ucCommSingleSelect)fmMain.FindControl(strObjID); oDdl.ucSourceDictionary = Util.getDictionary(AclExpress.getAclRuleData(), 0, 1, true); if (dr != null) { oDdl.ucSelectedID = dr[strObjID].ToString().Trim(); } oDdl.Refresh(); strObjID = "AreaGrant"; oCascad = (Util_ucCascadingDropDown)fmMain.FindControl(strObjID); oCascad.ucServiceMethod = AclExpress._AclAreaGrantServiceMethod; oCascad.ucCategory01 = "AreaID"; oCascad.ucCategory02 = "GrantID"; oCascad.ucDropDownListEnabled01 = true; oCascad.ucDropDownListEnabled02 = true; oCascad.ucDropDownListEnabled03 = false; oCascad.ucDropDownListEnabled04 = false; oCascad.ucDropDownListEnabled05 = false; if (dr != null) { oCascad.ucDefaultSelectedValue01 = dr["AreaID"].ToString().Trim(); } if (dr != null) { oCascad.ucDefaultSelectedValue02 = dr["GrantID"].ToString().Trim(); } oCascad.Refresh(); strObjID = "AuthType"; oDdl = (Util_ucCommSingleSelect)fmMain.FindControl(strObjID); oDdl.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthTypeList()); if (dr != null) { oDdl.ucSelectedID = dr[strObjID].ToString().Trim(); } oDdl.Refresh(); strObjID = "AllowActList"; oChkList = (Util_ucCheckBoxList)fmMain.FindControl(strObjID); oChkList.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthActList()); if (dr != null) { oChkList.ucSelectedIDList = dr[strObjID].ToString().Trim(); } oChkList.Refresh(); strObjID = "Remark"; oText = (Util_ucTextBox)fmMain.FindControl(strObjID); if (dr != null) { oText.ucTextData = dr[strObjID].ToString().Trim(); } } //「編輯」模式 if (fmMain.CurrentMode == FormViewMode.Edit) { //自訂檢核失敗時的JS提醒訊息 Util.setJS_AlertPageNotValid("btnUpdate"); strObjID = "RuleID"; oDdl = (Util_ucCommSingleSelect)fmMain.FindControl(strObjID); oDdl.ucSourceDictionary = Util.getDictionary(AclExpress.getAclRuleData(), 0, 1, true); oDdl.ucIsReadOnly = true; //鍵值欄位需為唯讀 if (dr != null) { oDdl.ucSelectedID = dr[strObjID].ToString().Trim(); } oDdl.Refresh(); strObjID = "AreaGrant"; oCascad = (Util_ucCascadingDropDown)fmMain.FindControl(strObjID); oCascad.ucServiceMethod = AclExpress._AclAreaGrantServiceMethod; oCascad.ucCategory01 = "AreaID"; oCascad.ucCategory02 = "GrantID"; oCascad.ucDropDownListEnabled01 = true; oCascad.ucDropDownListEnabled02 = true; oCascad.ucDropDownListEnabled03 = false; oCascad.ucDropDownListEnabled04 = false; oCascad.ucDropDownListEnabled05 = false; oCascad.ucIsReadOnly01 = true; //鍵值欄位需為唯讀 oCascad.ucIsReadOnly02 = true; //鍵值欄位需為唯讀 if (dr != null) { oCascad.ucDefaultSelectedValue01 = dr["AreaID"].ToString().Trim(); } if (dr != null) { oCascad.ucDefaultSelectedValue02 = dr["GrantID"].ToString().Trim(); } oCascad.Refresh(); strObjID = "AuthType"; oDdl = (Util_ucCommSingleSelect)fmMain.FindControl(strObjID); oDdl.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthTypeList()); if (dr != null) { oDdl.ucSelectedID = dr[strObjID].ToString().Trim(); } oDdl.Refresh(); strObjID = "AllowActList"; oChkList = (Util_ucCheckBoxList)fmMain.FindControl(strObjID); oChkList.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthActList()); if (dr != null) { oChkList.ucSelectedIDList = dr[strObjID].ToString().Trim(); } oChkList.Refresh(); strObjID = "Remark"; oText = (Util_ucTextBox)fmMain.FindControl(strObjID); if (dr != null) { oText.ucTextData = dr[strObjID].ToString().Trim(); } //刪除確認訊息 Button oBtn = (Button)fmMain.FindControl("btnDelete"); if (oBtn != null) { Util.ConfirmBox(oBtn, RS.Resources.Msg_Confirm_Delete); } } }
/// <summary> /// 更新授權資料(By User) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdByUserID_Click(object sender, EventArgs e) { //by UserID ucSeleGrantList.ucSourceDictionary = _DicGrantList; ucSeleGrantList.Refresh(); if (_UserGrantList != ucSeleGrantList.ucSelectedIDList) { try { string[] tmpList = null; string strTable = "AclAuthUserAreaGrantList"; Dictionary <string, string> dicKey = new Dictionary <string, string>(); DbHelper db = new DbHelper(AclExpress._AclDBName); string strSQL = ""; //刪除既有授權資料 if (!string.IsNullOrEmpty(_UserGrantList)) { tmpList = _UserGrantList.Split(','); for (int i = 0; i < tmpList.Count(); i++) { dicKey.Clear(); dicKey.Add("UserID", ucSeleUserID.ucSelectedID); dicKey.Add("AreaID", PageAclAreaID); dicKey.Add("GrantID", tmpList[i]); AclExpress.IsAclTableLog(strTable, dicKey, LogHelper.AppTableLogType.Delete); strSQL = Util.getDataDeleteSQL(Util.getArray(dicKey, 0), Util.getArray(dicKey, 1), strTable.Split(',')); db.ExecuteNonQuery(strSQL); } } //添加新的授權資料 if (!string.IsNullOrEmpty(ucSeleGrantList.ucSelectedIDList)) { string strAuthType = AclExpress.getAclAuthTypeList().Keys.Last(); tmpList = ucSeleGrantList.ucSelectedIDList.Split(','); for (int i = 0; i < tmpList.Count(); i++) { dicKey.Clear(); dicKey.Add("UserID", ucSeleUserID.ucSelectedID); dicKey.Add("AreaID", PageAclAreaID); dicKey.Add("GrantID", tmpList[i]); strSQL = "Insert " + strTable + " (UserID,AreaID,GrantID,UserName,AuthType,AllowActList,Remark,UpdUser,UpdDateTime) "; strSQL += string.Format(" Values ('{0}','{1}','{2}','{3}','{4}','','By AclAuthUtil','{5}',getdate());", dicKey["UserID"], dicKey["AreaID"], dicKey["GrantID"], UserInfo.findUserName(dicKey["UserID"]), strAuthType, UserInfo.getUserInfo().UserID); db.ExecuteNonQuery(strSQL); AclExpress.IsAclTableLog(strTable, dicKey, LogHelper.AppTableLogType.Create); } } _UserGrantList = ucSeleGrantList.ucSelectedIDList; Util.NotifyMsg(AclRS.Resources.Msg_AclAuthUpdateSucceed, Util.NotifyKind.Success); //[ACL] 授權資料更新成功! } catch (Exception ex) { LogHelper.WriteAppLog(AclExpress._AclDBName, LogHelper.AppLogType.Error, "AclExpress", "AclAuthUtil", ex.Message); Util.NotifyMsg(AclRS.Resources.Msg_AclAuthUpdateFail, Util.NotifyKind.Error); //[ACL] 授權資料更新失敗! } } else { Util.NotifyMsg(AclRS.Resources.Msg_AclAuthUpdateNoAction); //[ACL] 無異動,不需更新授權資料! } }
/// <summary> /// 重新整理 /// </summary> public void Refresh() { divActionBar.Visible = true; labErrMsg.Visible = false; if (!string.IsNullOrEmpty(ucCssClass)) { divActionBar.Attributes["class"] = ucCssClass; } if (!string.IsNullOrEmpty(ucCustStyle)) { divActionBar.Attributes["style"] = ucCustStyle; } Button tmpBtn; ArrayList tmpBtnList = new ArrayList(); //Query tmpBtn = (Button)this.FindControl("btnQuery"); tmpBtn.CommandName = "cmdQuery"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucQueryCaption; tmpBtn.ToolTip = this.ucQueryToolTip; tmpBtn.Visible = this.ucQueryEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Query); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } //Add tmpBtn = (Button)this.FindControl("btnAdd"); tmpBtn.CommandName = "cmdAdd"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucAddCaption; tmpBtn.ToolTip = this.ucAddToolTip; tmpBtn.Visible = this.ucAddEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Add); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } //Edit tmpBtn = (Button)this.FindControl("btnEdit"); tmpBtn.CommandName = "cmdEdit"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucEditCaption; tmpBtn.ToolTip = this.ucEditToolTip; tmpBtn.Visible = this.ucEditEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Edit); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } //Delete tmpBtn = (Button)this.FindControl("btnDelete"); tmpBtn.CommandName = "cmdDelete"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucDeleteCaption; tmpBtn.ToolTip = this.ucDeleteToolTip; tmpBtn.Visible = this.ucDeleteEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Delete); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } //Copy tmpBtn = (Button)this.FindControl("btnCopy"); tmpBtn.CommandName = "cmdCopy"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucCopyCaption; tmpBtn.ToolTip = this.ucCopyToolTip; tmpBtn.Visible = this.ucCopyEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Copy); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } //Export tmpBtn = (Button)this.FindControl("btnExport"); tmpBtn.CommandName = "cmdExport"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucExportCaption; tmpBtn.ToolTip = this.ucExportToolTip; tmpBtn.Visible = this.ucExportEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Export); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } //Download tmpBtn = (Button)this.FindControl("btnDownload"); tmpBtn.CommandName = "cmdDownload"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucDownloadCaption; tmpBtn.ToolTip = this.ucDownloadToolTip; tmpBtn.Visible = this.ucDownloadEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Download); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } //Information tmpBtn = (Button)this.FindControl("btnInformation"); tmpBtn.CommandName = "cmdInformation"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucInformationCaption; tmpBtn.ToolTip = this.ucInformationToolTip; tmpBtn.Visible = this.ucInformationEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Information); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } //Multilingual tmpBtn = (Button)this.FindControl("btnMultilingual"); tmpBtn.CommandName = "cmdMultilingual"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucMultilingualCaption; tmpBtn.ToolTip = this.ucMultilingualToolTip; tmpBtn.Visible = this.ucMultilingualEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Multilingual); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } //Print tmpBtn = (Button)this.FindControl("btnPrint"); tmpBtn.CommandName = "cmdPrint"; tmpBtn.CommandArgument = ""; tmpBtn.CssClass = ucBtnCssClass; tmpBtn.Width = ucButtonWidth; tmpBtn.Height = ucButtonHeight; tmpBtn.CausesValidation = this.ucBtnCausesValidation; tmpBtn.Text = this.ucPrintCaption; tmpBtn.ToolTip = this.ucPrintToolTip; tmpBtn.Visible = this.ucPrintEnabled; if (ucAclEnabled && tmpBtn.Visible) { tmpBtn.Visible = AclExpress.IsAclPageAuthAct(AclExpress.AclAuthActList.Print); } if (tmpBtn.Visible) { tmpBtnList.Add(tmpBtn.CommandName); } if (tmpBtnList.Count <= 0) { divActionBar.Visible = false; labErrMsg.Visible = true; labErrMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, string.Format(RS.Resources.Msg_AccessDenied1, "ActionBar")); } }
/// <summary> /// 資料清單執行命令 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ucGridView1_RowCommand(object sender, Util_ucGridView.RowCommandEventArgs e) { DbHelper db = new DbHelper(_DBName); DataTable dt = null; CommandHelper sb = db.CreateCommandHelper(); string[] oDataKeys = e.DataKeys; switch (e.CommandName) { case "cmdAdd": //新增模式 DivQryArea.Visible = false; divMainGridview.Visible = false; fmMain.ChangeMode(FormViewMode.Insert); fmMain.DataSource = null; fmMain.DataBind(); divMainFormView.Visible = true; break; case "cmdCopy": //資料複製 sb.Reset(); sb.AppendStatement("Select * From AclAuthRuleAreaGrantList Where 0 = 0 "); sb.Append(Util.getDataQueryKeySQL(_PKList, oDataKeys)); dt = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; DivQryArea.Visible = false; divMainGridview.Visible = false; fmMain.ChangeMode(FormViewMode.Insert); fmMain.DataSource = dt; fmMain.DataBind(); divMainFormView.Visible = true; break; case "cmdEdit": //資料編輯 DivQryArea.Visible = false; divMainGridview.Visible = false; sb.Reset(); sb.AppendStatement("Select * From AclAuthRuleAreaGrantList Where 0 = 0 "); sb.Append(Util.getDataQueryKeySQL(_PKList, oDataKeys)); dt = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; fmMain.ChangeMode(FormViewMode.Edit); fmMain.DataSource = dt; fmMain.DataBind(); divMainFormView.Visible = true; break; case "cmdDelete": //資料刪除 try { Dictionary <string, string> dicKey = Util.getDictionary(_PKList, oDataKeys); AclExpress.IsAclTableLog("AclAuthRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Delete); sb.Reset(); sb.AppendStatement("Delete From AclAuthRuleAreaGrantList Where 0 = 0 "); sb.Append(Util.getDataQueryKeySQL(_PKList, oDataKeys)); db.ExecuteNonQuery(sb.BuildCommand()); Util.NotifyMsg(RS.Resources.Msg_DeleteSucceed, Util.NotifyKind.Success); //刪除成功 } catch { Util.NotifyMsg(RS.Resources.Msg_DeleteFail, Util.NotifyKind.Error); } break; case "cmdDataDump": //Data Dump 2016.11.08 string strHeader = string.Format("[{0}] 資料轉儲 SQL", "AclAuthRuleAreaGrantList"); string strDumpSQL = string.Empty; strDumpSQL += "/* ==================================================================== */ \n"; strDumpSQL += string.Format("/* {0} on [{1}] */ \n", strHeader, DateTime.Now); strDumpSQL += "/* ==================================================================== */ \n"; strDumpSQL += string.Format("Use {0} \nGo\n", AclExpress._AclDBName); strDumpSQL += "/* ==================== */ \n"; strDumpSQL += "/* AclAuthRuleAreaGrantList 相關物件 */ \n"; strDumpSQL += "/* ==================== */ \n"; strDumpSQL += Util.getDataDumpSQL(AclExpress._AclDBName, "AclAuthRuleAreaGrantList"); txtDumpSQL.ucTextData = strDumpSQL; ucModalPopup1.Reset(); ucModalPopup1.ucPopupWidth = 850; ucModalPopup1.ucPopupHeight = 600; ucModalPopup1.ucPopupHeader = strHeader; ucModalPopup1.ucPanelID = pnlDumpSQL.ID; ucModalPopup1.Show(); break; default: Util.MsgBox(string.Format(RS.Resources.Msg_Undefined1, e.CommandName)); //無此命令 break; } }