Basf_FCL/FCL/FineUIPro.Web/SES/SESRelatedDataContractManag...

218 lines
9.6 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 SESRelatedDataContractManage3 : 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();
//上传人
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;
}
txtFO.Text = data.FO_NO;
this.txtInitialBudget.Text = data.InitialBudget.HasValue ? data.InitialBudget.ToString() : "";
this.txtCurrentAllocation.Text = data.Proportion_of_FC_Definition.HasValue ? (data.Proportion_of_FC_Definition.Value * Convert.ToDecimal(100.0)).ToString(): "";
}
}
this.txtRemark.Text = file.Remark;
}
}
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;
}
this.txtFO.Text = data.FO_NO;
this.txtInitialBudget.Text = data.InitialBudget.HasValue ? data.InitialBudget.ToString() : "";
this.txtCurrentAllocation.Text = data.Proportion_of_FC_Definition.HasValue ? (data.Proportion_of_FC_Definition.Value * Convert.ToDecimal(100.0)).ToString() : "";
}
}
this.drpUploadMan.SelectedValue = this.CurrUser.UserId;
string code = SQLHelper.RunProcNewId("SpGetNewCode3", "dbo.FC_ContractManagement", "FileName", "份额变更-" + 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)
{
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 = "3";//份额变更
newContract.FileName = this.txtFileName.Text.Trim();
if (this.drpUploadMan.SelectedValue != BLL.Const._Null)
{
newContract.UploadMan = this.drpUploadMan.SelectedValue;
}
newContract.UploadDate = DateTime.Now;
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.ContractManagementService.UpdateContractManagement(newContract);
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "修改份额变更!");
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, "增加份额变更!");
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, "3")));
}
#endregion
}
}