Exemplo n.º 1
0
    protected void btnAdd_ServerClick(Object sender, EventArgs e)
    {

        string currentCode = this.dOldCode.Value.Trim();
        //string oldId = this.dOldId.Value.Trim();

        string editor = this.HiddenUserName.Value.Trim();

        string isLine = this.dOldIsLine.Value.Trim();

        string resultId = "";
        try
        {
            WipBuffer item = new WipBuffer();
            item.Code = currentCode;
            item.Editor = editor;
            //item.ID = oldId;

            item.Line = this.cmbMaintainLightNoPdLine.InnerDropDownList.SelectedValue.Trim();

            item.LightNo = Int32.Parse(this.dLightNo.Text).ToString();
            item.Max_Stock = Int32.Parse(this.dMaxStock.Text.Trim());
            item.PartNo = this.dPartNo.Text.Trim(); //this.dPartNo.Text.ToUpper().Trim();
            item.Qty = Int32.Parse(this.dQty.Text.Trim());
            item.Remark = this.dRemark.Text.Trim();
            item.Safety_Stock = Int32.Parse(this.dSafeStock.Text.Trim());
            item.Sub = this.dSubstitution.Text.ToUpper().Trim();

            item.KittingType = this.cmbMaintainLightNoKittingType.InnerDropDownList.SelectedValue;
            item.Station = this.cmbMaintainLightNoStation.InnerDropDownList.SelectedValue;

            if (isLine.Trim() == "Yes")
            {
                resultId = iLightNo.AddLightNo(item,true);
            }
            else
            {
                resultId = iLightNo.AddLightNo(item,false);
            }
        }
        catch (FisException ex)
        {
            showErrorMessage(ex.mErrmsg);

            //if (ex.mErrcode == "DMT030" || ex.mErrcode == "DMT053")
            //{
            //    ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "InfoErrorPartNo();", true);
            //}

            return;
        }
        catch (Exception ex)
        {
            //show error
            showErrorMessage(ex.Message);
            return;
        }

        ShowList2();
        this.updatePanel2.Update();
        resultId = replaceSpecialChart(resultId);
        ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "DealHideWait();AddUpdateComplete('" + resultId + "');", true);

    }
Exemplo n.º 2
0
        //新增的id返回到结构里
        public string AddLightNo(WipBuffer item, Boolean codeIsLine)
        {
            String result = "";
            try
            {
                string code=item.Code;
                string partNo = item.PartNo;
                string lightNo = Null2String(item.LightNo);
                string Line;
                
                if (item.Line.Trim()=="")
                   Line ="";
                else
                   Line = item.Line.Substring(0, 1);

                IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();

                string kittingType = item.KittingType;
                //对应@family varchar(30),@loc char(4)

                if (kittingType == KITTING_TYPE_FA_KITTING)
                {
                    DataTable CheckResult = itemRepository.ExecOpKittingAutoCheck(code, lightNo, Line);
                    //DataTable CheckResult = itemRepository.ExecOpKittingAutoCheck(code, lightNo, kittingType);

                    if (CheckResult.Rows.Count > 0)
                    {
                        if (Null2String(CheckResult.Rows[0][0]) == "0")
                        {
                            //!!!msgbox DB.Recordset.fields(1)
                            //注意将存储过程中的Rows[0][1]转换为编号!!!
                            //if (Null2String(CheckResult.Rows[0][1]) == "1")
                            //{
                            //浮動庫位,不能手動Maintain!
                            List<string> erpara = new List<string>();
                            FisException ex;
                            ex = new FisException("DMT092", erpara);
                            throw ex;
                            //}
                        }
                    }
                }

                if (partNo.EndsWith(")") != true)
                {
                    DataTable PartData = itemRepository.GetPartInfoByPartNo(partNo);
                    if (PartData.Rows.Count <= 0)
                    {
                        //该PartNo不存在!
                        List<string> erpara = new List<string>();
                        FisException ex;
                        ex = new FisException("DMT091", erpara);
                        throw ex;
                    }
                    else
                    {
                        //tp中存part表中的descr
                        item.Tp = Null2String(PartData.Rows[0][0]);
                    }
                }


                Boolean exist=false;
                if (codeIsLine == true)
                {
                    exist = itemRepository.ExistWipBuffer(code, partNo, lightNo, item.KittingType);
                }
                else
                {   //item.line
                    exist = itemRepository.ExistWipBuffer(code, partNo, lightNo, item.KittingType,item.Line);
                }

                if (exist == true)
                {
                    //已经存在具有相同Code和PartNo的WipBuffer记录
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT090", erpara);
                    throw ex;

                }

                item.Cdt = DateTime.Now;
                item.Udt = DateTime.Now;
                itemRepository.AddLightNo(item);
                result = item.ID.ToString();
            }
            catch (Exception)
            {
                throw;
            }

            return result;
        }
Exemplo n.º 3
0
        //9) 更新的数据
        public void UpdateLightNo(WipBuffer item, Boolean codeIsLine)
        {

            try
            {
                string code = item.Code;
                string partNo = item.PartNo;
                int id = item.ID;

                string Line;

                if (item.Line.Trim() == "")
                    Line = "";
                else
                    Line = item.Line.Substring(0, 1);

                //!!!find 出来WipBuffer item
                string lightNo = Null2String(item.LightNo);
                IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();

                string kittingType = item.KittingType;
                //!!! need
                //DataTable CheckResult = itemRepository.ExecOpKittingAutoCheck(code, lightNo, kittingType);
                //对应@family varchar(30),@loc char(4)

                if (kittingType == KITTING_TYPE_FA_KITTING)
                {
                    DataTable CheckResult = itemRepository.ExecOpKittingAutoCheck(code, lightNo, Line);

                    if (CheckResult.Rows.Count > 0)
                    {
                        if (Null2String(CheckResult.Rows[0][0]) == "0")
                        {
                            //!!!msgbox DB.Recordset.fields(1)
                            //注意将存储过程中的Rows[0][1]转换为编号!!! 
                            //if (Null2String(CheckResult.Rows[0][1]) == "1")
                            //{
                            ////浮動庫位,不能手動Maintain!
                            List<string> erpara = new List<string>();
                            FisException ex;
                            ex = new FisException("DMT092", erpara);
                            throw ex;
                            //}
                        }
                    }
                }

                if (partNo.EndsWith(")") != true)
                {
                    DataTable PartData = itemRepository.GetPartInfoByPartNo(partNo);
                    if (PartData.Rows.Count <= 0)
                    {
                        //该PartNo不存在!
                        List<string> erpara = new List<string>();
                        FisException ex;
                        ex = new FisException("DMT091", erpara);
                        throw ex;
                    }
                    else
                    {
                        //tp中存part表中的descr
                        item.Tp = Null2String(PartData.Rows[0][0]);
                    }
                }


                Boolean exist=false;
                if (codeIsLine == true)
                {
                    exist = itemRepository.ExistWipBufferExceptCode(code, partNo, lightNo, id, item.KittingType);
                }
                else
                {
                    //item.line
                    exist = itemRepository.ExistWipBufferExceptCode(code, partNo, lightNo, id, item.KittingType,item.Line);
                }

                if (exist == true)
                {
                    //已经存在具有相同Code和PartNo的WipBuffer记录
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT090", erpara);
                    throw ex;

                }

                WipBuffer newItem = itemRepository.FindWipBufferById(id);

                if (newItem == null)
                {
                    //这条WipBuffer记录已经不存在,不能保存!
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT093", erpara);
                    throw ex;
                }

                newItem.Line = item.Line;
                newItem.Code = item.Code;
                newItem.Editor = item.Editor;
                newItem.KittingType = item.KittingType;
                newItem.LightNo = lightNo;
                newItem.Max_Stock = item.Max_Stock;
                newItem.PartNo = item.PartNo;
                newItem.Qty = item.Qty;
                newItem.Remark = item.Remark;
                newItem.Safety_Stock = item.Safety_Stock;
                newItem.Station = item.Station;
                newItem.Sub = item.Sub;
                newItem.Tp = item.Tp;
                newItem.Udt = DateTime.Now;

                itemRepository.UpdateLightNo(newItem);

            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// check Part Box From Model and then fix
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            /*
             * Model下一阶Type	Data
             * ======================
             * 
             * BM	根据Model展2阶,得到第二阶为KP的PartNo和Qty,且第一阶是BM [ BM->KP],即KP, 
             * 	    [还需要通过ModelBom反查其上阶为P1的PartNo(要求P1的PartNo的第七位为’-’) PartNo长度为10]
             * KP	根据Model展1阶,得到第一阶是KP的partNo和Qty,[KP],即KP  
             * 	    [还需要通过ModelBom反查其上阶为P1的PartNo(要求P1的PartNo的第七位为’-’) PartNo长度为10]
             * BM	根据Model展3阶,得到第二阶为P1的PartNo和第三阶为KP的Qty,
             * 	    且第一阶是BM 并且第三阶为KP[ BM->P1->KP],即P1
             * P1	根据Model展2阶,得到第一阶是P1的partNo和第二阶为KP的Qty,且其下阶为KP,[ P1->KP],即P1,
             * VK	根据Model展3阶,得到的第二阶为P1的PartNo,其中QTY取第一阶是VK的Qty和第二阶为P1的QTY 
             * 	    两者相比Qty大的那个,且第一阶是VK的,并且下下阶为KP,[ VK->P1->KP],即P1
             * C4	根据Model展3阶,得到第二阶为P1的PartNo和Qty,且第一阶是C4,第三阶是KP,[C4->P1->KP],即P1
             * MB(VGA)	根据Model展1阶,得到第一阶是MB的part和Qty, [ MB],并且第一阶的PartInfo存
             * 	    在InfoTyp='VGA' and InfoValue='SV'
             * PL	根据Model展2阶,得到第一阶是PL的part 和Qty, [ PL],即PL,第一阶的Descr描述为
             * 	    Descr like 'TPM%'    or Descr like 'JGS%' or  Descr =( 'Touch screen')
             * 	    or第一阶的PartInfo.InfoValue like '%Inverter%'
             * Common Parts	Part数据表中Part.PartNo(Part.BomNodeype='P1'  and  Part.Descr like 'CommonParts%')

             * 
             * Upper 3 kinds: *, ok, #
             *                *  -- call back: IList<IBOMNode> GetParentBomNodeByPnListAndBomNodeType(..., "P1")
             *                ok -- 
             *                #  -- call interface. IList<IPart> GetP1CommonParts(); 
             *            then combine the three kinds of ...
             * 
             * 注意Qty需要相乘,  要求P1的PartNo的第七位为’-’   ------- 此两句与我无关
             * 
             * IPartRepository  
             *      IList<IPart> GetP1CommonParts(); 
             * IBOMRepository           
             *     <summary>
             *     由给定的pnList得到BomNodeType=P1的父BOM节点
             *     </summary>
             *     <returns></returns>
             *     IList<IBOMNode> GetParentBomNodeByPnListAndBomNodeType(IList<string> pnList, string bomNodeType );
			 */

            IList<string> _sendList = new List<string>();
            IList<int> _qty_sendlist = new List<int>();
            IList<IBOMNode> _backList = new List<IBOMNode>();
            // 解 bom 分 3 种 
            // 1 种 
            IList<string> _okList_1 = new List<string>();
            IList<int> _qty_okList_1 = new List<int>();
            // 2 种 
            IList<string> _okList_2 = new List<string>();
            IList<int> _qty_okList_2 = new List<int>();
            // 3 种 
            IList<IPart> _okList_ret_3 = new List<IPart>();
            IList<string> _okList_3 = new List<string>();
            IList<int> _qty_okList_3 = new List<int>();

            IList<string> _ret_list = new List<string>();
            IList<int> _qty_ret_list = new List<int>();
            string[] _para;
            IList<string> _PartNo_list = new List<string>();
            IList<string> _LightNo_list = new List<string>();
            IList<int> _PartNo_LightNo_Qty_List = new List<int>();

            //string[] FirstLevelBomNodeType = new string[]{"KP","P1","P2","BM","VK","MB"};
            string[] FirstLevelBomNodeType = new string[] { "KP", "P1", "PL", "BM", "VK", "MB", "C4" };

            ArrayList passToInterface = new ArrayList();
            string _got_pdline = (string)CurrentSession.GetValue("inter_pdline");
            string _got_boxId = (string)CurrentSession.GetValue("_boxId");
            Product currentProduct = ((Product)CurrentSession.GetValue(Session.SessionKeys.Product));
            string prodId = currentProduct.ProId;
            string model = currentProduct.Model;
            string family = currentProduct.Family;

            //Convert.ToSingle(_lightNo);

            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
            IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
            IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
            IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(model);
            IList<IBOMNode> bomList = bom.FirstLevelNodes;
            //bom.GetNodesByNodeType(
            int c4_begin_count = 0;

            // --------------------------
            // 解 bom, 一级 type = FirstLevelBomNodeType [upper has defined...]
            // -------------------------

            //1st level nodes.
            foreach (IBOMNode node in bomList)
            {
                string _type = node.Part.BOMNodeType;
                if (FirstLevelBomNodeType.Contains(_type))
                {
                    switch (_type)
                    {
                        //KP	根据Model展1阶,得到第一阶是KP的partNo,[KP],即KP  
                        //   *  [还需要通过ModelBom反查其上阶为P1的PartNo(要求P1的PartNo的第七位为’-’) 
                        //      PartNo长度为10]
                        case "KP":
                            _qty_sendlist.Add(node.Qty);
                            _sendList.Add(node.Part.PN);
                            break;
                        // BM	根据Model展2阶,得到第二阶为KP的PartNo和Qty,且第一阶是BM [ BM->KP],即KP, 
                        // 	 *  [还需要通过ModelBom反查其上阶为P1的PartNo(要求P1的PartNo的第七位为’-’) PartNo长度为10]
                        // BM	根据Model展3阶,得到第二阶为P1的PartNo和第三阶为KP的Qty,
                        // 	ok  且第一阶是BM 并且第三阶为KP[ BM->P1->KP],即P1
                        // VK	根据Model展3阶,得到的第二阶为P1的PartNo,其中QTY取第一阶是VK的Qty和第二阶为P1的QTY 
                        // 	ok  两者相比Qty大的那个,且第一阶是VK的,并且下下阶为KP,[ VK->P1->KP],即P1
                        // C4	根据Model展3阶,得到第二阶为P1的PartNo和Qty,且第一阶是C4,第三阶是KP,[C4->P1->KP],即P1
                        //  ok
                        case "C4":
                        case "VK":
                        case "BM":
                            {
                                if (_type == "C4")
                                {
                                    c4_begin_count++;
                                }
                                IList<IBOMNode> _2ndBomList = node.Children;
                                foreach (IBOMNode _2nd_node in _2ndBomList)
                                {
                                    bool _2nd_node_is_p1_and_3rd_has_KP_node = false;
                                    int _2nd_node_is_p1_and_3rd_has_KP_node_3_qty = 0;
                                    if (_2nd_node.Part.BOMNodeType == "KP")
                                    {
                                        if (node.Part.BOMNodeType == "BM")
                                        {
                                            _qty_sendlist.Add(_2nd_node.Qty); //
                                            _sendList.Add(_2nd_node.Part.PN);
                                            continue;
                                        }
                                    }
                                    else if (_2nd_node.Part.BOMNodeType == "P1")
                                    {
                                        IList<IBOMNode> _3rdBomList = _2nd_node.Children;
                                        foreach (IBOMNode _3rd_node in _3rdBomList)
                                        {
                                            if (_3rd_node.Part.BOMNodeType == "KP")
                                            {
                                                _2nd_node_is_p1_and_3rd_has_KP_node = true;
                                                _2nd_node_is_p1_and_3rd_has_KP_node_3_qty = _3rd_node.Qty;
                                                break;
                                            }
                                        }
                                    }

                                    if (_2nd_node_is_p1_and_3rd_has_KP_node)
                                    {
                                        // to three case, set Qty list.
                                        if (node.Part.BOMNodeType == "BM")
                                        {
                                            _qty_okList_2.Add(_2nd_node_is_p1_and_3rd_has_KP_node_3_qty);
                                        }
                                        else if (node.Part.BOMNodeType == "VK")
                                        {
                                            // get lagger of level1's qty and level2's qty
                                            if (node.Qty >= _2nd_node.Qty)
                                            {
                                                _qty_okList_2.Add(node.Qty);
                                            }
                                            else
                                            {
                                                _qty_okList_2.Add(_2nd_node.Qty);
                                            }
                                        }
                                        else // C4
                                        {
                                            _qty_okList_2.Add(_2nd_node.Qty);
                                        }
                                        // set PN to be level2's PN
                                        _okList_2.Add(_2nd_node.Part.PN);
                                    }
                                }
                            }
                            break;
                        // P1 根据Model展2阶,得到第一阶是P1的partNo和第二阶为KP的Qty,且其下阶为KP,[ P1->KP],即P1,
                        //  ok
                        case "P1":
                            {
                                bool _2nd_node_is_KP = false;
                                int _2nd_node_is_KP__qty = 0;
                                IList<IBOMNode> _2ndBomList = node.Children;
                                foreach (IBOMNode _2nd_node in _2ndBomList)
                                {
                                    if (_2nd_node.Part.BOMNodeType == "KP")
                                    {
                                        _2nd_node_is_KP = true;
                                        _2nd_node_is_KP__qty = _2nd_node.Qty;
                                        break;
                                    }
                                }

                                if (_2nd_node_is_KP)
                                {
                                    _qty_okList_2.Add(_2nd_node_is_KP__qty);
                                    _okList_2.Add(node.Part.PN);
                                }
                            }
                            break;
                        //  MB(VGA)	根据Model展1阶,得到第一阶是MB的part和Qty, [ MB],并且第一阶的PartInfo存
                        //  	ok  在InfoTyp='VGA' and InfoValue='SV'
                        case "MB":
                            {
                                foreach (PartInfo info in node.Part.Attributes)
                                {
                                    if ((info.InfoType == "VGA") && (info.InfoValue == "SV"))
                                    {
                                        _qty_okList_2.Add(node.Qty);
                                        _okList_2.Add(node.Part.PN);
                                        break;
                                    }
                                }
                            }
                            break;
                        // PL	根据Model展2阶,得到第一阶是PL的part 和Qty, [ PL],即PL,第一阶的Descr描述为
                        // 	ok  Descr like 'TPM%'    or Descr like 'JGS%' or  Descr =( 'Touch screen')
                        // 	    or第一阶的PartInfo.InfoValue like '%Inverter%'
                        case "PL":
                            {
                                bool _is_right_node = false;
                                if ((node.Part.Descr.StartsWith("TPM")) ||
                                    (node.Part.Descr.StartsWith("JGS")) ||
                                    (node.Part.Descr == "Touch screen"))
                                {
                                    _is_right_node = true;
                                }
                                else
                                {
                                    //check if PartInfo.InfoValue like '%Inverter%'
                                    foreach (PartInfo info in node.Part.Attributes)
                                    {
                                        //if (info.InfoType.Contains("Inverter"))
                                        if (info.InfoValue.Contains("Inverter"))
                                        {
                                            _is_right_node = true;
                                            break;
                                        }
                                    }
                                }

                                if (_is_right_node)
                                {
                                    _qty_okList_2.Add(node.Qty);
                                    _okList_2.Add(node.Part.PN);
                                }
                            }
                            break;
                        default:
                            break;
                    }
                }
            }

            // translate list1 into string.
            if (_sendList.Count > 0)
            {
                /*
                 *  PROBLEM!! PERHAPS MAY LEAD A BUG!
                 *  2 in node -> 1 node case.
                 *  应避免多对一的情况
                 */
                // 反 查 
                _backList = bomRep.GetParentBomNodeByPnListAndBomNodeType(_sendList, "P1");

                foreach (IBOMNode node in _backList)
                {
                    int i = 0;
                    int _index = -1;

                    // 改 bug.
                    if ((node.Part.PN.Length != 10) || (node.Part.PN.Substring(6, 1) != "-"))
                    {
                        continue;
                    }

                    IBOMNode child = node.Children[0];
                    
                    for (i = 0; i < _sendList.Count; i++)
                    {
                        if (child.Part.PN == _sendList[i])
                        {
                            _index = i;
                            break;
                        }
                    }

                    if (_index >= 0)
                    {
                        _qty_okList_1.Add(_qty_sendlist[i]);//node.Qty); // here this sentence must check!!!
                    }
                    else
                    {
                        // here Create an Exception!
                        // have not find the parent to whose partno = %s corresponding.
                        FisException ex = new FisException("CHK239", new string[] { child.Part.PN }); //"have not find the parent to whose partno = %s corresponding!"
                        throw ex;
                    }

                    _okList_1.Add(node.Part.PN);
                }
            }

            // call interface to get list3.
            // --- UC -----------
            //   Common Parts	Part数据表中Part.PartNo(Part.BomNodeype='P1'  and  Part.Descr like 'CommonParts%')
            // ---- UC end ------
            _okList_ret_3 = partRep.GetPartsByBomNodeTypeAndLikeDescr("P1", "CommonParts"); //GetP1CommonParts();
            if (_okList_ret_3.Count > 0)
            {
                foreach (IPart part in _okList_ret_3)
                {
                    /*
                     * 
                     *  QTY PROBLEM!! BUG!
                     *  There is no corresponding Qty we need! 
                     * 
                     */
                    
                        _qty_okList_3.Add(1); // ;)
                        _okList_3.Add(part.PN);
                    
                }
            }

            // 解完 bom, 3种加起来
            // combine 3 list.
            //foreach (string str in _okList_1)
            for (int i = 0; i < _okList_1.Count; i++)
            {
                _ret_list.Add(_okList_1[i]);
                _qty_ret_list.Add(_qty_okList_1[i]);
            }

            for (int i = 0; i < _okList_2.Count; i++)
            {
                _ret_list.Add(_okList_2[i]);
                _qty_ret_list.Add(_qty_okList_2[i]);
            }

            for (int i = 0; i < _okList_3.Count; i++)
            {
                _ret_list.Add(_okList_3[i]);
                _qty_ret_list.Add(_qty_okList_3[i]);

            }

            //IList<WipBuffer> wipbufferList = productRep.GetWipBufferListByPnoListAndCode(string[] pnoList, string code);
            _para = _ret_list.ToArray();
            // UC modified, and liudong write another interface:
            //      DataTable GetPartNoAndLightNoFromWipBuffer(string family);
            //IList<WipBuffer> wipbufferList = productRep.GetWipBufferListByPnoListAndCode(_para, family);

            // chuli shu ju kuai......
            // --- UC ---
            // 7.	根据Model得到此unit的part BOM和下列两种方法取得的库位信息的合集的交集
            // --- UC ---
            {
                string partNo = "";
                string lightno = "";
                //string sub = "";
                //string sub_3 = "";
                WipBuffer __condition__wipbuffer__ = new WipBuffer();
                __condition__wipbuffer__.Code = family;
                __condition__wipbuffer__.Line = _got_pdline.Substring(0,1);
                //DataTable _datatable = new DataTable();
                if (productRep.CheckExistLightNoFromKitLocAndWipBuffer(family, _got_pdline.Substring(0, 1)) == true)
                {
                    // ----------------------------------
                    if (productRep.CheckExistWipBuffer(__condition__wipbuffer__) == true)
                    {
                        DataTable _datatable = productRep.GetPartNoAndLightNoFromWipBufferWithLineForDoubleLine(family, _got_pdline.Substring(0, 1));
                        //DataTable _datatable_new = _datatable_to_get_new(_datatable, _ret_list);
                        DataTable _datatable_new = _datatable;

                        // transfer _datatable_new -> partNo, lightNo --> 3 lists...
                        foreach (DataRow row in _datatable_new.Rows)
                        {
                            partNo = row["PartNo"].ToString().Trim();
                            lightno = row["LightNo"].ToString().Trim();
                            for (int i = 0; i < _ret_list.Count; i++)
                            {
                                if (_ret_list[i] == partNo)
                                {
                                    _PartNo_list.Add(partNo);
                                    _LightNo_list.Add(lightno);
                                    _PartNo_LightNo_Qty_List.Add(_qty_ret_list[i]);
                                    break;
                                }
                            }
                        }
                    }
                    else // code = family and line = PdLine.SbString(0,1) -- can not find, so only use code = family.
                    {
                        //DataTable _datatable = productRep.GetPartNoAndLightNoFromWipBuffer(family);
                        DataTable _datatable = productRep.GetPartNoAndLightNoFromWipBufferForDoubleLine(family, _got_pdline.Substring(0, 1));
                        //DataTable _datatable_new = _datatable_to_get_new(_datatable, _ret_list);
                        DataTable _datatable_new = _datatable;

                        foreach (DataRow row in _datatable_new.Rows)
                        {
                            partNo = row["PartNo"].ToString().Trim();
                            lightno = row["LightNo"].ToString().Trim();
                            for (int i = 0; i < _ret_list.Count; i++)
                            {
                                if (_ret_list[i] == partNo)
                                {
                                    _PartNo_list.Add(partNo);
                                    _LightNo_list.Add(lightno);
                                    _PartNo_LightNo_Qty_List.Add(_qty_ret_list[i]);
                                    break;
                                }
                            }
                        }
                    }
                    // ------------------------------------
                }
                else // origionally.
                {
                    // origionally codes for :
                    // if condition1
                    //      1.1
                    // else
                    //      1.2
                    //
                    // union
                    //
                    // 1.2
                    if (productRep.CheckExistWipBuffer(__condition__wipbuffer__) == true)
                    {
                        DataTable _datatable = productRep.GetPartNoAndLightNoFromWipBufferWithLine(family, _got_pdline.Substring(0, 1));

                        //DataTable _datatable_new = _datatable_to_get_new(_datatable, _ret_list);
                        DataTable _datatable_new = _datatable;

                        foreach (DataRow row in _datatable_new.Rows)
                        {
                            partNo = row["PartNo"].ToString().Trim();
                            lightno = row["LightNo"].ToString().Trim();
                            for (int i = 0; i < _ret_list.Count; i++)
                            {
                                if (_ret_list[i] == partNo)
                                {
                                    _PartNo_list.Add(partNo);
                                    _LightNo_list.Add(lightno);
                                    _PartNo_LightNo_Qty_List.Add(_qty_ret_list[i]);
                                    break;
                                }
                            }
                        }
                    }
                    else // code = family and line = PdLine.SbString(0,1) -- can not find, so only use code = family.
                    {
                        //DataTable _datatable = productRep.GetPartNoAndLightNoFromWipBuffer(family);
                        DataTable _datatable = productRep.GetPartNoAndLightNoFromWipBuffer(family, _got_pdline.Substring(0, 1));

                        //DataTable _datatable_new = _datatable_to_get_new(_datatable, _ret_list);
                        DataTable _datatable_new = _datatable;

                        foreach (DataRow row in _datatable_new.Rows)
                        {
                            partNo = row["PartNo"].ToString().Trim();
                            lightno = row["LightNo"].ToString().Trim();
                            for (int i = 0; i < _ret_list.Count; i++)
                            {
                                if (_ret_list[i] == partNo)
                                {
                                    _PartNo_list.Add(partNo);
                                    _LightNo_list.Add(lightno);
                                    _PartNo_LightNo_Qty_List.Add(_qty_ret_list[i]);
                                    break;
                                }
                            }
                        }
                    }
                }
            } // chu li shu ju kuai jie shu.
            //HAS: //.Tp//.ID//.KittingType//.Max_Stock//.Remark//.Safety_Stock;//.Qty;//PartNo;//LightNo;
            // Important: PartNo, LightNo, Qty -- Qty is not right perhaps, so we do not use it!

            //CurrentSession.AddValue("_wipbufferList", wipbufferList);
            CurrentSession.AddValue("_ret_list", _ret_list);
            CurrentSession.AddValue("_qty_ret_list", _qty_ret_list);
            CurrentSession.AddValue("_PartNo_list", _PartNo_list);
            CurrentSession.AddValue("_LightNo_list", _LightNo_list);
            CurrentSession.AddValue("_PartNo_LightNo_Qty_List", _PartNo_LightNo_Qty_List);

            /*
             * The following is to write database, so must move into another activity. 
             */

            return base.DoExecute(executionContext);
        }