ChengDa_English/SGGL/FineUIPro.Web/ZHGL/ManagementReport/CheckSpecial.aspx.cs

209 lines
7.2 KiB
C#
Raw Normal View History

2022-12-20 09:32:32 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using BLL;
namespace FineUIPro.Web.ZHGL.ManagementReport
{
public partial class CheckSpecial : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
////权限按钮方法
this.GetButtonPower();
Technique_CheckItemSetService.InitCheckItemSetDropDownList(this.drpSupCheckItemSet, "2", "0", true);
// 绑定表格
//BindGrid();
InitTreeMenu();
}
}
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "项目";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
var project = (from x in Funs.DB.Base_Project
select new { x.ProjectId, x.ProjectName }).Distinct();
if (project.Count() > 0)
{
foreach (var pro in project)
{
TreeNode tnProject = new TreeNode();//年节点
tnProject.Text = SubStr(pro.ProjectName);
tnProject.NodeID = pro.ProjectId;
tnProject.ToolTip = pro.ProjectName;
tnProject.EnableClickEvent = true;
rootNode.Nodes.Add(tnProject);
}
}
}
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
BindGrid();
}
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = @"SELECT CheckSpecial.CheckSpecialId,CodeRecords.Code AS CheckSpecialCode,"
+ @" CheckItemSet.CheckItemName,CheckSpecial.CheckTime,(CASE WHEN CheckSpecial.CheckType ='1' THEN '联合检查' ELSE '专项检查' END) AS CheckTypeName"
+ @" ,(CASE WHEN CheckSpecial.States='2' THEN '已完成' WHEN CheckSpecial.States='1' THEN '待整改' ELSE '待提交' END) AS StatesName"
+ @" FROM Check_CheckSpecial AS CheckSpecial "
+ @" LEFT JOIN Sys_CodeRecords AS CodeRecords ON CheckSpecial.CheckSpecialId=CodeRecords.DataId "
+ @" LEFT JOIN Technique_CheckItemSet AS CheckItemSet ON CheckItemSet.CheckItemSetId = CheckSpecial.CheckItemSetId where 1=1";
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
strSql += " AND CheckSpecial.ProjectId = @ProjectId";
listStr.Add(new SqlParameter("@ProjectId", tvControlItem.SelectedNodeID));
}
if (this.rbStates.SelectedValue != "-1")
{
strSql += " AND CheckSpecial.States = @States";
listStr.Add(new SqlParameter("@States", this.rbStates.SelectedValue));
}
if (this.rbType.SelectedValue != "-1")
{
if (this.rbType.SelectedValue == "1")
{
strSql += " AND CheckSpecial.CheckType = @CheckType";
listStr.Add(new SqlParameter("@CheckType", this.rbType.SelectedValue));
}
else
{
strSql += " AND (CheckSpecial.CheckType = @CheckType OR CheckSpecial.CheckType IS NULL) ";
listStr.Add(new SqlParameter("@CheckType", this.rbType.SelectedValue));
}
}
if (this.drpSupCheckItemSet.SelectedValue != BLL.Const._Null)
{
strSql += " AND CheckSpecial.CheckItemSetId = @CheckItemSetId";
listStr.Add(new SqlParameter("@CheckItemSetId", this.drpSupCheckItemSet.SelectedValue));
}
if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim()))
{
strSql += " AND CheckSpecial.CheckTime >= @StartTime";
listStr.Add(new SqlParameter("@StartTime", this.txtStartTime.Text.Trim()));
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
{
strSql += " AND CheckSpecial.CheckTime <= @EndTime";
listStr.Add(new SqlParameter("@EndTime", this.txtEndTime.Text.Trim()));
}
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 TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
protected void rbStates_SelectedIndexChanged(object sender, EventArgs e)
{
this.BindGrid();
}
protected void drpSupCheckItemSet_SelectedIndexChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs 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 Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
}
#endregion
private string SubStr(string str)
{
2023-01-30 14:14:20 +08:00
string reStr = str;
2022-12-20 09:32:32 +08:00
if (!string.IsNullOrEmpty(str) && str.Length > 16)
{
reStr = str.Substring(0, 16) + "..";
}
return reStr;
}
}
}