예제 #1
0
        private TCALINV GetTCALINV(string CompCd, string Sn)
        {
            var con = new Conditions <DataBase.TCALINV>();

            con.And(x => x.Comp_Cd == CompCd);
            con.And(x => x.Sn == Sn);
            TCALINV TCALINV = _CALINVRepo.Get(con);

            return(TCALINV);
        }
예제 #2
0
        /// <summary>
        /// 廠商銷案案件
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Boolean VendorConfirm(Tcallog input)
        {
            _logger.Info($"案件銷案-公司別:{input.CompCd},案件編號:{input.Sn}");

            string SapAssetKind = _ImgRepo.GetSpcAssetKind(input.CompCd, input.AssetCd);


            var con = new Conditions <DataBase.TCALLOG>();

            con.And(g => g.Sn == input.Sn);
            con.And(g => g.Comp_Cd == input.CompCd);
            con.Allow(g => g.Arrive_Date);
            con.Allow(g => g.Fc_Date);
            con.Allow(g => g.TimePoint);
            con.Allow(g => g.Work_Id);
            con.Allow(g => g.Finish_Id);
            con.Allow(g => g.Damage_Proc_No);
            if (SapAssetKind == "1")
            {
                con.Allow(g => g.Coffee_Cup);
            }
            con.Allow(g => g.Close_Sts);
            con.Allow(g => g.Work_Desc);
            con.Allow(g => g.VndEng_Id);
            con.Allow(g => g.AppClose_Date);
            con.Allow(g => g.Update_User);
            con.Allow(g => g.Update_Date);

            List <TCallLogDateRecord> AddCDR = new List <TCallLogDateRecord>();

            if (input.TcallLogDateRecords != null)
            {
                AddCDR = input.TcallLogDateRecords.Where(x => x.Seq == 0).ToList();
            }

            //檢查是否已有既有紀錄,若有則進行更新就好
            TCALINV sqlCALINV = GetTCALINV(input.CompCd, input.Sn);
            var     conINV    = new Conditions <DataBase.TCALINV>();

            conINV.And(g => g.Comp_Cd == input.CompCd);
            conINV.And(g => g.Sn == input.Sn);
            if (sqlCALINV != null)
            {
                conINV.Allow(g => g.Work_Id);
                conINV.Allow(g => g.Pre_Amt);
                conINV.Allow(g => g.Update_User);
                conINV.Allow(g => g.Update_Date);
            }

            using (TransactionScope scope = new TransactionScope())
            {
                _logger.Info($"案件銷案-準備更新資料");

                #region 儲存資料

                _callogRepo.Update(con, input);

                if (input.TCALINV != null)
                {
                    if (sqlCALINV == null)
                    {
                        _CALINVRepo.Add(conINV, input.TCALINV);
                    }
                    else
                    {
                        _CALINVRepo.Update(conINV, input.TCALINV);
                    }
                }

                if (AddCDR != null)
                {
                    _callogFactory.AddDateRecords(AddCDR);
                }

                #endregion

                _logger.Info($"案件銷案-準備儲存照片");

                #region 儲存照片

                _ImgRepo.AddImg(input);

                #endregion

                scope.Complete();
            }

            return(true);
        }