202305291、修改奖励通知单、奖惩通知单。
This commit is contained in:
@@ -2,16 +2,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.HSSE.CostGoods
|
||||
{
|
||||
public partial class Expense : PageBase
|
||||
{
|
||||
#region 项目主键
|
||||
/// <summary>
|
||||
/// 项目主键
|
||||
/// 项目id
|
||||
/// </summary>
|
||||
public string ProjectId
|
||||
{
|
||||
@@ -24,93 +22,214 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
ViewState["ProjectId"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#region Page_Init
|
||||
|
||||
// 注意:动态创建的代码需要放置于Page_Init(不是Page_Load),这样每次构造页面时都会执行
|
||||
protected void Page_Init(object sender, EventArgs e)
|
||||
{
|
||||
InitYearGrid();
|
||||
}
|
||||
|
||||
protected static DateTime sDate = new DateTime();
|
||||
protected static DateTime eDate = new DateTime();
|
||||
#region 按年份
|
||||
private void InitYearGrid()
|
||||
{
|
||||
FineUIPro.BoundField bf;
|
||||
|
||||
bf = new FineUIPro.BoundField();
|
||||
bf.DataField = "Id";
|
||||
bf.DataFormatString = "{0}";
|
||||
bf.HeaderText = "编号";
|
||||
bf.Width = 60;
|
||||
bf.Hidden = true;
|
||||
Grid1.Columns.Add(bf);
|
||||
|
||||
bf = new FineUIPro.BoundField();
|
||||
bf.DataField = "SupCostTypeName";
|
||||
bf.DataFormatString = "{0}";
|
||||
bf.HeaderText = "类别名称";
|
||||
bf.Width = 90;
|
||||
bf.HeaderTextAlign = TextAlign.Center;
|
||||
Grid1.Columns.Add(bf);
|
||||
|
||||
bf = new FineUIPro.BoundField();
|
||||
bf.DataField = "CostTypeName";
|
||||
bf.DataFormatString = "{0}";
|
||||
bf.HeaderText = "分项名称";
|
||||
bf.Width = 120;
|
||||
bf.HeaderTextAlign = TextAlign.Center;
|
||||
Grid1.Columns.Add(bf);
|
||||
|
||||
this.ProjectId = this.ProjectId ?? this.CurrUser.LoginProjectId;
|
||||
var getProject = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == this.ProjectId);
|
||||
if (getProject != null)
|
||||
{
|
||||
sDate= getProject.StartDate ?? DateTime.Now;
|
||||
eDate = getProject.EndDate ?? DateTime.Now;
|
||||
for (int i = 0; sDate.Year + i <= eDate.Year; i++)
|
||||
{
|
||||
bf = new FineUIPro.BoundField();
|
||||
bf.DataField = (sDate.Year + i).ToString();
|
||||
bf.DataFormatString = "{0}";
|
||||
bf.HeaderText = (sDate.Year + i).ToString() +"年";
|
||||
bf.Width = 200;
|
||||
bf.HeaderTextAlign = TextAlign.Center;
|
||||
Grid1.Columns.Add(bf);
|
||||
}
|
||||
}
|
||||
|
||||
bf = new FineUIPro.BoundField();
|
||||
bf.DataField = "SumC";
|
||||
bf.DataFormatString = "{0}";
|
||||
bf.HeaderText = "合计";
|
||||
bf.Width = 90;
|
||||
bf.HeaderTextAlign = TextAlign.Center;
|
||||
Grid1.Columns.Add(bf);
|
||||
|
||||
Grid1.DataKeyNames = new string[] { "Id", "CostTypeName" };
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 加载
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
Funs.DropDownPageSize(this.ddlPageSize);
|
||||
////权限按钮方法
|
||||
this.GetButtonPower();
|
||||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
|
||||
{
|
||||
this.ProjectId = Request.Params["projectId"];
|
||||
}
|
||||
BLL.UnitService.InitUnitDropDownList(this.drpUnitId, this.ProjectId, true);
|
||||
if (BLL.ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(this.ProjectId, this.CurrUser.UnitId))
|
||||
{
|
||||
this.drpUnitId.SelectedValue = this.CurrUser.UnitId;
|
||||
this.drpUnitId.Enabled = false;
|
||||
}
|
||||
Funs.DropDownPageSize(this.ddlPageSize);
|
||||
////权限按钮方法
|
||||
this.GetButtonPower();
|
||||
this.btnNew.OnClientClick = Window1.GetShowReference("ExpenseEdit.aspx") + "return false;";
|
||||
// 绑定表格
|
||||
this.BindGrid();
|
||||
this.btnUnit.OnClientClick = Window2.GetShowReference("ExpenseUnit.aspx") + "return false;";
|
||||
UnitService.InitUnitDropDownList(this.drpUnit, this.ProjectId, false);
|
||||
Funs.FineUIPleaseSelect(drpUnit, "请选择单位");
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string strSql = @" SELECT Expense.ExpenseId, "
|
||||
+ @" Expense.ProjectId,"
|
||||
+ @" CodeRecords.Code AS ExpenseCode,"
|
||||
+ @" Expense.UnitId,"
|
||||
+ @" Expense.CompileMan,"
|
||||
+ @" Expense.Months,"
|
||||
+ @" Expense.CompileDate,"
|
||||
+ @" Expense.States,"
|
||||
+ @" Unit.UnitName,"
|
||||
+ @" (CASE WHEN Expense.States = " + BLL.Const.State_0 + " OR Expense.States IS NULL THEN '待['+OperateUser.PersonName+']提交' WHEN Expense.States = " + BLL.Const.State_2 + " THEN '审核/审批完成' ELSE '待['+OperateUser.PersonName+']办理' END) AS FlowOperateName"
|
||||
+ @" FROM CostGoods_Expense AS Expense "
|
||||
+ @" LEFT JOIN Sys_CodeRecords AS CodeRecords ON Expense.ExpenseId = CodeRecords.DataId "
|
||||
+ @" LEFT JOIN Sys_FlowOperate AS FlowOperate ON Expense.ExpenseId = FlowOperate.DataId AND FlowOperate.IsClosed <> 1"
|
||||
+ @" LEFT JOIN Person_Persons AS OperateUser ON FlowOperate.OperaterId = OperateUser.PersonId"
|
||||
+ @" LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = Expense.UnitId WHERE 1=1 ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
strSql += " AND Expense.ProjectId = @ProjectId";
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"])) ///是否文件柜查看页面传项目值
|
||||
{
|
||||
listStr.Add(new SqlParameter("@ProjectId", Request.Params["projectId"]));
|
||||
strSql += " AND Expense.States = @States"; ///状态为已完成
|
||||
listStr.Add(new SqlParameter("@States", BLL.Const.State_2));
|
||||
}
|
||||
else
|
||||
{
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
}
|
||||
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
strSql += " AND Expense.UnitId = @UnitId";
|
||||
listStr.Add(new SqlParameter("@UnitId", this.drpUnitId.SelectedValue.Trim()));
|
||||
}
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据
|
||||
/// </summary>
|
||||
private void LoadData()
|
||||
{
|
||||
DataTable tb = GetDataTable(); //this.LINQToDataTable(getData.ToList());
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// 获取模拟树表格
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DataTable GetDataTable()
|
||||
{
|
||||
DataTable table = new DataTable();
|
||||
table.Columns.Add(new DataColumn("Id", typeof(string)));
|
||||
table.Columns.Add(new DataColumn("SupCostTypeName", typeof(string)));
|
||||
table.Columns.Add(new DataColumn("CostTypeName", typeof(string)));
|
||||
for (int i = 0; sDate.Year + i <= eDate.Year; i++)
|
||||
{
|
||||
table.Columns.Add(new DataColumn((sDate.Year + i).ToString(), typeof(string)));
|
||||
}
|
||||
|
||||
table.Columns.Add(new DataColumn("SumC", typeof(String)));
|
||||
|
||||
if (!string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpUnit.SelectedValue != Const._Null)
|
||||
{
|
||||
var getDetail = from x in Funs.DB.CostGoods_ExpenseDetail
|
||||
join y in Funs.DB.CostGoods_Expense on x.ExpenseId equals y.ExpenseId
|
||||
where y.ProjectId == this.ProjectId && y.UnitId == this.drpUnit.SelectedValue
|
||||
orderby y.Year, x.SupSortIndex, x.SortIndex
|
||||
select new { x.ExpenseDetailId, x.ExpenseId, y.Year, x.SupCostTypeId, x.SupCostTypeName, x.SupSortIndex, x.CostType, x.CostTypeName, x.SortIndex, x.CostMoney };
|
||||
|
||||
foreach (var item in getDetail)
|
||||
{
|
||||
DataRow row = table.NewRow();
|
||||
row[0] = item.ExpenseDetailId +"#" +item.ExpenseId;
|
||||
row[1] = item.SupCostTypeName;
|
||||
row[2] = item.CostTypeName;
|
||||
int r = 3;
|
||||
for (int i = 0; sDate.Year + i <= eDate.Year; i++)
|
||||
{
|
||||
var getV = getDetail.Where(x => x.Year == sDate.Year + i && x.CostType == item.CostType);
|
||||
if (getV.Count() > 0)
|
||||
{
|
||||
row[r] = getV.Sum(x => x.CostMoney ?? 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
row[r] = 0.00;
|
||||
}
|
||||
|
||||
r = i + 4;
|
||||
}
|
||||
row[r] = getDetail.Where(x => x.CostType == item.CostType).Sum(x => x.CostMoney ?? 0);
|
||||
table.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var getDetail = from x in Funs.DB.CostGoods_ExpenseDetail
|
||||
join y in Funs.DB.CostGoods_Expense on x.ExpenseId equals y.ExpenseId
|
||||
where y.ProjectId == this.ProjectId
|
||||
orderby y.Year, x.SupSortIndex, x.SortIndex
|
||||
select new { x.ExpenseDetailId, x.ExpenseId, y.Year, x.SupCostTypeId, x.SupCostTypeName, x.SupSortIndex, x.CostType, x.CostTypeName, x.SortIndex, x.CostMoney };
|
||||
|
||||
foreach (var item in getDetail)
|
||||
{
|
||||
DataRow row = table.NewRow();
|
||||
row[0] = item.ExpenseDetailId + "#" + item.ExpenseId;
|
||||
row[1] = item.SupCostTypeName;
|
||||
row[2] = item.CostTypeName;
|
||||
int r = 3;
|
||||
for (int i = 0; sDate.Year + i <= eDate.Year; i++)
|
||||
{
|
||||
var getV = getDetail.Where(x => x.Year == sDate.Year + i && x.CostType == item.CostType);
|
||||
if (getV.Count() > 0)
|
||||
{
|
||||
row[r] = getV.Sum(x => x.CostMoney ?? 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
row[r] = "0.00";
|
||||
}
|
||||
|
||||
r = i + 4;
|
||||
}
|
||||
row[r] = getDetail.Where(x => x.CostType == item.CostType).Sum(x => x.CostMoney ?? 0);
|
||||
table.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
#region 导出按钮
|
||||
/// 导出按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
protected void btnOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.BindGrid();
|
||||
Response.ClearContent();
|
||||
string filename = Funs.GetNewFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("费用计划" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
Response.ContentType = "application/excel";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
this.Grid1.PageSize = this.Grid1.RecordCount;
|
||||
|
||||
Response.Write(GetTableHtml(GetDataTable()));
|
||||
Response.End();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -122,7 +241,7 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -133,21 +252,31 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
||||
BindGrid();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
||||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||||
{
|
||||
this.BindGrid();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 编辑
|
||||
/// <summary>
|
||||
/// 查看
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnView_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.EditData("view");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 双击事件
|
||||
/// </summary>
|
||||
@@ -169,30 +298,33 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑数据方法
|
||||
/// 编辑数据
|
||||
/// </summary>
|
||||
private void EditData()
|
||||
private void EditData(string type = null)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
string id = Grid1.SelectedRowID;
|
||||
var expense = BLL.ExpenseService.GetExpenseById(id);
|
||||
if (expense != null)
|
||||
string id = Grid1.SelectedRow.Values[0].ToString();
|
||||
var getID = Funs.GetStrListByStr(id, '#');
|
||||
if (getID != null && getID.Count > 1)
|
||||
{
|
||||
if (this.btnMenuEdit.Hidden || expense.States == BLL.Const.State_2) ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
|
||||
var getEx = ExpenseService.GetExpenseById(getID[1]);
|
||||
if (getEx != null && !string.IsNullOrEmpty(getEx.UnitId))
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ExpenseView.aspx?ExpenseId={0}", id, "查看 - ")));
|
||||
}
|
||||
else
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ExpenseEdit.aspx?ExpenseId={0}", id, "编辑 - ")));
|
||||
if (this.btnMenuEdit.Hidden || type == "view") ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ExpenseView.aspx?ExpenseId={0}", id, "查看 - ")));
|
||||
}
|
||||
else
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ExpenseEdit.aspx?ExpenseId={0}", id, "编辑 - ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除
|
||||
/// <summary>
|
||||
@@ -207,21 +339,30 @@ namespace FineUIPro.Web.HSSE.CostGoods
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
var expense = BLL.ExpenseService.GetExpenseById(rowID);
|
||||
if (expense != null)
|
||||
var getEx = ExpenseService.GetExpenseById(rowID);
|
||||
if (getEx != null && !string.IsNullOrEmpty(getEx.UnitId))
|
||||
{
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, expense.ExpenseCode, expense.ExpenseId, BLL.Const.ProjectExpenseMenuId, BLL.Const.BtnDelete);
|
||||
BLL.ExpenseDetailService.DeleteCostDetailByExpenseId(rowID);
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, getEx.ExpenseCode, getEx.ExpenseId, BLL.Const.ProjectExpenseMenuId, BLL.Const.BtnDelete);
|
||||
BLL.ExpenseService.DeleteExpenseById(rowID);
|
||||
}
|
||||
}
|
||||
|
||||
this.BindGrid();
|
||||
this.LoadData();
|
||||
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 单位查询事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.LoadData();
|
||||
}
|
||||
|
||||
#region 获取按钮权限
|
||||
/// <summary>
|
||||
/// 获取按钮权限
|
||||
|
||||
Reference in New Issue
Block a user