using System; using System.Collections.Generic; using System.Linq; using System.Web.UI.WebControls; using System.Data; using BLL; using System.Data.SqlClient; namespace FineUIPro.Web.CQMS.WBS { public partial class ProjectControlPointAuditRecord : PageBase { #region 项目主键 /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } public bool Editable { get { return (bool)ViewState["Editable"]; } set { ViewState["Editable"] = value; } } #endregion #region 页面加载 /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Editable = false; 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.ProjectId)) { this.panelLeftRegion.Hidden = true; ////权限按钮方法 this.GetButtonPower(); } BindGrid(); } } #endregion /// /// 公司级树加载 /// /// /// protected void changeTree(object sender, EventArgs e) { this.ProjectId = this.ucTree.ProjectId; if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) { btnNew.Hidden = true; } this.GetButtonPower(); this.BindGrid(); } #region 修改关闭窗口 /// /// 关闭窗口 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } #endregion #region 删除 /// /// 删除 /// /// /// protected void btnMenuDel_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } BLL.BreakdownProjectAuditRecordService.DeleteBreakdown(Grid1.SelectedRowID); Grid1.DataBind(); BindGrid(); Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success); } #endregion #region 绑定数据 /// /// 绑定数据 /// /// /// protected void Grid1_FilterChange(object sender, EventArgs e) { BindGrid(); } protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// Grid1排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } /// /// 分页下拉选择事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 加载Grid /// private void BindGrid() { if (string.IsNullOrEmpty(this.ProjectId)) { return; } string strSql = @"SELECT AuditId ,WBS_BreakdownProjectAuditRecord.ProjectId ,AuditCode ,AuditDate ,AuditName ,Auditer ,Sys_User.UserName ,WBS_BreakdownProjectAuditRecord.Remark ,Creater ,CreateDate FROM dbo.WBS_BreakdownProjectAuditRecord left join Sys_User on Auditer = UserId "; List listStr = new List(); strSql += " where WBS_BreakdownProjectAuditRecord.ProjectId=@ProjectId"; listStr.Add(new SqlParameter("@ProjectId", this.ProjectId)); if (!string.IsNullOrEmpty(txtAuditCode.Text)) { strSql += " and AuditCode like '%" + txtAuditCode.Text + "%'"; } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #endregion #region 行点击事件 protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { string id = e.RowID; if (e.CommandName.Equals("download")) { string menuId = Const.ProjectControlPointAuditMenuId; PageContext.RegisterStartupScript(Windowtt.GetShowReference( String.Format("../../AttachFile/webuploader.aspx?type={0}&source=1&toKeyId={1}&path=FileUpload/BreakdownProject&menuId={2}",Editable?"1":"0", id, menuId))); } } #endregion /// /// 增加 /// /// /// protected void btnNew_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window1.GetShowReference("ProjectControlPointAuditRecordEdit.aspx", "新增 - ")); } protected void btnMenuEdit_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectControlPointAuditRecordEdit.aspx?AuditId={0}", this.Grid1.SelectedRowID, "新增 - "))); } #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.ProjectControlPointAuditMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnAdd)) { this.btnNew.Hidden = false; Editable = true; } if (buttonList.Contains(BLL.Const.BtnModify)) { this.Grid1.EnableRowDoubleClickEvent = true; this.btnMenuEdit.Hidden = false; Editable = true; } if (buttonList.Contains(BLL.Const.BtnDelete)) { this.btnMenuDelete.Hidden = false; } } } #endregion #region 查询 /// /// 查询 /// /// /// protected void btnSearch_Click(object sender, EventArgs e) { BindGrid(); } #endregion protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectControlPointAuditRecordEdit.aspx?AuditId={0}", e.RowID, "新增 - "))); } } }