Beispiel #1
0
        private void fpView_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Graphics gfx = e.Graphics;

            //หาขอบเขตแถวที่จะต้องวาด
            int startRowIndex        = m_vScrollBar.Value;
            int countRow             = m_vScrollBar.LargeChange;
            int currentCountRowIndex = startRowIndex;

            int currentRowIndex = startRowIndex;

            while (currentCountRowIndex < countRow + startRowIndex)
            {
                //หาพื้นที่ที่ใช้วาด
                currentRowIndex = GetNextVisibleRowIndex(currentRowIndex);
                Rectangle rect = fpView.GetCellRectangle(0, 0, currentRowIndex, 0);
                if (rect == Rectangle.Empty)
                {
                    break;
                }

                //วาดรูปได้เฉพาะในพื้นที่ของ Cell เท่านั้น
                gfx.ResetClip();
                gfx.SetClip(rect, System.Drawing.Drawing2D.CombineMode.Intersect);

                BOMNode currentNode = (BOMNode)shtView.Rows[currentRowIndex].Tag;

                // image index
                // 0 = Blank
                // 1 = Plus
                // 2 = Minus
                Image img      = imgListStateNode.Images[0]; // default: Blank image.
                Point location = Point.Empty;

                //คำนวณตำแหน่งที่จะวางรูป
                location.Y = rect.Y + (rect.Height / 2) - 8;                    // vertical-align : center
                location.X = rect.X + GetLeftIndentPosition(currentNode.Level); // indent = 16px * level.

                //เลือกรูปที่วาดลง Cell
                if (currentNode.Nodes.Count > 0)
                {
                    if (currentNode.IsExpanded)
                    {
                        img = imgListStateNode.Images[2];
                    }
                    else
                    {
                        img = imgListStateNode.Images[1];
                    }
                }

                //วาดรูป และตำแหน่งที่ถูกต้อง
                gfx.DrawImage(img, location);


                // เลื่อนตำแหน่ง Pointer
                currentCountRowIndex++;
                currentRowIndex++;
            }
        }
Beispiel #2
0
        /// <summary>
        /// ไม่ใช้คำสั่งนี้  ให้ใช้คำสั่ง GetNode แทน
        /// </summary>
        /// <param name="root"></param>
        /// <param name="upperItemCode"></param>
        /// <param name="lowerItemCode"></param>
        /// <param name="buffer"></param>
        /// <returns></returns>
        private void RetrieveNode_Child(BOMNode root, string upperItemCode, string lowerItemCode, List <BOMNode> buffer)
        {
            if (upperItemCode != null && lowerItemCode != null)
            {
                if (Equals(root.DTO.UPPER_ITEM_CD.Value, upperItemCode) &&
                    Equals(root.DTO.LOWER_ITEM_CD.Value, lowerItemCode))
                {
                    buffer.Add(root);
                    return;
                }
            }
            else if (upperItemCode == null)
            {
                if (Equals(root.DTO.LOWER_ITEM_CD.Value, lowerItemCode))
                {
                    buffer.Add(root);
                    return;
                }
            }
            else
            {
                if (Equals(root.DTO.UPPER_ITEM_CD.Value, upperItemCode))
                {
                    buffer.Add(root);
                    return;
                }
            }


            for (int i = 0; i < root.Nodes.Count; i++)
            {
                RetrieveNode_Child((BOMNode)root.Nodes[i], upperItemCode, lowerItemCode, buffer);
            }
        }
Beispiel #3
0
        private void LoadData()
        {
            m_executeScript.Clear();
            shtView.RowCount = 0;

            List <BOMSetupViewDTO> list = m_bomSetupController.LoadBOMSetup(txtItemCD.Text.ToNZString());

            if (m_rootBOMNode != null)
            {
                m_rootBOMNode.Nodes.Clear();
            }


            m_rootBOMNode = WriteToBOMNode(list);
            if (m_rootBOMNode != null)
            {
                m_rootBOMNode.ExpandAll();
                FillBOMNodeToGrid((BOMNode)m_rootBOMNode);
                ExpandNode(m_rootBOMNode);
            }

            SetOrderLoactionandMRPFlag();

            UpdateUpDownButton();
        }
Beispiel #4
0
        private void fpView_CellDoubleClick(object sender, CellClickEventArgs e)
        {
            if (shtView.RowCount <= 0)
            {
                return;
            }
            if (e.Button == MouseButtons.Left)
            {
                //if (!e.ColumnHeader)
                //    miEditItem.PerformClick();

                if (!e.ColumnHeader)
                {
                    BOMNode node = shtView.Rows[e.Row].Tag as BOMNode;
                    if (node.IsExpanded)
                    {
                        node.Collapse(true);
                        CollapseNode(node);
                    }
                    else
                    {
                        node.Expand();
                        ExpandNode(node);
                    }
                }
            }
        }
Beispiel #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="node"></param>
 private void ExpandNode(BOMNode node)
 {
     for (int i = 0; i < node.Nodes.Count; i++)
     {
         int RowIndex = SearchRowIndex((BOMNode)node.Nodes[i], eSearchType.Forward, 0);
         ExpandNode_Recursive((BOMNode)node.Nodes[i], RowIndex);
     }
 }
Beispiel #6
0
        /// <summary>
        /// ค้นหารายการ Node ทั้งหมดที่เป็นตัวลูก  โดยเริ่มนับจาก startNode เป็นจุดตั้งต้น แล้ววนหาโหนดลูกภายในไปยังตัวสุดท้าย
        /// </summary>
        /// <param name="startNode"></param>
        /// <param name="buffer">ตัวแปรเก็บรายการที่ค้นพบ</param>
        private void RetrieveListOfNodes(BOMNode startNode, List <BOMNode> buffer)
        {
            buffer.Add(startNode);

            for (int i = 0; i < startNode.Nodes.Count; i++)
            {
                RetrieveListOfNodes((BOMNode)startNode.Nodes[i], buffer);
            }
        }
Beispiel #7
0
        /// <summary>
        /// วาดโครงสร้าง BOM ลง Grid จะวนหาทุก Node ที่สัมพันธ์กันเพื่อวาดโครงสร้าง
        /// </summary>
        /// <param name="node"></param>
        private void FillBOMNodeToGrid(BOMNode node)
        {
            FillRowGrid(node);

            for (int i = 0; i < node.Nodes.Count; i++)
            {
                FillBOMNodeToGrid((BOMNode)node.Nodes[i]);
            }
        }
Beispiel #8
0
        /// <summary>
        /// เพิ่มแถวใน Grid จากข้อมูลใน DTO
        /// รวมถึงการวาดระดับ Level ด้วย  แถวที่เพิ่มเสร็จแล้วจะเก็บ Tag = DTO
        /// </summary>
        /// <param name="dto"></param>
        private void FillRowGrid(BOMNode node)
        {
            int iRow = shtView.Rows.Count;

            shtView.Rows.Add(iRow, 1);

            shtView.Rows[iRow].Tag = node;

            UpdateRowGrid(iRow);
        }
Beispiel #9
0
        private void CollapseNode_Recursive(BOMNode node, int rowIndex)
        {
            for (int i = 0; i < node.Nodes.Count; i++)
            {
                int RowIndex = SearchRowIndex((BOMNode)node.Nodes[i], eSearchType.Forward, rowIndex);
                HideRow(RowIndex);

                CollapseNode_Recursive((BOMNode)node.Nodes[i], RowIndex);
            }
        }
Beispiel #10
0
            public override object Clone()
            {
                BOMNode node = base.Clone() as BOMNode;

                if (node != null)
                {
                    node.DTO = this.DTO.Clone() as BOMSetupViewDTO;
                }

                return(node);
            }
Beispiel #11
0
        private bool IsLeafItem(int rowIndex)
        {
            BOMNode node = shtView.Rows[rowIndex].Tag as BOMNode;

            if (node != null)
            {
                return(node.Nodes.Count == 0);
            }

            return(false);
        }
Beispiel #12
0
        /// <summary>
        /// ค้นหารายการ Node ทั้งหมด โดยเริ่มนับจาก startNode เป็นจุดตั้งต้น
        /// แล้ววนหา Parent ไปยัง TopItem
        /// </summary>
        /// <param name="startNode"></param>
        /// <param name="buffer">ตัวแปรที่ใช้เก็บรายการที่ค้นหา</param>
        private void RetrieveListOfTopNodes(BOMNode startNode, List <BOMNode> buffer)
        {
            buffer.Add(startNode);

            BOMNode parent = (BOMNode)startNode.Parent;

            while (parent != null)
            {
                buffer.Add(parent);
                parent = (BOMNode)parent.Parent;
            }
        }
Beispiel #13
0
        private void ExpandNode_Recursive(BOMNode node, int rowIndex)
        {
            ShowRow(rowIndex);

            if (node.IsExpanded)
            {
                for (int i = 0; i < node.Nodes.Count; i++)
                {
                    int RowIndex = SearchRowIndex((BOMNode)node.Nodes[i], eSearchType.Forward, rowIndex);
                    ExpandNode_Recursive((BOMNode)node.Nodes[i], RowIndex);
                }
            }
        }
Beispiel #14
0
        private bool IsPurchaseItem(int rowIndex)
        {
            BOMNode node = shtView.Rows[rowIndex].Tag as BOMNode;

            if (node != null)
            {
                //if (Equals(node.DTO.LOWER_ITEM_CLS.Value, DataDefine.Convert2ClassCode(eItemType.RawMaterial)))  // check raw material.
                //    return true;
                return(false);
            }

            return(false);
        }
Beispiel #15
0
        /// <summary>
        /// ปรังปรุงการ เปิด/ปิดของปุ่มเลื่อนค่า Seq
        /// </summary>
        private void UpdateUpDownButton()
        {
            int rowIndex = shtView.ActiveRowIndex;

            if (shtView.RowCount == 0 || rowIndex < 0)
            {
                CtrlUtil.EnabledControl(false, btnMoveDown, btnMoveUp);
                return;
            }

            BOMSetupViewDTO dto   = ((BOMNode)shtView.Rows[shtView.ActiveRowIndex].Tag).DTO;
            List <BOMNode>  nodes = GetNodes(dto.UPPER_ITEM_CD.StrongValue, dto.LOWER_ITEM_CD.StrongValue);

            BOMNode node = null;

            if (nodes != null && nodes.Count > 0)
            {
                node = nodes[0];
            }

            if (node == null)
            {
                CtrlUtil.EnabledControl(false, btnMoveDown, btnMoveUp);
                return;
            }

            if (node.Parent == null)
            {
                CtrlUtil.EnabledControl(false, btnMoveUp, btnMoveDown);
                return;
            }

            if (node.Equals(node.Parent.FirstNode))
            {
                CtrlUtil.EnabledControl(false, btnMoveUp);
            }
            else
            {
                CtrlUtil.EnabledControl(true, btnMoveUp);
            }

            if (node.Equals(node.Parent.LastNode))
            {
                CtrlUtil.EnabledControl(false, btnMoveDown);
            }
            else
            {
                CtrlUtil.EnabledControl(true, btnMoveDown);
            }
        }
Beispiel #16
0
        private void miDeleteTree_Click(object sender, EventArgs e)
        {
            // Delete RawMaterial item Only!!!!
            BOMNode         activeNode   = shtView.ActiveRow.Tag as BOMNode;
            BOMSetupViewDTO activeBOMDTO = activeNode.DTO;

            List <BOMNode> listBuffer = new List <BOMNode>();

            RetrieveListOfNodes(activeNode, listBuffer);

            if (IsTopItem(shtView.ActiveRowIndex))
            {
                for (int i = 0; i < listBuffer.Count; i++)
                {
                    listBuffer[i].Remove();
                }
            }
            else
            {
                // ลบ Node ที่ถูกคลิก
                activeNode.Remove();

                // Remove node that has same upper item code.
                List <BOMNode> listSameUpper = GetNodes(activeBOMDTO.UPPER_ITEM_CD.StrongValue, activeBOMDTO.LOWER_ITEM_CD.StrongValue);
                for (int i = 0; i < listSameUpper.Count; i++)
                {
                    listSameUpper[i].Remove();
                }

                // Remove node not same upper item code, but has same lower item code.
                List <BOMNode> listNotSameUpper = GetNodesOnLowerItem(activeBOMDTO.LOWER_ITEM_CD.StrongValue);
                for (int i = 0; i < listNotSameUpper.Count; i++)
                {
                    BOMNode node = listNotSameUpper[i];
                    node.Nodes.Clear();
                }
            }

            for (int i = 0; i < listBuffer.Count; i++)
            {
                DeleteSqlExecute execute1 = new DeleteSqlExecute(listBuffer[i].DTO);
                m_executeScript.Add(execute1);
            }

            shtView.RowCount = 0;
            FillBOMNodeToGrid(m_rootBOMNode);
            CollapseNode(m_rootBOMNode);
            ExpandNode(m_rootBOMNode);
        }
Beispiel #17
0
        /// <summary>
        /// Adjust level of BOMNode by relative position.
        /// </summary>
        /// <param name="startNode"></param>
        /// <param name="index"></param>
        private void AdjustLevelByRelative(BOMNode startNode, int index)
        {
            if (startNode == null)
            {
                return;
            }

            int newLevel = startNode.DTO.LEVEL.NVL(0);

            startNode.DTO.LEVEL.Value = newLevel + index;

            for (int i = 0; i < startNode.Nodes.Count; i++)
            {
                AdjustLevelByRelative((BOMNode)startNode.Nodes[i], index);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Write list of BOM structure to root BOMNode.
        /// </summary>
        /// <param name="listData"></param>
        /// <returns></returns>
        private BOMNode WriteToBOMNode(List <BOMSetupViewDTO> listData)
        {
            //##############
            // Generate BOMNode Structure
            //##############
            BOMNode rootNode = null;

            BOMNode currentNode = null;

            for (int i = 0; i < listData.Count; i++)
            {
                BOMSetupViewDTO dto  = listData[i];
                BOMNode         node = new BOMNode(dto);

                if (dto.LEVEL.StrongValue == 0)
                {
                    rootNode    = node;
                    currentNode = rootNode;
                }
                else if (dto.LEVEL.StrongValue > currentNode.DTO.LEVEL.StrongValue)
                {
                    currentNode.Nodes.Add(node);
                }
                else if (dto.LEVEL.StrongValue == currentNode.DTO.LEVEL.StrongValue)
                {
                    currentNode.Parent.Nodes.Add(node);
                }
                else
                {
                    // move back currentNode.
                    int posBack = (currentNode.DTO.LEVEL.StrongValue - dto.LEVEL.StrongValue) + 1;
                    for (int iMoveBack = 0; iMoveBack < posBack; iMoveBack++)
                    {
                        currentNode = (BOMNode)currentNode.Parent;
                    }

                    currentNode.Nodes.Add(node);
                }

                currentNode = node;
            } // end for-loop.

            return(rootNode);
        }
Beispiel #19
0
        private void tsbCancel_Click(object sender, EventArgs e)
        {
            // Do you want to save?
            if (MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9003.ToString()), MessageDialogButtons.YesNo) == MessageDialogResult.No)
            {
                return;
            }

            m_rootBOMNode.Nodes.Clear();
            m_rootBOMNode = new BOMNode();

            shtView.RowCount   = 0;
            shtView.DataSource = null;

            CtrlUtil.ClearControlData(txtItemCD, txtItemDesc);
            CtrlUtil.FocusControl(txtItemCD);

            UpdateUpDownButton();
        }
Beispiel #20
0
        /// <summary>
        /// Update การแสดงผลใน Grid ให้ตรงตาม DTO ที่เก็บไว้ใน Tag
        /// </summary>
        /// <param name="rowIndex"></param>
        private void UpdateRowGrid(int rowIndex)
        {
            try
            {
                int             iRow = rowIndex;
                BOMNode         node = shtView.Rows[iRow].Tag as BOMNode;
                BOMSetupViewDTO dto  = node.DTO;

                int    whiteSpaceNum = GetNumWhiteSpaceAtLevel(node.Level);
                string space         = string.Empty.PadLeft(whiteSpaceNum, ' ');

                shtView.Cells[rowIndex, (int)eColView.ITEM_CD].Value         = space + dto.LOWER_ITEM_CD.Value;
                shtView.Cells[rowIndex, (int)eColView.ITEM_DESC].Value       = dto.LOWER_ITEM_DESC.Value;
                shtView.Cells[rowIndex, (int)eColView.ITEM_CLS].Value        = dto.LOWER_ITEM_CLS.Value;
                shtView.Cells[rowIndex, (int)eColView.LOT_CONTROL_CLS].Value = dto.LOWER_LOT_CONTROL_CLS.Value;
                shtView.Cells[rowIndex, (int)eColView.CONSUMTION_CLS].Value  = dto.LOWER_CONSUMTION_CLS.Value;
                //shtView.Cells[rowIndex, (int)eColView.SEQ].Value = dto.SEQ.Value;
                shtView.Cells[rowIndex, (int)eColView.CHILD_RATE].Value  = dto.LOWER_QTY.Value;
                shtView.Cells[rowIndex, (int)eColView.PARENT_RATE].Value = dto.UPPER_QTY.Value;
                //shtView.Cells[rowIndex, (int)eColView.CHILD_ORDER_LOC].Value = dto.CHILD_ORDER_LOC_CD.Value;

                // edit by Chatas C. 13/6/2011
                //if (dto.MRP_FLAG.StrongValue != string.Empty)
                //{
                //    BOMBIZ bizBom = new BOMBIZ();
                //    try
                //    {
                //        NZString str = ((Convert.ToString(dto.MRP_FLAG)).Substring(0, 2)).ToNZString();
                //        NZString strMRPFlag = bizBom.FindMRPFlag(str);
                //        shtView.Cells[rowIndex, (int)eColView.MRP_FLAG].Value = str + " : " +strMRPFlag;
                //    }
                //    catch (Exception ex)
                //    { }
                //}
            }
            catch (Exception err)
            {
                MessageDialog.ShowBusiness(this, null, err.Source);
            }
        }
Beispiel #21
0
        /// <summary>
        /// ตรวจสอบ Node ก่อนที่จะทำการเปลี่ยน LowerItem.
        /// </summary>
        private bool CheckBeforeChangeItem(BOMNode activeNode, BOMNode newNode)
        {
            //== Check Recursion Looping.
            List <BOMNode> listNewChild = new List <BOMNode>();

            RetrieveListOfNodes(newNode, listNewChild);

            List <BOMNode> listTopNode = new List <BOMNode>();

            RetrieveListOfTopNodes((BOMNode)activeNode.Parent, listTopNode);

            for (int i = 0; i < listTopNode.Count; i++)
            {
                for (int j = 0; j < listNewChild.Count; j++)
                {
                    if (Equals(listTopNode[i].DTO.LOWER_ITEM_CD.Value, listNewChild[j].DTO.LOWER_ITEM_CD.Value))
                    {
                        MessageDialog.ShowBusiness(this, null, "Recursive occurs.");
                        return(false);
                    }
                }
            }

            //== Check duplicate Node on same level.
            BOMNode parentNode = (BOMNode)activeNode.Parent;

            for (int i = 0; i < parentNode.Nodes.Count; i++)
            {
                BOMSetupViewDTO childDTO = ((BOMNode)parentNode.Nodes[i]).DTO;
                if (Equals(childDTO.LOWER_ITEM_CD.Value, newNode.DTO.LOWER_ITEM_CD.Value))
                {
                    MessageDialog.ShowBusiness(this, null, "Duplicate occurs.");
                    return(false);
                }
            }



            return(true);
        }
Beispiel #22
0
        /// <summary>
        /// ค้นหา RowIndex จาก Node ที่ระบุ
        /// </summary>
        /// <param name="node"></param>
        /// <param name="searchType"></param>
        /// <param name="startIndex"></param>
        /// <returns></returns>
        private int SearchRowIndex(BOMNode node, eSearchType searchType, int startIndex)
        {
            if (searchType == eSearchType.Forward)
            {
                for (int i = startIndex; i < shtView.Rows.Count; i++)
                {
                    if (shtView.Rows[i].Tag.Equals(node))
                    {
                        return(i);
                    }
                }
                return(-1);
            }

            for (int i = startIndex; i >= 0; i--)
            {
                if (shtView.Rows[i].Tag.Equals(node))
                {
                    return(i);
                }
            }
            return(-1);
        }
Beispiel #23
0
        private void miDeleteItem_Click(object sender, EventArgs e)
        {
            // Delete RawMaterial item Only!!!!
            BOMNode         activeNode   = shtView.ActiveRow.Tag as BOMNode;
            BOMSetupViewDTO activeBOMDTO = activeNode.DTO;

            List <BOMNode> listNodes = GetNodes(activeBOMDTO.UPPER_ITEM_CD.StrongValue, activeBOMDTO.LOWER_ITEM_CD.StrongValue);

            for (int i = 0; i < listNodes.Count; i++)
            {
                listNodes[i].Remove();
            }

            shtView.RowCount = 0;
            FillBOMNodeToGrid(m_rootBOMNode);

            CollapseNode(m_rootBOMNode);
            ExpandNode(m_rootBOMNode);


            DeleteSqlExecute execute1 = new DeleteSqlExecute(activeBOMDTO);

            m_executeScript.Add(execute1);
        }
Beispiel #24
0
        private void MoveSequenceDown(int rowIndex)
        {
            BOMNode activeNode      = shtView.Rows[rowIndex].Tag as BOMNode;
            BOMNode activeLowerNode = activeNode.Parent.Nodes[activeNode.Index + 1] as BOMNode;

            BOMSetupViewDTO currentBOM = activeNode.DTO;
            List <BOMNode>  listNodes  = GetNodes(currentBOM.UPPER_ITEM_CD.StrongValue, currentBOM.LOWER_ITEM_CD.StrongValue);

            for (int i = 0; i < listNodes.Count; i++)
            {
                BOMNode currentNode = listNodes[i];
                BOMNode lowerNode   = currentNode.Parent.Nodes[currentNode.Index + 1] as BOMNode;

                //== Update sequence in DTO object.
                //int currentSeq = currentNode.DTO.SEQ.NVL(1);
                //currentNode.DTO.SEQ.Value = lowerNode.DTO.SEQ.Value;
                //lowerNode.DTO.SEQ.Value = currentSeq;

                // swap position on node-list.
                BOMNode parentNode = currentNode.Parent as BOMNode;
                currentNode.Remove();

                if (parentNode != null)
                {
                    parentNode.Nodes.Insert(lowerNode.Index + 1, currentNode);
                }


                //== Save script Update.
                UpdateSqlExecute execute1 = new UpdateSqlExecute(
                    (BOMDTO)currentNode.DTO.Clone(),
                    currentNode.DTO.UPPER_ITEM_CD,
                    currentNode.DTO.LOWER_ITEM_CD);

                UpdateSqlExecute execute2 = new UpdateSqlExecute(
                    (BOMDTO)lowerNode.DTO.Clone(),
                    lowerNode.DTO.UPPER_ITEM_CD,
                    lowerNode.DTO.LOWER_ITEM_CD);

                m_executeScript.Add(execute1);
                m_executeScript.Add(execute2);
            }


            //TODO: ตอนที่ทำการย้าย Node ที่มีลูกหลายๆ ชั้น  ยังแสดงไม่ถูกต้อง
            // Refill grid.
            shtView.RowCount = 0;
            FillBOMNodeToGrid(m_rootBOMNode);

            // Expand / collapse the last action.
            if (activeNode.IsExpanded)
            {
                ExpandNode(activeNode);
            }
            else
            {
                CollapseNode(activeNode);
            }

            if (activeLowerNode.IsExpanded)
            {
                ExpandNode(activeLowerNode);
            }
            else
            {
                CollapseNode(activeLowerNode);
            }

            // Hilight current row.
            int newRowIndex = SearchRowIndex(activeNode, eSearchType.Forward, 0);

            shtView.SetActiveCell(newRowIndex, 0);
            shtView.AddSelection(newRowIndex, 0, 1, 1);


            // Update button.
            UpdateUpDownButton();
        }
Beispiel #25
0
        private void miAddChildItem_Click(object sender, EventArgs e)
        {
            BOMNode         activeNode   = shtView.ActiveRow.Tag as BOMNode;
            BOMSetupViewDTO activeBOMDTO = activeNode.DTO;

            MAS051_RegisterBOM dialog = new MAS051_RegisterBOM(activeBOMDTO.LOWER_ITEM_CD.StrongValue);

            dialog.ShowDialog();

            if (dialog.IsSelected)
            {
                BOMRegisterUIDM selectedItem = dialog.SelectedItem;

                //== Decision to use data from in-memory or database.
                List <BOMNode> listCopyNode = GetNodesOnLowerItem(selectedItem.ITEM_CD.StrongValue);
                BOMNode        copyNode     = null;
                if (listCopyNode != null && listCopyNode.Count > 0)
                {
                    //if (listCopyNode[0].Nodes.Count > 0)  // has child.
                    copyNode = (BOMNode)listCopyNode[0].Clone();
                }
                else
                {
                    List <BOMSetupViewDTO> dbListDTO = m_bomSetupController.LoadBOMSetup(selectedItem.ITEM_CD);
                    copyNode = WriteToBOMNode(dbListDTO);
                }


                // == Validate before add child item.

                bool bCheck = CheckBeforeAddNewChildItem(activeNode, copyNode);
                if (bCheck == false)
                {
                    return;
                }

                //===================

                BOMNode lastChildNode = (BOMNode)activeNode.LastNode;
                int     nextSeq       = 1;
                if (lastChildNode != null)
                {
                    //nextSeq = lastChildNode.DTO.SEQ.NVL(0) + 1;
                }

                //BOMBIZ biz = new BOMBIZ();
                //int nextSeq = biz.GetNextSequenceOfUpperItem(activeBOMDTO.LOWER_ITEM_CD);

                // Create new BOMDTO
                BOMSetupViewDTO dto = new BOMSetupViewDTO();
                dto.UPPER_ITEM_CD.Value = activeBOMDTO.LOWER_ITEM_CD.Value;
                dto.LOWER_ITEM_CD.Value = selectedItem.ITEM_CD.Value;
                //dto.SEQ.Value = nextSeq;
                dto.UPPER_QTY.Value = selectedItem.UPPER_QTY.Value;
                dto.LOWER_QTY.Value = selectedItem.LOWER_QTY.Value;

                dto.UPPER_ITEM_CLS.Value        = activeBOMDTO.LOWER_ITEM_CLS.Value;
                dto.UPPER_ITEM_DESC.Value       = activeBOMDTO.LOWER_ITEM_DESC.Value;
                dto.UPPER_LOT_CONTROL_CLS.Value = activeBOMDTO.LOWER_LOT_CONTROL_CLS.Value;
                dto.UPPER_CONSUMTION_CLS.Value  = activeBOMDTO.LOWER_CONSUMTION_CLS.Value;

                dto.LOWER_ITEM_DESC.Value = selectedItem.ITEM_DESC.Value;
                //dto.LOWER_ITEM_CLS.Value = selectedItem.ITEM_CLS.Value;
                //dto.LOWER_LOT_CONTROL_CLS.Value = selectedItem.LOT_CONTROL_CLS.Value;
                //dto.LOWER_CONSUMTION_CLS.Value = selectedItem.CONSUMTION_CLS.Value;

                dto.PATH.Value = activeBOMDTO.PATH.StrongValue + "~" + selectedItem.ITEM_CD.StrongValue;
                //dto.CHILD_ORDER_LOC_CD.Value = selectedItem.CHILD_ORDER_LOC_CD.Value;
                //dto.MRP_FLAG.Value = selectedItem.MRP_FLAG.Value;
                // Insert new node.
                List <BOMNode> listNodes = GetNodesOnLowerItem(activeBOMDTO.LOWER_ITEM_CD.StrongValue);
                for (int i = 0; i < listNodes.Count; i++)
                {
                    BOMSetupViewDTO newDTO = dto.Clone() as BOMSetupViewDTO;

                    BOMNode newNode = null;
                    if (copyNode == null)
                    {
                        newNode     = (BOMNode)copyNode.Clone();
                        newNode.DTO = newDTO;
                    }
                    else
                    {
                        newNode     = copyNode.Clone() as BOMNode;
                        newNode.DTO = newDTO;
                        newNode.ExpandAll();
                    }

                    listNodes[i].Nodes.Add(newNode);
                }

                shtView.RowCount = 0;

                FillBOMNodeToGrid(m_rootBOMNode);

                activeNode.Expand();
                CollapseNode(m_rootBOMNode);
                ExpandNode(m_rootBOMNode);

                InsertSqlExecute execute1 = new InsertSqlExecute(dto);
                m_executeScript.Add(execute1);

                SetOrderLoactionandMRPFlag();
            }
        }
Beispiel #26
0
        private void miEditItem_Click(object sender, EventArgs e)
        {
            BOMNode         activeNode   = shtView.ActiveRow.Tag as BOMNode;
            BOMSetupViewDTO activeBOMDTO = activeNode.DTO;
            //if(activeBOMDTO.MRP_FLAG.Value.ToString().Length > 2)
            //    activeBOMDTO.MRP_FLAG = ((Convert.ToString(activeBOMDTO.MRP_FLAG.StrongValue)).Substring(0, 2)).ToNZString();

            MAS052_ChangeItem dialog = new MAS052_ChangeItem(activeBOMDTO);

            dialog.ShowDialog();

            if (dialog.IsSelected)
            {
                BOMRegisterUIDM selectedItem = dialog.SelectedItem;

                //== Decision to use data from in-memory or database.
                List <BOMNode> listCopyNode = GetNodesOnLowerItem(selectedItem.ITEM_CD.StrongValue);
                BOMNode        copyNode     = null;
                if (listCopyNode != null && listCopyNode.Count > 0)
                {
                    // Use explosion BOM from in-memory.
                    copyNode = (BOMNode)listCopyNode[0].Clone();
                }
                else
                {
                    // Load Explosion BOM from database.
                    List <BOMSetupViewDTO> dbListDTO = m_bomSetupController.LoadBOMSetup(selectedItem.ITEM_CD);
                    copyNode = WriteToBOMNode(dbListDTO);
                }

                //== Create new DTO.
                //BOMSetupViewDTO dto = activeNode.DTO.Clone() as BOMSetupViewDTO;
                BOMSetupViewDTO dto = copyNode.DTO.Clone() as BOMSetupViewDTO;
                dto.UPPER_ITEM_CD.Value         = activeBOMDTO.UPPER_ITEM_CD.Value;
                dto.UPPER_ITEM_CLS.Value        = activeBOMDTO.UPPER_ITEM_CLS.Value;
                dto.UPPER_ITEM_DESC.Value       = activeBOMDTO.UPPER_ITEM_DESC.Value;
                dto.UPPER_LOT_CONTROL_CLS.Value = activeBOMDTO.UPPER_LOT_CONTROL_CLS.Value;

                dto.LOWER_ITEM_CD.Value = selectedItem.ITEM_CD.Value;
                //dto.LOWER_ITEM_CLS.Value = selectedItem.ITEM_CLS.Value;
                dto.LOWER_ITEM_DESC.Value = selectedItem.ITEM_DESC.Value;
                //dto.LOWER_LOT_CONTROL_CLS.Value = selectedItem.LOT_CONTROL_CLS.Value;

                //dto.SEQ.Value = activeBOMDTO.SEQ.Value;
                dto.UPPER_QTY.Value = selectedItem.UPPER_QTY.Value;
                dto.LOWER_QTY.Value = selectedItem.LOWER_QTY.Value;
                //dto.CHILD_ORDER_LOC_CD.Value = selectedItem.CHILD_ORDER_LOC_CD.Value;
                //dto.MRP_FLAG.Value = selectedItem.MRP_FLAG.Value;
                copyNode.DTO = dto;

                List <BOMNode> listNodes = GetNodes(activeBOMDTO.UPPER_ITEM_CD.StrongValue, activeBOMDTO.LOWER_ITEM_CD.StrongValue);
                for (int i = 0; i < listNodes.Count; i++)
                {
                    // Remove old node and replace with new node.

                    BOMNode oldNode    = listNodes[i];
                    int     oldIndex   = oldNode.Index;
                    BOMNode parentNode = (BOMNode)oldNode.Parent;

                    oldNode.Remove();
                    BOMNode newNode = (BOMNode)copyNode.Clone();
                    newNode.ExpandAll();
                    parentNode.Nodes.Insert(oldIndex, newNode);
                }

                shtView.RowCount = 0;
                FillBOMNodeToGrid(m_rootBOMNode);
                CollapseNode(m_rootBOMNode);
                ExpandNode(m_rootBOMNode);


                UpdateSqlExecute execute1 = new UpdateSqlExecute(dto, activeBOMDTO.UPPER_ITEM_CD, activeBOMDTO.LOWER_ITEM_CD);
                m_executeScript.Add(execute1);

                SetOrderLoactionandMRPFlag();
            }
        }