163 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			163 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			C#
		
	
	
	
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.SES
 | 
						|
{
 | 
						|
    public partial class OneTimeContractManagement : PageBase
 | 
						|
    {
 | 
						|
        #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();
 | 
						|
 | 
						|
                //文件类型
 | 
						|
                BLL.FileTypeService.InitFileTypeDropDownList(this.drpFileType, true);
 | 
						|
                //上传人
 | 
						|
                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.EMC_OneTimeContractManagement contracts = BLL.OneTimeContractManagementService.GetOneTimeContractManagementById(fileId);
 | 
						|
                    if (contracts != null)
 | 
						|
                    {
 | 
						|
                        this.hdId.Text = contracts.FileId;
 | 
						|
                        if (!string.IsNullOrEmpty(contracts.OneTimeContractsId))
 | 
						|
                        {
 | 
						|
                            var data = BLL.OneTimeContractsService.GetOneTimeContractsById(contracts.OneTimeContractsId);
 | 
						|
                            if (data != null)
 | 
						|
                            {
 | 
						|
                                this.txtFO.Text = data.ItemNumber;
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        this.txtFileName.Text = contracts.FileName;
 | 
						|
                        if (!string.IsNullOrEmpty(contracts.FileTypeId))
 | 
						|
                        {
 | 
						|
                            this.drpFileType.SelectedValue = contracts.FileTypeId;
 | 
						|
                        }
 | 
						|
                        this.txtFileTypeCode.Text = contracts.FileTypeCode;
 | 
						|
                        if (!string.IsNullOrEmpty(contracts.UploadMan))
 | 
						|
                        {
 | 
						|
                            this.drpUploadMan.SelectedValue = contracts.UploadMan;
 | 
						|
                        }
 | 
						|
                        this.txtUploadDate.Text = contracts.UploadDate.HasValue ? string.Format("{0:yyyy-MM-dd}", contracts.UploadDate) : "";
 | 
						|
                        this.txtRemark.Text = contracts.Remark;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    string id = Request.Params["oneTimeContractsId"];
 | 
						|
                    if (!string.IsNullOrEmpty(id))
 | 
						|
                    {
 | 
						|
                        var data = BLL.OneTimeContractsService.GetOneTimeContractsById(id);
 | 
						|
                        if (data != null)
 | 
						|
                        {
 | 
						|
                            this.txtFO.Text = data.ItemNumber;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    this.drpUploadMan.SelectedValue = this.CurrUser.UserId;
 | 
						|
                    this.txtUploadDate.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)
 | 
						|
        {
 | 
						|
            string oneTimeContractsId = Request.Params["oneTimeContractsId"];
 | 
						|
            string fileId = Request.Params["fileId"];
 | 
						|
            Model.EMC_OneTimeContractManagement newContract = new Model.EMC_OneTimeContractManagement();
 | 
						|
            newContract.OneTimeContractsId = oneTimeContractsId;
 | 
						|
            newContract.FileName = this.txtFileName.Text.Trim();
 | 
						|
            if (this.drpFileType.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                newContract.FileTypeId = this.drpFileType.SelectedValue;
 | 
						|
            }
 | 
						|
            newContract.FileTypeCode = this.txtFileTypeCode.Text.Trim();
 | 
						|
            if (this.drpUploadMan.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                newContract.UploadMan = this.drpUploadMan.SelectedValue;
 | 
						|
            }
 | 
						|
            newContract.UploadDate = Funs.GetNewDateTime(this.txtUploadDate.Text.Trim());
 | 
						|
            newContract.Remark = this.txtRemark.Text.Trim();
 | 
						|
            if (!string.IsNullOrEmpty(fileId))
 | 
						|
            {
 | 
						|
                newContract.FileId = fileId;
 | 
						|
                var att = from x in Funs.DB.AttachFile where x.ToKeyId == fileId select x;
 | 
						|
                if (att.Count() > 0)
 | 
						|
                {
 | 
						|
                    newContract.AttachUrl = att.First().AttachUrl;
 | 
						|
                }
 | 
						|
                BLL.OneTimeContractManagementService.UpdateOneTimeContractManagement(newContract);
 | 
						|
                BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Modify Contract Management!");
 | 
						|
                ShowNotify("Save successfully!", MessageBoxIcon.Success);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                if (!string.IsNullOrEmpty(this.hdId.Text))
 | 
						|
                {
 | 
						|
                    newContract.FileId = this.hdId.Text.Trim();
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    newContract.FileId = SQLHelper.GetNewID(typeof(Model.EMC_OneTimeContractManagement));
 | 
						|
                    this.hdId.Text = newContract.FileId;
 | 
						|
                }
 | 
						|
 | 
						|
                var att = from x in Funs.DB.AttachFile where x.ToKeyId == newContract.FileId select x;
 | 
						|
                if (att.Count() > 0)
 | 
						|
                {
 | 
						|
                    newContract.AttachUrl = att.First().AttachUrl;
 | 
						|
                }
 | 
						|
                BLL.OneTimeContractManagementService.AddOneTimeContractManagement(newContract);
 | 
						|
                BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Add Contract Management!");
 | 
						|
                ShowNotify("Save successfully!", 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.EMC_OneTimeContractManagement));
 | 
						|
            }
 | 
						|
            PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../AttachFile/webuploader2.aspx?type=0&toKeyId={0}&path=FileUpload/SES/OneTimeContracts/ContractManagement&menuId={1}", this.hdId.Text, BLL.Const.OneTimeContractsMenuId)));
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
} |