using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.OleDb; using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.CQMS.WBS { public partial class ProjectQuality : PageBase { #region 定义变量 /// /// 上传预设的虚拟路径 /// private string initPath = Const.ExcelUrl; #endregion protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // 绑定表格 BindGrid(); } } /// /// 加载Grid /// private void BindGrid() { int? type = null; if (!string.IsNullOrEmpty(txtProjectQualityType.SelectedValue)) { type = Convert.ToInt32(txtProjectQualityType.SelectedValue); } DataTable tb = BLL.ProjectQualityService.GetProjectQualityList(type); Grid1.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ControlPointMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnAdd)) { this.btnNew.Hidden = false; //this.btnMenuAdd.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnModify)) { this.btnEdit.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnDelete)) { this.btnDel.Hidden = false; } } } #endregion /// /// 新增 /// /// /// protected void btnNew_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectQualityEdit.aspx?type=add&ProjectQualityId={0}", "", "新增 - "))); } /// /// 查看 /// /// /// protected void btnView_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectQualityEdit.aspx?type=detail&ProjectQualityId={0}", this.Grid1.SelectedRowID, "查看 - "))); } /// /// 修改 /// /// /// protected void btnEdit_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectQualityEdit.aspx?type=edit&ProjectQualityId={0}", this.Grid1.SelectedRowID, "修改 - "))); } /// /// 删除 /// /// /// protected void btnDel_Click(object sender, EventArgs e) { var result = BLL.ProjectQualityService.DelProjectQuality(this.Grid1.SelectedRowID); if (result) { ShowNotify("删除数据成功!", MessageBoxIcon.Success); 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(); } /// /// 分页索引事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } #region 关闭弹出窗口 /// /// 关闭弹出窗口 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } #endregion protected void txtProjectQualityType_SelectedIndexChanged(object sender, EventArgs e) { BindGrid(); } #region 下载模板 /// /// 下载模板按钮 /// /// /// protected void btnDownLoad_Click(object sender, EventArgs e) { string rootPath = Server.MapPath("~/"); string uploadfilepath = rootPath + Const.ProjectQualityTemplateUrl; string filePath = Const.PersonTemplateUrl; string fileName = Path.GetFileName(filePath); FileInfo info = new FileInfo(uploadfilepath); long fileSize = info.Length; Response.ClearContent(); Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.ContentType = "excel/plain"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.AddHeader("Content-Length", fileSize.ToString().Trim()); Response.TransmitFile(uploadfilepath, 0, fileSize); Response.End(); } #endregion #region 导入 /// /// 导入 /// /// /// protected void btnImport_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("ProjectQualityIn.aspx", "导入 - "))); } #endregion /// /// 关闭导入弹出窗口 /// /// /// protected void Window2_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } } }