using BLL; using System; using System.Linq; namespace FineUIPro.Web.SES { public partial class SESRelatedDataSigned : PageBase { #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); //文件类型 this.drpFileType.DataTextField = "Text"; this.drpFileType.DataValueField = "Value"; this.drpFileType.DataSource = BLL.DropListService.getFileTypeDropList(); this.drpFileType.DataBind(); Funs.FineUIPleaseSelect(this.drpFileType); //上传人 BLL.Sys_UserService.InitUserDropDownList(this.drpUploadMan, true); if (CurrUser.Account == Const.Gly) { drpUploadMan.Enabled = true; } else { drpUploadMan.SelectedValue = CurrUser.UserId; drpUploadMan.Enabled = false; } string fileId = Request.Params["fileId"]; if (!string.IsNullOrEmpty(fileId)) { Model.FC_SignedContracts signedContracts = BLL.SignedContractsService.GetSignedContractsById(fileId); if (signedContracts != null) { this.hdId.Text = signedContracts.FileId; if (!string.IsNullOrEmpty(signedContracts.FC_ID.ToString())) { var data = BLL.SESRelatedDataService.GetSESRelatedDataById(signedContracts.FC_ID.ToString()); if (data != null) { this.txtFO.Text = data.FO_NO; } } this.txtFileName.Text = signedContracts.FileName; if (!string.IsNullOrEmpty(signedContracts.FileType) ) { this.drpFileType.SelectedValue = signedContracts.FileType; } this.txtFileTypeCode.Text = signedContracts.FileTypeCode; if (!string.IsNullOrEmpty(signedContracts.UploadMan)) { this.drpUploadMan.SelectedValue = signedContracts.UploadMan; } this.txtUploadDate.Text = signedContracts.UploadDate.HasValue ? string.Format("{0:yyyy-MM-dd}", signedContracts.UploadDate) : ""; this.txtRemark.Text = signedContracts.Remark; } } else { string id = Request.Params["id"]; if (!string.IsNullOrEmpty(id)) { var data = BLL.SESRelatedDataService.GetSESRelatedDataById(id); if (data != null) { this.txtFO.Text = data.FO_NO; } } this.drpUploadMan.SelectedValue = this.CurrUser.UserId; this.txtUploadDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { string id = Request.Params["id"]; string fileId = Request.Params["fileId"]; Model.FC_SignedContracts newSignedContracts = new Model.FC_SignedContracts(); newSignedContracts.FC_ID = Convert.ToInt32(id); newSignedContracts.FileName = this.txtFileName.Text.Trim(); if (this.drpFileType.SelectedValue != BLL.Const._Null) { newSignedContracts.FileType = this.drpFileType.SelectedValue.Trim(); } newSignedContracts.FileTypeCode = this.txtFileTypeCode.Text.Trim(); if (this.drpUploadMan.SelectedValue != BLL.Const._Null) { newSignedContracts.UploadMan = this.drpUploadMan.SelectedValue; } newSignedContracts.UploadDate = Funs.GetNewDateTime(this.txtUploadDate.Text.Trim()); newSignedContracts.Remark = this.txtRemark.Text.Trim(); if (!string.IsNullOrEmpty(fileId)) { newSignedContracts.FileId= fileId; var att = from x in Funs.DB.AttachFile where x.ToKeyId == fileId select x; if (att.Count() > 0) { newSignedContracts.AttachUrl = att.First().AttachUrl; } BLL.SignedContractsService.UpdateSignedContracts(newSignedContracts); BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Modify Signed Contracts!"); ShowNotify("Save successfully!", MessageBoxIcon.Success); } else { if (!string.IsNullOrEmpty(this.hdId.Text)) { newSignedContracts.FileId = this.hdId.Text.Trim(); } else { newSignedContracts.FileId = SQLHelper.GetNewID(typeof(Model.FC_SignedContracts)); this.hdId.Text = newSignedContracts.FileId; } var att = from x in Funs.DB.AttachFile where x.ToKeyId == newSignedContracts.FileId select x; if (att.Count() > 0) { newSignedContracts.AttachUrl= att.First().AttachUrl; } BLL.SignedContractsService.AddSignedContracts(newSignedContracts); BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Add Signed Contracts!"); ShowNotify("Save successfully!", MessageBoxIcon.Success); } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录 { this.hdId.Text = SQLHelper.GetNewID(typeof(Model.FC_SignedContracts)); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../AttachFile/webuploader2.aspx?type=0&toKeyId={0}&path=FileUpload/SES/SESRelatedData/SignedContracts&menuId={1}", this.hdId.Text, BLL.Const.SESRelatedDateMenuId))); } #endregion } }