This commit is contained in:
2025-04-06 23:26:34 +08:00
5 changed files with 133 additions and 16 deletions
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Collections;
using System.Web.UI.WebControls;
using System.Data;
namespace BLL
{
@@ -269,5 +270,121 @@ namespace BLL
else
return null;
}
/// <summary>
/// 获取模拟树表格
/// </summary>
/// <returns></returns>
public static DataTable GetAllTreeDataTable(string projectId)
{
using (var db = new Model.SGGLDB(Funs.ConnString))
{
IQueryable<Model.Base_CNProfessional> cNProfessionals = from x in db.Base_CNProfessional where x.CNProfessionalId != BLL.Const.CNProfessionalConstructId orderby x.SortIndex select x;
IQueryable<Model.View_QuantityManagement_Base> bases = from x in db.View_QuantityManagement_Base where x.ProjectId == projectId select x;
DataTable table = new DataTable();
table.Columns.Add(new DataColumn("BaseId", typeof(String)));
table.Columns.Add(new DataColumn("SupId", typeof(String)));
table.Columns.Add(new DataColumn("Name", typeof(String)));
table.Columns.Add(new DataColumn("ProjectId", typeof(String)));
table.Columns.Add(new DataColumn("DrawingNo", typeof(String)));
table.Columns.Add(new DataColumn("DrawingName", typeof(String)));
table.Columns.Add(new DataColumn("Part", typeof(String)));
table.Columns.Add(new DataColumn("ProjectContent", typeof(String)));
table.Columns.Add(new DataColumn("Unit", typeof(String)));
table.Columns.Add(new DataColumn("Amount", typeof(decimal)));
table.Columns.Add(new DataColumn("WorkTeam", typeof(String)));
table.Columns.Add(new DataColumn("State", typeof(String)));
DataRow row;
row = table.NewRow();
row[0] = "0";
row[1] = null;
row[2] = "工程量基础表";
row[3] = projectId;
row[4] = "";
row[5] = "";
row[6] = "";
row[7] = "";
row[8] = "";
row[9] = DBNull.Value;
row[10] = "";
row[11] = "";
table.Rows.Add(row);
foreach (var item in cNProfessionals)
{
row = table.NewRow();
row[0] = item.CNProfessionalId;
row[1] = "0";
row[2] = item.ProfessionalName;
row[3] = projectId;
row[4] = "";
row[5] = "";
row[6] = "";
row[7] = "";
row[8] = "";
row[9] = DBNull.Value;
row[10] = "";
row[11] = "";
table.Rows.Add(row);
var workSections = bases.Where(x => x.Major == item.ProfessionalName).Select(x => x.WorkSection).Distinct().ToList();
foreach (var workSection in workSections)
{
row = table.NewRow();
row[0] = item.CNProfessionalId + workSection;
row[1] = item.CNProfessionalId;
row[2] = workSection;
row[3] = projectId;
row[4] = "";
row[5] = "";
row[6] = "";
row[7] = "";
row[8] = "";
row[9] = DBNull.Value;
row[10] = "";
row[11] = "";
table.Rows.Add(row);
var bs = from x in bases
where x.WorkSection == workSection && x.Major == item.ProfessionalName
orderby x.DrawingNo, x.Part, x.WorkSection
select x;
foreach (var b in bs)
{
row = table.NewRow();
row[0] = b.BaseId;
row[1] = item.CNProfessionalId + workSection;
row[2] = b.Part;
row[3] = projectId;
row[4] = b.DrawingNo;
row[5] = b.DrawingName;
row[6] = b.Part;
row[7] = b.ProjectContent;
row[8] = b.Unit;
row[9] = b.Amount;
row[10] = b.WorkTeam;
row[11] = b.State;
table.Rows.Add(row);
}
}
}
//foreach (var item in bases)
//{
// row = table.NewRow();
// row[0] = item.BaseId;
// row[1] = "0";
// row[2] = item.ProfessionalName;
// row[3] = projectId;
// row[4] = "";
// row[5] = "";
// row[6] = "";
// row[7] = "";
// row[8] = "";
// row[9] = DBNull.Value;
// row[10] = "";
// row[11] = "";
// table.Rows.Add(row);
//}
return table;
}
}
}
}