Example #1
0
        // 課題No329 Del start

        ///// <summary>
        ///// 入出庫履歴テーブル更新チェック
        ///// </summary>
        ///// <param name="context">TRAC3Entities</param>
        ///// <param name="pRow">StocktakingDataMember</param>
        //private bool CheckS04_HISTORYUpdate(TRAC3Entities context, StocktakingDataMember pRow)
        //{
        //    bool bolResult = true;

        //    // 在庫数と実在庫数のチェック
        //    if (pRow.在庫数 == pRow.実在庫数)
        //    {
        //        bolResult = false;
        //    }

        //    return bolResult;
        //}

        // 課題No329 end

        /// <summary>
        /// 入出庫履歴テーブル 更新
        /// </summary>
        /// <param name="context">TRAC3Entities</param>
        /// <param name="pRow">StocktakingDataMember</param>
        private void Update_S04_HISTORY(TRAC3Entities context, StocktakingDataMember pRow)
        {
            // 入出庫履歴テーブル 編集
            decimal dcmStockQtyhist = 0;

            dcmStockQtyhist = pRow.実在庫数 - pRow.在庫数;
            int intInOutKbn = 0;

            if (dcmStockQtyhist > 0)
            {
                intInOutKbn = (int)CommonConstants.入出庫区分.ID01_入庫;
            }
            else
            {
                intInOutKbn = (int)CommonConstants.入出庫区分.ID02_出庫;
            }

            S04_HISTORY history = new S04_HISTORY();

            history.入出庫日  = pRow.棚卸日;
            history.入出庫時刻 = com.GetDbDateTime().TimeOfDay;
            history.庫コード  = pRow.庫コード;
            history.入出庫区分 = intInOutKbn;
            history.品番コード = pRow.品番コード;
            history.賞味期限  = pRow.賞味期限;
            history.数量    = decimal.ToInt32(Math.Abs(dcmStockQtyhist));
            history.伝票番号  = null;

            // ---------------------------
            // 入出庫履歴テーブル 登録
            // ---------------------------
            S04Service.CreateProductHistory(history);
        }
Example #2
0
        /// <summary>
        /// 入出庫履歴の作成をおこなう
        /// </summary>
        public void CreateProductHistory(S04_HISTORY history)
        {
            history.作成機能ID = _functionId;
            history.登録者    = _loginUserId;
            history.登録日時   = com.GetDbDateTime();
            history.最終更新者  = _loginUserId;
            history.最終更新日時 = com.GetDbDateTime();

            _context.S04_HISTORY.ApplyChanges(history);
        }
Example #3
0
        /// <summary>
        /// 入出庫履歴の登録・更新をおこなう
        /// </summary>
        /// <param name="context"></param>
        /// <param name="idohd">移動ヘッダデータ</param>
        /// <param name="dtlTbl">移動明細データテーブル</param>
        /// <param name="orghd">変更前仕入ヘッダデータ</param>
        /// <param name="isSubtract">減算フラグ(True:減算,False:減算しない)</param>
        private void setS04_HISTORY_Update(TRAC3Entities context, T05_IDOHD idohd, DataTable dtlTbl, bool isSubtract)
        {
            if (isSubtract == true)
            {
                // 登録済み入出庫データの削除
                int intSlipNumber = idohd.伝票番号;
                // 入出庫データの物理削除
                S04Service.PhysicalDeletionProductHistory(context, intSlipNumber, (int)S04.機能ID.振替入力);
            }

            List <T05_IDODTL> t05dtl = getDetailDataList(dtlTbl);

            foreach (T05_IDODTL row in t05dtl)
            {
                int souko = isSubtract ? (int)idohd.出荷元倉庫コード : (int)idohd.出荷先倉庫コード;

                S04_HISTORY history = new S04_HISTORY();
                history.入出庫日  = idohd.日付;
                history.入出庫時刻 = com.GetDbDateTime().TimeOfDay;
                history.庫コード  = souko;
                history.入出庫区分 = !isSubtract ? (int)CommonConstants.入出庫区分.ID01_入庫 : (int)CommonConstants.入出庫区分.ID02_出庫;
                history.品番コード = row.品番コード;
                history.賞味期限  = row.賞味期限;
                history.数量    = decimal.ToInt32(row.数量);
                history.伝票番号  = row.伝票番号;

                Dictionary <string, string> hstDic = new Dictionary <string, string>()
                {
                    { S04.COLUMNS_NAME_入出庫日, history.入出庫日.ToString("yyyy/MM/dd") },
                    { S04.COLUMNS_NAME_倉庫コード, history.庫コード.ToString() },
                    { S04.COLUMNS_NAME_伝票番号, history.伝票番号.ToString() },
                    { S04.COLUMNS_NAME_品番コード, history.品番コード.ToString() },
                };

                // 履歴作成
                S04Service.CreateProductHistory(history);
            }
        }
Example #4
0
        /// <summary>
        /// 入出庫履歴の登録・更新をおこなう
        /// </summary>
        /// <param name="context"></param>
        /// <param name="srhd">仕入ヘッダデータ</param>
        /// <param name="dtlTable">仕入明細データテーブル</param>
        /// <param name="orghd">変更前仕入ヘッダデータ</param>
        private void setS04_HISTORY_Create(TRAC3Entities context, T03_SRHD srhd, DataTable dtlTable, DataRow orghd)     // No-258 Mod
        {
            // No-258 Mod Start
            // 登録済み入出庫データの削除
            int intSlipNumber = srhd.伝票番号;

            // 入出庫データの物理削除
            S04Service.PhysicalDeletionProductHistory(context, intSlipNumber, (int)S04.機能ID.仕入入力);

            // 不要レコード除去
            DataTable dtlTblTmp = dtlTable.Clone();

            foreach (DataRow row in dtlTable.Rows)
            {
                T03_SRDTL dtlRow = convertDataRowToT03_SRDTL_Entity(row);

                if (dtlRow.品番コード <= 0)
                {
                    continue;
                }

                dtlTblTmp.ImportRow(row);
            }

            // 入出庫データ作成単位に集約
            var dtlTblWk = dtlTblTmp.AsEnumerable()
                           .Where(x => x.RowState != DataRowState.Deleted)
                           .GroupBy(g => new
            {
                伝票番号  = g.Field <int>("伝票番号"),
                品番コード = g.Field <int>("品番コード"),
                賞味期限  = g.Field <DateTime?>("賞味期限")
            })
                           .Select(s => new T03_SRDTL
            {
                伝票番号  = s.Key.伝票番号,
                品番コード = s.Key.品番コード,
                賞味期限  = s.Key.賞味期限,
                数量    = s.Sum(m => m.Field <decimal>("数量"))
            })
                           .ToList();

            foreach (T03_SRDTL row in dtlTblWk)
            {
                decimal stockQtyhist = 0;                               // No-155 Add
                stockQtyhist = row.数量;
                S04_HISTORY history = new S04_HISTORY();

                history.入出庫日  = srhd.仕入日;
                history.入出庫時刻 = com.GetDbDateTime().TimeOfDay;
                history.庫コード  = T03Service.get倉庫コード(srhd.入荷先コード);
                history.入出庫区分 = (int)CommonConstants.入出庫区分.ID01_入庫;
                history.品番コード = row.品番コード;
                history.賞味期限  = row.賞味期限;
                history.数量    = decimal.ToInt32(row.数量);
                history.伝票番号  = srhd.伝票番号;

                Dictionary <string, string> hstDic = new Dictionary <string, string>()
                {
                    // No.156-1 Mod Start
                    { S04.COLUMNS_NAME_入出庫日, orghd == null?
                      history.入出庫日.ToString("yyyy/MM/dd") : string.Format("{0:yyyy/MM/dd}", orghd["仕入日", DataRowVersion.Original]) },
                    { S04.COLUMNS_NAME_倉庫コード, orghd == null?
                      history.庫コード.ToString() :
                          orghd["入荷先コード", DataRowVersion.Original] == DBNull.Value?
                          null : T03Service.get倉庫コード(Convert.ToInt32(orghd["入荷先コード", DataRowVersion.Original])).ToString() },
                    { S04.COLUMNS_NAME_伝票番号, orghd == null?
                      history.伝票番号.ToString() : orghd["伝票番号", DataRowVersion.Original].ToString() },
                    { S04.COLUMNS_NAME_品番コード, history.品番コード.ToString() }
                    // No.156-1 Mod End
                };

                // 履歴作成
                S04Service.CreateProductHistory(history);
            }
            // No-258 Mod End
        }
Example #5
0
        /// <summary>
        /// 入出庫履歴の登録・更新をおこなう
        /// </summary>
        /// <param name="context"></param>
        /// <param name="idohd">移動ヘッダデータ</param>
        /// <param name="dtlTbl">移動明細データテーブル</param>
        /// <param name="orghd">変更前仕入ヘッダデータ</param>
        /// <param name="isSubtract">減算フラグ(True:減算,False:減算しない)</param>
        private void setS04_HISTORY_Update(TRAC3Entities context, T05_IDOHD idohd, DataTable dtlTbl, bool isSubtract)
        {
            // No-258 Mod Start
            if (isSubtract == true)
            {
                // 登録済み入出庫データの削除
                int intSlipNumber = idohd.伝票番号;
                // 入出庫データの物理削除
                S04Service.PhysicalDeletionProductHistory(context, intSlipNumber, (int)S04.機能ID.商品移動入力);
            }

            // 不要レコード除去
            DataTable dtlTblTmp = dtlTbl.Clone();

            foreach (DataRow row in dtlTbl.Rows)
            {
                T05_IDODTL dtlRow = convertDataRowToT05_IDODTL_Entity(row);

                if (dtlRow.品番コード <= 0)
                {
                    continue;
                }

                dtlTblTmp.ImportRow(row);
            }

            // 入出庫データ作成単位に集約
            var dtlTblWk = dtlTblTmp.AsEnumerable()
                           .Where(x => x.RowState != DataRowState.Deleted)
                           .GroupBy(g => new { 伝票番号    = g.Field <int>("伝票番号")
                                               , 品番コード = g.Field <int>("品番コード")
                                               , 賞味期限  = g.Field <DateTime?>("賞味期限") })
                           .Select(s => new T05_IDODTL
            {
                伝票番号  = s.Key.伝票番号,
                品番コード = s.Key.品番コード,
                賞味期限  = s.Key.賞味期限,
                数量    = s.Sum(m => m.Field <decimal>("数量"))
            })
                           .ToList();

            foreach (T05_IDODTL row in dtlTblWk)
            {
                int souko = isSubtract ? (int)idohd.出荷元倉庫コード : (int)idohd.出荷先倉庫コード;

                decimal stockQtyhist = 0;                               // No-155 Add
                stockQtyhist = row.数量;
                S04_HISTORY history = new S04_HISTORY();

                history.入出庫日  = idohd.日付;
                history.入出庫時刻 = com.GetDbDateTime().TimeOfDay;
                history.庫コード  = souko;
                history.入出庫区分 = !isSubtract ? (int)CommonConstants.入出庫区分.ID01_入庫 : (int)CommonConstants.入出庫区分.ID02_出庫;
                history.品番コード = row.品番コード;
                history.賞味期限  = row.賞味期限;
                history.数量    = decimal.ToInt32(stockQtyhist);      // No-155 Mod
                history.伝票番号  = row.伝票番号;

                Dictionary <string, string> hstDic = new Dictionary <string, string>()
                {
                    { S04.COLUMNS_NAME_入出庫日, history.入出庫日.ToString("yyyy/MM/dd") },
                    { S04.COLUMNS_NAME_倉庫コード, history.庫コード.ToString() },
                    { S04.COLUMNS_NAME_伝票番号, history.伝票番号.ToString() },
                    { S04.COLUMNS_NAME_品番コード, history.品番コード.ToString() },
                };

                // 履歴作成
                S04Service.CreateProductHistory(history);
            }
            // No-258 Mod End
        }
Example #6
0
        /// <summary>
        /// 入出庫履歴の更新をおこなう
        /// </summary>
        /// <param name="history"></param>
        /// <param name="conditionDic"></param>
        public void UpdateProductHistory(S04_HISTORY history, Dictionary <string, string> conditionDic)
        {
            // パラメータを展開
            long?    seq       = null; // シーケンス
            DateTime?date      = null, // 入出庫日
                    expiration = null; // 賞味期限
            TimeSpan?time      = null; // 入出庫時刻
            int?     souk      = null, // 倉庫コード
               kbn             = null, // 入出庫区分
               code            = null, // 品番コード
               qty             = null, // 数量
               denNo           = null; // 伝票番号

            getRequestParams(conditionDic, ref seq, ref date, ref time, ref souk, ref kbn, ref code, ref expiration, ref qty, ref denNo);

            // 更新対象データを取得
            var tmp =
                _context.S04_HISTORY.Where(w => w.削除日時 == null && w.作成機能ID == _functionId);

            #region データ絞込み
            if (seq != null)
            {
                tmp = tmp.Where(w => w.SEQ == seq);
            }

            if (date != null)
            {
                tmp = tmp.Where(w => w.入出庫日 == date);
            }

            if (time != null)
            {
                tmp = tmp.Where(w => w.入出庫時刻 == time);
            }

            if (souk != null)
            {
                tmp = tmp.Where(w => w.庫コード == souk);
            }

            if (kbn != null)
            {
                tmp = tmp.Where(w => w.入出庫区分 == kbn);
            }

            if (code != null)
            {
                tmp = tmp.Where(w => w.品番コード == code);
            }

            if (expiration != null)
            {
                tmp = tmp.Where(w => w.賞味期限 == expiration);
            }

            if (qty != null)
            {
                tmp = tmp.Where(w => w.数量 == qty);
            }

            if (denNo != null)
            {
                tmp = tmp.Where(w => w.伝票番号 == denNo);
            }
            #endregion

            // 対象データの更新を実施
            var hst = tmp.FirstOrDefault();

            if (hst != null)
            {
                hst.入出庫日   = history.入出庫日;    // No.156-1 Add
                hst.入出庫時刻  = history.入出庫時刻;   // No.156-1 Add
                hst.庫コード   = history.庫コード;
                hst.入出庫区分  = history.入出庫区分;
                hst.賞味期限   = history.賞味期限;
                hst.数量     = history.数量;
                hst.最終更新者  = _loginUserId;
                hst.最終更新日時 = com.GetDbDateTime();

                hst.AcceptChanges();
            }
        }
Example #7
0
        /// <summary>
        /// 入出庫履歴の登録・更新をおこなう
        /// </summary>
        /// <param name="srhd">仕入ヘッダデータ</param>
        /// <param name="dtlTable">仕入明細データテーブル</param>
        /// <param name="orghd">変更前仕入ヘッダデータ</param>
        protected void setS04_HISTORY_Create(T03_SRHD srhd, DataTable dtlTable, DataRow orghd)
        {
            foreach (DataRow row in dtlTable.Rows)
            {
                // 仕入明細データ取得
                T03_SRDTL srdtl = convertDataRowToT03_SRDTL_Entity(row);

                // 商品未設定レコードは処理しない
                if (srdtl.品番コード <= 0)
                {
                    continue;
                }

                // 元伝票からの返品対象外商品なので処理しない
                if (row.RowState == DataRowState.Deleted)
                {
                    continue;
                }

                S04_HISTORY history = new S04_HISTORY();

                history.入出庫日  = srhd.仕入日;
                history.入出庫時刻 = com.GetDbDateTime().TimeOfDay;
                history.庫コード  = T03Service.get倉庫コード(srhd.入荷先コード);
                history.入出庫区分 = (int)S04Service.getInboundType(row, "数量", srdtl.数量);
                history.品番コード = srdtl.品番コード;
                history.賞味期限  = srdtl.賞味期限;
                history.数量    = Math.Abs(decimal.ToInt32(srdtl.数量));
                history.伝票番号  = srhd.伝票番号;

                Dictionary <string, string> hstDic = new Dictionary <string, string>()
                {
                    // No.156-2 Mod Start
                    { S04.COLUMNS_NAME_入出庫日, orghd == null?
                      history.入出庫日.ToString("yyyy/MM/dd") : string.Format("{0:yyyy/MM/dd}", orghd["仕入日", DataRowVersion.Original]) },
                    { S04.COLUMNS_NAME_倉庫コード, orghd == null?
                      history.庫コード.ToString() :
                          orghd["入荷先コード", DataRowVersion.Original] == DBNull.Value?
                          null : T03Service.get倉庫コード(Convert.ToInt32(orghd["入荷先コード", DataRowVersion.Original])).ToString() },
                    { S04.COLUMNS_NAME_伝票番号, orghd == null?
                      history.伝票番号.ToString() : orghd["伝票番号", DataRowVersion.Original].ToString() },
                    { S04.COLUMNS_NAME_品番コード, history.品番コード.ToString() }
                    // No.156-2 Mod End
                };

                if (row.RowState == DataRowState.Added)
                {
                    // 仕入作成の為、履歴作成
                    S04Service.CreateProductHistory(history);
                }
                else if (row.RowState == DataRowState.Deleted)
                {
                    S04Service.DeleteProductHistory(hstDic);
                }
                // No.156-2 Mod Start
                else
                {
                    // (DataRowState.Modified、DataRowState.Unchanged)
                    // 仕入更新の為、履歴更新
                    S04Service.UpdateProductHistory(history, hstDic);
                }
                // No.156-2 Mod End
            }
        }