}//PrepDefaultValue private void databind() { #region ErrorMsgLabel.Text = ""; //抓取本頁初次登記的時間 SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); SYSModel.MaintainRoleprogauthrel BCO = new SYSModel.MaintainRoleprogauthrel(ConnectionDB); ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(this.SLP_ROLECODE.Text, "string", false)); ParameterList.Add(ddl_Module2.SelectedValue); DataTable Dt = BCO.QueryProgramHierarchyByRole(ParameterList); #region 使用XML放置到前端資料 #endregion dt_Result = Dt; SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; GridView1.DataBind(); if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { ErrorMsgLabel.Text = "查無資料"; } #endregion }
/// <summary> /// 存檔 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { switch (this.hid_PageStatus.Value) { case "EDIT": #region 處理修改作業 try { ErrorMsgLabel.Text = ""; if (GridView1.Rows.Count <= 0) { ErrorMsgLabel.Text = "無資料"; return; } else { SYSModel.MaintainRoleprogauthrel BCO = new SYSModel.MaintainRoleprogauthrel(ConnectionDB); #region 取得更新前舊值 #region 使用XML轉回DataSet DataTable dtDetailOLD = dt_Result; #endregion if (dtDetailOLD.Rows.Count == 0) { throw new Exception("抓取不到舊值,更新失敗!"); } #endregion BCO.UpdateMaster(this.getMasterParameterList(), this.getDetailData(), null, dtDetailOLD); //由檢視模式切換至編輯模式 this.hid_PageStatus.Value = "VIEW"; SetPageStatus(); databind(); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion break; default: break; } GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other; GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "SYS17A.aspx?mode=VIEW&Code=SYS17&ROLE=" + role_name + "&ID=" + role_id, null, WUI_GMToolbarV.ClickAction.LinkURL); GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, true, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick); EnableSelectAll(); }
/// <summary> /// 於檢視模式,按下刪除鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteButton_Click(object sender, EventArgs e) { try { ErrorMsgLabel.Text = ""; int DeleteRecord = 0; #region 取得畫面元件的值 DateTime processtime = DateTime.Now; #endregion #region 取得刪除前舊值 #region 使用XML轉回DataSet DataSet Ds = new DataSet(); DataTable Dt = dt_Result; #endregion if (Dt.Rows.Count == 0) { throw new Exception("抓取不到舊值,更新失敗!"); } #endregion #region 加入更新條件 ParameterList.Clear(); //舊值 ParameterList.Add(Dt.Rows[0]["ID"]); ParameterList.Add(Dt.Rows[0]["CODE"]); ParameterList.Add(Dt.Rows[0]["NAME"]); ParameterList.Add(Dt.Rows[0]["CREATEDATE"]); ParameterList.Add(Dt.Rows[0]["CREATEUID"]); ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]); ParameterList.Add(Dt.Rows[0]["UPDATEUID"]); ParameterList.Add(Dt.Rows[0]["ENABLE"]); ParameterList.Add(Dt.Rows[0]["ROLECODE"]); ParameterList.Add(Dt.Rows[0]["SYSTEMCODE"]); ParameterList.Add(Dt.Rows[0]["PROGRAMCODE"]); ParameterList.Add(Dt.Rows[0]["CANCREATE"]); ParameterList.Add(Dt.Rows[0]["CANREAD"]); ParameterList.Add(Dt.Rows[0]["CANUPDATE"]); ParameterList.Add(Dt.Rows[0]["CANDELETE"]); //需要更新值 ParameterList.Add(processtime); ParameterList.Add(Session["UID"].ToString()); #endregion SYSModel.MaintainRoleprogauthrel BCO = new SYSModel.MaintainRoleprogauthrel(ConnectionDB); DeleteRecord = BCO.DeleteRoleprogauthrel(ParameterList, null); if (DeleteRecord == 0) { throw new Exception("刪除失敗!"); } else { Response.Write("<script>alert('刪除完成');location.replace('SYS171.aspx?Code=SYS17');</script>"); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
/// <summary> /// 查詢資料庫取得資料 /// </summary> private void databind() { //抓取本頁初次登記的時間 string SessionIDName = "SYS171_" + PageTimeStamp.Value; SYSModel.MaintainRoleprogauthrel BCO = new SYSModel.MaintainRoleprogauthrel(ConntionDB); ParameterList.Clear(); ParameterList.Add(""); //ParameterList.Add(TextBoxCode.Text.Trim()); ParameterList.Add(TextBoxName.Text.Trim()); ParameterList.Add(TextBoxCreateDate.StartDate.Trim()); ParameterList.Add(TextBoxCreateDate.EndDate.Trim()); ParameterList.Add(TextBoxCreateUID.Text.Trim()); ParameterList.Add(TextBoxUpdateDate.StartDate.Trim()); ParameterList.Add(TextBoxUpdateDate.EndDate.Trim()); ParameterList.Add(TextBoxUpdateUID.Text.Trim()); ParameterList.Add(SLP_RoleCode.Text.Trim()); ParameterList.Add(SLP_ProgramCode.Text.Trim()); ParameterList.Add(""); //ParameterList.Add(TextBoxSystemCode.Text.Trim()); ParameterList.Add(SLP_CanCreate.Text); ParameterList.Add(SLP_CanDelete.Text); ParameterList.Add(SLP_CanRead.Text); ParameterList.Add(SLP_CanUpdate.Text); ParameterList.Add("1");//SLP_Enable.Text); ParameterList.Add(TextBoxRowCountLimit.Text.Trim()); DataTable Dt = BCO.QueryRow(ParameterList, CheckBoxLikeSearch.Checked); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; //設定分頁大小 if (TextBoxPagesize.Text == "0") { GridView1.PageSize = 1; } else { GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); } GridView1.PageIndex = 0; GridView1.DataBind(); #region 將Key值存到Session中 ArrayList arl_Key = new ArrayList(); foreach (DataRow drRow in Dt.Rows) { arl_Key.Add("id=" + drRow["ID"].ToString()); } Session["SYS17_SortKey" + this.PageTimeStamp.Value] = arl_Key; #endregion if (Dt.Rows.Count == 0) { this.ErrorMsgLabel.Text = "查無資料"; } }
}//end EditCancelButton_Click /// <summary> /// 編輯模式,按下更新確認鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void EditCommitButton_Click(object sender, EventArgs e) { //Trace.Warn("EditCommit"); try { ErrorMsgLabel.Text = ""; int UpdateRecord = 0; #region 取得畫面元件的值 string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim(); DateTime processtime = DateTime.Now; string v_RoleCode = ((WUI.SLP.Role)this.FormView1.FindControl("SLP_RoleCode")).Text; string v_SystemCode = "VDS2G";// string v_SystemCode = ((TextBox)FormView1.FindControl("TextBoxSystemCode")).Text; string v_ProgramCode = ((WUI.SLP.Program)this.FormView1.FindControl("SLP_ProgramCode")).Text; string v_CanCreate = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanCreate")).Text.Trim(); string v_CanRead = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanRead")).Text.Trim(); string v_CanUpdate = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanUpdate")).Text.Trim(); string v_CanDelete = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanDelete")).Text.Trim(); string v_Enable = "1";// ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_Enable")).Text.Trim(); #endregion #region 取得更新前舊值 #region 使用XML轉回DataSet DataSet Ds = new DataSet(); DataTable Dt = dt_Result; #endregion if (Dt.Rows.Count == 0) { throw new Exception("抓取不到舊值,更新失敗!"); } #endregion #region 加入更新條件 ParameterList.Clear(); //舊值 // ParameterList.Add(Dt.Rows[0]["ID"]); // ParameterList.Add(Dt.Rows[0]["CODE"]); ParameterList.Add(Dt.Rows[0]["NAME"]); ParameterList.Add(Dt.Rows[0]["CREATEDATE"]); ParameterList.Add(Dt.Rows[0]["CREATEUID"]); ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]); ParameterList.Add(Dt.Rows[0]["UPDATEUID"]); ParameterList.Add(Dt.Rows[0]["ENABLE"]); ParameterList.Add(Dt.Rows[0]["ROLECODE"]); ParameterList.Add(Dt.Rows[0]["SYSTEMCODE"]); ParameterList.Add(Dt.Rows[0]["PROGRAMCODE"]); ParameterList.Add(Dt.Rows[0]["CANCREATE"]); ParameterList.Add(Dt.Rows[0]["CANREAD"]); ParameterList.Add(Dt.Rows[0]["CANUPDATE"]); ParameterList.Add(Dt.Rows[0]["CANDELETE"]); //需要更新值 ParameterList.Add(v_Name); ParameterList.Add(processtime); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(v_RoleCode); ParameterList.Add(v_SystemCode); ParameterList.Add(v_ProgramCode); ParameterList.Add(v_CanCreate); ParameterList.Add(v_CanRead); ParameterList.Add(v_CanUpdate); ParameterList.Add(v_CanDelete); ParameterList.Add(v_Enable); #endregion SYSModel.MaintainRoleprogauthrel BCO = new SYSModel.MaintainRoleprogauthrel(ConnectionDB); UpdateRecord = BCO.UpdateRoleprogauthrel(ParameterList, null); if (UpdateRecord == 0) { throw new Exception("更新0筆資料!"); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "SYS172", "<script>alert('更改完成');</script>"); ChangeFormMode(FormViewMode.ReadOnly); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
}//end InsertCancelButton_Click /// <summary> /// 由新增模式,確認新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertButton_Click(object sender, EventArgs e) { try { ErrorMsgLabel.Text = ""; int AddRecord = 0; #region 取得畫面元件的值 string v_Code = ""; //string v_Code = ((WUI.SLP.SLPUnique)FormView1.FindControl("TextBoxCode")).Text.Trim(); //string v_Name = ((TextBox)FormView1.FindControl("SLP_RoleCode")).Text.Trim(); DateTime processtime = DateTime.Now; string v_RoleCode = ((WUI.SLP.Role)this.FormView1.FindControl("SLP_RoleCode")).Text; string v_SystemCode = "VDS2G"; //string v_SystemCode = ((TextBox)FormView1.FindControl("SLP_SystemCode")).Text; string v_ProgramCode = ((WUI.SLP.Program)this.FormView1.FindControl("SLP_ProgramCode")).Text; string v_CanCreate = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanCreate")).Text.Trim(); string v_CanRead = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanRead")).Text.Trim(); string v_CanUpdate = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanUpdate")).Text.Trim(); string v_CanDelete = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanDelete")).Text.Trim(); SYSModel.MaintainRole BCO2 = new SYSModel.MaintainRole(ConnectionDB); ParameterList.Clear(); ParameterList.Add(v_RoleCode); DataTable Chkrole = BCO2.QueryRoleByCode(ParameterList); if (Chkrole.Rows.Count != 1) { ErrorMsgLabel.Text = "請輸入正確角色代號"; return; } SYSModel.MaintainRoleprogauthrel Uniq = new SYSModel.MaintainRoleprogauthrel(ConnectionDB); ParameterList.Clear(); ParameterList.Add(v_RoleCode); ParameterList.Add(v_ProgramCode); DataTable Dup = Uniq.QueryDup(ParameterList); if (Dup.Rows.Count > 0) { if (Dup.Rows[0]["ENABLE"].ToString() == "1") { throw new Exception("資料重覆!"); } } ParameterList.Clear(); ParameterList.Add(v_RoleCode); DataTable role_name = BCO2.QueryRoleByCode(ParameterList); string v_Name = role_name.Rows[0]["NAME"].ToString(); #endregion #region 加入輸入條件 ParameterList.Clear(); ParameterList.Add(v_Code); ParameterList.Add(v_Name); ParameterList.Add(processtime); //vCreateDate ParameterList.Add(Session["UID"].ToString()); //vCreateUID ParameterList.Add(processtime); //vUpdateDate ParameterList.Add(Session["UID"].ToString()); //vUpdateUID ParameterList.Add(v_RoleCode); ParameterList.Add(v_SystemCode); ParameterList.Add(v_ProgramCode); ParameterList.Add(v_CanCreate); ParameterList.Add(v_CanRead); ParameterList.Add(v_CanUpdate); ParameterList.Add(v_CanDelete); #endregion SYSModel.MaintainRoleprogauthrel BCO = new SYSModel.MaintainRoleprogauthrel(ConnectionDB); AddRecord = BCO.CreateRoleprogauthrel(ParameterList, null); if (AddRecord == 0) { throw new Exception("新增0筆資料!"); } else { Response.Write("<script>alert('新增完成');location.replace('SYS172.aspx?ID=" + AddRecord + "');</script>"); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
/// <summary> /// 取得所有Master資料以巡覽 /// </summary> private void GetAllMasterRecordsForBrowse() { #region SYSModel.MaintainRoleprogauthrel BCO = new SYSModel.MaintainRoleprogauthrel(ConnectionDB); DataTable dtTemp = BCO.QueryRoleprogauthrelByALL(); DataView dvForBrowse = dtTemp.DefaultView; dtForBrowse = dvForBrowse.ToTable(); #endregion }
private void Loaddata(string NewCode) { SYSModel.MaintainRoleprogauthrel BCO = new SYSModel.MaintainRoleprogauthrel(ConnectionDB); ParameterList.Clear(); ParameterList.Add(NewCode); DataTable Dt = BCO.QueryRoleprogauthrelByID(ParameterList); if (Dt != null) { if (Dt.Rows.Count == 0) { ArrayList AL = (ArrayList)Session["SYS17_SortKey" + Request.QueryString["SYS172_PageTimeStamp"]]; string strRemove = "id=" + NewCode; AL.Remove(strRemove); Session["SYS17_SortKey" + Request.QueryString["SYS172_PageTimeStamp"]] = AL; throw new Exception("此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!"); } } }
/// <summary> /// 繫結資料 /// </summary> /// <param name=VirtualDataID></param> private void databind(FormViewMode fvm) { try { SYSModel.MaintainRoleprogauthrel BCO = new SYSModel.MaintainRoleprogauthrel(ConnectionDB); ParameterList.Clear(); if (Request["ID"] != null) ParameterList.Add(Request["ID"].ToString()); else ParameterList.Add("0"); dt_Result = BCO.QuerySwitch(SYSModel.MaintainRoleprogauthrel.QueryType.ID, ParameterList ); if (dt_Result.Rows.Count > 0) { this.hiddenID.Value = dt_Result.Rows[0]["ID"].ToString(); FormView1.DataSource = dt_Result; FormView1.DataBind(); } AuthorityControls(this); //ToolBarStatus switch (fvm) { case FormViewMode.Edit: ToolBarStatus("edit"); break; case FormViewMode.Insert: ToolBarStatus("insert"); break; case FormViewMode.ReadOnly: ToolBarStatus("readonly"); break; } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }//databind