SGGL_SHJ/SGGL/FineUIPro.Web/HSSE/CostGoods/ExpenseView.aspx.cs

114 lines
3.7 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
namespace FineUIPro.Web.HSSE.CostGoods
{
public partial class ExpenseView : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string ExpenseId
{
get
{
return (string)ViewState["ExpenseId"];
}
set
{
ViewState["ExpenseId"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
#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.GetHideRefreshReference();
this.ProjectId = this.CurrUser.LoginProjectId;
this.ExpenseId = Request.Params["ExpenseId"];
BLL.UnitService.InitUnitDropDownList(this.drpUnit, this.ProjectId, false);
this.drpUnit.SelectedValue = this.CurrUser.UnitId ?? Const.UnitId_SEDIN;
if (!string.IsNullOrEmpty(this.CurrUser.UnitId) && !CommonService.IsSedinOrSub(this.CurrUser.UnitId))
{
this.drpUnit.Readonly = true;
}
SetPage(BLL.ExpenseService.GetExpenseById(this.ExpenseId));
}
}
#endregion
private void SetPage(Model.CostGoods_Expense expense)
{
if (expense != null)
{
this.drpUnit.SelectedValue = expense.UnitId;
this.txtYear.Text = expense.Year.ToString();
this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", expense.ReportDate);
this.Grid1.DataSource = from x in Funs.DB.CostGoods_ExpenseDetail
where x.ExpenseId == this.ExpenseId
orderby x.SupSortIndex, x.SortIndex
select x;
this.Grid1.DataBind();
}
}
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.ExpenseId))
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&menuId={1}&type=-1", ExpenseId, BLL.Const.ProjectExpenseMenuId)));
}
}
#endregion
#region
/// <summary>
/// 单位变化事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.drpUnit.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.txtYear.Text))
{
SetPage(Funs.DB.CostGoods_Expense.FirstOrDefault(x => x.ProjectId == this.ProjectId && x.UnitId == this.drpUnit.SelectedValue && x.Year.ToString() == this.txtYear.Text));
}
}
#endregion
}
}