160 lines
6.4 KiB
C#
160 lines
6.4 KiB
C#
using BLL;
|
|
using System;
|
|
|
|
namespace FineUIPro.Web.CQMS.Comprehensive
|
|
{
|
|
public partial class DesignDetailsEdit : PageBase
|
|
{
|
|
#region 定义变量
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string DesignDetailsId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["DesignDetailsId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["DesignDetailsId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true);
|
|
BLL.UnitWorkService.InitUnitWorkDownList(this.drpUnitWorks, this.CurrUser.LoginProjectId, false);
|
|
BLL.UnitService.InitUnitDownList(this.drpUnitIds, this.CurrUser.LoginProjectId, false);
|
|
this.DesignDetailsId = Request.Params["DesignDetailsId"];
|
|
Model.Comprehensive_DesignDetails designDetails = BLL.DesignDetailsService.GetDesignDetailsById(this.DesignDetailsId);
|
|
if (designDetails != null)
|
|
{
|
|
this.DesignDetailsId = designDetails.DesignDetailsId;
|
|
this.hdAttachUrl.Text = this.DesignDetailsId;
|
|
if (!string.IsNullOrEmpty(designDetails.CNProfessionalId))
|
|
{
|
|
this.drpCNProfessionalId.SelectedValue = designDetails.CNProfessionalId;
|
|
}
|
|
this.txtDesignDetailsCode.Text = designDetails.DesignDetailsCode;
|
|
this.txtDetailsMan.Text = designDetails.DetailsMan;
|
|
if (designDetails.DetailsDate != null)
|
|
{
|
|
this.txtDetailsDate.Text = string.Format("{0:yyyy-MM-dd}", designDetails.DetailsDate);
|
|
}
|
|
if (!string.IsNullOrEmpty(designDetails.UnitWorkId))
|
|
{
|
|
this.drpUnitWorks.SelectedValueArray = designDetails.UnitWorkId.Split(',');
|
|
}
|
|
if (!string.IsNullOrEmpty(designDetails.UnitName))
|
|
{
|
|
this.drpUnitIds.SelectedValueArray = designDetails.UnitName.Split(',');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtDetailsDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (drpCNProfessionalId.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择专业!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Model.Comprehensive_DesignDetails designDetails = new Model.Comprehensive_DesignDetails();
|
|
designDetails.ProjectId = this.CurrUser.LoginProjectId;
|
|
if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
designDetails.CNProfessionalId = this.drpCNProfessionalId.SelectedValue;
|
|
}
|
|
designDetails.DesignDetailsCode = this.txtDesignDetailsCode.Text.Trim();
|
|
designDetails.DetailsMan = this.txtDetailsMan.Text.Trim();
|
|
if (!string.IsNullOrEmpty(this.txtDetailsDate.Text))
|
|
{
|
|
designDetails.DetailsDate = Convert.ToDateTime(this.txtDetailsDate.Text);
|
|
}
|
|
string ids = string.Empty;
|
|
var lists = this.drpUnitWorks.SelectedValueArray;
|
|
foreach (var item in lists)
|
|
{
|
|
ids += item + ",";
|
|
}
|
|
if (!string.IsNullOrEmpty(ids))
|
|
{
|
|
ids = ids.Substring(0, ids.LastIndexOf(","));
|
|
}
|
|
designDetails.UnitWorkId = ids;
|
|
|
|
string unitIds = string.Empty;
|
|
var units = this.drpUnitIds.SelectedValueArray;
|
|
foreach (var item in units)
|
|
{
|
|
unitIds += item + ",";
|
|
}
|
|
if (!string.IsNullOrEmpty(unitIds))
|
|
{
|
|
unitIds = unitIds.Substring(0, unitIds.LastIndexOf(","));
|
|
}
|
|
designDetails.UnitName = unitIds;
|
|
if (string.IsNullOrEmpty(this.DesignDetailsId))
|
|
{
|
|
if (!string.IsNullOrEmpty(this.hdAttachUrl.Text))
|
|
{
|
|
designDetails.DesignDetailsId = this.hdAttachUrl.Text;
|
|
}
|
|
else
|
|
{
|
|
designDetails.DesignDetailsId = SQLHelper.GetNewID(typeof(Model.Comprehensive_DesignDetails));
|
|
this.hdAttachUrl.Text = designDetails.DesignDetailsId;
|
|
}
|
|
designDetails.CompileMan = this.CurrUser.UserId;
|
|
designDetails.CompileDate = DateTime.Now;
|
|
BLL.DesignDetailsService.AddDesignDetails(designDetails);
|
|
}
|
|
else
|
|
{
|
|
designDetails.DesignDetailsId = this.DesignDetailsId;
|
|
BLL.DesignDetailsService.UpdateDesignDetails(designDetails);
|
|
}
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 附件上传
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttach_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.hdAttachUrl.Text)) //新增记录
|
|
{
|
|
this.hdAttachUrl.Text = SQLHelper.GetNewID(typeof(Model.Comprehensive_DesignDetails));
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/DesignDetails&menuId={1}", this.hdAttachUrl.Text, BLL.Const.DesignDetailsMenuId)));
|
|
}
|
|
#endregion
|
|
}
|
|
} |