/// <summary> /// 使用者登入所需作業 /// </summary> /// <param name="UserName">使用者名稱</param> public void UserLogin(string UserName) { //記錄使用者ID Session["UID"] = UserName; //統計人數 #region 傳入使用者ID ParameterList.Clear(); ParameterList.Add(UserName); #endregion //載入使用者資訊 SYSModel.MaintainUser user = new SYSModel.MaintainUser(ConnectionDB); Session["UserInfo"] = user.QueryUserByCode(ParameterList); //載入使用者功能表單 SYSModel.MaintainProgram prog = new SYSModel.MaintainProgram(ConnectionDB); DataTable Dt = prog.QueryAllProgramForUser(ParameterList); SYSModel.MaintainProgauthrel progth = new SYSModel.MaintainProgauthrel(ConnectionDB); DataTable Dt2 = progth.QueryCustProgramForUser(ParameterList); //如果為admin if (ParameterList[0].ToString() == __AdminUser) { for (int i = 0; i < Dt.Rows.Count; i++) { Dt.Rows[i]["Status"] = 1; } } Session["UserProgramStatus"] = Dt; Session["Cust_UserProgramStatus"] = Dt2; }
}//end InsertCancelButton_Click /// <summary> /// 由新增模式,確認新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertButton_Click(object sender, EventArgs e) { ErrorMsgLabel.Text = ""; int AddRecord = 0; try { #region 取得畫面元件的值 DateTime processtime = DateTime.Now; string v_UserCode = ((WUI.SLP.User)this.FormView1.FindControl("TextBoxUserCode")).Text; string v_RoleCode = ((WUI.SLP.Role)this.FormView1.FindControl("TextBoxRoleCode")).Text; //TextBox rolename = ((TextBox)this.FormView1.FindControl("TextBoxRoleCode").FindControl("TextBoxName")); string v_RoleName = ""; SYSModel.MaintainUser BCO1 = new SYSModel.MaintainUser(ConnectionDB); ParameterList.Clear(); ParameterList.Add(v_UserCode); DataTable Chkuser = BCO1.QueryUserByCode(ParameterList); if (Chkuser.Rows.Count != 1) { ErrorMsgLabel.Text = "請輸入正確人員代號"; return; } 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; } else { v_RoleName = Chkrole.Rows[0]["NAME"].ToString(); } ParameterList.Clear(); SYSModel.MaintainProgram Uniq = new SYSModel.MaintainProgram(ConnectionDB); ParameterList.Add(v_UserCode); ParameterList.Add("SYS_USERROLEREL"); ParameterList.Add("USERCODE"); ParameterList.Add(""); DataTable Dup = Uniq.QuerySwitch(SYSModel.MaintainProgram.QueryType.Duplicate, ParameterList ); if (Dup.Rows.Count > 0) { if (Dup.Rows[0]["ENABLE"].ToString() == "1") { throw new Exception("人員已存在角色關連!"); } } #endregion #region 加入輸入條件 ParameterList.Clear(); ParameterList.Add("");//ParameterList.Add(v_Code); ParameterList.Add(v_RoleName);//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_UserCode); ParameterList.Add(v_RoleCode); #endregion SYSModel.MaintainUserRoleRel BCO = new SYSModel.MaintainUserRoleRel(ConnectionDB); AddRecord = BCO.CreateUserRoleRel(ParameterList, null); if (AddRecord == 0) { throw new Exception("新增0筆資料!"); } else { Response.Write("<script>alert('新增完成');location.replace('SYS052.aspx?mode=readonly&ID=" + AddRecord + "');</script>"); } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }