SGGL_JT/SUBQHSE/FineUIPro.Web/CQMS/Comprehensive/QualityAssuranceEdit.aspx.cs

201 lines
7.5 KiB
C#
Raw Normal View History

2025-06-20 22:32:18 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Comprehensive
{
public partial class QualityAssuranceEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string QualityAssuranceId
{
get
{
return (string)ViewState["QualityAssuranceId"];
}
set
{
ViewState["QualityAssuranceId"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
/// <summary>
/// 主键
/// </summary>
//public string UnitId
//{
// get
// {
// return (string)ViewState["UnitId"];
// }
// set
// {
// ViewState["UnitId"] = value;
// }
//}
#endregion
#region
/// <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.UnitId = Request.Params["UnitId"];
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.InitDropDownList();
this.QualityAssuranceId = Request.Params["QualityAssuranceId"];
if (!string.IsNullOrEmpty(this.QualityAssuranceId))
{
var getData = BLL.QualityAssuranceService.GetQualityAssuranceById(this.QualityAssuranceId);
if (getData != null)
{
this.ProjectId = getData.ProjectId;
//this.UnitId = getData.UnitId;
if (this.ProjectId != this.CurrUser.LoginProjectId)
{
this.InitDropDownList();
}
this.txtCode.Text = getData.QualityAssuranceCode;
this.txtName.Text = getData.QualityAssuranceName;
if (!string.IsNullOrEmpty(getData.QualityAssuranceType))
{
this.drpType.SelectedValue = getData.QualityAssuranceType;
}
this.txtContents.Text = HttpUtility.HtmlDecode(getData.ContentTexts);
if (!string.IsNullOrEmpty(getData.CompileMan))
{
this.drpCompileMan.SelectedValue = getData.CompileMan;
}
this.txtCompileDate.Text = getData.CompileDate.HasValue ? string.Format("{0:yyyy-MM-dd}", getData.CompileDate) : "";
}
}
else
{
this.drpCompileMan.SelectedValue = this.CurrUser.UserId;
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
//var codeTemplateRule = BLL.ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(BLL.Const.ProjectThemeActivitiesMenuId, this.ProjectId);
//if (codeTemplateRule != null)
//{
// this.txtContents.Text = HttpUtility.HtmlDecode(codeTemplateRule.Template);
//}
}
}
}
#endregion
/// <summary>
/// 初始化下拉框
/// </summary>
private void InitDropDownList()
{
//类别
this.drpType.DataValueField = "Value";
this.drpType.DataTextField= "Text";
this.drpType.DataSource= BLL.DropListService.drpQualityAssuranceTypeList();
this.drpType.DataBind();
Funs.FineUIPleaseSelect(this.drpType);
UserService.InitUserDropDownList(this.drpCompileMan, this.ProjectId, true);
this.drpCompileMan.SelectedValue = this.CurrUser.UserId;
}
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (this.drpType.SelectedValue==BLL.Const._Null)
{
Alert.ShowInTop("请选择类别", MessageBoxIcon.Warning);
return;
}
this.SaveData(BLL.Const.BtnSave);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
Model.Comprehensive_QualityAssurance newData = new Model.Comprehensive_QualityAssurance
{
ProjectId = this.ProjectId,
QualityAssuranceCode = this.txtCode.Text.Trim(),
QualityAssuranceName = this.txtName.Text.Trim(),
CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim()),
};
if (this.drpType.SelectedValue != BLL.Const._Null)
{
newData.QualityAssuranceType = this.drpType.SelectedValue;
}
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
{
newData.CompileMan = this.drpCompileMan.SelectedValue;
}
newData.ContentTexts = HttpUtility.HtmlEncode(this.txtContents.Text);
if (!string.IsNullOrEmpty(this.QualityAssuranceId))
{
newData.QualityAssuranceId = this.QualityAssuranceId;
BLL.QualityAssuranceService.UpdateQualityAssurance(newData);
BLL.LogService.AddSys_Log(this.CurrUser, newData.QualityAssuranceCode, newData.QualityAssuranceId, BLL.Const.CQMS_QualityAssuranceMenuId, BLL.Const.BtnModify);
}
else
{
this.QualityAssuranceId = SQLHelper.GetNewID(typeof(Model.Comprehensive_QualityAssurance));
newData.QualityAssuranceId = this.QualityAssuranceId;
BLL.QualityAssuranceService.AddQualityAssurance(newData);
BLL.LogService.AddSys_Log(this.CurrUser, newData.QualityAssuranceCode, newData.QualityAssuranceId, BLL.Const.CQMS_QualityAssuranceMenuId, 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.QualityAssuranceId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/QualityAssuranceAttachUrl&menuId={1}", QualityAssuranceId, BLL.Const.CQMS_QualityAssuranceMenuId)));
}
#endregion
}
}