135 lines
5.6 KiB
C#
135 lines
5.6 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.SysManage
|
|
{
|
|
public partial class OutputValueProject : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string OutputValueProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["OutputValueProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["OutputValueProjectId"] = 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.GetHideReference();
|
|
this.OutputValueProjectId = Request.Params["OutputValueProjectId"];
|
|
string year= Request.Params["year"];
|
|
string month = Request.Params["month"];
|
|
BLL.ConstValue.InitConstValueDropDownList(this.drpYear, ConstValue.Group_0008, false);
|
|
if (!string.IsNullOrEmpty(year))
|
|
{
|
|
this.drpYear.SelectedValue = year;
|
|
}
|
|
BLL.ConstValue.InitConstValueDropDownList(this.drpMonth, ConstValue.Group_0009, false);
|
|
if (!string.IsNullOrEmpty(month))
|
|
{
|
|
this.drpMonth.SelectedValue = month;
|
|
}
|
|
BLL.ProjectService.InitProjectDropDownList(this.drpProject, false);
|
|
if (!string.IsNullOrEmpty(this.OutputValueProjectId))
|
|
{
|
|
var getOutP = Funs.DB.Sys_OutputValueProject.FirstOrDefault(x => x.OutputValueProjectId == this.OutputValueProjectId);
|
|
if (getOutP != null)
|
|
{
|
|
this.drpProject.SelectedValue = getOutP.ProjectId;
|
|
this.drpProject.Readonly = true;
|
|
this.drpYear.SelectedValue = getOutP.Year.ToString();
|
|
this.drpMonth.SelectedValue = getOutP.Month.ToString();
|
|
this.txtPlanOutPutValue.Text = getOutP.PlanOutPutValue.ToString();
|
|
this.txtActualOutPutValue.Text = getOutP.ActualOutPutValue.ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var getProjects = from x in Funs.DB.Base_Project
|
|
where x.ProjectState == null || x.ProjectState == BLL.Const.ProjectState_1
|
|
//&& x.ProjectId != Const.Project_TestProjectId
|
|
select x;
|
|
var getProjectLits = (from x in Funs.DB.Sys_OutputValueProject
|
|
where x.Year.ToString() == year && x.Month.ToString() == month
|
|
select x.ProjectId).ToList();
|
|
if (getProjectLits.Count() > 0)
|
|
{
|
|
getProjects = getProjects.Where(x => !getProjectLits.Contains(x.ProjectId));
|
|
}
|
|
|
|
this.drpProject.Items.Clear();
|
|
this.drpProject.DataValueField = "ProjectId";
|
|
this.drpProject.DataTextField = "ProjectName";
|
|
this.drpProject.DataSource = getProjects.OrderBy(x => x.ProjectName);
|
|
this.drpProject.DataBind();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
int year = Funs.GetNewIntOrZero(this.drpYear.SelectedValue);
|
|
int month = Funs.GetNewIntOrZero(this.drpMonth.SelectedValue);
|
|
string projectId = this.drpProject.SelectedValue;
|
|
if (year > 0 && month > 0 && !string.IsNullOrEmpty(projectId))
|
|
{
|
|
Model.Sys_OutputValueProject newO = new Model.Sys_OutputValueProject
|
|
{
|
|
OutputValueProjectId = BLL.SQLHelper.GetNewID(),
|
|
ProjectId = projectId,
|
|
Year = year,
|
|
Month=month,
|
|
PlanOutPutValue=Funs.GetNewDecimalOrZero(this.txtPlanOutPutValue.Text.Trim()),
|
|
ActualOutPutValue = Funs.GetNewDecimalOrZero(this.txtActualOutPutValue.Text.Trim()),
|
|
};
|
|
|
|
var getIsExit = Funs.DB.Sys_OutputValueProject.FirstOrDefault(x => x.ProjectId == projectId && x.Year == year && x.Month == month);
|
|
if (getIsExit != null)
|
|
{
|
|
getIsExit.PlanOutPutValue = newO.PlanOutPutValue;
|
|
getIsExit.ActualOutPutValue = newO.ActualOutPutValue;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
else
|
|
{
|
|
Funs.DB.Sys_OutputValueProject.InsertOnSubmit(newO);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
SysConstSetService.SetYearOutputValue(this.drpYear.SelectedValue);
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
} else
|
|
{
|
|
Alert.ShowInParent ("请先确认项目、年度、月份有值!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
} |