2023-10-19
This commit is contained in:
@@ -0,0 +1,270 @@
|
||||
using BLL;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
{
|
||||
public partial class ContractWBS : PageBase
|
||||
{
|
||||
public string ContractId
|
||||
{
|
||||
get => (string)ViewState["ContractId"];
|
||||
set => ViewState["ContractId"] = value;
|
||||
}
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.GetButtonPower();
|
||||
//主合同编号
|
||||
this.DropContractCode.DataTextField = "ContractNum";
|
||||
this.DropContractCode.DataValueField = "ContractNum";
|
||||
this.DropContractCode.DataSource = BLL.PHTGL_ContractReviewService.GetContractReview_CompleteData(this.CurrUser.LoginProjectId);
|
||||
this.DropContractCode.DataBind();
|
||||
Funs.FineUIPleaseSelect(this.DropContractCode);
|
||||
DropMainContractCode_SelectedIndexChanged(null, null);
|
||||
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
||||
// 绑定表格
|
||||
this.BindGrid();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region 绑定数据
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
var db = Funs.DB;
|
||||
var q =
|
||||
from x in db.PHTGL_ContractTrack
|
||||
join y in db.PHTGL_ContractTrackMatchWBS on x.Id equals y.ContractTrackId into g
|
||||
from y in g.DefaultIfEmpty()
|
||||
join z in db.WBS_ControlItemAndCycle on y.ControlItemAndCycleId equals z.ControlItemAndCycleId into _ControlJoin
|
||||
from z in _ControlJoin.DefaultIfEmpty()
|
||||
|
||||
where (string.IsNullOrEmpty(ContractId) || x.ContractId.Contains(ContractId)) &&
|
||||
(string.IsNullOrEmpty(CurrUser.LoginProjectId) || x.ProjectId.Contains(CurrUser.LoginProjectId)) &&
|
||||
(string.IsNullOrEmpty(this.txtProjectCode.Text.Trim()) || x.ProjectCode.Contains(this.txtProjectCode.Text.Trim())) &&
|
||||
(string.IsNullOrEmpty(this.txtProjectName.Text.Trim()) || x.ProjectName.Contains(this.txtProjectName.Text.Trim()))
|
||||
|
||||
select new
|
||||
{
|
||||
MatchWbsId= y.Id ,
|
||||
y.ContractTrackId,
|
||||
y.ControlItemAndCycleId,
|
||||
z.ControlItemAndCycleCode,
|
||||
z.ControlItemContent,
|
||||
z.Weights,
|
||||
y.WorkPackageEstimate,
|
||||
x.Id,
|
||||
x.ContractNum,
|
||||
x.MainItemCode,
|
||||
x.MainItemName,
|
||||
x.MajorName,
|
||||
x.MajorCode,
|
||||
x.SubProject,
|
||||
x.SubItemProject,
|
||||
x.ProjectCode,
|
||||
x.ProjectName,
|
||||
x.ProjectDescription,
|
||||
x.UnitOfMeasurement,
|
||||
x.Quantity,
|
||||
x.TotalCostFixedComprehensiveUnitPrice,
|
||||
x.MainMaterialCost,
|
||||
x.TotalPrice,
|
||||
x.CalculationRule,
|
||||
x.WorkContent,
|
||||
x.Remarks,
|
||||
x.ConstructionSubcontractor,
|
||||
x.ContractWeight,
|
||||
x.MaterialSupplier,
|
||||
x.IsWithinGeneralContractScope,
|
||||
x.EstimatedQuantity,
|
||||
x.EstimatedAmount,
|
||||
x.SettledQuantity,
|
||||
x.SettledAmount,
|
||||
x.ContractId
|
||||
};
|
||||
;
|
||||
Grid1.RecordCount = q.Count();
|
||||
Grid1.DataSource = q.ToList();
|
||||
Grid1.DataBind();
|
||||
|
||||
}
|
||||
|
||||
protected void DropMainContractCode_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(DropContractCode.SelectedValue))
|
||||
{
|
||||
var model = ContractService.GetContractByContractNum(DropContractCode.SelectedValue);
|
||||
if (model != null)
|
||||
{
|
||||
ContractId = model.ContractId;
|
||||
this.txtContractName.Text = model.ContractName;
|
||||
}
|
||||
else
|
||||
{
|
||||
ContractId = "";
|
||||
this.txtContractName.Text = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GV 数据操作
|
||||
/// <summary>
|
||||
/// 分页
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
this.Grid1.PageIndex = e.NewPageIndex;
|
||||
this.BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||||
{
|
||||
this.Grid1.SortDirection = e.SortDirection;
|
||||
this.Grid1.SortField = e.SortField;
|
||||
this.BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页显示条数下拉框
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
||||
this.BindGrid();
|
||||
}
|
||||
protected void btnQuery_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据编辑事件
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
object[] ID = Grid1.DataKeys[Grid1.SelectedRowIndex];
|
||||
var model = BLL.PhtglContractTrackService.GetPHTGL_ContractTrackById(ID[0].ToString());
|
||||
if (model != null) ///已上报时不能删除
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ContractTrackMatchWBS.aspx?ContractTrackId={0}", ID, "编辑 - ")));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||||
{
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
object[] rowID = Grid1.DataKeys[rowIndex];
|
||||
var model = BLL.PhtglContracttrackmatchwbsService.GetPHTGL_ContractTrackMatchWBSById(rowID[1].ToString());
|
||||
if (model != null)
|
||||
{
|
||||
BLL.PhtglContracttrackmatchwbsService.DeleteModelById(rowID[1].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
BindGrid();
|
||||
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
}
|
||||
|
||||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
object[] ID = Grid1.DataKeys[Grid1.SelectedRowIndex];
|
||||
var model = BLL.PhtglContractTrackService.GetPHTGL_ContractTrackById(ID[0].ToString());
|
||||
if (model != null) ///已上报时不能删除
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ContractTrackMatchWBS.aspx?ContractTrackId={0}", ID, "编辑 - ")));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 关闭弹出窗
|
||||
/// <summary>
|
||||
/// 关闭弹出窗
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取权限按钮
|
||||
/// <summary>
|
||||
/// 获取按钮权限
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
private void GetButtonPower()
|
||||
{
|
||||
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.PHTGL_ContractWBSMenuId);
|
||||
if (buttonList.Count > 0)
|
||||
{
|
||||
if (buttonList.Contains(BLL.Const.BtnAdd))
|
||||
{
|
||||
this.btnNew.Hidden = false;
|
||||
}
|
||||
if (buttonList.Contains(BLL.Const.BtnModify))
|
||||
{
|
||||
this.btnMenuEdit.Hidden = false;
|
||||
}
|
||||
if (buttonList.Contains(BLL.Const.BtnDelete))
|
||||
{
|
||||
this.btnMenuDelete.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user