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 定义项 /// /// 主键 /// public string QualityAssuranceId { get { return (string)ViewState["QualityAssuranceId"]; } set { ViewState["QualityAssuranceId"] = value; } } /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } /// /// 主键 /// //public string UnitId //{ // get // { // return (string)ViewState["UnitId"]; // } // set // { // ViewState["UnitId"] = value; // } //} #endregion #region 加载 /// /// 加载页面 /// /// /// 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 /// /// 初始化下拉框 /// 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 保存 /// /// 保存按钮 /// /// /// 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()); } /// /// 保存数据 /// /// 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 附件上传 /// /// 上传附件 /// /// /// 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 } }