270 lines
10 KiB
C#
270 lines
10 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace FineUIPro.Web.CQMS.Material
|
|
{
|
|
public partial class MaterialTestEdit : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string MaterialTestId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["MaterialTestId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["MaterialTestId"] = 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.UnitService.InitUnitDropDownList(this.drpCheckUnit, this.CurrUser.LoginProjectId, true);
|
|
BLL.MaterialTypeService.InitMaterialType(this.drpMaterialType, true);
|
|
BLL.Person_PersonsService.InitUserProjectIdUnitIdRoleIdDropDownList(this.drpWitness, this.CurrUser.LoginProjectId, string.Empty, string.Empty, true);
|
|
MaterialTestId = Request.Params["MaterialTestId"];
|
|
if (!string.IsNullOrEmpty(MaterialTestId))
|
|
{
|
|
Model.Material_MaterialTest materialTest = BLL.CQMS_MaterialTestService.GetMaterialTestByMaterialTestId(MaterialTestId);
|
|
Model.Material_Inspection inspection = BLL.CQMS_InspectionService.GetInspectionByInspectionId(materialTest.InspectionId);
|
|
txtInspectionCode.Text = inspection.InspectionCode;
|
|
if (!string.IsNullOrEmpty(materialTest.UnitId))
|
|
{
|
|
drpUnit.SelectedValue = materialTest.UnitId;
|
|
}
|
|
if (!string.IsNullOrEmpty(materialTest.MaterialTypeId))
|
|
{
|
|
drpMaterialType.SelectedValue = materialTest.MaterialTypeId;
|
|
}
|
|
this.txtSpotCheckRate.Text = materialTest.SpotCheckRate;
|
|
this.txtSpotCheckNum.Text = materialTest.SpotCheckNum;
|
|
if (!string.IsNullOrEmpty(materialTest.Witness))
|
|
{
|
|
string[] strs = materialTest.Witness.Split(',');
|
|
this.drpWitness.SelectedValueArray = strs;
|
|
}
|
|
if (materialTest.CheckResult != null)
|
|
{
|
|
if (materialTest.CheckResult == true)
|
|
{
|
|
this.rblCheckResult.SelectedValue = "True";
|
|
}
|
|
else
|
|
{
|
|
this.rblCheckResult.SelectedValue = "False";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(materialTest.CheckUnit))
|
|
{
|
|
drpCheckUnit.SelectedValue = materialTest.CheckUnit;
|
|
}
|
|
BindData(inspection.InspectionType, materialTest.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 imgBtnFile_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=1&toKeyId={0}&path=FileUpload/CQMS/MaterialTest&menuId={1}", this.MaterialTestId, BLL.Const.MaterialTestMenuId)));
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
Saveinspection("save");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
public void Saveinspection(string saveType)
|
|
{
|
|
Model.Material_MaterialTest materialTest = BLL.CQMS_MaterialTestService.GetMaterialTestByMaterialTestId(this.MaterialTestId);
|
|
if (materialTest != null)
|
|
{
|
|
if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
materialTest.UnitId = this.drpUnit.SelectedValue;
|
|
}
|
|
if (this.drpMaterialType.SelectedValue != BLL.Const._Null)
|
|
{
|
|
materialTest.MaterialTypeId = this.drpMaterialType.SelectedValue;
|
|
}
|
|
materialTest.SpotCheckRate = this.txtSpotCheckRate.Text.Trim();
|
|
materialTest.SpotCheckNum = this.txtSpotCheckNum.Text.Trim();
|
|
string wintness = string.Empty;
|
|
foreach (var item in this.drpWitness.SelectedValueArray)
|
|
{
|
|
if (item != BLL.Const._Null)
|
|
{
|
|
wintness += item + ",";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(wintness))
|
|
{
|
|
materialTest.Witness = wintness.Substring(0, wintness.Length - 1);
|
|
}
|
|
materialTest.CheckResult = Convert.ToBoolean(this.rblCheckResult.SelectedValue);
|
|
if (this.drpCheckUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
materialTest.CheckUnit = this.drpCheckUnit.SelectedValue;
|
|
}
|
|
materialTest.CompileMan = this.CurrUser.PersonId;
|
|
materialTest.CompileDate = DateTime.Now;
|
|
CQMS_MaterialTestService.UpdateMaterialTest(materialTest);
|
|
Model.Material_Inspection inspection = BLL.CQMS_InspectionService.GetInspectionByInspectionId(materialTest.InspectionId);
|
|
if (inspection != null)
|
|
{
|
|
if (inspection.State == BLL.Const.Inspection_SpotCheck) //若状态为正在抽检,则更新报验单状态为总包工程师审核
|
|
{
|
|
inspection.State = BLL.Const.Inspection_Audit1;
|
|
BLL.CQMS_InspectionService.UpdateInspection(inspection);
|
|
}
|
|
}
|
|
LogService.AddSys_Log(CurrUser, materialTest.InspectionId, materialTest.MaterialTestId, Const.MaterialTestMenuId, "修改材料试验");
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
|
|
}
|
|
/// <summary>
|
|
/// 表格数据验证
|
|
/// </summary>
|
|
private bool validate()
|
|
{
|
|
bool res = false;
|
|
string err = string.Empty;
|
|
if (this.drpUnit.SelectedValue == BLL.Const._Null)
|
|
{
|
|
err += "请选择分包单位!";
|
|
}
|
|
//var att = BLL.AttachFileService.GetAttachFileByToKeyId(this.MaterialTestId);
|
|
//if (att == null)
|
|
//{
|
|
// err += "请上传质量证明文件!";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(err))
|
|
{
|
|
Alert.ShowInTop(err, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
res = true;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |