using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using BLL; namespace FineUIPro.Web.CQMS.ManageReport { public partial class MonthReport : PageBase { #region 项目主键 /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion 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; this.BindGrid(); if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) { btnNew.Hidden = false; this.panelLeftRegion.Hidden = true; // this.Grid1.Columns[0].Hidden = true; ////权限按钮方法 this.GetButtonPower(); } } } protected void changeTree(object sender, EventArgs e) { this.ProjectId = this.ucTree.ProjectId; this.BindGrid(); this.GetButtonPower(); } public void BindGrid() { if (!string.IsNullOrEmpty(this.ProjectId)) { string strSql = @"select ReportId, Period, StartDate, EndDate, ProjectId, ReportType from Report_WeekAndMonthReport C where C.ProjectId = @ProjectId and ReportType=2"; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", this.ProjectId)); 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(); } } /// /// 格式化字符串 /// /// /// protected static string ConvertDate(object reportId) { string date = string.Empty; if (reportId != null) { var r = BLL.WeekAndMonthReportService.GetWeekAndMonthReportById(reportId.ToString()); if (r != null) { date = string.Format("{0:yyyy-MM-dd}", r.StartDate) + " 至 " + string.Format("{0:yyyy-MM-dd}", r.EndDate); } } return date; } protected void btnNew_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportEdit.aspx", "添加 - "))); } protected void btnMenuModify_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportEdit.aspx?reportId=" + Grid1.SelectedRowID, "添加 - "))); } protected void btnMenuDel_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string ReportId = Grid1.SelectedRowID.Split(',')[0]; BLL.ThisWeekOrMonthContentService.DeleteThisWeekOrMonthContentByReportId(ReportId); BLL.RowMaterialProblemService.DeleteRowMaterialProbleByReportId(ReportId); BLL.ConstructionProblemsService.DeleteConstructionProblemsByReportId(ReportId); BLL.NextQualityControlService.DeleteNextQualityControlByReportId(ReportId); BLL.ComprehensiveService.DeleteComprehensiveByReportId(ReportId); BLL.WeekAndMonthReportService.DeleteWeekAndMonthReportById(ReportId); Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success); } protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == BLL.Const._Null) { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.CQMS_MonthReportMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnModify)) { this.btnMenuModify.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnDelete)) { this.btnMenuDel.Hidden = false; } } } #endregion } }