using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Net; namespace FineUIPro.Web.CQMS.Plan { public partial class SubPlan : PageBase { #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.SubPlanMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(Const.BtnAdd)) { btnNew.Hidden = false; } if (buttonList.Contains(Const.BtnModify) || buttonList.Contains(Const.BtnSubmit)) { btnMenuModify.Hidden = false; } if (buttonList.Contains(Const.BtnDelete)) { btnMenuDel.Hidden = false; } } } #endregion protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetButtonPower(); Funs.FineUIPleaseSelect(drpState); UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true); CNProfessionalService.InitCNProfessionalDownList(drpCNProfessional, true); UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpProposeUnit, CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true); btnNew.OnClientClick = window_tt.GetShowReference("SubPlanEdit.aspx") + "return false;"; BindGrid(); } //else //{ // var eventArgs = GetRequestEventArgument(); // 此函数所在文件:PageBase.cs // if (eventArgs.StartsWith("ButtonClick")) // { // string rootPath = Server.MapPath("~/"); // string path = string.Empty; // if (drpModelType.SelectedValue == "1") // { // path = Const.SubPlanTemplateUrl1; // } // else // { // path = Const.SubPlanTemplateUrl3; // } // string uploadfilepath = rootPath + path; // string fileName = Path.GetFileName(uploadfilepath); // FileInfo fileInfo = new FileInfo(uploadfilepath); // FileInfo info = new FileInfo(uploadfilepath); // long fileSize = info.Length; // Response.Clear(); // Response.ContentType = "application/octet-stream"; // Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); // Response.AddHeader("Content-Length", fileSize.ToString()); // Response.TransmitFile(uploadfilepath, 0, fileSize); // Response.Flush(); // } //} } protected DataTable ChecklistData() { string strSql = @"SELECT chec.subPlanId,chec.ProjectId,chec.UnitId,chec.UnitWorkIds,chec.CNProfessionalCodes," + @" chec.CompileMan,chec.CompileDate,chec.code,chec.state,chec.PlanName," + @" unit.UnitName,u.PersonName as CompileManName" + @" FROM Plan_SubPlan chec " + @" left join Base_Unit unit on unit.unitId=chec.UnitId " + @" left join Person_Persons u on u.PersonId = chec.CompileMan" + @" where chec.ProjectId=@ProjectId"; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId)); if (drpProposeUnit.SelectedValue != Const._Null) { strSql += " AND chec.UnitId=@unitId"; listStr.Add(new SqlParameter("@unitId", drpProposeUnit.SelectedValue)); } if (drpUnitWork.SelectedValue != Const._Null) { strSql += " AND CHARINDEX(@unitworkId,chec.unitworkIds) > 0 "; listStr.Add(new SqlParameter("@unitworkId", drpUnitWork.SelectedValue)); } if (drpCNProfessional.SelectedValue != Const._Null) { strSql += " AND CHARINDEX(@CNProfessionalCode,chec.CNProfessionalCodes) > 0 "; //strSql += " AND chec.CNProfessionalCode=@CNProfessionalCode"; listStr.Add(new SqlParameter("@CNProfessionalCode", drpCNProfessional.SelectedValue)); } if (drpState.SelectedValue != Const._Null) { if (drpState.SelectedValue == "1") //已闭合 { strSql += " AND State=@State"; listStr.Add(new SqlParameter("@State", "C")); } else //未闭合 { strSql += " AND State!=@State"; listStr.Add(new SqlParameter("@State", "C")); } } strSql += " order by chec.code desc "; //if (drpUnitWork.SelectedValue != Const._Null) //{ // strSql += " AND chec.unitworkId=@unitworkId"; // listStr.Add(new SqlParameter("@unitworkId", drpUnitWork.SelectedValue)); //} //if (drpCNProfessional.SelectedValue != Const._Null) //{ // strSql += " AND chec.CNProfessionalCode=@CNProfessionalCode"; // listStr.Add(new SqlParameter("@CNProfessionalCode", drpCNProfessional.SelectedValue)); //} //if (drpQuestionType.SelectedValue != Const._Null) //{ // strSql += " AND chec.QuestionType=@QuestionType"; // listStr.Add(new SqlParameter("@QuestionType", drpQuestionType.SelectedValue)); //} //if (dpHandelStatus.SelectedValue != Const._Null) //{ // if (dpHandelStatus.SelectedValue.Equals("1")) // { // strSql += " AND (chec.state='5' or chec.state='6')"; // } // else if (dpHandelStatus.SelectedValue.Equals("2")) // { // strSql += " AND chec.state='7'"; // } // else if (dpHandelStatus.SelectedValue.Equals("3")) // { // strSql += " AND DATEADD(day,1,chec.LimitDate)< GETDATE() and chec.state<>5 and chec.state<>6 and chec.state<>7"; // } // else if (dpHandelStatus.SelectedValue.Equals("4")) // { // strSql += " AND DATEADD(day,1,chec.LimitDate)> GETDATE() and chec.state<>5 and chec.state<>6 and chec.state<>7"; // } //} SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); return tb; } private void BindGrid() { var list = ChecklistData(); Grid1.RecordCount = list.Rows.Count; var CNProfessional = CNProfessionalService.GetCNProfessionalItem(); var uniWork = UnitWorkService.GetUnitWorkLists(CurrUser.LoginProjectId); if (list.Rows.Count > 0) { for (int i = 0; i < list.Rows.Count; i++) { if (list.Rows[i]["CNProfessionalCodes"] != null) { var code = list.Rows[i]["CNProfessionalCodes"].ToString().Split(','); var listf = CNProfessional.Where(p => code.Contains(p.Value)).Select(p => p.Text).ToArray(); list.Rows[i]["CNProfessionalCodes"] = string.Join(",", listf); } if (list.Rows[i]["UnitWorkIds"] != null) { var code = list.Rows[i]["UnitWorkIds"].ToString().Split(','); var workid = uniWork.Where(p => code.Contains(p.UnitWorkId)).Select(p => p.UnitWorkName + BLL.UnitWorkService.GetProjectType(p.ProjectType)).ToArray(); list.Rows[i]["UnitWorkIds"] = string.Join(",", workid); } } } list = GetFilteredTable(Grid1.FilteredData, list); var table = GetPagedDataTable(Grid1, list); Grid1.DataSource = table; Grid1.DataBind(); } protected void btnQuery_Click(object sender, EventArgs e) { BindGrid(); } protected void btnRset_Click(object sender, EventArgs e) { drpProposeUnit.SelectedIndex = 0; drpUnitWork.SelectedIndex = 0; drpCNProfessional.SelectedIndex = 0; drpState.SelectedIndex = 0; BindGrid(); } protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } protected void btnMenuModify_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID.Split(',')[0]; Model.Plan_SubPlan subPlan = CQMS_SubPlanService.GetSubPlanBySubPlanId(id); if (subPlan.State == Const.SubPlan_Complete) { Alert.ShowInTop("该质量计划已经审批完成,无法操作,请右键查看!", MessageBoxIcon.Warning); return; } else if (subPlan.State == Const.SubPlan_Compile) { if (subPlan.CompileMan == CurrUser.PersonId || CurrUser.PersonId == Const.sysglyId) { PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("SubPlanEdit.aspx?subPlanId={0}", id))); } else { Alert.ShowInTop("您不是编制人,无法操作!请右键查看", MessageBoxIcon.Warning); return; } } else if (subPlan.State == Const.SubPlan_Audit || subPlan.State == Const.SubPlan_ReCompile) { Model.Plan_SubPlanApprove approve = CQMS_SubPlanApproveService.GetSubPlanApproveByApproveMan(id, CurrUser.PersonId); if (approve != null || CurrUser.PersonId == Const.sysglyId) { PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("SubPlanEdit.aspx?subPlanId={0}", id))); return; //Response.Redirect("SubPlanAudit.aspx?subPlanId=" + id); //PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", id, "查看 - "))); } else { if (subPlan.CompileMan.Equals(CurrUser.PersonId)) { PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("SubPlanEdit.aspx?subPlanId={0}", id))); } else { Alert.ShowInTop("您不是办理用户,无法操作!请右键查看", MessageBoxIcon.Warning); return; } } } } protected void btnMenuView_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID.Split(',')[0]; PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("SubPlanView.aspx?subPlanId={0}", id))); } protected void btnMenuDel_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID.Split(',')[0]; if (CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.SubPlanMenuId, Const.BtnDelete)) { var subPlan = CQMS_SubPlanService.GetSubPlanBySubPlanId(id); if (File.Exists(Funs.RootPath + subPlan.FilePath)) { File.Delete(Funs.RootPath + subPlan.FilePath); } CQMS_SubPlanApproveService.DeleteSubPlanApprovesBySubPlanId(id); CQMS_SubPlanService.DeleteSubPlan(id); LogService.AddSys_Log(CurrUser, subPlan.Code, id, Const.SubPlanMenuId, "删除分包施工质量计划"); BindGrid(); Alert.ShowInTop("删除成功!", MessageBoxIcon.Success); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Success); } } protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } protected void window_tt_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { btnMenuModify_Click(sender, e); } protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } // //获取办理人姓名 // // // protected string ConvertMan(object SubPlanId) { if (SubPlanId != null) { List aList = BLL.CQMS_SubPlanApproveService.GetNotHandleConstruct(SubPlanId.ToString()); string names = string.Empty; foreach (var a in aList) { if (a.ApproveMan != null) { names += BLL.Person_PersonsService.GetPersonsNameById(a.ApproveMan) + ","; } } if (!string.IsNullOrEmpty(names)) { names = names.Substring(0, names.Length - 1); } return names; } return ""; } protected void imgBtnFile_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Grid1.SelectedRowID)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/AttachFile/IndexOffice.aspx?cmd={0}|CQMSSubPlan", Grid1.SelectedRowID, "查看 -"))); PageContext.RegisterStartupScript(Window1.GetHideReference()); } else { Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); return; } } } }