249 lines
11 KiB
C#
249 lines
11 KiB
C#
using BLL;
|
||
using Org.BouncyCastle.Asn1.Cmp;
|
||
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 SESRelatedDataContractManage5 : PageBase
|
||
{
|
||
public string FC_ID
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["FC_ID"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["FC_ID"] = value;
|
||
}
|
||
}
|
||
|
||
#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.drpAuditResult.DataTextField = "Text";
|
||
this.drpAuditResult.DataValueField = "Value";
|
||
this.drpAuditResult.DataSource = BLL.DropListService.getAuditResultDropList();
|
||
this.drpAuditResult.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpAuditResult);
|
||
//上传人
|
||
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_ContractManagement file = BLL.ContractManagementService.GetContractManagementById(fileId);
|
||
if (file != null)
|
||
{
|
||
this.FC_ID = file.FC_ID.ToString();
|
||
this.hdId.Text = file.FileId;
|
||
this.txtFileName.Text = file.FileName;
|
||
if (!string.IsNullOrEmpty(file.UploadMan))
|
||
{
|
||
this.drpUploadMan.SelectedValue = file.UploadMan;
|
||
}
|
||
if (!string.IsNullOrEmpty(file.FC_ID.ToString()))
|
||
{
|
||
var data = BLL.SESRelatedDataService.GetSESRelatedDataById(file.FC_ID.ToString());
|
||
if (data != null && !string.IsNullOrEmpty(data.Contractor))
|
||
{
|
||
var con = BLL.ContractorService.GetContractorById(data.Contractor);
|
||
if (con != null)
|
||
{
|
||
string contractor = string.Empty;
|
||
if (string.IsNullOrEmpty(con.Contractor) && !string.IsNullOrEmpty(con.ContractorCN))
|
||
{
|
||
contractor = con.ContractorCN;
|
||
}
|
||
else if (string.IsNullOrEmpty(con.ContractorCN) && !string.IsNullOrEmpty(con.Contractor))
|
||
{
|
||
contractor = con.Contractor;
|
||
}
|
||
else
|
||
{
|
||
contractor = con.Contractor + " " + con.ContractorCN;
|
||
}
|
||
txtContractor.Text = contractor;
|
||
|
||
}
|
||
if (!string.IsNullOrEmpty(data.Type))
|
||
{
|
||
var t = BLL.TypeService.GetTypeById(data.Type);
|
||
if (t != null)
|
||
{
|
||
this.txtType.Text = t.Type;
|
||
}
|
||
}
|
||
this.txtFO.Text = data.FO_NO;
|
||
}
|
||
}
|
||
this.txtAuditDate.Text = file.AuditDate.HasValue ? string.Format("{0:yyyy-MM-dd}", file.AuditDate) : "";
|
||
if (!string.IsNullOrEmpty(file.AuditResult.Trim()))
|
||
{
|
||
this.drpAuditResult.SelectedValue = file.AuditResult.Trim();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
string id = Request.Params["id"];
|
||
if (!string.IsNullOrEmpty(id))
|
||
{
|
||
this.FC_ID = id;
|
||
var data = BLL.SESRelatedDataService.GetSESRelatedDataById(id);
|
||
if (data != null)
|
||
{
|
||
var con = BLL.ContractorService.GetContractorById(data.Contractor);
|
||
if (con != null)
|
||
{
|
||
string contractor = string.Empty;
|
||
if (string.IsNullOrEmpty(con.Contractor) && !string.IsNullOrEmpty(con.ContractorCN))
|
||
{
|
||
contractor = con.ContractorCN;
|
||
}
|
||
else if (string.IsNullOrEmpty(con.ContractorCN) && !string.IsNullOrEmpty(con.Contractor))
|
||
{
|
||
contractor = con.Contractor;
|
||
}
|
||
else
|
||
{
|
||
contractor = con.Contractor + " " + con.ContractorCN;
|
||
}
|
||
txtContractor.Text = contractor;
|
||
}
|
||
if (!string.IsNullOrEmpty(data.Type))
|
||
{
|
||
var t = BLL.TypeService.GetTypeById(data.Type);
|
||
if (t != null)
|
||
{
|
||
this.txtType.Text = t.Type;
|
||
}
|
||
}
|
||
this.txtFO.Text = data.FO_NO;
|
||
}
|
||
}
|
||
this.drpUploadMan.SelectedValue = this.CurrUser.UserId;
|
||
string code = SQLHelper.RunProcNewId("SpGetNewCode3", "dbo.FC_ContractManagement", "FileName", "EHSQ审计报告-" + txtFO.Text + "-");
|
||
txtFileName.Text = code;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 保存
|
||
/// <summary>
|
||
/// 保存按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.drpAuditResult.SelectedValue == BLL.Const._Null)
|
||
{
|
||
Alert.ShowInTop("请选择审计结果!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string id = Request.Params["id"];
|
||
string fileId = Request.Params["fileId"];
|
||
Model.FC_ContractManagement newContract = new Model.FC_ContractManagement();
|
||
newContract.FC_ID = Convert.ToInt32(id);
|
||
newContract.FileTypeId = "5";//承包商EHSQ审计报告
|
||
newContract.FileName = this.txtFileName.Text.Trim();
|
||
if (this.drpUploadMan.SelectedValue != BLL.Const._Null)
|
||
{
|
||
newContract.UploadMan = this.drpUploadMan.SelectedValue;
|
||
}
|
||
newContract.UploadDate = DateTime.Now;
|
||
newContract.AuditDate = Funs.GetNewDateTime(this.txtAuditDate.Text);
|
||
if (this.drpAuditResult.SelectedValue!=BLL.Const._Null)
|
||
{
|
||
newContract.AuditResult = this.drpAuditResult.SelectedValue;
|
||
}
|
||
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.ContractManagementService.UpdateContractManagement(newContract);
|
||
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "修改承包商EHSQ审计报告!");
|
||
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.FC_ContractManagement));
|
||
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.ContractManagementService.AddContractManagement(newContract);
|
||
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "增加承包商EHSQ审计报告!");
|
||
ShowNotify("Save successfully!", MessageBoxIcon.Success);
|
||
}
|
||
//回写Current Allocation值
|
||
//var sESRelatedData = BLL.SESRelatedDataService.GetSESRelatedDataById(id);
|
||
//if (sESRelatedData != null)
|
||
//{
|
||
// decimal? value = Funs.GetNewDecimal(this.txtCurrentAllocation.Text.Trim());
|
||
// if (value != null)
|
||
// {
|
||
// sESRelatedData.Proportion_of_FC_Definition = value / Convert.ToDecimal(100.0);
|
||
// }
|
||
// Funs.DB.SubmitChanges();
|
||
//}
|
||
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.FC_ContractManagement));
|
||
}
|
||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../AttachFile/webuploader2.aspx?type=0&toKeyId={0}&path=FileUpload/SES/SESRelatedData/ContractManagement&menuId={1}&fcid={2}&fileTypeId={3}", this.hdId.Text, BLL.Const.SESRelatedDateMenuId, this.FC_ID, "5")));
|
||
}
|
||
#endregion
|
||
}
|
||
} |