using Aspose.Words.Lists; using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; namespace FineUIPro.Web.ProjectData { public partial class PreProjectApplyList : PageBase { #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ////权限按钮方法 //this.GetButtonPower(); this.btnApply.Hidden = false; this.btnMenuEdit.Hidden = false; this.btnMenuDelete.Hidden = false; Funs.DropDownPageSize(this.ddlPageSize); // 绑定表格 this.BindGrid(); } } /// /// 项目预立项申请 /// /// /// protected void btnApply_Click(object sender, EventArgs e) { string projectName = this.txtProjectName.Text.Trim(); PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PreProjectApply.aspx?ProjectName={0}", projectName, "项目预立项申请"))); } #endregion #region 绑定数据 /// /// 查询 /// /// /// protected void btnSearch_Click(object sender, EventArgs e) { BindGrid(); } protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } /// /// 绑定数据 /// private void BindGrid() { string strSql = @"SELECT (CASE State WHEN 1 THEN '通过' WHEN 2 THEN '不通过' ELSE '待审核' END) AS StateStr,* FROM DataGovernance_PreProjectApply WHERE 1=1 "; List listStr = new List(); string unitName = this.txtUnitName.Text.Trim(); string projectName = this.txtProjectName.Text.Trim(); if (!string.IsNullOrEmpty(unitName)) { strSql += " AND UnitName LIKE @UnitName"; listStr.Add(new SqlParameter("@UnitName", "%" + unitName + "%")); } if (!string.IsNullOrEmpty(projectName)) { strSql += " AND ProjectName LIKE @ProjectName"; listStr.Add(new SqlParameter("@ProjectName", "%" + projectName + "%")); } int state = int.Parse(this.rblState.SelectedValue); if (state >= 0) { strSql += " AND State = @State"; listStr.Add(new SqlParameter("@State", state)); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; Grid1.DataSource = this.GetPagedDataTable(Grid1, tb); Grid1.DataBind(); } #endregion #region 操作 Events /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length > 0) { foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); BLL.PreProjectApplyService.DeletePreProjectApply(rowID); } BindGrid(); ShowNotify("操作完成!", MessageBoxIcon.Success); } } #endregion /// /// /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { 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) { BindGrid(); } /// /// 双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditData(); } /// /// 右键编辑事件 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { this.EditData(); } /// /// 编辑数据方法 /// private void EditData() { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } var apply = BLL.PreProjectApplyService.GetPreProjectApplyById(Grid1.SelectedRowID); if (apply != null) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PreProjectApply.aspx?Id={0}", apply.Id, "项目预立项申请"))); } } /// /// 查看 /// /// /// protected void btnView_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Grid1.SelectedRowID)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectSetMap.aspx?projectId={0}&value=0", Grid1.SelectedRowID, "查看 - "))); } } #region 获取按钮权限 ///// ///// 获取按钮权限 ///// ///// ///// //private void GetButtonPower() //{ // if (Request.Params["value"] == "0") // { // return; // } // string menuId = Const.SeverProjectSetMenuId; // if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) // { // menuId = BLL.Const.ProjectSetMenuId; // } // var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, menuId); // if (buttonList.Count() > 0) // { // if (buttonList.Contains(BLL.Const.BtnAdd)) // { // this.btnApply.Hidden = false; // } // if (buttonList.Contains(BLL.Const.BtnModify) || buttonList.Contains(BLL.Const.BtnSave)) // { // this.btnMenuEdit.Hidden = false; // } // if (buttonList.Contains(BLL.Const.BtnDelete)) // { // this.btnMenuDelete.Hidden = false; // } // } //} #endregion #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 导出按钮 /// 导出按钮 /// /// /// protected void btnOut_Click(object sender, EventArgs e) { Response.ClearContent(); string filename = Funs.GetNewFileName(); Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("项目信息" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; this.Grid1.PageSize = 500; this.BindGrid(); Response.Write(GetGridTableHtml(Grid1)); Response.End(); } #endregion protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { object[] keys = Grid1.DataKeys[e.RowIndex]; string fileId = string.Empty; if (keys == null) { return; } else { fileId = keys[0].ToString(); } if (e.CommandName == "ProjectUnit") { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectUnit.aspx?projectId={0}&type=project", fileId))); } else if (e.CommandName == "ProjectUser") { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectUser.aspx?projectId={0}&type=project", fileId))); } } } }