346 lines
13 KiB
C#
346 lines
13 KiB
C#
|
|
using BLL;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Data.SqlClient;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace FineUIPro.Web.DigData
|
|||
|
|
{
|
|||
|
|
public partial class CQMSDataCollect : PageBase
|
|||
|
|
{
|
|||
|
|
#region 加载
|
|||
|
|
/// <summary>
|
|||
|
|
/// 加载页面
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!IsPostBack)
|
|||
|
|
{
|
|||
|
|
ConstValue.InitConstValueDropDownList(this.drpYear, BLL.ConstValue.Group_0008, false);
|
|||
|
|
this.drpYear.SelectedValue = DateTime.Now.Year.ToString();
|
|||
|
|
var getCQMSDataCollect = CQMSDataCollectService.GetCQMSDataCollectByYear(DateTime.Now.Year);
|
|||
|
|
if (getCQMSDataCollect == null)
|
|||
|
|
{
|
|||
|
|
CQMSDataCollectService.CreateCQMSDataCollectByYear(DateTime.Now.Year);
|
|||
|
|
}
|
|||
|
|
// 绑定表格
|
|||
|
|
this.BindGrid();
|
|||
|
|
this.BindGrid2();
|
|||
|
|
if (this.CurrUser.PersonId == Const.sysglyId || this.CurrUser.PersonId == Const.hfnbdId)
|
|||
|
|
{
|
|||
|
|
this.btnRefresh.Hidden = false;
|
|||
|
|
this.btnDel.Hidden = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 绑定数据Grid1
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定数据Grid1
|
|||
|
|
/// </summary>
|
|||
|
|
private void BindGrid()
|
|||
|
|
{
|
|||
|
|
var getData = Funs.DB.Sp_DigData_CQMSDataCollect(Funs.GetNewIntOrZero(this.drpYear.SelectedValue));
|
|||
|
|
DataTable tb = GetTreeDataTable(getData.ToList()); //this.LINQToDataTable(getData.ToList());
|
|||
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|||
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|||
|
|
Grid1.DataSource = table;
|
|||
|
|
Grid1.DataBind();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取模拟树表格
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetTreeDataTable(List<Model.DigDataCQMSDataCollectItem> getData)
|
|||
|
|
{
|
|||
|
|
DataTable table = new DataTable();
|
|||
|
|
table.Columns.Add(new DataColumn("CQMSDataCollectItemId", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("ParentId", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("SortIndex", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("CQMSContent", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("MeasureUnit", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month1", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month2", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month3", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month4", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month5", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month6", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month7", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month8", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month9", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month10", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month11", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("Month12", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("MonthSum", typeof(string)));
|
|||
|
|
table.Columns.Add(new DataColumn("IntS", typeof(int)));
|
|||
|
|
DataRow row;
|
|||
|
|
for (int i = 1; i <= 4; i++)
|
|||
|
|
{
|
|||
|
|
row = table.NewRow();
|
|||
|
|
row[0] = i.ToString();
|
|||
|
|
row[1] = "-1";
|
|||
|
|
row[2] = i.ToString();
|
|||
|
|
row[3] = getSupCQMSContent(i);
|
|||
|
|
row[18] = i;
|
|||
|
|
table.Rows.Add(row);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (var item in getData)
|
|||
|
|
{
|
|||
|
|
row = table.NewRow();
|
|||
|
|
row[0] = item.CQMSDataCollectItemId;
|
|||
|
|
row[1] = getSupID(item.SortIndex);
|
|||
|
|
row[2] = row[1].ToString() + "." + getNewSortIndex(item.SortIndex);
|
|||
|
|
row[3] = item.CQMSContent;
|
|||
|
|
row[4] = item.MeasureUnit;
|
|||
|
|
row[5] = item.Month1;
|
|||
|
|
row[6] = item.Month2;
|
|||
|
|
row[7] = item.Month3;
|
|||
|
|
row[8] = item.Month4;
|
|||
|
|
row[9] = item.Month5;
|
|||
|
|
row[10] = item.Month6;
|
|||
|
|
row[11] = item.Month7;
|
|||
|
|
row[12] = item.Month8;
|
|||
|
|
row[13] = item.Month9;
|
|||
|
|
row[14] = item.Month10;
|
|||
|
|
row[15] = item.Month11;
|
|||
|
|
row[16] = item.Month12;
|
|||
|
|
row[17] = item.MonthSum;
|
|||
|
|
row[18] = item.SortIndex;
|
|||
|
|
table.Rows.Add(row);
|
|||
|
|
}
|
|||
|
|
return table;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region 获取父级名称
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取父级名称
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="i"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private string getSupCQMSContent(int i)
|
|||
|
|
{
|
|||
|
|
string name = string.Empty;
|
|||
|
|
switch (i)
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
name = "质量缺陷/不合格项整改关闭情况";
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
name = "无损检测情况";
|
|||
|
|
break;
|
|||
|
|
case 3:
|
|||
|
|
name = "焊工资格评定情况";
|
|||
|
|
break;
|
|||
|
|
case 4:
|
|||
|
|
name = "质量验收情况";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
name = "";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
return name;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 获取父级ID
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取父级名称
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="i"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private string getSupID(int sortIndex)
|
|||
|
|
{
|
|||
|
|
string supId = "-1";
|
|||
|
|
if (sortIndex <= 4)
|
|||
|
|
{
|
|||
|
|
supId = "1";
|
|||
|
|
}
|
|||
|
|
else if (sortIndex > 4 && sortIndex <= 11)
|
|||
|
|
{
|
|||
|
|
supId = "2";
|
|||
|
|
}
|
|||
|
|
else if (sortIndex > 11 && sortIndex <= 17)
|
|||
|
|
{
|
|||
|
|
supId = "3";
|
|||
|
|
}
|
|||
|
|
else if (sortIndex > 17)
|
|||
|
|
{
|
|||
|
|
supId = "4";
|
|||
|
|
}
|
|||
|
|
return supId;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string getNewSortIndex(int sortIndex)
|
|||
|
|
{
|
|||
|
|
int supId = 1;
|
|||
|
|
if (sortIndex <= 6)
|
|||
|
|
{
|
|||
|
|
supId = sortIndex;
|
|||
|
|
}
|
|||
|
|
else if (sortIndex >= 8 && sortIndex <= 18)
|
|||
|
|
{
|
|||
|
|
supId = sortIndex - 7;
|
|||
|
|
}
|
|||
|
|
else if (sortIndex >= 22 && sortIndex <= 24)
|
|||
|
|
{
|
|||
|
|
supId = sortIndex - 21;
|
|||
|
|
}
|
|||
|
|
else if (sortIndex >= 25 && sortIndex <= 35)
|
|||
|
|
{
|
|||
|
|
supId = sortIndex - 24;
|
|||
|
|
}
|
|||
|
|
else if (sortIndex >= 36 && sortIndex <= 37)
|
|||
|
|
{
|
|||
|
|
supId = sortIndex - 35;
|
|||
|
|
}
|
|||
|
|
else if (sortIndex >= 38 && sortIndex <= 39)
|
|||
|
|
{
|
|||
|
|
supId = sortIndex - 37;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return supId.ToString();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 绑定数据Grid2
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定数据Grid2
|
|||
|
|
/// </summary>
|
|||
|
|
private void BindGrid2()
|
|||
|
|
{
|
|||
|
|
string strSql = @"SELECT CQMSDataCollectSubmissionId,CQMSDataCollectId,Year,C.ProjectId,P.ProjectCode,P.ProjectName, Month1,Month2,Month3,Month4,Month5,Month6,Month7,Month8,Month9,Month10,Month11,Month12
|
|||
|
|
FROM dbo.DigData_CQMSDataCollectSubmission AS C
|
|||
|
|
LEFT JOIN Base_Project AS P ON C.ProjectId=P.ProjectId
|
|||
|
|
WHERE (Month1 IS NOT NULL OR Month2 IS NOT NULL OR Month3 IS NOT NULL OR Month4 IS NOT NULL OR Month5 IS NOT NULL OR Month6 IS NOT NULL OR Month7 IS NOT NULL OR Month8 IS NOT NULL OR Month9 IS NOT NULL OR Month10 IS NOT NULL OR Month11 IS NOT NULL OR Month12 IS NOT NULL)
|
|||
|
|
AND ProjectState ='1' ";
|
|||
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
|
if (this.drpYear.SelectedValue != BLL.Const._Null)
|
|||
|
|
{
|
|||
|
|
strSql += " AND Year = @Year";
|
|||
|
|
listStr.Add(new SqlParameter("@Year", Funs.GetNewInt(this.drpYear.SelectedValue)));
|
|||
|
|
}
|
|||
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|||
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|||
|
|
Grid2.RecordCount = tb.Rows.Count;
|
|||
|
|
var table = this.GetPagedDataTable(Grid2, tb);
|
|||
|
|
Grid2.DataSource = table;
|
|||
|
|
Grid2.DataBind();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 查询
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
int year = Funs.GetNewInt(this.drpYear.SelectedValue) ?? DateTime.Now.Year;
|
|||
|
|
var getCQMSDataCollect = CQMSDataCollectService.GetCQMSDataCollectByYear(year);
|
|||
|
|
if (getCQMSDataCollect == null)
|
|||
|
|
{
|
|||
|
|
CQMSDataCollectService.CreateCQMSDataCollectByYear(year);
|
|||
|
|
}
|
|||
|
|
this.BindGrid();
|
|||
|
|
this.BindGrid2();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void btnRefresh_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
int year = Funs.GetNewInt(this.drpYear.SelectedValue) ?? DateTime.Now.Year;
|
|||
|
|
var getCheck_CheckMonths = from x in Funs.DB.Check_CheckMonth
|
|||
|
|
where x.Months.Value.Year == year
|
|||
|
|
orderby x.Months
|
|||
|
|
select x;
|
|||
|
|
if (getCheck_CheckMonths.Count() > 0)
|
|||
|
|
{
|
|||
|
|
foreach (var item in getCheck_CheckMonths)
|
|||
|
|
{
|
|||
|
|
BLL.CQMSDataCollectService.SaveCQMSDataCollectItem(item);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
this.BindGrid();
|
|||
|
|
this.BindGrid2();
|
|||
|
|
ShowNotify("刷新完成!", MessageBoxIcon.Success);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected void Grid2_RowCommand(object sender, GridCommandEventArgs e)
|
|||
|
|
{
|
|||
|
|
int? year = Funs.GetNewInt(this.drpYear.SelectedValue);
|
|||
|
|
int? month = Funs.GetNewInt(e.CommandName);
|
|||
|
|
if (year.HasValue && month.HasValue)
|
|||
|
|
{
|
|||
|
|
var getSubmission = Funs.DB.DigData_CQMSDataCollectSubmission.FirstOrDefault(x => x.CQMSDataCollectSubmissionId == e.RowID);
|
|||
|
|
if (getSubmission != null)
|
|||
|
|
{
|
|||
|
|
var getMont = Funs.DB.Check_CheckMonth.FirstOrDefault(x => x.Months.Value.Year == year.Value && x.Months.Value.Month == month.Value && x.ProjectId == getSubmission.ProjectId);
|
|||
|
|
if (getMont != null)
|
|||
|
|
{
|
|||
|
|
PrinterDocService.PrinterDocMethod(Const.CheckMonthMenuId, getMont.CheckMonthId, "质量月报");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Alert.ShowInParent("当前月报不存在!", MessageBoxIcon.Warning);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//protected void Grid1_Collapse(object sender, EventArgs e)
|
|||
|
|
//{
|
|||
|
|
// this.Grid2.Collapsed = !this.Grid1.Collapsed;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//protected void Grid2_Collapse(object sender, EventArgs e)
|
|||
|
|
//{
|
|||
|
|
// this.Grid1.Collapsed = !this.Grid2.Collapsed;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
protected void rblShow_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (this.rblShow.SelectedValue == "1")
|
|||
|
|
{
|
|||
|
|
this.Grid1.Hidden = false;
|
|||
|
|
this.Grid2.Hidden = true;
|
|||
|
|
}
|
|||
|
|
else if (this.rblShow.SelectedValue == "2")
|
|||
|
|
{
|
|||
|
|
this.Grid1.Hidden = true;
|
|||
|
|
this.Grid2.Hidden = false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Grid1.Hidden = false;
|
|||
|
|
this.Grid2.Hidden = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected void btnDel_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(this.drpYear.SelectedValue))
|
|||
|
|
{
|
|||
|
|
int year = Funs.GetNewInt(this.drpYear.SelectedValue) ?? DateTime.Now.Year;
|
|||
|
|
CQMSDataCollectService.DeleteCQMSDataCollect(year);
|
|||
|
|
this.BindGrid();
|
|||
|
|
this.BindGrid2();
|
|||
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|