2026-05-21 15:58:21 +08:00
|
|
|
using BLL;
|
2026-05-22 18:06:04 +08:00
|
|
|
using FineUIPro.Web.BaseInfo;
|
|
|
|
|
using Model;
|
2026-05-21 15:58:21 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
2026-05-22 18:06:04 +08:00
|
|
|
using AspNet = System.Web.UI.WebControls;
|
2026-05-21 15:58:21 +08:00
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.ProjectData
|
|
|
|
|
{
|
|
|
|
|
public partial class MasterProjectData : PageBase
|
|
|
|
|
{
|
|
|
|
|
#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.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
|
|
|
// 绑定表格
|
|
|
|
|
this.BindGrid();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 绑定数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 绑定数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindGrid()
|
|
|
|
|
{
|
|
|
|
|
var db = Funs.DB;
|
|
|
|
|
var masterProDatas = ProjectService.GetMasterProjectDataInfos();
|
|
|
|
|
var query = from x in masterProDatas
|
|
|
|
|
join pro in db.Base_Project on x.Pro_id equals pro.MasterSysId into proGroup
|
|
|
|
|
from pro in proGroup.DefaultIfEmpty()
|
2026-05-22 18:06:04 +08:00
|
|
|
join use in db.Project_MasterDataUsage on x.Pro_id equals use.Pro_id into useGroup
|
|
|
|
|
from use in useGroup.DefaultIfEmpty()
|
2026-05-21 15:58:21 +08:00
|
|
|
select new
|
|
|
|
|
{
|
2026-05-22 18:06:04 +08:00
|
|
|
//Pid = x.Pro_id + (pro != null ? $"-{pro.ProjectId}" : ""),
|
|
|
|
|
Pid = $"{x.Pro_id}|{(pro != null ? $"{pro.ProjectId}" : "")}|{(use != null ? use.Id : "")}",
|
2026-05-21 15:58:21 +08:00
|
|
|
x.Pro_id,
|
|
|
|
|
x.Pro_name,
|
|
|
|
|
x.Pro_code,
|
|
|
|
|
x.Start_date,
|
|
|
|
|
x.Pro_status,
|
2026-05-22 18:06:04 +08:00
|
|
|
ProjectId = pro != null ? pro.ProjectId : null,
|
2026-05-21 15:58:21 +08:00
|
|
|
ProjectName = pro != null ? pro.ProjectName : "",
|
|
|
|
|
ProjectCode = pro != null ? pro.ProjectCode : "",
|
|
|
|
|
StartDate = pro != null ? pro.StartDate : null,
|
|
|
|
|
ProjectState = pro != null ? pro.ProjectState : "",
|
2026-05-22 18:06:04 +08:00
|
|
|
relate = pro != null && pro.MasterSysId != null ? "已关联" : "未关联",
|
|
|
|
|
UseId = use != null ? use.Id : null,
|
|
|
|
|
Use = use == null ? "" : (use != null && use.Is_use == true) ? "已使用" : "未使用",
|
|
|
|
|
Reason = use != null ? use.Reason : "",
|
|
|
|
|
Situation = use != null ? use.Situation : "",
|
|
|
|
|
Remark = use != null ? use.Remark : "",
|
2026-05-21 15:58:21 +08:00
|
|
|
};
|
|
|
|
|
|
2026-05-22 18:06:04 +08:00
|
|
|
string proName = this.txtProName.Text.Trim();
|
|
|
|
|
string proCode = this.txtProCode.Text.Trim();
|
|
|
|
|
string projectName = this.txtProjectName.Text.Trim();
|
|
|
|
|
string projectCode = this.txtProjectCode.Text.Trim();
|
|
|
|
|
string relate = this.rblIsRelate.SelectedValue;
|
|
|
|
|
|
2026-05-21 15:58:21 +08:00
|
|
|
if (!string.IsNullOrEmpty(proName))
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.Pro_name.Contains(proName));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(proCode))
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.Pro_code.Contains(proCode));
|
|
|
|
|
}
|
2026-05-22 18:06:04 +08:00
|
|
|
if (!string.IsNullOrEmpty(projectName))
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.ProjectName.Contains(projectName));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(projectCode))
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.ProjectCode.Contains(projectCode));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(relate))
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.relate == relate);
|
|
|
|
|
}
|
2026-05-21 15:58:21 +08:00
|
|
|
DataTable tb = Funs.LINQToDataTable(query);
|
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
|
|
|
Grid1.DataSource = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
|
Grid1.DataBind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 项目状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="addType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected string ConvertProjectState(object state)
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
string stateStr = state.ToString();
|
|
|
|
|
if (state != null && !string.IsNullOrWhiteSpace(stateStr))
|
|
|
|
|
{
|
|
|
|
|
result = stateStr == "2" ? "暂停中" : stateStr == "3" ? "已完工" : "施工中";
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Grid
|
|
|
|
|
|
2026-05-22 18:06:04 +08:00
|
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
EditData(sender, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编辑数据方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void EditData(object sender, GridRowClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var pId = Grid1.SelectedRowID;
|
|
|
|
|
|
|
|
|
|
string pro_id = pId.Split('|')[0];
|
|
|
|
|
string projectId = pId.Split('|')[1];
|
|
|
|
|
string useId = pId.Split('|')[2];
|
|
|
|
|
|
|
|
|
|
var obj = Grid1.SelectedRow.Values;
|
|
|
|
|
string num = obj[0].ToString();
|
|
|
|
|
string pro_name = obj[2].ToString();
|
|
|
|
|
string pro_code = obj[3].ToString();
|
|
|
|
|
string startdate = obj[4].ToString();
|
|
|
|
|
string prostatus = obj[5].ToString();
|
|
|
|
|
string projectName = obj[7].ToString();
|
|
|
|
|
string projectCode = obj[8].ToString();
|
|
|
|
|
string startDate = obj[9].ToString();
|
|
|
|
|
string lblState = (Grid1.SelectedRow.FindControl("lblState") as AspNet.Label).Text;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(pro_id))
|
|
|
|
|
{
|
|
|
|
|
var masterUsage = Funs.DB.Project_MasterDataUsage.Where(x => x.Pro_id == pro_id).FirstOrDefault();
|
|
|
|
|
if (masterUsage != null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
useId = SQLHelper.GetNewID(typeof(Model.Project_MasterDataUsage));
|
|
|
|
|
Model.Project_MasterDataUsage model = new Model.Project_MasterDataUsage();
|
|
|
|
|
model.Id = useId;
|
|
|
|
|
model.Pro_id = pro_id;
|
|
|
|
|
model.Pro_code = pro_code;
|
|
|
|
|
model.Pro_name = pro_name;
|
|
|
|
|
model.Is_relate = !string.IsNullOrWhiteSpace(projectId);
|
|
|
|
|
model.Is_use = !string.IsNullOrWhiteSpace(projectId);
|
|
|
|
|
model.Projectid = projectId;
|
|
|
|
|
model.Projectcode = projectName;
|
|
|
|
|
model.Projectname = projectCode;
|
|
|
|
|
model.Create_user = this.CurrUser.UserName;
|
|
|
|
|
model.Create_date = DateTime.Now;
|
|
|
|
|
ProjectMasterDataUsageService.AddProjectMasterDataUsage(model);
|
|
|
|
|
}
|
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MasterProjectDataUsage.aspx?UseId={0}", useId)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.BindGrid();
|
|
|
|
|
}
|
2026-05-21 15:58:21 +08:00
|
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 导出按钮
|
|
|
|
|
/// 导出按钮
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
this.BindGrid();
|
|
|
|
|
Response.Write(GetGridMultiHeaderTableHtml(Grid1));
|
|
|
|
|
//Response.Write(GetGridTableHtml(Grid1));
|
|
|
|
|
Response.End();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|