SGGL_JT/SUBQHSE/FineUIPro.Web/HSSE/License/HSETechnicalEdit.aspx.cs

197 lines
8.0 KiB
C#
Raw Normal View History

2025-04-07 17:43:30 +08:00
using BLL;
using System;
namespace FineUIPro.Web.License
{
public partial class HSETechnicalEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string HSETechnicalId
{
get
{
return (string)ViewState["HSETechnicalId"];
}
set
{
ViewState["HSETechnicalId"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.ProjectId = this.CurrUser.LoginProjectId;
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.InitDropDownList();
Funs.FineUIPleaseSelect(this.drpTeamGroupId);
this.HSETechnicalId = Request.Params["HSETechnicalId"];
if (!string.IsNullOrEmpty(this.HSETechnicalId))
{
Model.License_HSETechnical hseTechnical = BLL.HSETechnicalService.GetHSETechnicalById(this.HSETechnicalId);
if (hseTechnical != null)
{
this.ProjectId = hseTechnical.ProjectId;
if (this.ProjectId != this.CurrUser.LoginProjectId)
{
this.InitDropDownList();
}
this.txtHSETechnicalCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.HSETechnicalId);
this.txtHSETechnicalDate.Text = string.Format("{0:yyyy-MM-dd}", hseTechnical.HSETechnicalDate);
if (!string.IsNullOrEmpty(hseTechnical.UnitId))
{
this.drpUnitId.SelectedValue = hseTechnical.UnitId;
this.drpTeamGroupId.DataValueField = "TeamGroupId";
this.drpTeamGroupId.DataTextField = "TeamGroupName";
this.drpTeamGroupId.DataSource = BLL.TeamGroupService.GetTeamGroupListByUnitId(this.ProjectId, hseTechnical.UnitId);
this.drpTeamGroupId.DataBind();
Funs.FineUIPleaseSelect(this.drpTeamGroupId);
}
if (!string.IsNullOrEmpty(hseTechnical.TeamGroupId))
{
this.drpTeamGroupId.SelectedValue = hseTechnical.TeamGroupId;
}
this.txtWorkContents.Text = hseTechnical.WorkContents;
this.txtAddress.Text = hseTechnical.Address;
}
}
else
{
this.txtHSETechnicalDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
////自动生成编码
this.txtHSETechnicalCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectHSETechnicalMenuId, this.ProjectId, this.CurrUser.UnitId);
this.drpUnitId.SelectedValue = this.CurrUser.UnitId;
}
}
}
/// <summary>
/// 初始化下拉框
/// </summary>
private void InitDropDownList()
{
BLL.UnitService.InitUnitDropDownList(this.drpUnitId, this.ProjectId, true);
}
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveData(BLL.Const.BtnSave);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
Model.License_HSETechnical hSETechnical = new Model.License_HSETechnical
{
ProjectId = this.ProjectId,
HSETechnicalCode = this.txtHSETechnicalCode.Text.Trim(),
HSETechnicalDate = Funs.GetNewDateTime(this.txtHSETechnicalDate.Text.Trim())
};
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
{
hSETechnical.UnitId = this.drpUnitId.SelectedValue;
}
if (this.drpTeamGroupId.SelectedValue != BLL.Const._Null)
{
hSETechnical.TeamGroupId = this.drpTeamGroupId.SelectedValue;
}
hSETechnical.WorkContents = this.txtWorkContents.Text.Trim();
hSETechnical.Address = this.txtAddress.Text.Trim();
hSETechnical.CompileMan = this.CurrUser.UserId;
hSETechnical.CompileDate = DateTime.Now;
hSETechnical.States = BLL.Const.State_0;
if (!string.IsNullOrEmpty(this.HSETechnicalId))
{
hSETechnical.HSETechnicalId = this.HSETechnicalId;
BLL.HSETechnicalService.UpdateHSETechnical(hSETechnical);
BLL.LogService.AddSys_Log(this.CurrUser, hSETechnical.HSETechnicalCode, hSETechnical.HSETechnicalId, BLL.Const.ProjectHSETechnicalMenuId, BLL.Const.BtnModify);
}
else
{
this.HSETechnicalId = SQLHelper.GetNewID(typeof(Model.License_HSETechnical));
hSETechnical.HSETechnicalId = this.HSETechnicalId;
hSETechnical.QRCodeAttachUrl = CreateQRCodeService.CreateCode_Simple("HSETechnical$" + this.HSETechnicalId);
BLL.HSETechnicalService.AddHSETechnical(hSETechnical);
BLL.LogService.AddSys_Log(this.CurrUser, hSETechnical.HSETechnicalCode, hSETechnical.HSETechnicalId, BLL.Const.ProjectHSETechnicalMenuId, BLL.Const.BtnAdd);
}
}
#endregion
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.HSETechnicalId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HSETechnicalAttachUrl&menuId={1}", this.HSETechnicalId, BLL.Const.ProjectHSETechnicalMenuId)));
}
#endregion
/// <summary>
/// 单位下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpUnitId_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
{
this.drpTeamGroupId.Items.Clear();
this.drpTeamGroupId.DataValueField = "TeamGroupId";
this.drpTeamGroupId.DataTextField = "TeamGroupName";
this.drpTeamGroupId.DataSource = BLL.TeamGroupService.GetTeamGroupListByUnitId(this.ProjectId, this.drpUnitId.SelectedValue);
this.drpTeamGroupId.DataBind();
Funs.FineUIPleaseSelect(this.drpTeamGroupId);
this.drpTeamGroupId.SelectedIndex = 0;
}
else
{
this.drpTeamGroupId.Items.Clear();
Funs.FineUIPleaseSelect(this.drpTeamGroupId);
this.drpTeamGroupId.SelectedIndex = 0;
}
}
}
}