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

343 lines
11 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BLL;
namespace FineUIPro.Web.ZHGL.ManagementReport
{
public partial class CQMSCheckSpecial : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
////权限按钮方法
this.GetButtonPower();
UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpSponsorUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true);
CNProfessionalService.InitCNProfessionalDownList(drpCNProfessional, true);
// 绑定表格
//BindGrid();
InitTreeMenu();
}
}
protected void btnQuery_Click(object sender, EventArgs e)
{
BindGrid();
}
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>
/// <returns></returns>
protected IDictionary<int, string> Handelstatus()
{
Dictionary<int, string> dic = new Dictionary<int, string>();
dic.Add(1, "未确认");
dic.Add(2, "已闭环");
dic.Add(3, "超期未整改");
dic.Add(4, "未整改");
return dic;
}
public Task<DataTable> data()
{
Task<DataTable> task = new Task<DataTable>(() =>
{
return ChecklistData();
});
task.Start();
return task;
}
protected DataTable ChecklistData()
{
string strSql = @"SELECT * from Check_CheckSpecialDataIn chec
where 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
strSql += " AND chec.ProjectId = @ProjectId";
listStr.Add(new SqlParameter("@ProjectId", tvControlItem.SelectedNodeID));
}
strSql += " AND (chec.CheckTime>=@startTime or @startTime='') and (chec.CheckTime<=@endTime or @endTime='') ";
listStr.Add(new SqlParameter("@startTime", !string.IsNullOrEmpty(txtStartTime.Text.Trim()) ? txtStartTime.Text.Trim() + " 00:00:00" : ""));
listStr.Add(new SqlParameter("@endTime", !string.IsNullOrEmpty(txtEndTime.Text.Trim()) ? txtEndTime.Text.Trim() + " 23:59:59" : ""));
if (drpSponsorUnit.SelectedValue != BLL.Const._Null)
{
strSql += " AND chec.UnitId=@unitId";
listStr.Add(new SqlParameter("@unitId", drpSponsorUnit.SelectedValue));
}
if (drpUnitWork.SelectedValue != Const._Null)
{
strSql += " AND chec.WorkAreaId=@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));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
return tb;
}
protected string ConvertUnit(object unitId)
{
if (unitId != null)
{
var unit = UnitService.GetUnitByUnitId(unitId.ToString());
if (unit != null)
{
return unit.UnitName;
}
}
return "";
}
protected string ConvertUser(object userId)
{
if (userId != null)
{
var type = UserService.GetUserNameByUserId(userId.ToString());
return type;
}
return "";
}
protected string ConvertWorkArea(object WorkAreaId)
{
if (WorkAreaId != null)
{
var type = UnitWorkService.getUnitWorkByUnitWorkId(WorkAreaId.ToString());
if (type != null)
{
return type.UnitWorkName;
}
}
return "";
}
protected string ConvertCNProfessional(object WorkAreaId)
{
if (WorkAreaId != null)
{
var type = CNProfessionalService.GetCNProfessional(WorkAreaId.ToString());
if (type != null)
{
return type.ProfessionalName;
}
}
return "";
}
protected string ConvertImageUrlByImage(object registrationId)
{
string url = string.Empty;
if (registrationId != null)
{
IList<Model.AttachFile> sourlist = AttachFileService.GetBeforeFileList(registrationId.ToString(), BLL.Const.CheckListMenuId);
if (sourlist != null && sourlist.Count > 0)
{
string AttachUrl = "";
foreach (var item in sourlist)
{
if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png"))
AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
}
url = BLL.UploadAttachmentService.ShowImage("../../", AttachUrl.TrimEnd(','));
}
}
return url;
}
protected string ConvertImgUrlByImage(object registrationId)
{
string url = string.Empty;
if (registrationId != null)
{
IList<Model.AttachFile> sourlist = AttachFileService.Getfilelist(registrationId.ToString() + "r", BLL.Const.CheckListMenuId);
if (sourlist != null && sourlist.Count > 0)
{
string AttachUrl = "";
foreach (var item in sourlist)
{
if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png"))
AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
}
url = BLL.UploadAttachmentService.ShowImage("../../", AttachUrl.TrimEnd(','));
}
}
return url;
}
public string Convertstatus(Object code)
{
Model.Check_CheckControl checkControl = BLL.CheckControlService.GetCheckControl(code.ToString());
if (checkControl.State.Equals("5") || checkControl.State.Equals("6"))
{
return "未确认";
}
else if (checkControl.State == Const.CheckControl_Complete)
{ //闭环
return "已闭环";
}
//else if( checkControl.LimitDate> )
else if (Convert.ToDateTime(checkControl.LimitDate).AddDays(1) < DateTime.Now) //延期未整改
{
return "超期未整改";
}
else //期内未整改
{
return "未整改";
}
}
/// <summary>
/// 绑定数据
/// </summary>
public void BindGrid()
{
DataTable tb = ChecklistData();
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
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)
{
string reStr = str;
if (!string.IsNullOrEmpty(str) && str.Length > 16)
{
reStr = str.Substring(0, 16) + "..";
}
return reStr;
}
}
}