245 lines
11 KiB
C#
245 lines
11 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;
|
|
using static NPOI.SS.Formula.PTG.ArrayPtg;
|
|
|
|
namespace FineUIPro.Web.SES
|
|
{
|
|
public partial class SESRelatedDataContractManage2 : 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.txtSupplementedBudget.Text = file.SupplementedBudget.HasValue ? file.SupplementedBudget.ToString() : "";
|
|
this.txtTotalBudget.Text = file.TotalBudget.HasValue ? file.TotalBudget.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.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 = "2";//费用增补
|
|
newContract.FileName = this.txtFileName.Text.Trim();
|
|
if (this.drpUploadMan.SelectedValue != BLL.Const._Null)
|
|
{
|
|
newContract.UploadMan = this.drpUploadMan.SelectedValue;
|
|
}
|
|
newContract.UploadDate = DateTime.Now;
|
|
newContract.SupplementedBudget = Funs.GetNewDecimal(this.txtSupplementedBudget.Text.Trim());
|
|
newContract.TotalBudget = Funs.GetNewDecimal(this.txtTotalBudget.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.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);
|
|
}
|
|
|
|
//费用增补回写到Contract Budget中
|
|
var data = BLL.SESRelatedDataService.GetSESRelatedDataById(id);
|
|
if (data != null)
|
|
{
|
|
//decimal? totalBudget = 0;
|
|
//var conMaLists = BLL.ContractManagementService.GetContractManagementByDataIdFileType(id, "2");
|
|
//foreach (var item in conMaLists)
|
|
//{
|
|
// totalBudget += item.TotalBudget;
|
|
//}
|
|
data.Actual_Budget = newContract.TotalBudget;
|
|
BLL.SESRelatedDataService.UpdateSESRelatedData(data);
|
|
}
|
|
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, "2")));
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtSupplementedBudget_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.txtTotalBudget.Text = string.Empty;
|
|
if (!string.IsNullOrEmpty(this.txtSupplementedBudget.Text.Trim()))
|
|
{
|
|
string id = Request.Params["id"];
|
|
decimal? totalSupp = 0;
|
|
var totals = ContractManagementService.GetContractManagementByDataIdFileType(id, "2");
|
|
foreach (var item in totals)
|
|
{
|
|
totalSupp += item.SupplementedBudget;
|
|
}
|
|
this.txtTotalBudget.Text = (Funs.GetNewIntOrZero(txtInitialBudget.Text.Trim()) + totalSupp + Funs.GetNewDecimalOrZero(this.txtSupplementedBudget.Text.Trim())).ToString();
|
|
}
|
|
}
|
|
}
|
|
} |