SGGL_SHJ/SGGL/FineUIPro.Web/CQMS/Material/ConstructionTestEdit.aspx.cs

233 lines
8.6 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.CQMS.Material
{
public partial class ConstructionTestEdit : PageBase
{
/// <summary>
/// 主键
/// </summary>
public string ConstructionTestId
{
get
{
return (string)ViewState["ConstructionTestId"];
}
set
{
ViewState["ConstructionTestId"] = 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.ConstructionTestTypeService.InitConstructionTestType(this.drpConstructionTestType, true);
BLL.Person_PersonsService.InitUserProjectIdUnitIdRoleIdDropDownList(this.drpWitness, this.CurrUser.LoginProjectId, string.Empty, string.Empty, true);
ConstructionTestId = Request.Params["ConstructionTestId"];
if (!string.IsNullOrEmpty(ConstructionTestId))
{
Model.Material_ConstructionTest ConstructionTest = BLL.CQMS_ConstructionTestService.GetConstructionTestByConstructionTestId(ConstructionTestId);
this.txtConstructionTestName.Text = ConstructionTest.ConstructionTestName;
this.hdId.Text = ConstructionTestId;
if (!string.IsNullOrEmpty(ConstructionTest.UnitId))
{
drpUnit.SelectedValue = ConstructionTest.UnitId;
}
if (!string.IsNullOrEmpty(ConstructionTest.ConstructionTestTypeId))
{
drpConstructionTestType.SelectedValue = ConstructionTest.ConstructionTestTypeId;
}
this.txtSpotCheckRate.Text = ConstructionTest.SpotCheckRate;
this.txtSpotCheckNum.Text = ConstructionTest.SpotCheckNum;
if (!string.IsNullOrEmpty(ConstructionTest.Witness))
{
string[] strs = ConstructionTest.Witness.Split(',');
this.drpWitness.SelectedValueArray = strs;
}
if (ConstructionTest.CheckResult != null)
{
if (ConstructionTest.CheckResult == true)
{
this.rblCheckResult.SelectedValue = "True";
}
else
{
this.rblCheckResult.SelectedValue = "False";
}
}
if (!string.IsNullOrEmpty(ConstructionTest.CheckUnit))
{
drpCheckUnit.SelectedValue = ConstructionTest.CheckUnit;
}
}
}
}
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)
{
if (string.IsNullOrEmpty(this.hdId.Text))
{
this.hdId.Text = SQLHelper.GetNewID();
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=1&toKeyId={0}&path=FileUpload/CQMS/ConstructionTest&menuId={1}", this.hdId.Text, BLL.Const.ConstructionTestMenuId)));
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (validate())
{
Saveinspection("save");
}
}
/// <summary>
/// 保存
/// </summary>
public void Saveinspection(string saveType)
{
Model.Material_ConstructionTest ConstructionTest = new Model.Material_ConstructionTest();
ConstructionTest.ProjectId = this.CurrUser.LoginProjectId;
ConstructionTest.ConstructionTestName = this.txtConstructionTestName.Text.Trim();
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
ConstructionTest.UnitId = this.drpUnit.SelectedValue;
}
if (this.drpConstructionTestType.SelectedValue != BLL.Const._Null)
{
ConstructionTest.ConstructionTestTypeId = this.drpConstructionTestType.SelectedValue;
}
ConstructionTest.SpotCheckRate = this.txtSpotCheckRate.Text.Trim();
ConstructionTest.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))
{
ConstructionTest.Witness = wintness.Substring(0, wintness.Length - 1);
}
ConstructionTest.CheckResult = Convert.ToBoolean(this.rblCheckResult.SelectedValue);
if (this.drpCheckUnit.SelectedValue != BLL.Const._Null)
{
ConstructionTest.CheckUnit = this.drpCheckUnit.SelectedValue;
}
ConstructionTest.CompileMan = this.CurrUser.PersonId;
ConstructionTest.CompileDate = DateTime.Now;
if (!string.IsNullOrEmpty(this.ConstructionTestId))
{
ConstructionTest.ConstructionTestId = this.ConstructionTestId;
CQMS_ConstructionTestService.UpdateConstructionTest(ConstructionTest);
LogService.AddSys_Log(CurrUser, ConstructionTest.ConstructionTestName, ConstructionTest.ConstructionTestId, Const.ConstructionTestMenuId, "修改施工试验");
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
ConstructionTest.ConstructionTestId = this.hdId.Text;
}
else
{
ConstructionTest.ConstructionTestId = SQLHelper.GetNewID();
}
CQMS_ConstructionTestService.AddConstructionTest(ConstructionTest);
LogService.AddSys_Log(CurrUser, ConstructionTest.ConstructionTestName, ConstructionTest.ConstructionTestId, Const.ConstructionTestMenuId, "增加施工试验");
}
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.ConstructionTestId);
//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;
}
}
}