300 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			300 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using BLL; | |||
|  | using FineUIPro.Web.BoSheng; | |||
|  | using Newtonsoft.Json.Linq; | |||
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Data; | |||
|  | using System.Data.SqlClient; | |||
|  | using System.Linq; | |||
|  | using System.Text; | |||
|  | using AspNet = System.Web.UI.WebControls; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.Opinion | |||
|  | { | |||
|  |     public partial class OpinionCollection : PageBase | |||
|  |     { | |||
|  |         #region 定义项 | |||
|  |         /// <summary> | |||
|  |         /// 主键 | |||
|  |         /// </summary> | |||
|  |         public string OpinionCollectionId | |||
|  |         { | |||
|  |             get | |||
|  |             { | |||
|  |                 return (string)ViewState["OpinionCollectionId"]; | |||
|  |             } | |||
|  |             set | |||
|  |             { | |||
|  |                 ViewState["OpinionCollectionId"] = value; | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 加载页面 | |||
|  |         /// <summary> | |||
|  |         /// 加载页面 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 Funs.DropDownPageSize(this.ddlPageSize); | |||
|  |                 this.btnMenuDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("请至少选择一项!"); | |||
|  |                 this.btnMenuDelete.ConfirmText = String.Format("你确定要删除选中的 <b><script>{0}</script></b> 行数据吗?", Grid1.GetSelectedCountReference()); | |||
|  | 
 | |||
|  |                 BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList1(this.drpUnitId, this.CurrUser.LoginProjectId, true); | |||
|  |                 BLL.ConstValue.InitConstNameDropDownList(this.drpProblemClass, "MenuType_P", true); | |||
|  | 
 | |||
|  |                 ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); | |||
|  |                 // 绑定表格 | |||
|  |                 BindGrid(); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 绑定数据 | |||
|  |         /// </summary> | |||
|  |         private void BindGrid() | |||
|  |         { | |||
|  |             string strSql = "select Opinion.OpinionCollectionId" | |||
|  |                       + @",Opinion.ProjectId" | |||
|  |                       + @",Opinion.UnitId" | |||
|  |                       + @",Opinion.RoleId" | |||
|  |                       + @",Opinion.ProblemClass" | |||
|  |                       + @",Opinion.Opinion" | |||
|  |                       + @",Opinion.CompileMan" | |||
|  |                       + @",Opinion.CompileDate" | |||
|  |                       + @",Opinion.State" | |||
|  |                       + @",Opinion.ProjectName" | |||
|  |                       + @",Opinion.UnitName" | |||
|  |                       + @",Opinion.CompileManName" | |||
|  |                       + @",(CASE WHEN Opinion.State = " + BLL.Const.State_0 + " OR Opinion.State IS NULL THEN '待['+Opinion.CompileManName+']提交' WHEN Opinion.State =  " + BLL.Const.State_2 + " THEN '审核/审批完成' ELSE '待['+OperateUser.UserName+']办理' END) AS  FlowOperateName" | |||
|  |                       + @" from View_Opinion_OpinionCollection AS Opinion " | |||
|  |                       + @" LEFT JOIN Opinion_OpinionCollectionApprove AS FlowOperate ON Opinion.OpinionCollectionId=FlowOperate.OpinionCollectionId and ApproveDate is null" | |||
|  |                       + @" LEFT JOIN Sys_User AS OperateUser ON OperateUser.UserId=FlowOperate.ApproveMan WHERE 1=1"; | |||
|  |             List<SqlParameter> listStr = new List<SqlParameter>(); | |||
|  |             strSql += " AND Opinion.ProjectId = @ProjectId"; | |||
|  |             listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); | |||
|  |             if (!string.IsNullOrEmpty(this.txtCompileManName.Text.Trim())) | |||
|  |             { | |||
|  |                 strSql += " AND Opinion.CompileManName like @userName"; | |||
|  |                 listStr.Add(new SqlParameter("@userName", "%" + this.txtCompileManName.Text.Trim() + "%")); | |||
|  |             } | |||
|  |             if (!string.IsNullOrEmpty(this.drpUnitId.SelectedValue) && this.drpUnitId.SelectedValue != BLL.Const._Null) | |||
|  |             { | |||
|  |                 strSql += " AND Opinion.UnitId = @unitId"; | |||
|  |                 listStr.Add(new SqlParameter("@unitId", this.drpUnitId.SelectedValue)); | |||
|  |             } | |||
|  |             if (!string.IsNullOrEmpty(this.drpProblemClass.SelectedValue) && this.drpProblemClass.SelectedValue != BLL.Const._Null) | |||
|  |             { | |||
|  |                 strSql += " AND Opinion.ProblemClass = @ProblemClass"; | |||
|  |                 listStr.Add(new SqlParameter("@ProblemClass", this.drpProblemClass.SelectedValue)); | |||
|  |             } | |||
|  |             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 页索引改变事件 | |||
|  |         /// <summary> | |||
|  |         /// 页索引改变事件 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 排序 | |||
|  |         /// <summary> | |||
|  |         /// 排序 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Grid1_Sort(object sender, GridSortEventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 分页选择下拉改变事件 | |||
|  |         /// <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(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 增加 | |||
|  |         /// <summary> | |||
|  |         /// 增加 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnNew_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("OpinionCollectionEdit.aspx", "编辑 - "))); | |||
|  |         } | |||
|  |         #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(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 编辑 | |||
|  |         /// </summary> | |||
|  |         private void EditData() | |||
|  |         { | |||
|  |             if (Grid1.SelectedRowIndexArray.Length == 0) | |||
|  |             { | |||
|  |                 Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |             this.OpinionCollectionId = Grid1.SelectedRowID; | |||
|  |             var opinion = OpinionCollectionService.GetOpinionCollectionById(this.OpinionCollectionId); | |||
|  |             if (opinion != null) | |||
|  |             { | |||
|  |                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("OpinionCollectionEdit.aspx?opinionCollectionId={0}", this.OpinionCollectionId, "编辑 - "))); | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 删除 | |||
|  |         /// <summary> | |||
|  |         /// 右键删除事件 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnMenuDelete_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             this.DeleteData(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 删除方法 | |||
|  |         /// </summary> | |||
|  |         private void DeleteData() | |||
|  |         { | |||
|  |             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 opinionCollection = OpinionCollectionService.GetOpinionCollectionById(rowID); | |||
|  |                         if (opinionCollection != null) | |||
|  |                         { | |||
|  |                             OpinionCollectionApproveService.DeleteApproveByOpinionCollectionId(rowID); | |||
|  |                             OpinionCollectionService.DeleteOpinionCollectionById(rowID); | |||
|  |                             BindGrid(); | |||
|  |                             ShowNotify("删除数据成功!(表格数据已重新绑定)", MessageBoxIcon.Success); | |||
|  |                         } | |||
|  |                     } | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 判断是否可删除 | |||
|  |         /// </summary> | |||
|  |         /// <param name="rowID"></param> | |||
|  |         /// <param name="isShow"></param> | |||
|  |         /// <returns></returns> | |||
|  |         private bool judgementDelete(string rowID, bool isShow) | |||
|  |         { | |||
|  |             string content = string.Empty; | |||
|  |             if (string.IsNullOrEmpty(content)) | |||
|  |             { | |||
|  |                 return true; | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 if (isShow) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop(content); | |||
|  |                 } | |||
|  |                 return false; | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 关闭弹出窗 | |||
|  |         /// <summary> | |||
|  |         /// 关闭弹出窗 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Window1_Close(object sender, WindowCloseEventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 查询事件 | |||
|  |         /// <summary> | |||
|  |         /// 查询事件 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Text_TextChanged(object sender, EventArgs e) | |||
|  |         { | |||
|  |             this.BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 格式化字符串 | |||
|  |         /// <summary> | |||
|  |         /// 根据角色Id获取角色名称 | |||
|  |         /// </summary> | |||
|  |         /// <param name="roleId"></param> | |||
|  |         /// <returns></returns> | |||
|  |         protected string ConvertRoleName(object roleId) | |||
|  |         { | |||
|  |             string roleName = string.Empty; | |||
|  |             if (roleId != null) | |||
|  |             { | |||
|  |                 roleName = BLL.RoleService.getRoleNamesRoleIds(roleId.ToString()); | |||
|  |             } | |||
|  |             return roleName; | |||
|  |         } | |||
|  |         #endregion | |||
|  |     } | |||
|  | } |