CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/HSSE/CostGoods/PayRegistrationNewEdit.aspx.cs

178 lines
8.7 KiB
C#
Raw Normal View History

using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HSSE.CostGoods
{
public partial class PayRegistrationNewEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.Id = Request.Params["Id"];
///单位下拉框
2024-07-05 14:11:35 +08:00
BLL.UnitService.InitUnitDownList(this.drpUnit, this.CurrUser.LoginProjectId, false);
if (!string.IsNullOrEmpty(this.Id)) {
var result = HseExpenseService.Detail(Id);
if (result!=null)
{
this.txtDate.Text = string.Format("{0:yyyy-MM-dd}", result.PayDate);
if (!string.IsNullOrEmpty(result.UnitId))
{
this.drpUnit.SelectedValue = result.UnitId;
}
this.txtSMonthType1.Text= Convert.ToString(result.SMonthType1);
this.txtSMonthType2.Text = Convert.ToString(result.SMonthType2);
this.txtSMonthType3.Text = Convert.ToString(result.SMonthType3);
this.txtSMonthType4.Text = Convert.ToString(result.SMonthType4);
this.txtSMonthType5.Text = Convert.ToString(result.SMonthType5);
this.txtSMonthType6.Text = Convert.ToString(result.SMonthType6);
this.txtSMonthType7.Text = Convert.ToString(result.SMonthType7);
this.txtSMonthType8.Text = Convert.ToString(result.SMonthType8);
this.txtSMonthType9.Text = Convert.ToString(result.SMonthType9);
this.txtSMonthType10.Text = Convert.ToString(result.SMonthType10);
txtSMonthTypeAll.Text = Convert.ToString(result.SMonthType1 + result.SMonthType2 + result.SMonthType3 + result.SMonthType4 +
result.SMonthType5 + result.SMonthType6 + result.SMonthType7 + result.SMonthType8
+ result.SMonthType9 + result.SMonthType10);
}
}
else
{
this.txtDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
getXmlj();
}
}
private void getXmlj() {
#region
var list = (from x in Funs.DB.CostGoods_HseExpense
where x.ProjectId == CurrUser.LoginProjectId
&& x.PayDate <= BLL.Funs.GetNewDateTime(this.txtDate.Text.Trim())
select x).ToList();
decimal? sMonthType1_1 = 0, sMonthType1_2 = 0, sMonthType1_3 = 0, sMonthType1_4 = 0, sMonthType1_5 = 0, sMonthType1_6 = 0, sMonthType1_7 = 0, sMonthType1_8 = 0, sMonthType1_9 = 0, sMonthType1_10 = 0;
foreach (var item in list) {
sMonthType1_1 += item.SMonthType1;
sMonthType1_2 += item.SMonthType2;
sMonthType1_3 += item.SMonthType3;
sMonthType1_4 += item.SMonthType4;
sMonthType1_5 += item.SMonthType5;
sMonthType1_6 += item.SMonthType6;
sMonthType1_7 += item.SMonthType7;
sMonthType1_8 += item.SMonthType8;
sMonthType1_9 += item.SMonthType9;
sMonthType1_10 += item.SMonthType10;
}
this.txtSTotalType1.Text = Convert.ToString(sMonthType1_1);
this.txtSTotalType2.Text = Convert.ToString(sMonthType1_2);
this.txtSTotalType3.Text = Convert.ToString(sMonthType1_3);
this.txtSTotalType4.Text = Convert.ToString(sMonthType1_4);
this.txtSTotalType5.Text = Convert.ToString(sMonthType1_5);
this.txtSTotalType6.Text = Convert.ToString(sMonthType1_6);
this.txtSTotalType7.Text = Convert.ToString(sMonthType1_7);
this.txtSTotalType8.Text = Convert.ToString(sMonthType1_8);
this.txtSTotalType9.Text = Convert.ToString(sMonthType1_9);
this.txtSTotalType10.Text = Convert.ToString(sMonthType1_10);
txtSTotalTypeAll.Text = Convert.ToString(sMonthType1_1 + sMonthType1_2 + sMonthType1_3 + sMonthType1_4 + sMonthType1_5 + sMonthType1_6 + sMonthType1_7 + sMonthType1_8 + sMonthType1_9 + sMonthType1_10);
#endregion
}
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveData();
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
#endregion
#region
/// <summary>
/// 保存方法
/// </summary>
private void SaveData()
{
var model = new Model.CostGoods_HseExpense();
model.UnitId = drpUnit.SelectedValue;
model.ProjectId = CurrUser.LoginProjectId;
model.PayDate = Funs.GetNewDateTime(this.txtDate.Text.Trim());
model.PayMonth = Convert.ToDateTime(this.txtDate.Text.Trim()).ToString("yyyy-MM");
model.SMonthType1 = Funs.GetNewDecimalOrZero(this.txtSMonthType1.Text.Trim());
model.SMonthType2 = Funs.GetNewDecimalOrZero(this.txtSMonthType2.Text.Trim());
model.SMonthType3 = Funs.GetNewDecimalOrZero(this.txtSMonthType3.Text.Trim());
model.SMonthType4 = Funs.GetNewDecimalOrZero(this.txtSMonthType4.Text.Trim());
model.SMonthType5 = Funs.GetNewDecimalOrZero(this.txtSMonthType5.Text.Trim());
model.SMonthType6 = Funs.GetNewDecimalOrZero(this.txtSMonthType6.Text.Trim());
model.SMonthType7 = Funs.GetNewDecimalOrZero(this.txtSMonthType7.Text.Trim());
model.SMonthType8 = Funs.GetNewDecimalOrZero(this.txtSMonthType8.Text.Trim());
model.SMonthType9 = Funs.GetNewDecimalOrZero(this.txtSMonthType9.Text.Trim());
model.SMonthType10 = Funs.GetNewDecimalOrZero(this.txtSMonthType10.Text.Trim());
model.CompileMan = this.CurrUser.UserId;
model.CompileDate = DateTime.Now;
if (!string.IsNullOrEmpty(this.Id))
{
model.Id = this.Id;
HseExpenseService.Update(model);
}
else
{
this.Id = SQLHelper.GetNewID(typeof(Model.CostGoods_PayRegistration));
model.Id = this.Id;
HseExpenseService.Insert(model);
}
}
#endregion
#region
/// <summary>
/// 当月费用统计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void SMonthTypeText_TextChanged(object sender, EventArgs e) {
decimal sMonthType1_1 = 0, sMonthType1_2 = 0, sMonthType1_3 = 0, sMonthType1_4 = 0, sMonthType1_5 = 0, sMonthType1_6 = 0, sMonthType1_7 = 0, sMonthType1_8 = 0, sMonthType1_9 = 0, sMonthType1_10 = 0;
sMonthType1_1 = Funs.GetNewDecimalOrZero(this.txtSMonthType1.Text.Trim());
sMonthType1_2 = Funs.GetNewDecimalOrZero(this.txtSMonthType2 .Text.Trim());
sMonthType1_3 = Funs.GetNewDecimalOrZero(this.txtSMonthType3 .Text.Trim());
sMonthType1_4 = Funs.GetNewDecimalOrZero(this.txtSMonthType4 .Text.Trim());
sMonthType1_5 = Funs.GetNewDecimalOrZero(this.txtSMonthType5 .Text.Trim());
sMonthType1_6 = Funs.GetNewDecimalOrZero(this.txtSMonthType6 .Text.Trim());
sMonthType1_7 = Funs.GetNewDecimalOrZero(this.txtSMonthType7 .Text.Trim());
sMonthType1_8 = Funs.GetNewDecimalOrZero(this.txtSMonthType8 .Text.Trim());
sMonthType1_9 = Funs.GetNewDecimalOrZero(this.txtSMonthType9.Text.Trim());
sMonthType1_10 = Funs.GetNewDecimalOrZero(this.txtSMonthType10.Text.Trim());
txtSMonthTypeAll.Text = Convert.ToString(sMonthType1_1 + sMonthType1_2 + sMonthType1_3 + sMonthType1_4 + sMonthType1_5 + sMonthType1_6 + sMonthType1_7 + sMonthType1_8 + sMonthType1_9 + sMonthType1_10);
}
#endregion
}
}