SGGL_SHJ/SGGL/FineUIPro.Web/CQMS/Material/NoticeAndSupervisionView.as...

188 lines
7.6 KiB
C#

using BLL;
using Newtonsoft.Json.Linq;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Material
{
public partial class NoticeAndSupervisionView : PageBase
{
/// <summary>
/// 主键
/// </summary>
public string NoticeAndSupervisionId
{
get
{
return (string)ViewState["NoticeAndSupervisionId"];
}
set
{
ViewState["NoticeAndSupervisionId"] = value;
}
}
/// <summary>
/// 办理类型
/// </summary>
public string State
{
get
{
return (string)ViewState["State"];
}
set
{
ViewState["State"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BLL.UnitService.InitUnitDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, true);
BLL.MainItemService.InitMainItemDownList(drpMainItem, this.CurrUser.LoginProjectId, true);
BLL.NoticeAndSupervisionTypeService.InitNoticeAndSupervisionType(this.drpNoticeAndSupervisionType, true);
NoticeAndSupervisionId = Request.Params["NoticeAndSupervisionId"];
if (!string.IsNullOrEmpty(NoticeAndSupervisionId))
{
Model.Material_NoticeAndSupervision NoticeAndSupervision = BLL.CQMS_NoticeAndSupervisionService.GetNoticeAndSupervisionByNoticeAndSupervisionId(NoticeAndSupervisionId);
Model.Material_Inspection inspection = BLL.CQMS_InspectionService.GetInspectionByInspectionId(NoticeAndSupervision.InspectionId);
txtInspectionCode.Text = inspection.InspectionCode;
if (!string.IsNullOrEmpty(NoticeAndSupervision.UnitId))
{
drpUnit.SelectedValue = NoticeAndSupervision.UnitId;
}
if (!string.IsNullOrEmpty(NoticeAndSupervision.MainItemId))
{
drpMainItem.SelectedValue = NoticeAndSupervision.MainItemId;
}
if (!string.IsNullOrEmpty(NoticeAndSupervision.NoticeAndSupervisionTypeId))
{
drpNoticeAndSupervisionType.SelectedValue = NoticeAndSupervision.NoticeAndSupervisionTypeId;
}
this.txtUnit.Text = NoticeAndSupervision.Unit;
if (NoticeAndSupervision.Num != null)
{
this.txtNum.Text = NoticeAndSupervision.Num.ToString();
}
if (NoticeAndSupervision.NoticeDate != null)
{
this.txtNoticeDate.Text = string.Format("{0:yyyy-MM-dd}", NoticeAndSupervision.NoticeDate);
}
this.txtConclusion.Text = NoticeAndSupervision.Conclusion;
BindData(inspection.InspectionType, NoticeAndSupervision.InspectionId);
}
}
}
private void BindData(string type, string inspectionId)
{
if (type == "M") //材料报验
{
string strSql = @"select C.*,C.MaterialId as Id,M.MainItemName,U.UnitName from [dbo].[Material_Material] C
left join [dbo].[ProjectData_MainItem] M on C.MainItemId=M.MainItemId
left join [dbo].[Base_Unit] U on U.UnitId=C.UnitId where 1=1";
List<SqlParameter> listStr = new List<SqlParameter>();
strSql += " AND C.InspectionId = @InspectionId";
listStr.Add(new SqlParameter("@InspectionId", inspectionId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
else
{
string strSql = @"select C.*,C.EquipmentId as Id,C.EquipmentName as MaterialName,C.EquipmentCode as MaterialCode,M.MainItemName,U.UnitName from [dbo].[Material_Equipment] C
left join [dbo].[ProjectData_MainItem] M on C.MainItemId=M.MainItemId
left join [dbo].[Base_Unit] U on U.UnitId=C.UnitId where 1=1";
List<SqlParameter> listStr = new List<SqlParameter>();
strSql += " AND C.InspectionId = @InspectionId";
listStr.Add(new SqlParameter("@InspectionId", inspectionId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
this.Grid1.Columns[4].HeaderText = "设备名称";
this.Grid1.Columns[6].HeaderText = "设备位号";
this.Grid1.Columns[7].Hidden = true;
}
}
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
}
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
{
}
/// <summary>
/// 时间转换
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public string ConvertDate(object date)
{
if (date != null)
{
return string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(date));
}
else
{
return null;
}
}
protected void imgBtnFileN_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/NoticeAndSupervision&menuId={1}", this.NoticeAndSupervisionId + "N", BLL.Const.NoticeAndSupervisionMenuId)));
}
protected void imgBtnFileS_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/NoticeAndSupervision&menuId={1}", this.NoticeAndSupervisionId + "S", BLL.Const.NoticeAndSupervisionMenuId)));
}
protected void imgBtnFile_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/NoticeAndSupervision&menuId={1}", this.NoticeAndSupervisionId, BLL.Const.NoticeAndSupervisionMenuId)));
}
private string GetStringByArray(string[] array)
{
string str = string.Empty;
foreach (var item in array)
{
if (item != BLL.Const._Null)
{
str += item + ",";
}
}
if (!string.IsNullOrEmpty(str))
{
str = str.Substring(0, str.LastIndexOf(","));
}
return str;
}
}
}