HSE费用菜单简化及功能优化

This commit is contained in:
2024-07-05 14:11:35 +08:00
parent e1010bbbfa
commit d281b1d9c1
10 changed files with 235 additions and 32 deletions
@@ -6,6 +6,11 @@
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style>
.textalign {
text-align: center;
}
</style>
</head>
<body>
<form id="form1" runat="server">
@@ -15,7 +20,8 @@
<Toolbars>
<f:Toolbar ID="Toolbar1" Position="Top" runat="server">
<Items>
<f:DatePicker ID="txtDate" runat="server" Label="日期" LabelAlign="Right" DateFormatString="yyyy-MM" DisplayType="Month">
<f:DatePicker ID="txtDate" runat="server" Label="日期" LabelAlign="Right" DateFormatString="yyyy-MM" DisplayType="Month"
AutoPostBack="true" OnTextChanged="TextBox_TextChanged">
</f:DatePicker>
<f:ToolbarFill runat="server"></f:ToolbarFill>
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" ToolTip="导出" Icon="FolderUp"
@@ -31,7 +37,8 @@
bordercolor="#bcd2e7" bordercolordark="#bcd2e7" bordercolorlight="#bcd2e7">
<tr>
<td align="center" valign="top">
<asp:GridView ID="gvTotalPayRegistration" runat="server" AllowPaging="false" AllowSorting="True"
<asp:GridView ID="gvTotalPayRegistration" runat="server" AllowPaging="false" AllowSorting="True" CssClass="textalign"
AutoGenerateColumns="True" HorizontalAlign="Justify" Width="100%" OnRowCreated="gvTotalPayRegistration_RowCreated"
OnDataBound="gvTotalPayRegistration_DataBound">
<AlternatingRowStyle CssClass="GridBgColr" />
@@ -11,22 +11,57 @@ namespace FineUIPro.Web.HSSE.CostGoods
{
private static string headerStr;
#region
/// <summary>
/// 主键
/// </summary>
public string getdatetime
{
get
{
return (string)ViewState["getdatetime"];
}
set
{
ViewState["getdatetime"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtDate.Text = DateTime.Now.ToString("yyyy-MM");
getdatetime = Request.Params["getdatetime"];
if (string.IsNullOrEmpty(getdatetime))
{
txtDate.Text = DateTime.Now.ToString("yyyy-MM");
}
else {
txtDate.Text =Convert.ToDateTime(getdatetime).ToString("yyyy-MM");
}
loadAll();
}
}
protected void TextBox_TextChanged(object sender, EventArgs e) {
//loadAll();
//重定向页面
//Response.Redirect("TargetPage.aspx?getdatetime="+ txtDate.Text);
Response.Redirect(Request.Url.ToString().Split('?')[0]+ "?getdatetime=" + txtDate.Text);
}
/// <summary>
/// 根据日期加载所有
/// </summary>
protected void loadAll() {
this.gvTotalPayRegistration.DataSource = null;
this.gvTotalPayRegistration.DataBind();
var pid = CurrUser.LoginProjectId;
var result = Funs.DB.CostGoods_HseExpense.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId && x.PayMonth == txtDate.Text);
if (result!=null)
if (result != null)
{
DateTime startTime = Convert.ToDateTime(result.PayDate.Value.Year + "-" + result.PayDate.Value.Month + "-1");
DateTime endTime = startTime.AddMonths(1);
@@ -37,6 +72,22 @@ namespace FineUIPro.Web.HSSE.CostGoods
dt.Columns.Add("R0"); //编号
dt.Columns.Add("R1"); //类别
var units = BLL.UnitService.GetMainAndSubUnitByProjectIdList(result.ProjectId);
//如果不是五环,只能看到自己单位的
//如果不是中国五环工程有限公司,只加载自己的
if (CurrUser.UnitId == CommonService.GetThisUnitId() || CurrUser.UserId == Const.hfnbdId)
{
}
else
{
var unit = new Model.Base_Unit()
{
UnitId = CurrUser.UnitId,
UnitName = UnitService.getUnitNamesUnitIds(CurrUser.UnitId)
};
units = new System.Collections.Generic.List<Model.Base_Unit>();
units.Add(unit);
}
int a = 0;
for (int i = 0; i < units.Count; i++)
@@ -56,8 +107,11 @@ namespace FineUIPro.Web.HSSE.CostGoods
var yearHseExpense = Funs.DB.CostGoods_HseExpense.Where(x => x.ProjectId == pid && x.PayDate.Value.Year == endTime.Year);
var monthHseExpense = Funs.DB.CostGoods_HseExpense.Where(x => x.ProjectId == pid && x.PayDate >= startTime && x.PayDate <= endTime);
for (int i = 0; i < units.Count; i++) {
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId ).Sum(x => x.SMonthType1);
var xmzje = Funs.DB.CostGoods_FeeRegistration.Where(x => x.ProjectId == pid);
for (int i = 0; i < units.Count; i++)
{
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType1);
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType1) ?? 0;
@@ -67,15 +121,15 @@ namespace FineUIPro.Web.HSSE.CostGoods
dt.Rows.Add(row1);
b = 2;
row1=dt.NewRow();
row1 = dt.NewRow();
row1[0] = "2";
row1[1] = "应急救援和演练";
for (int i = 0; i < units.Count; i++)
{
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType2 ) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType2) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType2 ) ?? 0;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType2) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
}
@@ -88,7 +142,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
for (int i = 0; i < units.Count; i++)
{
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType3) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType3) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
@@ -103,7 +157,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
for (int i = 0; i < units.Count; i++)
{
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType4) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType4) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
@@ -133,7 +187,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
for (int i = 0; i < units.Count; i++)
{
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType6) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType6) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
@@ -147,7 +201,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
row1[1] = "“四新”推广应用支出";
for (int i = 0; i < units.Count; i++)
{
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType7 ) ?? 0;
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType7) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType7) ?? 0;
@@ -163,7 +217,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
for (int i = 0; i < units.Count; i++)
{
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType8) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType8) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
@@ -193,7 +247,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
for (int i = 0; i < units.Count; i++)
{
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType10) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType10) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
@@ -201,6 +255,83 @@ namespace FineUIPro.Web.HSSE.CostGoods
}
dt.Rows.Add(row1);
b = 2;
row1 = dt.NewRow();
row1[0] = "投入小计";
row1[1] = "投入小计";
for (int i = 0; i < units.Count; i++)
{
row1[b] = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType1 + x.SMonthType2
+ x.SMonthType3 + x.SMonthType4 + x.SMonthType5 + x.SMonthType6 + x.SMonthType7
+ x.SMonthType8 + x.SMonthType9 + x.SMonthType10) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
row1[b] = yearHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType1 + x.SMonthType2
+ x.SMonthType3 + x.SMonthType4 + x.SMonthType5 + x.SMonthType6 + x.SMonthType7
+ x.SMonthType8 + x.SMonthType9 + x.SMonthType10) ?? 0;
row1[b] = Funs.GetNewDecimalOrZero(row1[b].ToString()).ToString("N2");
b++;
}
dt.Rows.Add(row1);
b = 2;
row1 = dt.NewRow();
row1[0] = "剩余金额";
row1[1] = "剩余金额";
for (int i = 0; i < units.Count; i++)
{
//登记总金额-项目累计
var Allmoney = xmzje.FirstOrDefault(x => x.UnitId == units[i].UnitId).Cost;
var xmlj = monthHseExpense.Where(x => x.UnitId == units[i].UnitId).Sum(x => x.SMonthType1 + x.SMonthType2
+ x.SMonthType3 + x.SMonthType4 + x.SMonthType5 + x.SMonthType6 + x.SMonthType7
+ x.SMonthType8 + x.SMonthType9 + x.SMonthType10) ?? 0;
var syje = Allmoney - xmlj;
row1[b] = syje;
b++;
row1[b] = syje;
b++;
}
dt.Rows.Add(row1);
this.gvTotalPayRegistration.DataSource = dt;
this.gvTotalPayRegistration.DataBind();
}
else {
headerStr = string.Empty;
headerStr += "编号#类别";
DataTable dt = new DataTable();
dt.Columns.Add("R0"); //编号
dt.Columns.Add("R1"); //类别
var units = BLL.UnitService.GetMainAndSubUnitByProjectIdList(CurrUser.LoginProjectId);
//如果不是五环,只能看到自己单位的
//如果不是中国五环工程有限公司,只加载自己的
if (CurrUser.UnitId == CommonService.GetThisUnitId() || CurrUser.UserId == Const.hfnbdId)
{
}
else
{
var unit = new Model.Base_Unit()
{
UnitId = CurrUser.UnitId,
UnitName = UnitService.getUnitNamesUnitIds(CurrUser.UnitId)
};
units = new System.Collections.Generic.List<Model.Base_Unit>();
units.Add(unit);
}
int a = 0;
for (int i = 0; i < units.Count; i++)
{
headerStr += "#" + units[i].UnitName + " 当月累计,当年累计";
dt.Columns.Add("M" + a); //当月累计
a++;
dt.Columns.Add("M" + a); //当年累计
a++;
}
this.gvTotalPayRegistration.DataSource = dt;
this.gvTotalPayRegistration.DataBind();
}
@@ -213,7 +344,44 @@ namespace FineUIPro.Web.HSSE.CostGoods
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gvTotalPayRegistration_DataBound(object sender, EventArgs e)
{ }
{
var units = BLL.UnitService.GetMainAndSubUnitByProjectIdList(CurrUser.LoginProjectId);
if (CurrUser.UnitId == CommonService.GetThisUnitId() || CurrUser.UserId == Const.hfnbdId)
{
}
else
{
var unit = new Model.Base_Unit()
{
UnitId = CurrUser.UnitId,
UnitName = UnitService.getUnitNamesUnitIds(CurrUser.UnitId)
};
units = new System.Collections.Generic.List<Model.Base_Unit>();
units.Add(unit);
}
for (int i = 0; i < this.gvTotalPayRegistration.Rows.Count - 1; i++) {
GridViewRow gvrNext = this.gvTotalPayRegistration.Rows[i + 1];
if (gvrNext.Cells[0].Text == gvrNext.Cells[1].Text) {
gvrNext.Cells[1].Visible = false;
gvrNext.Cells[0].ColumnSpan = 2;
}
if (gvrNext.Cells[0].Text=="剩余金额")
{
var item = 2;
for (int j = 0; j < units.Count; j++)
{
if (gvrNext.Cells[item].Text == gvrNext.Cells[item+1].Text) {
gvrNext.Cells[item].Visible = false;
gvrNext.Cells[item + 1].ColumnSpan = 2;
}
item += 2;
}
}
}
}
#endregion
#region Grid创建行
@@ -38,7 +38,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
BLL.UnitService.InitUnitDropDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true);
BLL.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true);
//如果不是中国五环工程有限公司,只加载自己的
if (CurrUser.UnitId == CommonService.GetThisUnitId() || CurrUser.UserId == Const.hfnbdId)
{
@@ -33,7 +33,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.Id = Request.Params["Id"];
///单位下拉框
BLL.UnitService.InitUnitDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, false);
BLL.UnitService.InitUnitDownList(this.drpUnit, this.CurrUser.LoginProjectId, false);
if (!string.IsNullOrEmpty(this.Id)) {
var result = HseExpenseService.Detail(Id);
if (result!=null)