Ejemplo n.º 1
0
        /// <summary>
        /// T03_KTRNの新規追加
        /// </summary>
        /// <param name="t03ktrn">T03_KTRN_Member</param>
        public void Insert(T03_KTRN_Member t03ktrn)
        {
            using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString()))
            {
                context.Connection.Open();

                T03_KTRN t03 = new T03_KTRN();
                t03.明細番号   = t03ktrn.明細番号;
                t03.明細行    = t03ktrn.明細行;
                t03.登録日時   = DateTime.Now;
                t03.更新日時   = DateTime.Now;
                t03.明細区分   = t03ktrn.明細区分;
                t03.入力区分   = t03ktrn.入力区分;
                t03.経費発生日  = t03ktrn.経費発生日;
                t03.車輌ID   = t03ktrn.車輌ID;
                t03.車輌番号   = t03ktrn.車輌番号;
                t03.乗務員KEY = t03ktrn.乗務員ID;
                t03.支払先KEY = t03ktrn.支払先ID;
                t03.自社部門ID = t03ktrn.自社部門ID;
                t03.経費項目ID = t03ktrn.経費項目ID;
                t03.経費補助名称 = t03ktrn.経費補助名称;
                t03.単価     = t03ktrn.単価;
                t03.内軽油税分  = t03ktrn.内軽油税分;
                t03.数量     = t03ktrn.数量;
                t03.金額     = t03ktrn.金額;
                t03.収支区分   = t03ktrn.収支区分;
                t03.摘要ID   = t03ktrn.摘要ID;
                t03.摘要名    = t03ktrn.摘要名;

                //未更新フィールド
                //入力者ID = t03ktrn.入力者ID;

                try
                {
                    // newのエンティティに対してはAcceptChangesで新規追加となる
                    context.T03_KTRN.ApplyChanges(t03);
                    context.SaveChanges();
                }
                catch (UpdateException ex)
                {
                    // PKey違反等
                    Console.WriteLine(ex);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// T03_KTRNの物理削除
        /// </summary>
        /// <param name="t03ktrn">T03_KTRN_Member</param>
        public void Delete(T03_KTRN_Member t03ktrn)
        {
            using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString()))
            {
                context.Connection.Open();

                //削除行を特定
                var ret = from x in context.T03_KTRN
                          where x.明細番号 == t03ktrn.明細番号 &&
                          x.明細行 == t03ktrn.明細行
                          orderby x.明細番号, x.明細行
                select x;
                var t03 = ret.FirstOrDefault();

                context.DeleteObject(t03);
                context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// T03_KTRNの更新
        /// </summary>
        /// <param name="t03ktrn">T03_KTRN_Member</param>
        public void Update(T03_KTRN_Member t03ktrn)
        {
            using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString()))
            {
                context.Connection.Open();

                //更新行を特定
                var ret = from x in context.T03_KTRN
                          where x.明細番号 == t03ktrn.明細番号 &&
                          x.明細行 == t03ktrn.明細行
                          orderby x.明細番号, x.明細行
                select x;
                var t03 = ret.FirstOrDefault();

                t03.更新日時   = DateTime.Now;
                t03.明細区分   = t03ktrn.明細区分;
                t03.入力区分   = t03ktrn.入力区分;
                t03.経費発生日  = t03ktrn.経費発生日;
                t03.車輌ID   = t03ktrn.車輌ID;
                t03.車輌番号   = t03ktrn.車輌番号;
                t03.乗務員KEY = t03ktrn.乗務員ID;
                t03.支払先KEY = t03ktrn.支払先ID;
                t03.自社部門ID = t03ktrn.自社部門ID;
                t03.経費項目ID = t03ktrn.経費項目ID;
                t03.経費補助名称 = t03ktrn.経費補助名称;
                t03.単価     = t03ktrn.単価;
                t03.内軽油税分  = t03ktrn.内軽油税分;
                t03.数量     = t03ktrn.数量;
                t03.金額     = t03ktrn.金額;
                t03.収支区分   = t03ktrn.収支区分;
                t03.摘要ID   = t03ktrn.摘要ID;
                t03.摘要名    = t03ktrn.摘要名;

                //未更新フィールド
                //入力者ID = t03ktrn.入力者ID;

                t03.AcceptChanges();
                context.SaveChanges();
            }
        }