/// <summary> /// 方法说明:获取下层PBOM /// 作 者:jason.tang /// 完成时间:2013-08-30 /// </summary> /// <param name="parentNode">父节点</param> /// <param name="childId">子节点ID</param> private void ShowPbomChildNode(TreeNode parentNode, string childId) { //根据物料类型查找物料分类 List <Model.MaterialVersionModule> versionModuleList = MaterialModuleBLL.GetChildPbomMaterialByPbomId(childId); if (versionModuleList.Count > 0) { versionModuleList.ForEach((v) => { TreeNode nod = new TreeNode(); MaterialModule mod = new MaterialModule(); mod.code = v.Code; mod.name = v.Name; mod.materialverid = v.MaterialVerId; mod.baseid = v.BaseId; mod.productname = v.ProductId; mod.pbomid = v.ChildId; nod.Text = string.Format("{0}({1})", v.Name, v.Code); //nod.Tag = v; nod.Tag = mod; nod.Name = v.ChildId; nod.ImageKey = "materialC"; ShowPbomChildNode(nod, v.ChildId); List <Model.ProcessCard> materialCardRelations = MaterialCardRelationBLL.GetProcessCardByMaterialId(v.BaseId, 2); if (materialCardRelations.Count > 0) { materialCardRelations.ForEach((m) => { TreeNode nd = new TreeNode(); nd.Text = m.Name; nd.Tag = m.ID; nd.Name = m.ID.ToString(); nd.ImageKey = "card"; nod.Nodes.Add(nd); nod.ImageKey = "materialCard"; }); } parentNode.Nodes.Add(nod); if (nod.ImageKey == "materialCard") { parentNode.ImageKey = nod.ImageKey; } }); } }
/// <summary> /// 方法说明:根据MaterialId和ProcessCardId删除物料下的卡片 /// 作 者:jason.tang /// 完成时间:2013-08-10 /// </summary> /// <param name="Id">业务ID</param> private void RemoveTreeNode(TreeNode currentNode) { if (currentNode == null || currentNode.Parent.Tag == null) { return; } string processCardId = currentNode.Tag.ToString(); MaterialModule materialModule = (MaterialModule)currentNode.Parent.Tag; string materialId = materialModule.baseid; TreeView treeView = new TreeView(); int type = 1; if (tcDesignView.SelectedTab == tbMaterial) { treeView = tvMaterialDesign; } else { treeView = tvMaterialPBom; type = 2; } bool result = MaterialCardRelationBLL.DeleteMaterialCard(materialId, processCardId, type); if (result) { if (!string.IsNullOrEmpty(currentNode.Parent.ImageKey)) { //tvMaterialDesign.SelectedNode = currentNode.Parent; //tvMaterialDesign.SelectedImageKey = currentNode.Parent.ImageKey; treeView.SelectedNode = currentNode.Parent; treeView.SelectedImageKey = currentNode.Parent.ImageKey; } else { //tvMaterialDesign.SelectedNode = tvMaterialDesign.Nodes[0]; ///// 如果选中的节点为空,默认为卡片 //tvMaterialDesign.SelectedImageKey = tvMaterialDesign.Nodes[0].ImageKey; treeView.SelectedNode = tvMaterialDesign.Nodes[0]; treeView.SelectedImageKey = tvMaterialDesign.Nodes[0].ImageKey; } //Remove treeview //tvMaterialDesign.Nodes.Remove(currentNode); //tvMaterialDesign.SelectedNode.Expand(); treeView.Nodes.Remove(currentNode); treeView.SelectedNode.Expand(); } }
/// <summary> /// 方法说明:获取查询条件 /// 作 者:jason.tang /// 完成时间:2013-09-10 /// </summary> /// <returns></returns> private string GetConditions() { string condtion = string.Empty; List <string> listConditions = new List <string>(); //零部件 if (!string.IsNullOrEmpty(txtMaterial.Text)) { //根据零部件名称得到挂在零部件下的卡片 List <ProcessCard> listProcessCards = MaterialCardRelationBLL.GetProcessCardByMaterialName(txtMaterial.Text); List <string> listCardIds = new List <string>(); if (listProcessCards != null && listProcessCards.Count > 0) { foreach (ProcessCard card in listProcessCards) { listCardIds.Add(string.Format("'{0}'", card.ID.ToString())); } listConditions.Add(string.Format("BaseId in ({0})", string.Join(",", listCardIds.ToArray()))); } } //文件类型 if (comboFileType.SelectedItem != null) { if (comboFileType.SelectedIndex == 0) { listConditions.Add("Type=1"); } else { listConditions.Add("Type=2"); } } //文件状态 if (comboFileStatus.SelectedItem != null) { if (comboFileStatus.SelectedIndex == 0) { listConditions.Add("IsShow=2"); } else if (comboFileStatus.SelectedIndex == 1) { listConditions.Add("IsShow=1"); } else { listConditions.Add("IsShow=0"); } } //编制人员 if (comboCreator.SelectedValue != null) { listConditions.Add(string.Format("v.Creator='{0}'", comboCreator.SelectedValue.ToString())); } if (dtpCreateDate.Value != null) { listConditions.Add(string.Format("CONVERT(varchar(100), CONVERT(datetime,v.CreateDate), 23)= '{0}'", dtpCreateDate.Value.ToString("yyyy-MM-dd"))); } if (listConditions.Count > 0) { condtion = string.Join(" And ", listConditions.ToArray()); } return(condtion); }
/// <summary> /// 方法说明:根据根节点加载子节点 /// 作 者:jason.tang /// 完成时间:2013-03-05 /// </summary> /// <param name="parentNode"></param> private void LoadPbomChildNode(string categoryid, string code) { //查找根节点(物料)下的子节点 materialModuleList = MaterialModuleBLL.GetMaterialModuleListByCategoryId(CategoryTypeIds[0], CategoryTypeIds[1]); if (materialModuleList.Count <= 0) { return; } List <string> listBaseIds = new List <string>(); foreach (MaterialModule material in materialModuleList) { listBaseIds.Add(string.Format("'{0}'", material.baseid)); } string baseIds = string.Join(",", listBaseIds.ToArray()); List <PBomModule> pbomModuleList = MaterialModuleBLL.GetPBomModuleListByBaseId(baseIds); if (pbomModuleList.Count <= 0) { return; } pbomModuleList.ForEach((o) => { TreeNode node = new TreeNode(); node.Text = o.FolderName; node.Tag = o.VerId; node.Name = o.VerId; node.ImageKey = "materialG"; node.ExpandAll(); //根据物料类型查找物料分类 List <Model.MaterialVersionModule> versionModuleList = MaterialModuleBLL.GetChildPbomMaterialByPbomId(o.VerId); if (versionModuleList.Count > 0) { versionModuleList.ForEach((v) => { TreeNode nod = new TreeNode(); MaterialModule mod = new MaterialModule(); mod.code = v.Code; mod.name = v.Name; mod.materialverid = v.MaterialVerId; mod.baseid = v.BaseId; mod.productname = v.ProductId; mod.pbomid = v.ChildId; nod.Text = string.Format("{0}({1})", v.Name, v.Code); //nod.Tag = v; nod.Tag = mod; nod.Name = v.ChildId; nod.ImageKey = "materialC"; ShowPbomChildNode(nod, v.ChildId); List <Model.ProcessCard> materialCardRelations = MaterialCardRelationBLL.GetProcessCardByMaterialId(v.BaseId, 2); if (materialCardRelations.Count > 0) { materialCardRelations.ForEach((m) => { TreeNode nd = new TreeNode(); nd.Text = m.Name; nd.Tag = m.ID; nd.Name = m.ID.ToString(); nd.ImageKey = "card"; nod.Nodes.Add(nd); nod.ImageKey = "materialCard"; }); } node.Nodes.Add(nod); if (nod.ImageKey == "materialCard") { node.ImageKey = nod.ImageKey; } }); } ////if (versionModuleList.Count > 0) ////{ //// versionModuleList.ForEach((v) => //// { //// TreeNode nod = new TreeNode(); //// MaterialModule mod = new MaterialModule(); //// mod.code = v.Code; //// mod.name = v.Name; //// mod.materialverid = v.MaterialVerId; //// mod.baseid = v.BaseId; //// mod.productname = v.ProductId; //// nod.Text = string.Format("{0}({1})", v.Code, v.Name); //// //nod.Tag = v; //// nod.Tag = mod; //// nod.Name = v.BaseId; //// nod.ImageKey = "materialC"; //// List<Model.ProcessCard> materialCardRelations = //// MaterialCardRelationBLL.GetProcessCardByMaterialId(v.BaseId, 2); //// if (materialCardRelations.Count > 0) //// { //// materialCardRelations.ForEach((m) => //// { //// TreeNode nd = new TreeNode(); //// nd.Text = m.Name; //// nd.Tag = m.ID; //// nd.Name = m.ID.ToString(); //// nd.ImageKey = "card"; //// nod.Nodes.Add(nd); //// }); //// } //// node.Nodes.Add(nod); //// }); ////} tvMaterialPBom.Nodes.Add(node); }); }
/// <summary> /// 方法说明:根据根节点加载子节点 /// 作 者:jason.tang /// 完成时间:2013-03-05 /// </summary> /// <param name="parentNode"></param> private void LoadMaterialChildNode(string categoryid, string code) { //if (parentNode == null) return; //parentNode.Nodes.Clear(); //查找根节点(物料)下的子节点 materialModuleList = MaterialModuleBLL.GetMaterialModuleListByCategoryId(categoryid, code); if (materialModuleList.Count <= 0) { return; } materialModuleList.ForEach((o) => { TreeNode node = new TreeNode(); node.Text = string.Format("({0})", o.name); node.Tag = o; node.Name = o.baseid; switch (o.TypeId) { case "1": node.ImageKey = "materialG"; break; case "2": node.ImageKey = "materialS"; break; case "3": node.ImageKey = "materialC"; break; case "4": node.ImageKey = "materialC"; break; default: break; } node.ExpandAll(); //根据物料类型查找物料分类 List <Model.MaterialVersionModule> versionModuleList = MaterialModuleBLL.GetChildMaterialByVersionId(o.materialverid); if (versionModuleList.Count > 0) { versionModuleList.ForEach((v) => { TreeNode nod = new TreeNode(); MaterialModule mod = new MaterialModule(); mod.code = v.Code; mod.name = v.Name; mod.materialverid = v.MaterialVerId; mod.baseid = v.BaseId; mod.productname = v.ProductId; nod.Text = string.Format("{0}({1})", v.Name, v.Code); //nod.Tag = v; nod.Tag = mod; nod.Name = v.MaterialVerId; nod.ImageKey = "materialC"; //TreeNode nod = new TreeNode(); //nod.Text = string.Format("{0}({1})", v.Code, v.Name); //nod.Tag = v.MaterialVerId; //nod.Name = v.BaseId; //nod.ImageKey = "materialC"; ShowMaterialChildNode(nod, v.MaterialVerId); List <Model.ProcessCard> materialCardRelations = MaterialCardRelationBLL.GetProcessCardByMaterialId(v.BaseId, 1); if (materialCardRelations.Count > 0) { materialCardRelations.ForEach((m) => { TreeNode nd = new TreeNode(); nd.Text = m.Name; nd.Tag = m.ID; nd.Name = m.ID.ToString(); nd.ImageKey = "card"; nod.Nodes.Add(nd); nod.ImageKey = "materialCard"; }); } node.Nodes.Add(nod); if (nod.ImageKey == "materialCard") { node.ImageKey = nod.ImageKey; } }); } //parentNode.Nodes.Add(node); tvMaterialDesign.Nodes.Add(node); }); }