158 lines
7.1 KiB
C#
158 lines
7.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.PublicInfo.FileControl
|
|
{
|
|
public partial class ForeignStandardsEdit : PageBase
|
|
{
|
|
#region 定义变量
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
private string ForeignStandardsId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ForeignStandardsId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ForeignStandardsId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
///加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
//整理人
|
|
this.drpCompileMan.DataTextField = "UserName";
|
|
this.drpCompileMan.DataValueField = "UserId";
|
|
this.drpCompileMan.DataSource = BLL.Sys_UserService.GetUserList();
|
|
this.drpCompileMan.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpCompileMan, Resources.Lan.PleaseSelect);
|
|
|
|
this.ForeignStandardsId = Request.Params["ForeignStandardsId"];
|
|
if (!string.IsNullOrEmpty(this.ForeignStandardsId))
|
|
{
|
|
Model.FileControl_ForeignStandards foreignStandards = BLL.FileControl_ForeignStandardsService.GetForeignStandardsById(this.ForeignStandardsId);
|
|
if (foreignStandards != null)
|
|
{
|
|
this.txtForeignStandardsCode.Text = foreignStandards.ForeignStandardsCode;
|
|
this.txtForeignStandardsName.Text = foreignStandards.ForeignStandardsName;
|
|
this.txtAbstract.Text = foreignStandards.Abstract;
|
|
if (!string.IsNullOrEmpty(foreignStandards.CompileMan))
|
|
{
|
|
this.drpCompileMan.SelectedValue = foreignStandards.CompileMan;
|
|
}
|
|
if (foreignStandards.CompileDate.HasValue)
|
|
{
|
|
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", foreignStandards.CompileDate);
|
|
}
|
|
this.txtRemark.Text = foreignStandards.Remarks;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.drpCompileMan.SelectedValue = this.CurrUser.UserId;
|
|
this.txtCompileDate.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 (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ForeignStandardsMenuId, Const.BtnSave))
|
|
{
|
|
SaveData("1");//保存方法
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存方法
|
|
/// </summary>
|
|
private void SaveData(string state)
|
|
{
|
|
//判断编号是否存在
|
|
var q1 = Funs.DB.FileControl_ForeignStandards.FirstOrDefault(x => x.ForeignStandardsCode == this.txtForeignStandardsCode.Text.Trim() && (x.ForeignStandardsId.ToString() != this.ForeignStandardsId || (this.ForeignStandardsId == null && x.ForeignStandardsId != null)));
|
|
if (q1 != null)
|
|
{
|
|
Alert.ShowInTop(Resources.Lan.DomesticStandardsCodeExists, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
//判断名称是否存在
|
|
var q2 = Funs.DB.FileControl_ForeignStandards.FirstOrDefault(x => x.ForeignStandardsName == this.txtForeignStandardsName.Text.Trim() && (x.ForeignStandardsId.ToString() != this.ForeignStandardsId || (this.ForeignStandardsId == null && x.ForeignStandardsId != null)));
|
|
if (q2 != null)
|
|
{
|
|
Alert.ShowInTop(Resources.Lan.DomesticStandardsNameExists, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Model.FileControl_ForeignStandards newForeignStandards = new Model.FileControl_ForeignStandards();
|
|
newForeignStandards.ForeignStandardsCode = this.txtForeignStandardsCode.Text.Trim();
|
|
newForeignStandards.ForeignStandardsName = this.txtForeignStandardsName.Text.Trim();
|
|
newForeignStandards.Abstract = this.txtAbstract.Text.Trim();
|
|
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
|
|
{
|
|
newForeignStandards.CompileMan = this.drpCompileMan.SelectedValue;
|
|
}
|
|
newForeignStandards.CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim());
|
|
newForeignStandards.Remarks = this.txtRemark.Text.Trim();
|
|
if (!string.IsNullOrEmpty(this.ForeignStandardsId))
|
|
{
|
|
newForeignStandards.ForeignStandardsId = this.ForeignStandardsId;
|
|
BLL.FileControl_ForeignStandardsService.UpdateForeignStandards(newForeignStandards);
|
|
BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ForeignStandardsMenuId, Const.BtnModify, newForeignStandards.ForeignStandardsId);
|
|
}
|
|
else
|
|
{
|
|
this.ForeignStandardsId = SQLHelper.GetNewID(typeof(Model.FileControl_ForeignStandards));
|
|
newForeignStandards.ForeignStandardsId = this.ForeignStandardsId;
|
|
BLL.FileControl_ForeignStandardsService.AddForeignStandards(newForeignStandards);
|
|
BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ForeignStandardsMenuId, Const.BtnAdd, newForeignStandards.ForeignStandardsId);
|
|
}
|
|
if (state == "1")
|
|
{
|
|
ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件资源
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.ForeignStandardsId))
|
|
{
|
|
SaveData("0");
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/FileControl/ForeignStandards&menuId={1}&edit=1", this.ForeignStandardsId, BLL.Const.ForeignStandardsMenuId)));
|
|
}
|
|
#endregion
|
|
}
|
|
} |