using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; namespace FineUIPro.Web.HSSE.Train { public partial class TestTrainRecord : PageBase { #region 项目主键 /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId) { this.ProjectId = Request.Params["projectId"]; } ////权限按钮方法 this.ucTree.UnitId = this.CurrUser.UnitId; this.ucTree.ProjectId = this.ProjectId; if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) { this.panelLeftRegion.Hidden = true; //////权限按钮方法 //this.GetButtonPower(); } this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); this.BindGrid(); } else { if (GetRequestEventArgument() == "reloadGrid") { BindGrid(); } } } /// /// 加载树 /// /// /// protected void changeTree(object sender, EventArgs e) { this.ProjectId = this.ucTree.ProjectId; this.BindGrid(); //this.GetButtonPower(); //if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) //{ // btnNew.Hidden = true; //} } #endregion #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { if (string.IsNullOrEmpty(this.ProjectId)) { return; } string strSql = @"SELECT Task.TaskId,Task.TaskDate,person.PersonName,TrainingItem.TrainingId,TrainingItem.TrainingItemId,Training.TrainingCode,Training.TrainingName" + @",TrainingItem.TrainingItemCode,TrainingItem.TrainingItemName " + @" FROM Training_Task AS Task" + @" LEFT JOIN Training_PlanItem AS PlanItem ON Task.PlanId =PlanItem.PlanId " + @" LEFT JOIN SitePerson_Person AS person ON Task.UserId =person.PersonId " + @" LEFT JOIN Training_TrainingItem AS TrainingItem ON PlanItem.TrainingEduItemId =TrainingItem.TrainingItemId" + @" LEFT JOIN Training_Training AS Training ON TrainingItem.TrainingId=Training.TrainingId" + @" WHERE 1=1 "; strSql += " AND Task.UserId=@UserId "; List listStr = new List { new SqlParameter("@UserId", this.CurrUser.UserId) }; if (!string.IsNullOrEmpty(this.ckStates.SelectedValue) && this.ckStates.SelectedValue != "0") { if (this.ckStates.SelectedValue == "1") { strSql += " AND (Task.States ='0') "; } else { strSql += " AND Task.States ='1' "; } } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #endregion #region 查看 /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditData(); } /// /// 右键编辑 /// /// /// protected void btnMenuView_Click(object sender, EventArgs e) { this.EditData(); } /// /// 编辑 /// private void EditData() { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TaskRecordView.aspx?TrainingEduItemId={0}", Grid1.SelectedRowID, "编辑 - "))); } #endregion /// /// 状态 /// /// /// protected void ckStates_SelectedIndexChanged(object sender, EventArgs e) { this.BindGrid(); } #region 分页排序 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } #endregion } }