398 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			398 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Data;
 | |
| using System.Data.SqlClient;
 | |
| using System.Linq;
 | |
| 
 | |
| namespace FineUIPro.Web.PZHGL.GJSX
 | |
| {
 | |
|     public partial class GJSXList : PageBase
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 类型
 | |
|         /// </summary>
 | |
|         public string classify
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 return (string)ViewState["classify"];
 | |
|             }
 | |
|             set
 | |
|             {
 | |
|                 ViewState["classify"] = value;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 加载页面
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 classify = Request.Params["classify"];
 | |
|                 Funs.DropDownPageSize(this.ddlPageSize);
 | |
|                 ////权限按钮方法
 | |
|                 this.GetButtonPower();
 | |
|                 if (classify != "0")
 | |
|                 {
 | |
|                     btnNew.Hidden = true;
 | |
|                 }
 | |
|                 this.btnNew.OnClientClick = Window1.GetShowReference("GJSXListEdit.aspx?EditType=add") + "return false;";
 | |
|                 if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
 | |
|                 {
 | |
|                     Grid1.PageSize = this.CurrUser.PageSize.Value;
 | |
|                 }
 | |
| 
 | |
|                 this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
 | |
|                 // 绑定表格
 | |
|                 this.BindGrid();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 绑定数据
 | |
|         /// </summary>
 | |
|         private void BindGrid()
 | |
|         {
 | |
|             string strSql = @"select 
 | |
|                                 a.GJSXID,a.ProjectId,a.detail,a.Userid,b.username,a.createDate
 | |
|                                 ,User_ReceiveID = STUFF((SELECT ',' + p2.UserName FROM dbo.Sys_User as p2 where PATINDEX('%,' + RTRIM(p2.UserId) + ',%', ',' + a.User_ReceiveID + ',') > 0 FOR XML PATH('')), 1, 1,'') 
 | |
|                                 , CNProfessionalId = STUFF((SELECT ',' + Base_CNProfessional.ProfessionalName FROM dbo.Base_CNProfessional where PATINDEX('%,' + RTRIM(Base_CNProfessional.CNProfessionalId) + ',%', ',' + a.CNProfessional_ID + ',') > 0 FOR XML PATH('')), 1, 1,'')
 | |
|                                 ,Base_Project.ProjectName,Base_Unit.unitname,a.CloseDate
 | |
|                                 ,case a.state when 2 then (case when GETDATE()>a.CompleteDate then 4 else a.state end) when 3 then (case when GETDATE()>a.CompleteDate then 4 else a.state end) when 0 then a.state  when  1 then a.state end  as state2 
 | |
|                                 ,case a.state when 2 then (case when GETDATE()>a.CompleteDate then '已超期' else '正在进行' end) when 3 then (case when GETDATE()>a.CompleteDate then '已超期' else '正在进行' end) when 0 then '已关闭'  when  1 then '编辑中' end  as stateStr 
 | |
|                                 --,a.state
 | |
|                                 --,case a.state when 2 then '正在进行' when 3 then '待办' when 0 then '已关闭' when 1 then '编辑中' end as stateStr
 | |
|                                 ,QuestionTypeName = STUFF((SELECT ',' + Base_QuestionType.QuestionTypeName FROM dbo.Base_QuestionType where PATINDEX('%,' + RTRIM(Base_QuestionType.QuestionTypeID) + ',%', ',' + a.QuestionTypeID + ',') > 0 FOR XML PATH('')), 1, 1,'')
 | |
|                                 ,GJSXTypeName = STUFF((SELECT ',' + Base_GJSXType.GJSXTypeName FROM dbo.Base_GJSXType where PATINDEX('%,' + RTRIM(Base_GJSXType.GJSXTypeID) + ',%', ',' + a.GJSXTypeID + ',') > 0 FOR XML PATH('')), 1, 1,'')
 | |
|                                 ,a.IsManypeople,a.CompleteDate,a.AttachUrl
 | |
|                                 ,user_Acceptance = STUFF((SELECT ',' + p2.UserName FROM dbo.Sys_User as p2 where PATINDEX('%,' + RTRIM(p2.UserId) + ',%', ',' + a.user_Acceptance + ',') > 0 FOR XML PATH('')), 1, 1,'') 
 | |
|                                 from GJSX as a 
 | |
|                                 left join Sys_User as b on a.UserId = b.UserId
 | |
|                                 left join[dbo].[Base_Project] on a.ProjectId = Base_Project.ProjectId
 | |
|                                 left join[dbo].[Base_Unit] on a.UnitId = Base_Unit.UnitId
 | |
|                                 left join[dbo].[Base_QuestionType] on a.QuestionTypeID = Base_QuestionType.QuestionTypeID
 | |
|                                 left join[dbo].[Base_GJSXType] on a.GJSXTypeID = Base_GJSXType.GJSXTypeID
 | |
|                             where a.ProjectId = @ProjectId";
 | |
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | |
| 
 | |
|             if (!string.IsNullOrEmpty(Request.Params["projectId"]))  ///是否文件柜查看页面传项目值
 | |
|             {
 | |
|                 listStr.Add(new SqlParameter("@ProjectId", Request.Params["projectId"]));
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
 | |
|             }
 | |
|             var uid = CurrUser.UserId;
 | |
|             //listStr.Add(new SqlParameter("@sql_where", strSql));
 | |
|             //我创建的
 | |
|             if (classify == "0")
 | |
|             {
 | |
|                 strSql += " AND a.Userid='" + uid + "' ";
 | |
|             }
 | |
|             //待我处理
 | |
|             else if (classify == "1")
 | |
|             {
 | |
|                 strSql += " AND (a.state ='2' and a.User_Acceptance like'%" + uid + "%'  ) or (a.state ='3' and (a.Userid like'%" + uid + "%' or a.User_ReceiveID like'%" + uid + "%'  ))";
 | |
|             }
 | |
|             //我已处理
 | |
|             else if (classify == "2")
 | |
|             {
 | |
|                 strSql += " AND (a.state ='0' and (a.Userid like'%" + uid + "%' or a.User_ReceiveID like'%" + uid + "%' or a.User_Acceptance  like'%" + uid + "%'   )) or (a.state ='3' and (a.Userid like'%" + uid + "%' or a.User_ReceiveID like'%" + uid + "%' or a.User_Acceptance  like'%" + uid + "%' ))";
 | |
|             }
 | |
|             //我参与的
 | |
|             else if (classify == "3")
 | |
|             {
 | |
|                 strSql += " AND a.CsUsers like'%" + uid + "%' ";
 | |
|             }
 | |
| 
 | |
|             strSql += " order by state2 desc,a.GJSXID asc ";
 | |
|             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();
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                 for (int i = 0; i < Grid1.Rows.Count; i++)
 | |
|                 {
 | |
|                     var state = tb.Rows[i]["state2"].ToString().Trim();
 | |
|                     var completeDate = tb.Rows[i]["CompleteDate"].ToString();
 | |
|                     DateTime dtCompleteDate = Convert.ToDateTime(completeDate);
 | |
|                     if (Grid1.Rows[i].DataKeys[0] != null && !string.IsNullOrWhiteSpace(state))
 | |
|                     {
 | |
|                         if (state == "0")
 | |
|                         {
 | |
|                             Grid1.Rows[i].CellCssClasses[6] = "green";
 | |
|                         }
 | |
|                         else if (state == "2" || state == "3")
 | |
|                         {
 | |
|                             Grid1.Rows[i].CellCssClasses[6] = "blue";
 | |
|                         }
 | |
|                         else if (state == "4")
 | |
|                         {
 | |
|                             Grid1.Rows[i].CellCssClasses[6] = "red";
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception ex) { }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         #region 查询
 | |
|         /// <summary>
 | |
|         /// 查询
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void TextBox_TextChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             this.BindGrid();
 | |
|         }
 | |
|         #endregion 
 | |
| 
 | |
|         #region 获取按钮权限
 | |
|         /// <summary>
 | |
|         /// 获取按钮权限
 | |
|         /// </summary>
 | |
|         /// <param name="button"></param>
 | |
|         /// <returns></returns>
 | |
|         private void GetButtonPower()
 | |
|         {
 | |
|             var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.GJSXMenuId);
 | |
|             if (buttonList.Count() > 0)
 | |
|             {
 | |
|                 if (buttonList.Contains(BLL.Const.BtnAdd))
 | |
|                 {
 | |
|                     this.btnNew.Hidden = false;
 | |
|                     //   this.btnImport.Hidden = false;
 | |
|                 }
 | |
|                 if (buttonList.Contains(BLL.Const.BtnModify))
 | |
|                 {
 | |
|                     this.btnMenuEdit.Hidden = false;
 | |
|                 }
 | |
|                 if (buttonList.Contains(BLL.Const.BtnDelete))
 | |
|                 {
 | |
|                     this.btnMenuDel.Hidden = false;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region  删除数据
 | |
|         /// <summary>
 | |
|         /// 右键删除事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnMenuDel_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.DeleteData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 删除方法
 | |
|         /// </summary>
 | |
|         private void DeleteData()
 | |
|         {
 | |
|             if (Grid1.SelectedRowIndexArray.Length > 0)
 | |
|             {
 | |
|                 int all = Grid1.SelectedRowIndexArray.Length;
 | |
|                 int succ = 0;
 | |
|                 string strShowNotify = string.Empty;
 | |
|                 foreach (int rowIndex in Grid1.SelectedRowIndexArray)
 | |
|                 {
 | |
|                     string rowID = Grid1.DataKeys[rowIndex][0].ToString();
 | |
|                     var gjsx = BLL.GJSXService.GetGJSXById(rowID);
 | |
|                     if (gjsx != null)
 | |
|                     {
 | |
|                         if (gjsx.State == "1")
 | |
|                         {
 | |
|                             BLL.LogService.AddSys_Log(this.CurrUser, gjsx.Detail, gjsx.GJSXID, BLL.Const.GJSXMenuId, BLL.Const.BtnDelete);
 | |
|                             BLL.GJSXItemService.DeleteGJSXMXByGJSXID(rowID);
 | |
|                             BLL.GJSXProcessService.DeleteProcess(rowID);
 | |
|                             BLL.GJSXService.DeleteGJSXById(rowID);
 | |
|                             succ++;
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
| 
 | |
|                 BindGrid();
 | |
|                 if (all != succ)
 | |
|                 {
 | |
|                     strShowNotify = "当前事项状态不可删除!";
 | |
|                 }
 | |
|                 if (!string.IsNullOrEmpty(strShowNotify))
 | |
|                 {
 | |
|                     Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning);
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     ShowNotify("删除数据成功!", MessageBoxIcon.Success);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 分页
 | |
|         /// <summary>
 | |
|         /// 分页
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 分页显示条数下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
 | |
|             BindGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 排序
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
| 
 | |
|         #region 双击,右键编辑事件
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Grid行双击事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | |
|         {
 | |
|             this.EditData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 右键编辑事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnMenuEdit_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.EditData();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 编辑数据方法
 | |
|         /// </summary>
 | |
|         private void EditData()
 | |
|         {
 | |
|             if (Grid1.SelectedRowIndexArray.Length == 0)
 | |
|             {
 | |
|                 Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
|             string Id = Grid1.SelectedRowID;
 | |
|             var gjsx = BLL.GJSXService.GetGJSXById(Id);
 | |
|             //必须是责任人、提出人、跟踪人才能修改
 | |
|             if (gjsx.User_Acceptance.Contains(this.CurrUser.UserId)
 | |
|                 || gjsx.UserID.Contains(this.CurrUser.UserId) ||
 | |
|                 gjsx.User_ReceiveID.Contains(this.CurrUser.UserId))
 | |
|             {
 | |
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("GJSXListEdit.aspx?EditType=Edit&Id={0}", Id, "编辑 - ")));
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("GJSXListEdit.aspx?EditType=See&Id={0}", Id), "查看 - "));
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         #region 判断是否可删除
 | |
|         /// <summary>
 | |
|         /// 判断是否可以删除
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         private string judgementDelete(string id)
 | |
|         {
 | |
|             string content = string.Empty;
 | |
|             if (Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.UserId == id) != null)
 | |
|             {
 | |
|                 content += "已在【项目员工】中使用,不能删除!";
 | |
|             }
 | |
| 
 | |
|             return content;
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 参与项目情况
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void lbtnPro_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ParticipateProject.aspx?userId={0}", Grid1.SelectedRowID, "参与项目情况 - "), "参与项目", 1000, 520));
 | |
|         }
 | |
| 
 | |
|         #region 导入
 | |
|         /// <summary>
 | |
|         /// 导入按钮
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnImport_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("PersonIn.aspx", "导入 - ")));
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 关闭导入弹出窗口
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Window2_Close(object sender, WindowCloseEventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
| 
 | |
|         protected void ckbAll_CheckedChanged(object sender, CheckedEventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
| 
 | |
|         protected string ConvertProgressDetail(object GJSXID)
 | |
|         {
 | |
|             string detailStr = string.Empty;
 | |
|             if (!string.IsNullOrEmpty(GJSXID.ToString()))
 | |
|             {
 | |
|                 Model.GJSX_detail detail = (from x in Funs.DB.GJSX_detail where x.GJSXID == GJSXID.ToString() && x.Progress_detail != null && x.Progress_detail != "" orderby x.Date descending select x).FirstOrDefault();
 | |
|                 if (detail != null)
 | |
|                 {
 | |
|                     detailStr = detail.Progress_detail;
 | |
|                 }
 | |
|             }
 | |
|             return detailStr;
 | |
|         }
 | |
|     }
 | |
| } |