/// <summary>
        /// ライン毎の在庫情報
        /// 数据主键是:部品番号 + サイト + ライン+ 位置 + Z軸 + Z軸ID
        /// </summary>
        /// <param name="libLinePartsStock"></param>
        /// <returns></returns>
        public DataTable GetLineStockData(Lib_LINE_PARTS_STOCK libLinePartsStock)
        {
            SqlDataReader dataReader = null;
            DataTable tblLineStock = null;

            try
            {
                String SqlString = string.Format("SELECT * FROM M_LINE_PARTS_STOCK "
                                            + "WHERE COMPONENT_PART='{0}' AND CONTRACT='{1}' AND WORK_CENTER_NO='{2}' AND POSITION='{3}' AND FEEDER='{4}' AND ARRAY_GRP_ID='{5}' "
                                            , libLinePartsStock.COMPONENT_PART, libLinePartsStock.CONTRACT, libLinePartsStock.WORK_CENTER_NO, libLinePartsStock.POSITION, libLinePartsStock.FEEDER, libLinePartsStock.ARRAY_GRP_ID);

                dataReader = DbHelperSQL.ExecuteReader(SqlString);

                tblLineStock = ConvertDataReaderToDataTable(dataReader);
            }
            catch (Exception)
            {
                throw;
            }

            return tblLineStock;
        }
        /// <summary>
        /// 更新ライン在庫マス数据
        /// </summary>
        /// <param name="tblPicked"></param>
        /// <returns></returns>
        public int SetLinePartsStockData(DataTable tblPicked)
        {
            int returnValue = -1;
            String SqlString;

            string shopListId;
            string kitNo = "";
            string revision_no;

            Decimal decPickedQty;

            DataTable tblHaizenDt = null;
            DataTable tblLinStock = null;
            string valKey;

            //ライン在庫マスタ
            Dictionary<string, Lib_LINE_PARTS_STOCK> dicLinePartsStock = new Dictionary<string,Lib_LINE_PARTS_STOCK>();
            //部品在庫マスタ
            List<Lib_PARTS_STOCK> lstPartsStock = new List<Lib_PARTS_STOCK>();

            Lib_LINE_PARTS_STOCK libLinePartsStock;
            Lib_PARTS_STOCK libPartsStock;
            string N_IF_SEQ;

            try
            {

                if (tblPicked != null && tblPicked.Rows.Count > 0)
                {
                    for (int i = 0; i < tblPicked.Rows.Count; i++)
                    {

                        libPartsStock = new Lib_PARTS_STOCK();

                        //買物配膳ID
                        shopListId = tblPicked.Rows[i]["N_SHOP_LIST_ID"].ToString();

                        //①部品番号
                        // ---> AIS配膳リストピッキング実績の品目番号
                        libPartsStock.COMPONENT_PART = tblPicked.Rows[i]["PART_NO"].ToString();
                        //リビジョン
                        revision_no = tblPicked.Rows[i]["ENG_CHG_LEVEL"].ToString();
                        //サイト
                        libPartsStock.CONTRACT = tblPicked.Rows[i]["CONTRACT"].ToString();
                        //生産ライン
                        libPartsStock.WORK_CENTER_NO = tblPicked.Rows[i]["WORK_CENTER_NO"].ToString();

                        //②フィーダー№
                        // ---> 配膳データより,( AIS配膳リストピッキング実績の買物配膳IDで参照)
                        tblHaizenDt = GetHaizenDtData(shopListId, libPartsStock, revision_no);

                        if (tblHaizenDt != null && tblHaizenDt.Rows.Count > 0)
                        {

                            //品目番号
                            kitNo = tblHaizenDt.Rows[0]["PART_NO"].ToString();
                            //Z軸
                            libPartsStock.FEEDER = tblHaizenDt.Rows[0]["N_Z_AXIS"].ToString();
                            //位置
                            libPartsStock.POSITION = tblHaizenDt.Rows[0]["N_POSITION"].ToString();

                            //③Z軸ID
                            // ---> 部品配列データより,( AIS配膳リストピッキング実績、配膳データの項目値で参照),参照配膳数据
                            libPartsStock.ARRAY_GRP_ID = GetPartListData(kitNo, libPartsStock, revision_no);
                        }

                        //ロットバッチ番号
                        libPartsStock.N_MATERIAL_LOT = tblPicked.Rows[i]["LOT_BATCH_NO"].ToString();

                        //④部材数量
                        // --->  AIS配膳リストピッキング実績のピッキング数量
                        Decimal.TryParse(tblPicked.Rows[i]["N_QTY_PICKED"].ToString(), out decPickedQty);
                        //在庫数
                        libPartsStock.N_ACTUAL_USED = decPickedQty;
                        //⑤更新担当---> 設定無しで可
                        libPartsStock.UPD_OPERATOR = "";
                        //⑥更新端末---> PGが動作するPC名
                        libPartsStock.UPD_PC = System.Net.Dns.GetHostName();

                        //部品在庫マスタ
                        lstPartsStock.Add(libPartsStock);
                    }
                }

                libLinePartsStock = new Lib_LINE_PARTS_STOCK();

                //数据解析处理
                for (int i = 0; i < lstPartsStock.Count; i++)
                {
                    valKey = lstPartsStock[i].COMPONENT_PART + lstPartsStock[i].CONTRACT + lstPartsStock[i].WORK_CENTER_NO + lstPartsStock[i].POSITION + lstPartsStock[i].FEEDER + lstPartsStock[i].ARRAY_GRP_ID;

                    if (!dicLinePartsStock.ContainsKey(valKey))
                    {
                        libLinePartsStock = new Lib_LINE_PARTS_STOCK();
                        libLinePartsStock.CONTRACT = lstPartsStock[i].CONTRACT;
                        libLinePartsStock.WORK_CENTER_NO = lstPartsStock[i].WORK_CENTER_NO;
                        libLinePartsStock.POSITION = lstPartsStock[i].POSITION;
                        libLinePartsStock.FEEDER = lstPartsStock[i].FEEDER;
                        libLinePartsStock.COMPONENT_PART = lstPartsStock[i].COMPONENT_PART;

                        libLinePartsStock.RESERVE_QTY = lstPartsStock[i].RESERVE_QTY;
                        libLinePartsStock.FREE_QTY = lstPartsStock[i].FREE_QTY;
                        libLinePartsStock.ARRAY_GRP_ID = lstPartsStock[i].ARRAY_GRP_ID;
                        libLinePartsStock.UPD_OPERATOR = lstPartsStock[i].UPD_OPERATOR;
                        libLinePartsStock.UPD_PC = lstPartsStock[i].UPD_PC;

                        dicLinePartsStock[valKey] = libLinePartsStock;
                    }

                    libLinePartsStock = dicLinePartsStock[valKey];
                    //部材数量
                    libLinePartsStock.STOCK_QTY += lstPartsStock[i].N_ACTUAL_USED;
                }

                //部品在庫マスタ
                for (int i = 0; i < lstPartsStock.Count; i++)
                {
                    libPartsStock = lstPartsStock[i];
                    //部品在庫マスタ
                    tblLinStock = GetStockData(libPartsStock);

                    if (tblLinStock != null && tblLinStock.Rows.Count > 0)
                    {
                        N_IF_SEQ = tblLinStock.Rows[0]["N_IF_SEQ"].ToString();

                        //⑦在庫数:レコードが存在している場合は、内容値にピッキング数量加算
                        //⑧引当数:レコードが存在している場合は、内容値そのまま
                        //⑨引当可能数:在庫数から引当数を減算,引当可能数=在库数-引当数
                        SqlString = string.Format("UPDATE M_PARTS_STOCK SET N_ACTUAL_USED = N_ACTUAL_USED + {0}, FREE_QTY = N_ACTUAL_USED - RESERVE_QTY + {0} WHERE N_IF_SEQ = '{1}'  ", libPartsStock.N_ACTUAL_USED, N_IF_SEQ);
                    }
                    else
                    {
                        N_IF_SEQ = DbHelperSQL.GetMaxID("N_IF_SEQ", "M_PARTS_STOCK").ToString();
                        //⑦在庫数:レコードが存在してない場合は、ピッキング数量
                        //⑧引当数:レコードが存在してない場合は、ZERO
                        //⑨引当可能数:在庫数から引当数を減算,引当可能数=在库数-引当数
                        SqlString = string.Format("INSERT INTO M_PARTS_STOCK "
                                                + "(N_IF_SEQ,COMPONENT_PART,N_MATERIAL_LOT,N_MATERIAL_TRACE_SEQ,N_ACTUAL_USED,CONTRACT"
                                                +   "       ,WORK_CENTER_NO,POSITION,FEEDER,ARRAY_GRP_ID,RESERVE_QTY,FREE_QTY,UPD_OPERATOR,UPD_PC) "
                                                + " VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}')"
                                                , N_IF_SEQ, libPartsStock.COMPONENT_PART, libPartsStock.N_MATERIAL_LOT, libPartsStock.N_MATERIAL_TRACE_SEQ, libPartsStock.N_ACTUAL_USED, libPartsStock.CONTRACT
                                                , libPartsStock.WORK_CENTER_NO, libPartsStock.POSITION, libPartsStock.FEEDER, libPartsStock.ARRAY_GRP_ID, libPartsStock.RESERVE_QTY, libPartsStock.N_ACTUAL_USED, libPartsStock.UPD_OPERATOR, libPartsStock.UPD_PC);

                    }

                    DbHelperSQL.ExecuteSql(SqlString);
                }

                //ライン在庫マスタ
                foreach (string key in dicLinePartsStock.Keys)
                {
                    libLinePartsStock = dicLinePartsStock[key];
                    //ライン在庫マスタ
                    tblLinStock = GetLineStockData(libLinePartsStock);

                    if (tblLinStock != null && tblLinStock.Rows.Count > 0)
                    {
                        N_IF_SEQ = tblLinStock.Rows[0]["N_IF_SEQ"].ToString();

                        //⑦在庫数:レコードが存在している場合は、内容値にピッキング数量加算
                        //⑧引当数:レコードが存在している場合は、内容値そのまま
                        //⑨引当可能数:在庫数から引当数を減算,引当可能数=在库数-引当数
                        SqlString = string.Format("UPDATE M_LINE_PARTS_STOCK SET STOCK_QTY = STOCK_QTY + {0}, FREE_QTY = STOCK_QTY - RESERVE_QTY + {0} WHERE N_IF_SEQ = '{1}'  ", libLinePartsStock.STOCK_QTY, N_IF_SEQ);
                    }
                    else
                    {
                        N_IF_SEQ = DbHelperSQL.GetMaxID("N_IF_SEQ", "M_LINE_PARTS_STOCK").ToString();
                        //⑦在庫数:レコードが存在してない場合は、ピッキング数量
                        //⑧引当数:レコードが存在してない場合は、ZERO
                        //⑨引当可能数:在庫数から引当数を減算,引当可能数=在库数-引当数
                        SqlString = string.Format("INSERT INTO M_LINE_PARTS_STOCK "
                                                + "(N_IF_SEQ,CONTRACT,WORK_CENTER_NO,POSITION,FEEDER,COMPONENT_PART"
                                                + "       ,STOCK_QTY,RESERVE_QTY,FREE_QTY,ARRAY_GRP_ID,UPD_OPERATOR,UPD_PC) "
                                                + " VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')"
                                                , N_IF_SEQ, libLinePartsStock.CONTRACT, libLinePartsStock.WORK_CENTER_NO, libLinePartsStock.POSITION, libLinePartsStock.FEEDER, libLinePartsStock.COMPONENT_PART
                                                , libLinePartsStock.STOCK_QTY, libLinePartsStock.RESERVE_QTY, libLinePartsStock.STOCK_QTY, libLinePartsStock.ARRAY_GRP_ID, libLinePartsStock.UPD_OPERATOR, libLinePartsStock.UPD_PC);

                    }

                    DbHelperSQL.ExecuteSql(SqlString);

                }

                returnValue = 1;
            }
            catch (Exception)
            {
                throw;
            }

            return returnValue;
        }