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 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 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); } }
/// <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); } }
/// <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; } }
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> /// 更新授權資料(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> /// <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; } }