protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //this.lblSignIn.Text = this.currentUser.empNm; } //获取当前登陆用户角色名称 string roleName = ""; DataSet ds = new DataSet(); PUserRoleBB userRoleBB = new PUserRoleBB(); try { ds = userRoleBB.GetVList("empId=" + this.currentUser.empId.ToString()); if (ds.Tables[0].Rows.Count > 0) { roleName = ds.Tables[0].Rows[0]["roleName"].ToString(); } } finally { userRoleBB.Dispose(); } //显示欢迎信息 this.labWelcome.Text = "" + this.currentUser.empNo + " " + this.currentUser.empNm; //显示日期信息 CNDate cNDate = new CNDate(); DateTime today = DateTime.Today; string lunarToday = cNDate.ToLunarCald(today); this.date_area.Text = today.Month.ToString() + "月" + today.Day.ToString() + "日" + " 农历 " + cNDate.GetLunarHolDay(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //this.lblSignIn.Text = this.currentUser.empNm; } //获取当前登陆用户角色名称 string roleName = ""; DataSet ds = new DataSet(); PUserRoleBB userRoleBB = new PUserRoleBB(); try { ds = userRoleBB.GetVList("empId=" + this.currentUser.empId.ToString()); if (ds.Tables[0].Rows.Count > 0) { roleName = ds.Tables[0].Rows[0]["roleName"].ToString(); } } finally { userRoleBB.Dispose(); } //显示欢迎信息 this.labWelcome.Text = "欢迎您:" + this.currentUser.empNm + " " + roleName; //显示日期信息 CNDate cNDate = new CNDate(); DateTime today = DateTime.Today; string lunarToday = cNDate.ToLunarCald(today); //this.date_area.Text = today.ToLongDateString() + " " + cNDate.GetWeekChi(today) + " 农历 " // + cNDate.GetLunarHolDay(); this.date_area.Text = today.Month.ToString() + "月" + today.Day.ToString() + "日" + " 农历 " + cNDate.GetLunarHolDay(); //注册客户端脚步,更新时间区域 //if (!this.ClientScript.IsStartupScriptRegistered("RefreshTime")) //{ // StringBuilder refreshTimeBuilder = new StringBuilder(); // DateTime now = DateTime.Now; // refreshTimeBuilder.Append(" <script type=\"text/javascript\" language=\"javascript\">\r\n"); // refreshTimeBuilder.Append(" var OA_TIME = new Date(" + now.Year.ToString() + "," + now.Month.ToString() + "," // + now.Day.ToString() + "," + now.Hour.ToString() + "," + now.Minute.ToString() + "," + now.Second.ToString() + ");\r\n"); // refreshTimeBuilder.Append(" function timeview()\r\n"); // refreshTimeBuilder.Append(" {\r\n"); // refreshTimeBuilder.Append(" timestr=OA_TIME.toLocaleString();\r\n"); // refreshTimeBuilder.Append(" timestr=timestr.substr(timestr.indexOf(\":\")-2);\r\n"); // refreshTimeBuilder.Append(" document.getElementById(\"time_area\").innerHTML = timestr;\r\n"); // refreshTimeBuilder.Append(" OA_TIME.setSeconds(OA_TIME.getSeconds()+1);\r\n"); // refreshTimeBuilder.Append(" window.setTimeout(\"timeview()\", 1000 );\r\n"); // refreshTimeBuilder.Append(" }\r\n"); // refreshTimeBuilder.Append(" </script>\r\n"); // this.ClientScript.RegisterStartupScript(this.GetType(), "RefreshTime", refreshTimeBuilder.ToString()); //} this.ShowMenuInfo(); }
protected void RemoveEmp_Click(object sender, EventArgs e) { if (this.empListed.SelectedIndex > -1) { PUserRoleBB userRoleBB = new PUserRoleBB(); try { userRoleBB.DeleteRecord(Convert.ToInt32(this.empListed.SelectedValue)); this.BindDataList(0, this.empListed.SelectedIndex); } finally { userRoleBB.Dispose(); } } }
protected void AddRole_Click(object sender, EventArgs e) { if (this.roleList.SelectedIndex > -1) { PUserRoleData model = new PUserRoleData(); PUserRoleBB userRoleBB = new PUserRoleBB(); try { model.empId = this.EmpId; model.roleId = Convert.ToInt32(this.roleList.SelectedValue); userRoleBB.AddRecord(model); this.BindDataList(this.roleList.SelectedIndex, 0); } finally { userRoleBB.Dispose(); } } }
/// <summary> /// 根据树列表绑定grid /// </summary> private void BindDataList(int roleListIndex, int roleListedIndex) { PUserRoleBB userRoleBB = new PUserRoleBB(); DataSet ds = new DataSet(); //绑定已有岗位 try { ds = userRoleBB.GetVList("empId=" + this.EmpId.ToString()); this.roleListed.DataTextField = "roleName"; this.roleListed.DataValueField = "id"; this.roleListed.DataSource = ds; this.roleListed.DataBind(); if (this.roleListed.Items.Count > roleListedIndex) { this.roleListed.SelectedIndex = roleListedIndex; } else if (this.roleListed.Items.Count > 0) { this.roleListed.SelectedIndex = this.roleListed.Items.Count - 1; } } finally { userRoleBB.Dispose(); } //绑定未有岗位 SCommBB commBB = new SCommBB(); try { string strSql = "select * from PRole where not exists(select 1 from PUserRole where empId=" + this.EmpId.ToString() + " and roleId=PRole.id)"; ds = commBB.Query(strSql); this.roleList.DataTextField = "roleName"; this.roleList.DataValueField = "id"; this.roleList.DataSource = ds; this.roleList.DataBind(); if (this.roleList.Items.Count > roleListIndex) { this.roleList.SelectedIndex = roleListIndex; } else if (this.roleList.Items.Count > 0) { this.roleList.SelectedIndex = this.roleList.Items.Count - 1; } } finally { commBB.Dispose(); } }
/// <summary> /// 根据树列表绑定grid /// </summary> private void BindDataList(int empListIndex, int empListedIndex) { PUserRoleBB userRoleBB = new PUserRoleBB(); DataSet ds = new DataSet(); //绑定已有人员 try { ds = userRoleBB.GetVList("roleId=" + this.RoleId.ToString()); this.empListed.DataTextField = "empNm"; this.empListed.DataValueField = "id"; this.empListed.DataSource = ds; this.empListed.DataBind(); if (this.empListed.Items.Count > empListedIndex) { this.empListed.SelectedIndex = empListedIndex; } else if (this.empListed.Items.Count > 0) { this.empListed.SelectedIndex = this.empListed.Items.Count - 1; } } finally { userRoleBB.Dispose(); } //绑定未有人员 SCommBB commBB = new SCommBB(); try { string strSql = "select * from HEemployee where isDel=0 and isEffect=1 and not exists(select 1 from PUserRole where roleId=" + this.RoleId.ToString() + " and empId=HEemployee.empId)"; ds = commBB.Query(strSql); this.empList.DataTextField = "empNm"; this.empList.DataValueField = "empId"; this.empList.DataSource = ds; this.empList.DataBind(); if (this.empList.Items.Count > empListIndex) { this.empList.SelectedIndex = empListIndex; } else if (this.empList.Items.Count > 0) { this.empList.SelectedIndex = this.empList.Items.Count - 1; } } finally { commBB.Dispose(); } }
/// <summary> /// ɾ�� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { PRoleBB roleBB = new PRoleBB(); PUserRoleBB userRoleBB = new PUserRoleBB(); PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB(); //��ȡѡ�е�����Id try { foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); int id = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["id"]); if (chkId.Checked == true) { PRoleData roleData = new PRoleData(); roleData = roleBB.GetModel(id); if (roleData.isSys) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"����λΪϵͳ��λ������ɾ����\");", true); return; } else { //ɾ����ɫ��ͬʱ��ɾ����Ա��ɫ����ɫȨ�� roleBB.DeleteRecord(id); userRoleBB.DeleteRecordByRole(id); rolePermissionsBB.DeleteRecordByRole(id, 2); } } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { roleBB.Dispose(); userRoleBB.Dispose(); rolePermissionsBB.Dispose(); } this.BindGrid(); }