ChengDa_English/SGGL/FineUIPro.Web/JDGL/JDCH/GsbmJdGlgdEdit.aspx.cs

122 lines
4.8 KiB
C#
Raw Normal View History

2022-12-20 09:32:32 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
namespace FineUIPro.Web.JDGL.JDCH
{
public partial class GsbmJdGlgdEdit : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
//上传人
UserService.InitUserDropDownList(drpUploadMan, CurrUser.LoginProjectId, false, Const.UnitId_CD);
drpUploadMan.SelectedIndex = 0;
string fileId = Request.Params["fileId"];
if (!string.IsNullOrEmpty(fileId))
{
Model.Common_FileManager t = BLL.FileManagerService.GetFileById(fileId);
if (t != null)
{
this.txtFileName.Text = t.FileName;
if (!string.IsNullOrEmpty(t.UploadMan))
{
this.drpUploadMan.SelectedValue = t.UploadMan;
}
this.txtUploadDate.Text = t.UploadDate.HasValue ? string.Format("{0:yyyy-MM-dd}", t.UploadDate) : "";
this.txtRemark.Text = t.Remark;
hdId.Text = fileId;
}
}
else
{
this.drpUploadMan.SelectedValue = this.CurrUser.UserId;
this.txtUploadDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
#region
protected void btnSave_Click(object sender, EventArgs e)
{
string fileId = Request.Params["fileId"];
Model.Common_FileManager temp = new Model.Common_FileManager();
2023-05-02 11:32:45 +08:00
temp.ProjectId = this.CurrUser.LoginProjectId;
2022-12-20 09:32:32 +08:00
if (txtFileName.Text == string.Empty)
{
ShowNotify("名称不能为空!", MessageBoxIcon.Warning);
return;
}
else
{
temp.FileName = txtFileName.Text.Trim();
}
if (this.drpUploadMan.SelectedValue != BLL.Const._Null)
{
temp.UploadMan = this.drpUploadMan.SelectedValue;
}
temp.UploadDate = Funs.GetNewDateTime(this.txtUploadDate.Text.Trim());
temp.ToMenu = "12";
temp.Remark = this.txtRemark.Text.Trim();
if (!string.IsNullOrEmpty(fileId))
{
temp.FileId = fileId;
var att = from x in Funs.DB.AttachFile where x.ToKeyId == fileId select x;
if (att.Count() > 0)
{
temp.AttachUrl = att.First().AttachUrl;
}
BLL.FileManagerService.UpdateFile(temp);
BLL.LogService.AddSys_Log(this.CurrUser, temp.FileName, temp.FileId, BLL.Const.GsbmJdGlgdMenuId, BLL.Const.BtnModify);
ShowNotify("保存成功!", MessageBoxIcon.Success);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
temp.FileId = this.hdId.Text.Trim();
}
else
{
temp.FileId = SQLHelper.GetNewID(typeof(Model.Common_FileManager));
this.hdId.Text = temp.FileId;
}
var att = from x in Funs.DB.AttachFile where x.ToKeyId == temp.FileId select x;
if (att.Count() > 0)
{
temp.AttachUrl = att.First().AttachUrl;
}
BLL.FileManagerService.AddFile(temp);
BLL.LogService.AddSys_Log(this.CurrUser, temp.FileName, temp.FileId, BLL.Const.GsbmJdGlgdMenuId, BLL.Const.BtnAdd);
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.hdId.Text)) //新增记录
{
this.hdId.Text = SQLHelper.GetNewID(typeof(Model.Common_FileManager));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/JDGL/GsbmJdGlgdUrl/&menuId={1}", this.hdId.Text, BLL.Const.GsbmJdGlgdMenuId)));
}
#endregion
}
}