提交代码

This commit is contained in:
2025-04-07 10:32:00 +08:00
parent a3e06cfc69
commit e4e4468b46
4 changed files with 161 additions and 40 deletions
@@ -20,45 +20,117 @@ namespace FineUIPro.Web.CQMS.QuantityManagement
if (!IsPostBack)
{
GetButtonPower();
DataTable table = BLL.BaseService.GetAllTreeDataTable(this.CurrUser.LoginProjectId);
Grid1.DataSource = table;
Grid1.DataBind();
//BindGrid();
InitTreeMenu();
}
}
#endregion
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.trWBS.Nodes.Clear();
this.trWBS.ShowBorder = false;
this.trWBS.ShowHeader = false;
this.trWBS.EnableIcons = true;
this.trWBS.AutoScroll = true;
this.trWBS.EnableSingleClickExpand = true;
TreeNode rootNode1 = new TreeNode();
rootNode1.Text = "工程量基础表";
rootNode1.NodeID = "0";
rootNode1.CommandName = "Node";
//rootNode1.EnableExpandEvent = true;
rootNode1.EnableClickEvent = true;
this.trWBS.Nodes.Add(rootNode1);
this.GetNodes(rootNode1.Nodes, rootNode1.NodeID);
}
/// <summary>
/// 遍历节点方法
/// </summary>
/// <param name="nodes">节点集合</param>
/// <param name="parentId">父节点</param>
private void GetNodes(TreeNodeCollection nodes, string parentId)
{
Model.SGGLDB db = Funs.DB;
if (parentId == "0") //工程量基础表节点
{
var cNProfessionals = from x in db.Base_CNProfessional where x.CNProfessionalId != BLL.Const.CNProfessionalConstructId orderby x.SortIndex select x;
var bases = from x in db.View_QuantityManagement_Base where x.ProjectId == this.CurrUser.LoginProjectId select x;
foreach (var q in cNProfessionals)
{
TreeNode newNode = new TreeNode();
newNode.Text = q.ProfessionalName;
newNode.NodeID = q.CNProfessionalId;
newNode.CommandName = "CNProfessional";
newNode.EnableClickEvent = true;
nodes.Add(newNode);
var workSections = bases.Where(x => x.Major == q.ProfessionalName).Select(x => x.WorkSection).Distinct().ToList();
foreach (var workSection in workSections)
{
TreeNode newNode2 = new TreeNode();
newNode2.Text = workSection;
newNode2.NodeID = workSection;
newNode2.CommandName = "WorkSection";
newNode2.EnableClickEvent = true;
newNode.Nodes.Add(newNode2);
}
}
}
}
#endregion
#region Tree点击事件
/// <summary>
/// Tree点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trWBS_NodeCommand(object sender, TreeCommandEventArgs e)
{
BindGrid();
}
#endregion
/// <summary>
/// 数据绑定
/// </summary>
public void BindGrid()
{
string strSql = @"select * from View_QuantityManagement_Base C
where C.ProjectId = @ProjectId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
if (!string.IsNullOrEmpty(this.txtDrawingNo.Text.Trim()))
if (this.trWBS.SelectedNode.CommandName == "WorkSection")
{
strSql += " AND DrawingNo like @DrawingNo";
listStr.Add(new SqlParameter("@DrawingNo", "%" + this.txtDrawingNo.Text.Trim() + "%"));
string strSql = @"select * from View_QuantityManagement_Base C
where C.ProjectId = @ProjectId and C.WorkSection=@WorkSection";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@WorkSection", this.trWBS.SelectedNodeID));
if (!string.IsNullOrEmpty(this.txtDrawingNo.Text.Trim()))
{
strSql += " AND DrawingNo like @DrawingNo";
listStr.Add(new SqlParameter("@DrawingNo", "%" + this.txtDrawingNo.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtPart.Text.Trim()))
{
strSql += " AND Part like @Part";
listStr.Add(new SqlParameter("@Part", "%" + this.txtPart.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtProjectContent.Text.Trim()))
{
strSql += " AND ProjectContent like @ProjectContent";
listStr.Add(new SqlParameter("@ProjectContent", "%" + this.txtProjectContent.Text.Trim() + "%"));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
if (!string.IsNullOrEmpty(this.txtPart.Text.Trim()))
{
strSql += " AND Part like @Part";
listStr.Add(new SqlParameter("@Part", "%" + this.txtPart.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtProjectContent.Text.Trim()))
{
strSql += " AND ProjectContent like @ProjectContent";
listStr.Add(new SqlParameter("@ProjectContent", "%" + this.txtProjectContent.Text.Trim() + "%"));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#endregion
#region
/// <summary>