using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; namespace FineUIPro.Web.PHTGL.BiddingManagement { public partial class ActionPlanFormation : PageBase { #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Funs.DropDownPageSize(this.ddlPageSize); this.DropState.DataValueField = "Value"; DropState.DataTextField = "Text"; DropState.DataSource = BLL.DropListService.GetState(); DropState.DataBind(); Funs.FineUIPleaseSelect(DropState); DropState.SelectedValue = Const.ContractCreating.ToString(); btnNew.OnClientClick = Window1.GetShowReference("ActionPlanFormationEdit.aspx", "实施计划编制") + "return false;"; GetButtonPower(); BindGrid(); } } #endregion #region 数据绑定 /// /// 数据绑定 /// private void BindGrid() { string strSql = @"SELECT Act.ActionPlanID ,Act.ActionPlanCode ,Act.ProjectShortName as Name ,Act.EPCCode ,(CASE Act.State WHEN @ContractCreating THEN '编制中' WHEN @ContractCreat_Complete THEN '编制完成' WHEN @Contract_countersign THEN '会签中' WHEN @ContractReviewing THEN '审批中' WHEN @ContractReview_Complete THEN '审批成功' WHEN @ContractReview_Refuse THEN '审批被拒' END) AS State ,U.PersonName as CreatUser ,Act.CreateTime ,Act.ProjectID ,Act.ProjectName ,Act.Unit ,Act.BidProject ,Act.BidType ,Act.PriceType ,Act.BidPrice ,Act.ConstructionSite FROM PHTGL_ActionPlanFormation AS Act LEFT JOIN Person_Persons AS U ON U.PersonId = Act.CreatUser LEFT JOIN Base_Project AS Pro ON Pro.ProjectId = Act.ProjectID WHERE 1=1"; List listStr = new List(); listStr.Add(new SqlParameter("@ContractCreating", Const.ContractCreating.ToString())); listStr.Add(new SqlParameter("@ContractCreat_Complete", Const.ContractCreat_Complete.ToString())); listStr.Add(new SqlParameter("@Contract_countersign", Const.Contract_countersign)); listStr.Add(new SqlParameter("@ContractReviewing", Const.ContractReviewing)); listStr.Add(new SqlParameter("@ContractReview_Complete", Const.ContractReview_Complete)); listStr.Add(new SqlParameter("@ContractReview_Refuse", Const.ContractReview_Refuse)); if (!(this.CurrUser.PersonId == Const.sysglyId)) { strSql += " and Act.ProjectID =@ProjectId"; listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); } if (!string.IsNullOrEmpty(txtActionPlanCode.Text)) { strSql += " and Act.ActionPlanCode like @ActionPlanCode "; listStr.Add(new SqlParameter("@ActionPlanCode", "%" + txtActionPlanCode.Text + "%")); } if (DropState.SelectedItemArray.Length > 0) { strSql += string.Format(" and Act.State in ({0}) ", string.Join(",", DropState.SelectedValueArray)); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #endregion #region 分页 排序 /// /// 改变索引事件 /// /// /// 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(); } #endregion #region 关闭弹出窗体 /// /// 关闭弹出窗体 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } #endregion #region 查询 /// /// 查询按钮 /// /// /// protected void btnSearch_Click(object sender, EventArgs e) { BindGrid(); } protected void btnRset_Click(object sender, EventArgs e) { txtActionPlanCode.Text = ""; DropState.SelectedValue = Const.ContractCreating.ToString(); BindGrid(); } #endregion #region 编辑 /// /// 双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditData(); } /// /// 行事件 /// /// /// 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 == "LooK") { string id = fileId; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanFormationEdit.aspx?ActionPlanID={0}", id, "编辑 - "))); return; } if (e.CommandName == "export") { btnPrinter_Click(null, null); } } /// /// 表格单击事件 /// /// /// protected void Grid1_RowClick(object sender, GridRowClickEventArgs e) { string id = Grid1.SelectedRowID; var actReview = PHTGL_ActionPlanReviewService.GetPHTGL_ActionPlanReviewByActionPlanID(id); if (actReview != null) { if (actReview.State == Const.ContractReview_Refuse) { btnEditAgain.Hidden = false; } else { btnEditAgain.Hidden = true; } if (actReview.State >= Const.ContractCreat_Complete) { btnDelete.Hidden = true; } else { var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.ActionPlanFormation); if (buttonList.Count() > 0) { if (buttonList.Contains(Const.BtnDelete)) { btnDelete.Hidden = false; } } } } } /// /// 编辑事件 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { this.EditData(); } /// /// 重新编辑 /// /// /// protected void btnEditAgain_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID; var model = PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(id); model.State = Const.ContractCreating; PHTGL_ActionPlanFormationService.UpdatePHTGL_ActionPlanFormation(model); PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanFormationEdit.aspx?ActionPlanID={0}", id, "编辑 - "))); } /// /// 编辑数据方法 /// private void EditData() { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanFormationEdit.aspx?ActionPlanID={0}", id, "编辑 - "))); } #endregion #region 删除 /// /// 删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length > 0) { bool isShow = false; if (Grid1.SelectedRowIndexArray.Length == 1) { isShow = true; } foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); if (this.judgementDelete(rowID, isShow)) { var p = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(rowID); if (p != null) { BLL.LogService.AddSys_Log(this.CurrUser, p.ProjectName, p.ActionPlanID, BLL.Const.ActionPlanFormation, BLL.Const.BtnDelete); BLL.PHTGL_ActionPlanFormationService.DeletePHTGL_ActionPlanFormationById(rowID); BLL.PHTGL_ActionPlanFormation_Sch1Service.DeletePHTGL_ActionPlanFormation_Sch1ById(rowID); } } } BindGrid(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } /// /// 判断是否可以删除 /// /// private bool judgementDelete(string id, bool isShow) { string content = string.Empty; if (string.IsNullOrEmpty(content)) { return true; } else { if (isShow) { Alert.ShowInTop(content); } return false; } } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.ActionPlanFormation); if (buttonList.Count() > 0) { if (buttonList.Contains(Const.BtnAdd)) { btnNew.Hidden = false; } if (buttonList.Contains(Const.BtnModify)) { btnEdit.Hidden = false; } if (buttonList.Contains(Const.BtnDelete)) { btnDelete.Hidden = false; } } } #endregion #region 打印 protected void btnPrinter_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string Id = Grid1.SelectedRowID; BLL.PHTGL_ActionPlanFormationService.PrintFile(Id); } #endregion } }