20230531 脚本、版本日志整理
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using BLL;
|
||||
using FineUIPro.Web.HSSE.License;
|
||||
using Model;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -49,82 +52,101 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||||
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||||
this.btnClose.OnClientClick = ActiveWindow.GetHideRefreshReference();
|
||||
BLL.UnitService.InitUnitDropDownList(this.drpUnit, this.ProjectId, false);
|
||||
this.drpUnit.SelectedValue = this.CurrUser.UnitId ?? Const.UnitId_SEDIN;
|
||||
this.txtYear.Text = DateTime.Now.Year.ToString();
|
||||
this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
if (!string.IsNullOrEmpty(this.CurrUser.UnitId) && !CommonService.IsSedinOrSub(this.CurrUser.UnitId))
|
||||
{
|
||||
this.drpUnit.SelectedValue = this.CurrUser.UnitId;
|
||||
this.drpUnit.Readonly = true;
|
||||
}
|
||||
|
||||
this.ExpenseId = Request.Params["ExpenseId"];
|
||||
Model.CostGoods_Expense expense = new Model.CostGoods_Expense();
|
||||
if (string.IsNullOrEmpty(this.ExpenseId))
|
||||
{
|
||||
this.drpUnit.SelectedValue = this.CurrUser.UnitId ?? Const.UnitId_SEDIN;
|
||||
this.txtYear.Text = DateTime.Now.Year.ToString();
|
||||
this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
var getEx = Funs.DB.CostGoods_Expense.FirstOrDefault(x => x.UnitId == this.drpUnit.SelectedValue && x.Year == Funs.GetNewInt(this.txtYear.Text));
|
||||
if (getEx != null)
|
||||
{
|
||||
this.ExpenseId = getEx.ExpenseId;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CommonService.IsSedinOrSub(this.drpUnit.SelectedValue))
|
||||
{
|
||||
this.lbSortIndex.Text = "1";
|
||||
}
|
||||
else
|
||||
{
|
||||
var index = Funs.DB.CostGoods_Expense.Where(x => x.Year.ToString() == this.txtYear.Text).Max(x => x.SortIndex);
|
||||
if (index.HasValue)
|
||||
{
|
||||
this.lbSortIndex.Text = (index.Value + 1).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lbSortIndex.Text = "2";
|
||||
}
|
||||
}
|
||||
|
||||
Model.CostGoods_Expense newExpense = new Model.CostGoods_Expense
|
||||
{
|
||||
ExpenseId = SQLHelper.GetNewID(),
|
||||
ProjectId = this.ProjectId,
|
||||
UnitId = this.drpUnit.SelectedValue,
|
||||
ReportDate = DateTime.Now,
|
||||
CreateDate = DateTime.Now,
|
||||
CompileMan =this.CurrUser.PersonId,
|
||||
CompileDate = DateTime.Now,
|
||||
Year =Funs.GetNewInt(this.txtYear.Text),
|
||||
SortIndex=Funs.GetNewIntOrZero(this.lbSortIndex.Text),
|
||||
};
|
||||
|
||||
ExpenseService.AddExpense(newExpense);
|
||||
ExpenseDetailService.AddCostDetail(newExpense.ExpenseId);
|
||||
}
|
||||
expense = Funs.DB.CostGoods_Expense.FirstOrDefault(x =>x.ProjectId == this.ProjectId && x.UnitId == this.drpUnit.SelectedValue && x.Year == Funs.GetNewInt(this.txtYear.Text));
|
||||
}
|
||||
else
|
||||
{
|
||||
expense = BLL.ExpenseService.GetExpenseById(this.ExpenseId);
|
||||
}
|
||||
|
||||
SetPage(BLL.ExpenseService.GetExpenseById(this.ExpenseId));
|
||||
SetPage(expense);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 页面呈现
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private void SetPage(Model.CostGoods_Expense expense)
|
||||
{
|
||||
{
|
||||
if (expense != null)
|
||||
{
|
||||
{
|
||||
this.ExpenseId = expense.ExpenseId;
|
||||
this.ProjectId = expense.ProjectId;
|
||||
this.drpUnit.SelectedValue = expense.UnitId;
|
||||
this.txtYear.Text = expense.Year.ToString();
|
||||
this.lbSortIndex.Text=expense.SortIndex.ToString();
|
||||
|
||||
}
|
||||
this.lbSortIndex.Text = expense.SortIndex.ToString();
|
||||
this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", expense.ReportDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
int Year = Funs.GetNewIntOrZero(this.txtYear.Text);
|
||||
var getProject = ProjectService.GetProjectByProjectId(this.ProjectId);
|
||||
if (getProject != null && (!getProject.EndDate.HasValue || Year <= getProject.EndDate.Value.Year) && (!getProject.StartDate.HasValue || Year >= getProject.StartDate.Value.Year))
|
||||
{
|
||||
if (CommonService.IsSedinOrSub(this.drpUnit.SelectedValue))
|
||||
{
|
||||
this.lbSortIndex.Text = "1";
|
||||
}
|
||||
else
|
||||
{
|
||||
var index = Funs.DB.CostGoods_Expense.Where(x =>x.ProjectId == this.ProjectId && x.Year.ToString() == this.txtYear.Text).Max(x => x.SortIndex);
|
||||
if (index.HasValue)
|
||||
{
|
||||
this.lbSortIndex.Text = (index.Value + 1).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lbSortIndex.Text = "2";
|
||||
}
|
||||
}
|
||||
|
||||
Model.CostGoods_Expense newExpense = new Model.CostGoods_Expense
|
||||
{
|
||||
ExpenseId = SQLHelper.GetNewID(),
|
||||
ProjectId = this.ProjectId,
|
||||
UnitId = this.drpUnit.SelectedValue,
|
||||
ReportDate = DateTime.Now,
|
||||
CreateDate = DateTime.Now,
|
||||
CompileMan = this.CurrUser.PersonId,
|
||||
CompileDate = DateTime.Now,
|
||||
Year = Funs.GetNewInt(this.txtYear.Text),
|
||||
SortIndex = Funs.GetNewIntOrZero(this.lbSortIndex.Text),
|
||||
};
|
||||
|
||||
ExpenseService.AddExpense(newExpense);
|
||||
this.ExpenseId = newExpense.ExpenseId;
|
||||
ExpenseDetailService.AddCostDetail(this.ExpenseId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("选择年度不在项目开始和竣工时间范围内!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存
|
||||
/// <summary>
|
||||
@@ -157,8 +179,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
CompileDate = DateTime.Now,
|
||||
CompileMan = this.CurrUser.PersonId,
|
||||
SortIndex = Funs.GetNewInt(this.lbSortIndex.Text),
|
||||
Year =Funs.GetNewInt(this.txtYear.Text),
|
||||
|
||||
Year =Funs.GetNewInt(this.txtYear.Text),
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(this.ExpenseId))
|
||||
@@ -166,7 +187,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
expense.ExpenseId = this.ExpenseId;
|
||||
BLL.ExpenseService.UpdateExpense(expense);
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, expense.ExpenseCode, expense.ExpenseId, BLL.Const.ProjectExpenseMenuId, BLL.Const.BtnModify);
|
||||
BLL.ExpenseDetailService.DeleteCostDetailByExpenseId(this.ExpenseId);
|
||||
// BLL.ExpenseDetailService.DeleteCostDetailByExpenseId(this.ExpenseId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -176,7 +197,12 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
BLL.ExpenseService.AddExpense(expense);
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, expense.ExpenseCode, expense.ExpenseId, BLL.Const.ProjectExpenseMenuId, BLL.Const.BtnAdd);
|
||||
}
|
||||
|
||||
|
||||
var getItem = jerqueSaveList();
|
||||
foreach (var item in getItem)
|
||||
{
|
||||
ExpenseDetailService.UpdateExpenseDetail(item);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -196,8 +222,6 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 单位变化事件
|
||||
/// <summary>
|
||||
/// 单位变化事件
|
||||
@@ -208,9 +232,33 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
{
|
||||
if (this.drpUnit.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.txtYear.Text))
|
||||
{
|
||||
SetPage(Funs.DB.CostGoods_Expense.FirstOrDefault(x => x.UnitId == this.drpUnit.SelectedValue && x.Year.ToString() == 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
|
||||
|
||||
#region 保存集合
|
||||
/// <summary>
|
||||
/// 保存集合
|
||||
/// </summary>
|
||||
private List<Model.CostGoods_ExpenseDetail> jerqueSaveList()
|
||||
{
|
||||
var returnList = Funs.DB.CostGoods_ExpenseDetail.Where(x => x.ExpenseId == this.ExpenseId);
|
||||
JArray mergedData = Grid1.GetMergedData();
|
||||
foreach (JObject mergedRow in mergedData)
|
||||
{
|
||||
string status = mergedRow.Value<string>("status");
|
||||
JObject values = mergedRow.Value<JObject>("values");
|
||||
var item = returnList.FirstOrDefault(e => e.ExpenseDetailId == values.Value<string>("ExpenseDetailId"));
|
||||
if (item != null)
|
||||
{
|
||||
item.CostMoney = Funs.GetNewDecimalOrZero(values.Value<string>("CostMoney"));
|
||||
}
|
||||
|
||||
}
|
||||
return returnList.ToList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user