Exemplo n.º 1
0
        /// <summary>
        /// 更改BOM面板参数的显示
        /// </summary>
        /// <param name="node">用于更新显示的节点</param>
        void ChangePanelPara(TreeNode node)
        {
            View_P_AssemblingBom bom = node.Tag as View_P_AssemblingBom;

            if (!GlobalObject.GeneralFunction.IsNullOrEmpty(bom.父总成编码))
            {
                txtParentName.Text = bom.父总成名称;
                txtParentCode.Text = bom.父总成编码;
            }

            txtCode.Text = bom.零件编码;
            txtName.Text = bom.零件名称;
            txtSpec.Text = bom.规格;

            numAssemblyCount.Value    = Convert.ToDecimal(bom.装配数量);
            chk缺料.Checked             = (bool)bom.是否缺料;
            chkCleanout.Checked       = bom.是否清洗;
            chkIsAdapting.Checked     = bom.是否选配零件;
            chkIsAssemblyPart.Checked = bom.是否总成;

            if (!GlobalObject.GeneralFunction.IsNullOrEmpty(bom.工位))
            {
                cmbWorkBench.Text = bom.工位;
            }

            if (!GlobalObject.GeneralFunction.IsNullOrEmpty(bom.备注))
            {
                txtRemark.Text = bom.备注;
            }

            dateTimePicker1.Value = bom.录入日期;
        }
Exemplo n.º 2
0
        private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0 || treeView1.Nodes.Count == 0)
            {
                return;
            }

            DataGridViewRow row  = dataGridView1.Rows[e.RowIndex];
            string          name = row.Cells["零件编码"].Value.ToString() + row.Cells["规格"].Value.ToString();

            TreeNode[] findNodes = treeView1.Nodes.Find(name, true);

            foreach (TreeNode node in findNodes)
            {
                View_P_AssemblingBom bom = node.Tag as View_P_AssemblingBom;

                if (bom.父总成编码 == row.Cells["父总成编码"].Value.ToString())
                {
                    m_selecteTreeNodeFromDataGridViewRow = true;
                    treeView1.SelectedNode = node;
                    break;
                }
            }

            ChangePanelPara();
        }
Exemplo n.º 3
0
        private void  除分总成下所有子零件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                MessageDialog.ShowPromptMessage("请选择分总成树节点后再进行此操作");
                return;
            }

            if (MessageDialog.ShowEnquiryMessage("您确定要进行此操作吗?") == DialogResult.No)
            {
                return;
            }

            string parentName = (treeView1.SelectedNode.Tag as View_P_AssemblingBom).零件名称;

            View_P_AssemblingBom result = m_lstAssemblingBomBackup.Find(p => p.是否总成 == true && p.零件名称 == parentName);

            if (result == null)
            {
                MessageDialog.ShowPromptMessage(parentName + " 不是总成");
            }
            else
            {
                if (m_assemblingBom.DeletePart(cmbProductType.Text, parentName, out m_err))
                {
                    MessageDialog.ShowPromptMessage("操作成功");
                    RefreshData();
                }
                else
                {
                    MessageDialog.ShowErrorMessage(m_err);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 生成树节点
        /// </summary>
        /// <param name="info">装配BOM信息</param>
        /// <returns>返回生成的树节点</returns>
        TreeNode CreateTreeNode(View_P_AssemblingBom info)
        {
            TreeNode node = new TreeNode();

            node.Tag  = info;
            node.Text = info.零件名称;
            node.Name = info.零件编码 + info.规格;

            Console.WriteLine("{0} \t {1}", node.Text, node.Name);

            return(node);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新指定分总成下所有零件工位号
        /// </summary>
        /// <param name="updateParentPart">是否一并更新分总成零件</param>
        private void UpdateWorkBench(bool updateParentPart)
        {
            if (treeView1.SelectedNode == null)
            {
                MessageDialog.ShowPromptMessage("请选择分总成树节点后再进行此操作");
                return;
            }

            if (MessageDialog.ShowEnquiryMessage("您确定要进行此操作吗?") == DialogResult.No)
            {
                return;
            }

            string parentName = (treeView1.SelectedNode.Tag as View_P_AssemblingBom).零件名称;

            View_P_AssemblingBom result = m_lstAssemblingBomBackup.Find(p => p.是否总成 == true && p.零件名称 == parentName);

            if (result == null)
            {
                MessageDialog.ShowPromptMessage(parentName + " 不是总成");
            }
            else
            {
                string workBench = InputBox.ShowDialog("输入工位号", "工位号", "").Trim().ToUpper();

                if (workBench == "")
                {
                    return;
                }
                else
                {
                    if (!cmbWorkBench.Items.Contains(workBench))
                    {
                        MessageDialog.ShowPromptMessage("不存在 " + workBench + " 工位");
                        return;
                    }

                    if (m_assemblingBom.UpdateWorkBench(cmbProductType.Text, parentName, workBench, updateParentPart, out m_err))
                    {
                        MessageDialog.ShowPromptMessage("操作成功");

                        btnRefresh_Click(null, null);
                    }
                    else
                    {
                        MessageDialog.ShowErrorMessage(m_err);
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 递归生成Bom表的树型结构
        /// </summary>
        /// <param name="parentNode">父节点</param>
        /// <param name="lstAssemblingBom">装配BOM信息</param>
        void RecursionBuildTreeView(TreeNode parentNode, List <View_P_AssemblingBom> lstAssemblingBom)
        {
            if (parentNode == null || lstAssemblingBom.Count == 0)
            {
                return;
            }

            View_P_AssemblingBom        parentInfo   = parentNode.Tag as View_P_AssemblingBom;
            List <View_P_AssemblingBom> assemblyPart = lstAssemblingBom.FindAll(p => p.是否总成 && p.父总成编码 == parentInfo.零件编码);

            //if (assemblyPart.Count == 0)
            //{
            //    List<View_P_AssemblingBom> leafagePart = lstAssemblingBom.FindAll(p => !p.是否总成 && p.父总成编码 == parentInfo.零件编码);
            //    foreach (var item in leafagePart)
            //    {
            //        TreeNode node = CreateTreeNode(item);
            //        parentNode.Nodes.Add(node);
            //    }

            //    lstAssemblingBom.RemoveAll(p => !p.是否总成 && p.父总成编码 == parentInfo.零件编码);
            //}

            for (int i = 0; i < assemblyPart.Count; i++)
            {
                TreeNode node = CreateTreeNode(assemblyPart[0]);

                parentNode.Nodes.Add(node);
                lstAssemblingBom.Remove(assemblyPart[0]);
                assemblyPart.RemoveAt(0);
                i--;

                RecursionBuildTreeView(node, lstAssemblingBom);
            }

            List <View_P_AssemblingBom> leafPart = lstAssemblingBom.FindAll(p => !p.是否总成 &&
                                                                            p.父总成编码 == parentInfo.零件编码);

            foreach (var item in leafPart)
            {
                TreeNode leafNode = CreateTreeNode(item);
                parentNode.Nodes.Add(leafNode);
            }

            lstAssemblingBom.RemoveAll(p => !p.是否总成 && p.父总成编码 == parentInfo.零件编码);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 检测设计与装配基数是否吻合
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheckBasicCount_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                MessageDialog.ShowPromptMessage("请选择要检测的树节点后再进行此操作!");
                return;
            }

            try
            {
                View_P_AssemblingBom bom = treeView1.SelectedNode.Tag as View_P_AssemblingBom;
                int assemblyAmount       = 0;

                foreach (var item in m_lstAssemblingBom)
                {
                    if (item.零件编码 == bom.零件编码 && item.规格 == bom.规格)
                    {
                        assemblyAmount += item.装配数量;
                    }
                }

                if (assemblyAmount != bom.基数)
                {
                    if (assemblyAmount == 0)
                    {
                        MessageDialog.ShowPromptMessage("此零件没有映射信息,无法匹配!");
                    }
                    else
                    {
                        MessageDialog.ShowErrorMessage(
                            string.Format("此零件设计基数为:{0},装配BOM中此零件装配数之和为:{1},不相匹配,请修改正确否则电子档案数据将不正确!", bom.基数, assemblyAmount));
                    }
                }
                else
                {
                    MessageDialog.ShowPromptMessage("匹配成功,完全正确!");
                }
            }
            catch (Exception err)
            {
                MessageDialog.ShowErrorMessage(err.Message);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 点击选择按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSelectField_Click(object sender, EventArgs e)
        {
            int index = 0;

            m_selectedProduct = new List <View_P_AssemblingBom>();

            foreach (DataGridViewRow item in dataGridView1.Rows)
            {
                if ((bool)item.Cells[0].Value)
                {
                    View_P_AssemblingBom user = (from r in m_lstAllProduct
                                                 where r.父总成名称 == item.Cells[1].Value.ToString() select r).Single();
                    m_selectedProduct.Add(user);
                }

                index++;
            }

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 9
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ResetBomPanelPara();
            ChangePanelPara(e.Node);

            if (m_preSelectedNode != null)
            {
                m_preSelectedNode.BackColor = treeView1.BackColor;
            }

            m_preSelectedNode = e.Node;
            e.Node.BackColor  = Color.Yellow;

            if (!m_selecteTreeNodeFromDataGridViewRow && dataGridView1.Rows.Count > 0)
            {
                View_P_AssemblingBom bom = treeView1.SelectedNode.Tag as View_P_AssemblingBom;

                if (bom.父总成编码 == null)
                {
                    bom.父总成编码 = "";
                }

                int visibleColumn = StapleInfo.GetVisibleColumn(dataGridView1);

                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    if (dataGridView1.Rows[i].Cells["父总成编码"].Value.ToString()
                        == bom.父总成编码 && dataGridView1.Rows[i].Cells["零件编码"].Value.ToString() == bom.零件编码)
                    {
                        dataGridView1.ClearSelection();
                        dataGridView1.Rows[i].Selected = true;
                        dataGridView1.CurrentCell      = dataGridView1.Rows[i].Cells[visibleColumn];

                        break;
                    }
                }
            }

            m_selecteTreeNodeFromDataGridViewRow = false;
        }
Exemplo n.º 10
0
        /// <summary>
        /// 刷新树视图
        /// </summary>
        /// <param name="lstAssemblingBom">获取到的装配BOM信息列表</param>
        void RefreshTreeView(List <View_P_AssemblingBom> lstAssemblingBom)
        {
            treeView1.Nodes.Clear();

            View_P_AssemblingBom productPart = lstAssemblingBom.Find(p => p.零件编码 == cmbProductType.Text);

            if (productPart == null)
            {
                MessageDialog.ShowErrorMessage("获取不到【" + cmbProductType.Text + "】根节点信息,无法继续");
                return;
            }

            TreeNode node = CreateTreeNode(productPart);

            treeView1.Nodes.Add(node);

            lstAssemblingBom.Remove(productPart);
            RecursionBuildTreeView(node, lstAssemblingBom);

            //ChangeBomPanelPara(treeView1.Nodes[0]);

            node.Expand();
        }
Exemplo n.º 11
0
        /// <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);
            }
        }
Exemplo n.º 12
0
        private void FormFZC_Load(object sender, EventArgs e)
        {
            try
            {
                if (AllProduct == null)
                {
                    List <View_P_AssemblingBom> list = new List <View_P_AssemblingBom>();

                    DataTable dt = m_preventErrorServer.GetAllAssemblingBom(m_productType);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            View_P_AssemblingBom assembling = new View_P_AssemblingBom();

                            assembling.父总成名称 = dt.Rows[i]["分总成名称"].ToString();

                            list.Add(assembling);
                        }
                    }

                    AllProduct = list;
                }

                DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();

                column.Visible    = true;
                column.Name       = "选中";
                column.HeaderText = "选中";
                column.ReadOnly   = false;

                dataGridView1.Columns.Add(column);

                dataGridView1.Columns.Add("分总成名称", "分总成名称");

                foreach (DataGridViewColumn item in dataGridView1.Columns)
                {
                    if (item.Name != "选中")
                    {
                        item.ReadOnly = true;
                        item.Width    = item.HeaderText.Length * (int)this.Font.Size + 100;
                    }
                    else
                    {
                        item.Width    = 68;
                        item.ReadOnly = false;
                        item.Frozen   = false;
                    }
                }

                bool selectedFlag = false;
                int  count        = 0;

                foreach (var item in AllProduct)
                {
                    selectedFlag = false;

                    if (SelectedProduct != null && count < SelectedProduct.Count)
                    {
                        if (SelectedProduct.FindIndex(c => c.父总成名称 == item.父总成名称) >= 0)
                        {
                            selectedFlag = true;
                            count++;
                        }
                    }

                    dataGridView1.Rows.Add(new object[] { selectedFlag, item.父总成名称 });
                }

                m_count = dataGridView1.Rows.Count;

                if (m_dataLocalizer == null)
                {
                    m_dataLocalizer = new UserControlDataLocalizer(dataGridView1, this.Name,
                                                                   UniversalFunction.SelectHideFields(this.Name, dataGridView1.Name, BasicInfo.LoginID));

                    panelTop.Controls.Add(m_dataLocalizer);

                    m_dataLocalizer.Dock = DockStyle.Bottom;
                }
            }
            catch (Exception err)
            {
                MessageDialog.ShowErrorMessage(err.Message);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 检查数据项是否正确
        /// </summary>
        /// <returns>正确返回true</returns>
        private bool CheckDataItem()
        {
            if (GlobalObject.GeneralFunction.IsNullOrEmpty(cmbProductType.Text))
            {
                cmbProductType.Focus();
                MessageDialog.ShowPromptMessage("请选择产品");
                return(false);
            }

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(txtParentCode.Text))
            {
                MessageDialog.ShowPromptMessage("请选择父总成");
                btnFindParentPart.PerformClick();
                return(false);
            }

            #region 检查录入的父总成是否是装配BOM中的零件

            m_lstAssemblingBom = m_assemblingBom.GetAssemblingBom(cmbProductType.Text);

            View_P_AssemblingBom info = m_lstAssemblingBom.Find(p => p.是否总成 && p.零件编码 == txtParentCode.Text);

            //if (info == null)
            //{
            //    MessageDialog.ShowErrorMessage(@"您录入的父总成编码不是当前装配BOM中的总成/分总成零件");
            //    return false;
            //}

            if (info != null && txtParentName.Text != info.零件名称)
            {
                MessageDialog.ShowErrorMessage("您录入的父总成名称与父总成编码不匹配");
                return(false);
            }

            #endregion

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(txtCode.Text) && GlobalObject.GeneralFunction.IsNullOrEmpty(txtName.Text))
            {
                MessageDialog.ShowPromptMessage("请选择零件");
                btnFindCode.PerformClick();
                return(false);
            }

            if (txtCode.Text == txtParentCode.Text)
            {
                MessageDialog.ShowPromptMessage("父总成与子零件不能是同一个零件");
                txtCode.Focus();
                return(false);
            }

            if (cmbWorkBench.SelectedIndex == -1)
            {
                MessageDialog.ShowPromptMessage("请选择工位");
                cmbWorkBench.Focus();
                return(false);
            }

            if (numAssemblyCount.Value == 0)
            {
                MessageDialog.ShowPromptMessage("装配数据必须 > 0");
                numAssemblyCount.Focus();
                return(false);
            }

            if (txtCode.Text.Contains("VIR_") && !chkIsAssemblyPart.Checked)
            {
                MessageDialog.ShowPromptMessage("对于虚拟总成零件必须选择为总成");
                chkIsAssemblyPart.Focus();
                return(false);
            }

            #region 2012.3.6 考虑后处理线返修专用软件需要设置装配顺序而增加

            //if (cmbProductType.Text.Contains(" FX") &&
            //    m_lstAssemblingBom.FindIndex(p => p.父总成编码 == txtParentCode.Text && (p.零件编码 != txtCode.Text || p.零件名称 != txtName.Text ||
            //        p.规格 != txtSpec.Text) && p.装配顺序 == Convert.ToInt32(numOrderNo.Value)) != -1)
            //{
            //    MessageDialog.ShowPromptMessage("此装配顺序已经存在");
            //    numOrderNo.Focus();
            //    return false;
            //}

            #endregion

            return(true);
        }