/// <summary> /// 刷新树视图 /// </summary> /// <param name="edition"></param> void RefreshTreeView(string edition) { string error; Dictionary <string, List <Bom> > DicBomTable; Dictionary <string, List <Bom> > tempDic; if (m_bomServer.GetBom(edition, "1.00", out tempDic, out m_err)) { DicBom = tempDic; } else { MessageDialog.ShowErrorMessage(m_err); treeView1.Nodes.Clear(); ResetBomPanelPara(); return; } treeView1.Nodes.Clear(); if (m_bomServer.GetBom(edition, "1.00", out DicBomTable, out error)) { List <Bom> listBom = DicBomTable[edition]; for (int i = 0; i < listBom.Count; i++) { if (listBom[i].ParentCode == "") { TreeNode node = new TreeNode(); node.Name = listBom[i].PartCode; node.Text = listBom[i].PartName; node.ToolTipText = listBom[i].Spec; node.Tag = listBom[i]; treeView1.Nodes.Add(node); DicBomTable[edition].RemoveAt(i--); } } for (int i = 0; i < treeView1.Nodes.Count; i++) { RecursionBuildTreeView(treeView1.Nodes[i], DicBomTable, edition); } ChangeBomPanelPara(treeView1.Nodes[0]); } else { MessageDialog.ShowErrorMessage(error); ResetBomPanelPara(); btnUpdate.Enabled = false; btnDelete.Enabled = false; return; } treeView1.ExpandAll(); }
/// <summary> /// 刷新DataGridView /// </summary> /// <param name="edition">版本</param> void RefreshDataGridView() { try { this.dataGridView1.CellEnter -= new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEnter); DataTable dataTable; if (!m_bomServer.GetBom(cmbProductType.Text, cmbDBOMVersion.Text, out dataTable, out m_err)) { MessageDialog.ShowErrorMessage(m_err); return; } dataGridView1.DataSource = dataTable; dataGridView1.Columns["序号"].Visible = false; // 添加数据定位控件 if (m_dataLocalizer == null) { m_dataLocalizer = new UserControlDataLocalizer(dataGridView1, this.Name, UniversalFunction.SelectHideFields(this.Name, dataGridView1.Name, BasicInfo.LoginID)); panelSearch.Controls.Add(m_dataLocalizer); m_dataLocalizer.Dock = DockStyle.Bottom; m_dataLocalizer.Visible = true; } this.dataGridView1.ColumnWidthChanged -= new System.Windows.Forms.DataGridViewColumnEventHandler( this.dataGridView1_ColumnWidthChanged); ColumnWidthControl.SetDataGridView(labelTitle.Text, dataGridView1); this.dataGridView1.ColumnWidthChanged += new System.Windows.Forms.DataGridViewColumnEventHandler( this.dataGridView1_ColumnWidthChanged); dataGridView1.Refresh(); } catch (Exception err) { MessageDialog.ShowErrorMessage(err.Message); } finally { this.dataGridView1.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEnter); } }
/// <summary> /// 从BOM中获取指定产品版本的零件信息对话框 /// </summary> /// <param name="isAllInfo">是否获取所有零件信息的标志</param> /// <param name="isAssemblyFlag">当isAllInfo为false时判断是获取总成还是零件信息的标志</param> /// <returns>成功则返回获取到的对话框,失败返回null</returns> static public FormQueryInfo GetAccessoryInfoDialog(string productEdition, bool isAllInfo, bool isAssemblyFlag) { List <View_P_ProductBom> bomInfo = null; IEnumerable <GoodsBasicInfo> queryResult = null; if (m_dicProductBom.ContainsKey(productEdition)) { bomInfo = m_dicProductBom[productEdition] as List <View_P_ProductBom>; } else { IBomServer server = ServerModuleFactory.GetServerModule <IBomServer>(); bomInfo = server.GetBom(productEdition).ToList(); m_dicProductBom[productEdition] = bomInfo; } if (!isAllInfo) { if (isAssemblyFlag) { queryResult = (from r in bomInfo where r.是否为总成 > 0 //&& (r.父总成编码 != null) select new GoodsBasicInfo { 图号型号 = r.零部件编码, 物品名称 = r.零部件名称, 规格 = r.规格 }); } else { queryResult = (from r in bomInfo where r.是否为总成 == 0 orderby r.零部件编码, r.规格 select new GoodsBasicInfo { 图号型号 = r.零部件编码, 物品名称 = r.零部件名称, 规格 = r.规格 }).Distinct(); } } else { queryResult = (from r in bomInfo orderby r.零部件编码, r.规格 select new GoodsBasicInfo { 图号型号 = r.零部件编码, 物品名称 = r.零部件名称, 规格 = r.规格 }).Distinct(); } //FormQueryInfo form = new FormQueryInfo(queryResult); System.Data.DataTable dataTable = GlobalObject.GeneralFunction.ConvertToDataTable <GoodsBasicInfo>(queryResult); FormQueryInfo form = new FormQueryInfo(dataTable); //form.ShowColumns = new string[] { "图号型号", "物品名称", "规格" }; return(form); }
/// <summary> /// 刷新数据 /// </summary> private void RefreshData() { if (cmbProductType.Items.Count > 0) { ResetBomPanelPara(); m_productBomInfo = m_bomServer.GetBom(cmbProductType.Text).ToList(); txtProductName.Text = (from r in m_productInfo where r.产品类型编码 == cmbProductType.Text select r.产品类型名称).First(); m_lstAssemblingBom = m_assemblingBom.GetAssemblingBom(cmbProductType.Text); View_P_AssemblingBom[] buffer = new View_P_AssemblingBom[m_lstAssemblingBom.Count]; m_lstAssemblingBom.CopyTo(buffer); m_lstAssemblingBomBackup = buffer.ToList(); InitViewData(m_lstAssemblingBom); } }