473 lines
19 KiB
C#
473 lines
19 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.CQMS.Material
|
|
{
|
|
public partial class InspectionEdit : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string InspectionId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["InspectionId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["InspectionId"] = 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);
|
|
InspectionId = Request.Params["InspectionId"];
|
|
this.HideOptions.Hidden = true;
|
|
this.rblIsAgree.Hidden = true;
|
|
if (!string.IsNullOrEmpty(InspectionId))
|
|
{
|
|
Model.Material_Inspection inspection = BLL.CQMS_InspectionService.GetInspectionByInspectionId(InspectionId);
|
|
txtInspectionCode.Text = inspection.InspectionCode;
|
|
if (!string.IsNullOrEmpty(inspection.UnitId))
|
|
{
|
|
drpUnit.SelectedValue = inspection.UnitId;
|
|
}
|
|
if (inspection.IsSpotCheck != null)
|
|
{
|
|
if (inspection.IsSpotCheck == true)
|
|
{
|
|
this.rblIsSpotCheck.SelectedValue = "True";
|
|
}
|
|
else
|
|
{
|
|
this.rblIsSpotCheck.SelectedValue = "False";
|
|
}
|
|
}
|
|
if (inspection.IsNoticeAndSupervision != null)
|
|
{
|
|
if (inspection.IsNoticeAndSupervision == true)
|
|
{
|
|
this.rblIsNoticeAndSupervision.SelectedValue = "True";
|
|
}
|
|
else
|
|
{
|
|
this.rblIsNoticeAndSupervision.SelectedValue = "False";
|
|
}
|
|
}
|
|
BindData(inspection.InspectionType);
|
|
gvApprove.DataSource = BLL.CQMS_InspectionApproveService.getListData(this.InspectionId);
|
|
gvApprove.DataBind();
|
|
if (!string.IsNullOrEmpty(inspection.State))
|
|
{
|
|
State = inspection.State;
|
|
}
|
|
else
|
|
{
|
|
State = BLL.Const.Inspection_Compile;
|
|
this.HideOptions.Hidden = true;
|
|
this.rblIsAgree.Hidden = true;
|
|
}
|
|
if (State != BLL.Const.Inspection_Complete.ToString())
|
|
{
|
|
this.drpHandleType.DataTextField = "Text";
|
|
this.drpHandleType.DataValueField = "Value";
|
|
drpHandleType.DataSource = BLL.CQMS_InspectionService.GetDHandleTypeByState(State);
|
|
drpHandleType.DataBind();
|
|
|
|
}
|
|
|
|
if (State == BLL.Const.Inspection_Compile || State == BLL.Const.Inspection_ReCompile)
|
|
{
|
|
this.HideOptions.Visible = false;
|
|
this.rblIsAgree.Visible = false;
|
|
this.drpHandleMan.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
this.HideOptions.Hidden = false;
|
|
this.rblIsAgree.Hidden = false;
|
|
}
|
|
if (State == Const.Inspection_Audit2)
|
|
{
|
|
this.drpHandleMan.Enabled = false;
|
|
}
|
|
if (State == BLL.Const.Inspection_Complete || !string.IsNullOrEmpty(Request.Params["see"]))
|
|
{
|
|
this.btnSave.Visible = false;
|
|
this.btnSubmit.Visible = false;
|
|
this.next.Hidden = true;
|
|
}
|
|
drpHandleType_SelectedIndexChanged(null, null);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void BindData(string type)
|
|
{
|
|
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", this.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", this.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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 把状态转换代号为文字形式
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertState(object state)
|
|
{
|
|
if (state != null)
|
|
{
|
|
if (state.ToString() == BLL.Const.Inspection_ReCompile)
|
|
{
|
|
return "重新编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.Inspection_Compile)
|
|
{
|
|
return "编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.Inspection_Audit1)
|
|
{
|
|
return "总包专业工程师审批";
|
|
}
|
|
else if (state.ToString() == BLL.Const.Inspection_Audit2)
|
|
{
|
|
return "监理工程师审批";
|
|
}
|
|
else if (state.ToString() == BLL.Const.Inspection_SpotCheck)
|
|
{
|
|
return "正在抽检";
|
|
}
|
|
else if (state.ToString() == BLL.Const.Inspection_Complete)
|
|
{
|
|
return "审批完成";
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
protected void imgBtnFile_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=1&toKeyId={0}&path=FileUpload/CQMS/Material&menuId={1}", this.InspectionId, BLL.Const.InspectionMenuId)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 同意审核单选框改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.drpHandleMan.Enabled = true;
|
|
string State = BLL.CQMS_InspectionService.GetInspectionByInspectionId(this.InspectionId).State;
|
|
if (this.RadioButtonList1.SelectedValue.Equals("true"))
|
|
{
|
|
if (State == Const.Inspection_Audit1)
|
|
{
|
|
this.drpHandleMan.Enabled = false;
|
|
}
|
|
this.drpHandleType.SelectedIndex = 0;
|
|
this.drpHandleMan.SelectedIndex = 0;
|
|
}
|
|
else
|
|
{
|
|
this.drpHandleMan.Items.Clear();
|
|
Funs.FineUIPleaseSelect(drpHandleMan);
|
|
this.drpHandleType.SelectedIndex = 1;
|
|
ListItem item = new ListItem();
|
|
var user = BLL.Person_PersonsService.GetPerson_PersonsById(BLL.CQMS_InspectionApproveService.GetAuditMan(this.InspectionId, BLL.Const.Inspection_Compile).ApproveMan);
|
|
item.Value = user.PersonId;
|
|
item.Text = user.PersonName;
|
|
this.drpHandleMan.Items.Add(item);
|
|
this.drpHandleMan.SelectedIndex = 1;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 办理步骤下拉框改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpHandleType_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.drpHandleMan.Items.Clear();
|
|
Funs.FineUIPleaseSelect(this.drpHandleMan);
|
|
if (this.drpHandleType.SelectedValue == BLL.Const.Inspection_Complete)
|
|
{
|
|
this.drpHandleMan.Enabled = false;
|
|
}
|
|
else if (this.drpHandleType.SelectedValue == BLL.Const.Inspection_ReCompile)
|
|
{
|
|
this.drpHandleMan.Enabled = true;
|
|
string userId = (from x in Funs.DB.Material_InspectionApprove where x.InspectionId == InspectionId && x.ApproveType == BLL.Const.Inspection_Compile select x.ApproveMan).First();
|
|
ListItem lis = new ListItem(BLL.Person_PersonsService.GetPersonsNameById(userId), userId);
|
|
this.drpHandleMan.Items.Add(lis);
|
|
this.drpHandleMan.SelectedIndex = 0;
|
|
}
|
|
else
|
|
{
|
|
this.drpHandleMan.Enabled = true;
|
|
if (this.drpHandleType.SelectedValue == BLL.Const.Inspection_Audit1)
|
|
{
|
|
SitePerson_PersonService.InitProjectUserListByProjectUnitTypeDropDownList(drpHandleMan, this.CurrUser.LoginProjectId, Const.ProjectUnitType_1, false);
|
|
}
|
|
else
|
|
{
|
|
SitePerson_PersonService.InitProjectUserListByProjectUnitTypeDropDownList(drpHandleMan, this.CurrUser.LoginProjectId, Const.ProjectUnitType_3, false);
|
|
}
|
|
this.drpHandleMan.SelectedIndex = 1;
|
|
}
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
Saveinspection("save");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
public void Saveinspection(string saveType)
|
|
{
|
|
Model.Material_Inspection inspection = BLL.CQMS_InspectionService.GetInspectionByInspectionId(this.InspectionId);
|
|
if (inspection != null)
|
|
{
|
|
inspection.InspectionCode = this.txtInspectionCode.Text.Trim();
|
|
inspection.UnitId = this.drpUnit.SelectedValue;
|
|
inspection.IsSpotCheck = Convert.ToBoolean(this.rblIsSpotCheck.SelectedValue);
|
|
inspection.IsNoticeAndSupervision = Convert.ToBoolean(this.rblIsNoticeAndSupervision.SelectedValue);
|
|
}
|
|
//inspection.State = "1"; //整改中
|
|
|
|
if (saveType == "submit")
|
|
{
|
|
if (inspection.IsSpotCheck == true && inspection.IsNoticeAndSupervision == false && (inspection.State == BLL.Const.Inspection_Compile || inspection.State == BLL.Const.Inspection_ReCompile)) //生成材料试验记录
|
|
{
|
|
Model.Material_MaterialTest oldTest = BLL.CQMS_MaterialTestService.GetMaterialTestByInspectionId(this.InspectionId);
|
|
if (oldTest == null)
|
|
{
|
|
Model.Material_MaterialTest test = new Model.Material_MaterialTest();
|
|
test.MaterialTestId = SQLHelper.GetNewID();
|
|
test.ProjectId = this.CurrUser.LoginProjectId;
|
|
test.InspectionId = this.InspectionId;
|
|
test.CompileMan = this.CurrUser.PersonId;
|
|
test.CompileDate = DateTime.Now;
|
|
BLL.CQMS_MaterialTestService.AddMaterialTest(test);
|
|
}
|
|
//inspection.State = BLL.Const.Inspection_SpotCheck;
|
|
inspection.State = BLL.Const.Inspection_Complete;
|
|
}
|
|
else if (inspection.IsSpotCheck == false && inspection.IsNoticeAndSupervision == true && (inspection.State == BLL.Const.Inspection_Compile || inspection.State == BLL.Const.Inspection_ReCompile)) //生成告知和监检记录
|
|
{
|
|
Model.Material_NoticeAndSupervision oldNoticeAndSupervision = BLL.CQMS_NoticeAndSupervisionService.GetNoticeAndSupervisionByInspectionId(this.InspectionId);
|
|
if (oldNoticeAndSupervision == null)
|
|
{
|
|
Model.Material_NoticeAndSupervision noticeAndSupervision = new Model.Material_NoticeAndSupervision();
|
|
noticeAndSupervision.NoticeAndSupervisionId = SQLHelper.GetNewID();
|
|
noticeAndSupervision.ProjectId = this.CurrUser.LoginProjectId;
|
|
noticeAndSupervision.InspectionId = this.InspectionId;
|
|
noticeAndSupervision.CompileMan = this.CurrUser.PersonId;
|
|
noticeAndSupervision.CompileDate = DateTime.Now;
|
|
BLL.CQMS_NoticeAndSupervisionService.AddNoticeAndSupervision(noticeAndSupervision);
|
|
}
|
|
//inspection.State = this.drpHandleType.SelectedValue;
|
|
inspection.State = BLL.Const.Inspection_Complete;
|
|
}
|
|
else
|
|
{
|
|
//inspection.State = this.drpHandleType.SelectedValue;
|
|
inspection.State = BLL.Const.Inspection_Complete;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Model.Material_Inspection inspection1 = CQMS_InspectionService.GetInspectionByInspectionId(InspectionId);
|
|
if (inspection1 != null)
|
|
{
|
|
if (string.IsNullOrEmpty(inspection1.State))
|
|
{
|
|
inspection.State = BLL.Const.Inspection_Compile;
|
|
}
|
|
else
|
|
{
|
|
inspection.State = inspection1.State;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
inspection.State = BLL.Const.Inspection_Compile;
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(InspectionId))
|
|
{
|
|
CQMS_InspectionService.UpdateInspection(inspection);
|
|
if (saveType == "submit")
|
|
{
|
|
Model.Material_InspectionApprove approve1 = BLL.CQMS_InspectionApproveService.GetInspectionApproveByInspectionId(InspectionId);
|
|
approve1.ApproveDate = DateTime.Now;
|
|
approve1.ApproveIdea = this.txtOpinions.Text.Trim();
|
|
approve1.IsAgree = Convert.ToBoolean(this.RadioButtonList1.SelectedValue);
|
|
BLL.CQMS_InspectionApproveService.UpdateInspectionApprove(approve1);
|
|
//Model.Material_InspectionApprove approve = new Model.Material_InspectionApprove();
|
|
//approve.InspectionId = inspection.InspectionId;
|
|
//if (this.drpHandleMan.SelectedValue != BLL.Const._Null)
|
|
//{
|
|
// approve.ApproveMan = this.drpHandleMan.SelectedValue;
|
|
//}
|
|
//approve.ApproveType = this.drpHandleType.SelectedValue;
|
|
//BLL.CQMS_InspectionApproveService.AddInspectionApprove(approve);
|
|
}
|
|
}
|
|
LogService.AddSys_Log(CurrUser, inspection.InspectionCode, inspection.InspectionId, Const.InspectionMenuId, "修改报验管理");
|
|
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.InspectionId);
|
|
//if (att == null)
|
|
//{
|
|
// err += "请上传质量证明文件!";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(err))
|
|
{
|
|
Alert.ShowInTop(err, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
res = true;
|
|
}
|
|
return res;
|
|
}
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
Saveinspection("submit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |